Skip to content

Recurring Payments

Overview

Recurring payments require two steps:

  1. Save a payment method — collect card details once and store a pm_xxx token on the customer
  2. Charge the saved method — create and confirm payment intents using the stored token, without the customer present

Save a payment method (Setup Intent)

A setup intent guides the customer through saving their payment method. Create one server-side, pass the client_secret to the widget, and the widget handles card collection.

Terminal window
curl -X POST https://api.elasticpay.co/api/v1/setup_intents \
-H "Authorization: Bearer sk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"customer_id": "cus_0abc123def456"}'

After the customer completes the widget flow, the setup_intent.succeeded event fires and the saved pm_xxx is available on the customer record.

Charge a saved payment method

Create a payment intent and confirm it server-side using the saved pm_xxx. No customer interaction required:

Terminal window
# 1. Create payment intent
curl -X POST https://api.elasticpay.co/api/v1/payment_intents \
-H "Authorization: Bearer sk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"amount": 4900, "currency": "AUD", "customer_id": "cus_0abc123def456"}'
# 2. Confirm with saved payment method
curl -X POST https://api.elasticpay.co/api/v1/payment_intents/pi_0abc123/confirm \
-H "Authorization: Bearer sk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"payment_method": "pm_0xyz789abc123def456ghi012jkl"}'

List saved payment methods

Retrieve all saved payment methods for a customer:

Terminal window
curl https://api.elasticpay.co/api/v1/customers/cus_0abc123def456/payment_methods \
-H "Authorization: Bearer sk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Managing payment plans

For scheduled recurring payments (weekly, monthly, etc.), use the portal’s Payment Plans feature instead of scheduling intents manually. The portal handles scheduling, failure recovery, and retry logic. See Understanding Plans for details.