Skip to navigation

Save and reuse payment methods

Use this flow when you need to save a customer’s card and charge it later without asking them to enter card details again. It works well for variable monthly billing, usage-based charges, add-ons to a subscription, or renewals controlled by your system.

The customer always enters their card on a Recurrente-hosted checkout. Your system stores only the payment_method_id returned by Recurrente and uses it to create future charges.

Before saving a card, make sure the customer accepts clear terms for future charges: frequency, how the amount is calculated, when charges happen, and how they can cancel or update their payment method.

Flow overview

  1. Create or identify the customer in Recurrente.
  2. Create a checkout with mode: "setup" to tokenize the card without charging it.
  3. Send the checkout_url to the customer.
  4. When the customer completes the checkout, store the payment_method.id, or look it up whenever you need it in the customer’s list of saved methods.
  5. Use POST /api/one_time_payments to charge that saved method when you know the final amount.

Step 1: Create or identify the customer

If you already have a Recurrente customer, pass their customer_id when creating the tokenization checkout. If you only have the user_id, you can pass that instead.

curl -X POST https://app.recurrente.com/api/customers \
-H "X-SECRET-KEY: your_secret_key" \
-H "Content-Type: application/json" \
-d '{
"email": "customer@example.com",
"full_name": "Ana Lopez"
}'

The response includes the customer id:

{
"id": "cus_abc123",
"user_id": "us_123456",
"email": "customer@example.com",
"name": "Ana Lopez"
}

Step 2: Create a tokenization checkout

Create a checkout with mode: "setup". This checkout does not charge anything; it only saves the card for future use.

When saving a new card, Recurrente verifies the account with a zero-amount authorization, without capturing funds. An approved authorization with a permanent token generates setup_intent.succeeded; a decline or failed verification generates setup_intent.cancelled, and the card is not enabled for charges. Saving a card does not guarantee that future charges will succeed or replace authentication that a later payment may require.

curl -X POST https://app.recurrente.com/api/checkouts \
-H "X-SECRET-KEY: your_secret_key" \
-H "Content-Type: application/json" \
-d '{
"mode": "setup",
"customer_id": "cus_abc123",
"success_url": "https://yoursite.com/payment-method-saved",
"cancel_url": "https://yoursite.com/payment-method-cancelled",
"metadata": {
"billing_agreement_id": "ba_789"
}
}'

Recurrente returns a hosted URL:

{
"id": "ch_eegw9j5zgqoae3ms",
"checkout_url": "https://app.recurrente.com/checkout-session/ch_eegw9j5zgqoae3ms"
}

Redirect the customer to checkout_url, or send it by email, WhatsApp, or inside your app.

Step 3: Store the payment_method_id

When the customer completes the checkout, Recurrente emits setup_intent.succeeded. The saved method is inside data.checkout.payment_method.

{
"eventType": "setup_intent.succeeded",
"eventId": "act_123",
"data": {
"event_type": "setup_intent.succeeded",
"status": "succeeded",
"checkout": {
"id": "ch_eegw9j5zgqoae3ms",
"status": "paid",
"payment_method": {
"id": "pay_m_7v5ie3pwq2xk9hrt",
"type": "card",
"card": {
"last4": "4242",
"network": "visa"
}
}
},
"customer": {
"id": "cus_abc123",
"email": "customer@example.com"
}
}
}

Store data.checkout.payment_method.id. This is the token you will use for future charges.

If you do not receive webhooks, retrieve the checkout after the customer returns to your success_url: GET /api/checkouts/{id}. Once the checkout is complete, the response includes payment_method.id.

curl https://app.recurrente.com/api/checkouts/ch_eegw9j5zgqoae3ms \
-H "X-SECRET-KEY: your_secret_key"
{
"id": "ch_eegw9j5zgqoae3ms",
"status": "paid",
"payment_method": {
"id": "pay_m_7v5ie3pwq2xk9hrt",
"type": "card",
"card": {
"last4": "4242",
"network": "visa"
}
}
}

List a customer’s saved payment methods

You don’t need to store card details in your system to show a customer their cards. List the methods they saved on your account, newest first, and charge the id of the one they pick:

curl "https://app.recurrente.com/api/customers/cus_abc123/payment_methods?type=card" \
-H "X-SECRET-KEY: your_secret_key"
[
{
"id": "pay_m_7v5ie3pwq2xk9hrt",
"object": "payment_method",
"type": "card",
"card": {
"last4": "4242",
"expiration_month": 12,
"expiration_year": 2028,
"network": "visa",
"issuer_name": "BAC"
},
"customer_id": "cus_abc123",
"status": "active",
"created_at": "2026-10-30T18:26:15.878-06:00",
"billing_details": {
"name": "Ana López",
"email": "customer@example.com",
"phone": null,
"address": { "address_line_1": null, "address_line_2": null, "city": null, "region": null, "country": "GT", "zip_code": "01010" }
},
"metadata": null
}
]
  • type filters by type (card includes cards in Apple Pay). limit (or items) and page paginate.
  • The same card saved twice is listed twice, each with its own id. Voided methods are left out. Today the methods that get saved are cards, including cards in Apple Pay.
  • limit and page answer with the link, current-page, total-pages and total-count headers, like every other list.
  • To check that a payment_method_id belongs to a customer, read it under that customer: GET /api/customers/{customer_id}/payment_methods/{id} answers 404 (code: payment_method_not_found) when it isn’t saved on them.
  • GET /api/payment_methods/{id} returns a method by its id, with customer_id naming the customer it is saved on. GET /api/payment_methods?customer_id= is the same list as above.
  • If you run a platform, send X-ACCOUNT-ID to read a connected account’s customers.
  • A card in Apple Pay (card.wallet: "apple_pay") is saved again on every payment, so the same card can show up more than once.

Step 4: Charge later with a variable amount

When your system knows the amount to charge, create a one-time payment with the saved payment_method_id and the customer’s customer_id. With customer_id, Recurrente only accepts a method saved on that customer and books the charge to them, even when someone else’s card paid for it. Use a unique idempotency key per charge attempt to avoid duplicates if you need to retry the request.

Apple Pay is not offered in a mode: "setup" checkout; the method is saved when the customer pays an Apple Pay-compatible checkout. You can also use a method saved through Apple Pay (card.wallet: "apple_pay") with the customer’s agreement to future charges. It does not require a subscription authorization: it is processed as an independent charge using the stored token. A revoked permission or missing token prevents the charge; the bank can decline it even when the token exists. Cancelling the subscription that granted the permission also revokes it and blocks later independent charges using that method.

curl -X POST https://app.recurrente.com/api/one_time_payments \
-H "X-SECRET-KEY: your_secret_key" \
-H "Idempotency-Key: invoice-2026-06-cus-abc123" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_abc123",
"payment_method_id": "pay_m_7v5ie3pwq2xk9hrt",
"items": [
{
"name": "June usage",
"amount_in_cents": 87500,
"currency": "GTQ",
"quantity": 1
}
]
}'

Successful response:

{
"object": "one_time_payment",
"id": "on_123456789",
"status": "paid"
}

If the bank declines the charge, Recurrente returns an error and you should not reuse the same Idempotency-Key for a new charge attempt. Create a new attempt with a different key when the customer confirms they want to retry or updates their payment method.

Variable charges tied to a subscription

If the customer already has a subscription and you want to add variable charges, you have two options.

For Apple Pay, this subscription_id variant does not support mode: "now". Use mode: "next_cycle"; if the invoice exceeds the authorized amount, the customer must pay through the renewal link. This differs from the independent payment_method_id and items charge described above.

To immediately charge the subscription’s saved payment method:

curl -X POST https://app.recurrente.com/api/one_time_payments \
-H "X-SECRET-KEY: your_secret_key" \
-H "Idempotency-Key: su-nehndm7j-extra-june" \
-H "Content-Type: application/json" \
-d '{
"subscription_id": "su_nehndm7j",
"amount_in_cents": 5000,
"description": "Additional usage charge",
"mode": "now"
}'

To add the charge to the next subscription cycle:

curl -X POST https://app.recurrente.com/api/one_time_payments \
-H "X-SECRET-KEY: your_secret_key" \
-H "Content-Type: application/json" \
-d '{
"subscription_id": "su_nehndm7j",
"amount_in_cents": 5000,
"description": "Additional usage charge",
"mode": "next_cycle"
}'

mode: "next_cycle" creates a pending invoice_item. It also supports negative amounts for credits.

Update the saved card

When the customer needs to change cards, create another mode: "setup" checkout. After completion, store the new payment_method.id.

If the method belongs to a subscription, update it with:

curl -X PUT https://app.recurrente.com/api/subscriptions/su_nehndm7j \
-H "X-SECRET-KEY: your_secret_key" \
-H "Content-Type: application/json" \
-d '{
"payment_method_id": "pay_m_new123"
}'

If you only use variable charges with POST /api/one_time_payments, store the new payment_method_id in your system and use it for future charges.

Considerations

  • POST /api/one_time_payments requires one-time payments to be enabled for your account.
  • The payment_method_id must belong to a customer in your account. Check it with GET /api/customers/{customer_id}/payment_methods/{id}.
  • Future charges can fail even if tokenization succeeded. Handle bank errors and let the customer update their card.
  • Real webhooks are only sent for production events. To validate the complete tokenization flow, use a LIVE key; the setup checkout does not charge an amount.
  • Never collect or store raw card numbers directly. Always use the Recurrente-hosted checkout.