Guide

Charging saved cards

Charge a saved card with the customer absent. The request, the answers, when the bank wants the customer, and safe retries.

The shape

To charge a saved card without the customer present, create a PaymentIntent that references both the customer and the saved PaymentMethod, with off_session: true and confirm: true. The Idempotency-Key header is required, and it names the charge:

Request
1curl -X POST https://api.cxpay.net/v1/payment-intents \
2 -H "X-Key-Id: ak_test_..." \
3 -H "Content-Type: application/json" \
4 -H "Idempotency-Key: renewal-2026-11-sub_8841" \
5 ... HMAC headers ... \
6 -d '{
7 "amount": 4900,
8 "currency": "USD",
9 "customer": "cus_01JQX...",
10 "payment_method": "pm_01JQX...",
11 "off_session": true,
12 "confirm": true,
13 "payment_method_options": { "card": { "stored_credential_usage": "recurring" } }
14 }'
TestPOST /v1/payment-intents

The four required pieces go together. Send some and not the others and the request is refused with 400 VALIDATION_FAILED:

FieldWhy
customerIdentifies the cardholder. The PaymentMethod must belong to this customer.
payment_methodThe saved card. It must be active, and saved for off_session use.
off_session: trueFlags the charge as merchant-initiated (no customer present).
confirm: trueCharge in the same call.

payment_method_options.card.stored_credential_usage says what kind of agreement the charge runs under:

stored_credential_usageWhen to use
recurringSubscription billing on a fixed schedule (monthly, annual).
installmentOne of a set number of payments for a single purchase (4 payments of $250).
unscheduledNo schedule: top-ups, ride completion, a no-show fee. The default.

You never send a network transaction id, a mandate id or a reason code. We read the consent from the saved card.

setup_future_usage and expires_in cannot be combined with confirm: true. A saved-card PaymentIntent never expires. capture_method, description and metadata work as on any PaymentIntent. An amount above 99999999 is refused with 400.

Charging saved cards is switched on per account, and off until CX Pay turns it on. Until then the charge is refused with 403 OFF_SESSION_NOT_ALLOWED. Contact support to have it enabled.

Outcomes

HTTPWhat happenedWhat you do
200, status: "succeeded"The card was charged.Fulfill.
200, status: "requires_capture"Authorized, with capture_method: "manual".Capture when ready.
200, status: "processing"We do not know yet: the answer from the card's bank did not say what happened to the card.Retry with the same Idempotency-Key. Never charge again under a new key.
402The card was refused, or the payment failed for a definite reason.Read error.code and error.meta.payment_intent.last_payment_error.
other 4xxThe request was refused before anything was charged. No PaymentIntent exists.Fix the cause. The same key can be used again.

An off-session charge never returns requires_action.

A refused charge answers 402. The PaymentIntent is in error.meta.payment_intent, back in requires_payment_method, with last_payment_error set (abridged):

JSON
1{
2 "error": {
3 "code": "insufficient_funds",
4 "message": "The card has insufficient funds.",
5 "meta": {
6 "advice_code": "try_again_later",
7 "payment_intent": {
8 "id": "pi_01JQX...",
9 "status": "requires_payment_method",
10 "url": null,
11 "latest_charge": "ch_01JQX...",
12 "last_payment_error": {
13 "type": "card_error",
14 "code": "insufficient_funds",
15 "message": "The card has insufficient funds.",
16 "advice_code": "try_again_later",
17 "retryable": true
18 }
19 }
20 }
21 }
22}

error.code equals last_payment_error.code. Two fields tell you whether to try the card again:

FieldValuesRead it as
retryabletrue, falseWhether the same card can succeed later. false for a decline a retry cannot fix.
advice_codetry_again_laterTry again later, under a new key.
do_not_try_againStop charging this card. Ask the customer for another.
confirm_card_dataThe card details are wrong or out of date. Ask the customer to update the card.

advice_code is absent when the card's bank gave no advice. Codes are specific: insufficient_funds, cvc_check_failed and expired_card come back where card_declined used to.

A request refused before anything is charged names its reason in error.code. The ones you will meet: MANDATE_REQUIRED (the card has no consent, or the consent is another customer's), MANDATE_INACTIVE (the consent was revoked), PAYMENT_METHOD_DETACHED, PAYMENT_METHOD_EXPIRED, PAYMENT_METHOD_COMPROMISED, PAYMENT_METHOD_CUSTOMER_MISMATCH, OFF_SESSION_NOT_ALLOWED, MISSING_BILLING_DETAILS.

When the bank wants the customer

Sometimes the card's bank wants the cardholder to authenticate, and the cardholder is not there. The charge is refused: 402 with error.code of authentication_required. There is no requires_action status and no link to send the customer. next_action is always null.

To collect the money, bring the customer back and take the payment with them present: create a new PaymentIntent or Checkout Session and send them to the hosted page. Add setup_future_usage: "off_session" there if later charges should run on the consent that payment creates. The refused PaymentIntent cannot be paid on the hosted page: its url is null.

Retry rules

The Idempotency-Key names the charge.

  • The same key is the same charge. It always returns the same PaymentIntent and never charges twice. The key does not expire. This holds after a timeout, a 5xx, a dropped connection or a rotated API key.
  • A new key is a new charge. Use one only when you mean to try the money again, for example after a 402 with try_again_later.
  • Never send a new key while the first answered processing, or after a 5xx or a timeout. The first request may have charged the card. Retry with the same key until you get a 200 with a final status or a 402.
  • The same key with a different amount, currency, customer, card, stored_credential_usage or capture_method answers 409 IDEMPOTENCY_KEY_CONFLICT. Derive the key from the thing being billed, such as the invoice id plus the attempt number.
  • The same key after a 402 answers the same 402, with no new attempt on the card.

While an earlier request with your key is still running, the answer is 202 with { "status": "processing" }: retry the same key. If that request was cut off, a retry from about 2 minutes on can answer 409 EFFECT_IN_PROGRESS (retryable: true): retry the same key again. Within about 15 minutes the answer becomes the charge's outcome, or 409 PAYMENT_OUTCOME_UNKNOWN (retryable: false, with the PaymentIntent id in error.meta.payment_intent). The card may or may not have been charged. Stop retrying, do not charge again under a new key, and contact support with the PaymentIntent id.

A PaymentIntent that stays in processing is not looked up automatically. After 24 hours it moves to uncertain, and later to requires_review. No webhook announces either: a same-key retry or GET/v1/payment-intents/{id} shows the status. Contact support with the PaymentIntent id and do not charge again under a new key until they answer.

Stripe parity

If you're porting from Stripe, the request is the same. Key differences:

ConceptStripeCX Pay
Charge a saved cardcustomer + payment_method + off_session: true + confirm: trueSame
Stored-credential typepayment_method_options.card.stored_credential_usageSame name and values
Refused charge402, PaymentIntent back in requires_payment_methodSame, with the PaymentIntent at error.meta.payment_intent
Bank wants the customerauthentication_required, never requires_actionSame. You cannot confirm the same PaymentIntent on-session: the customer pays a new one.
Decline reasoncode plus decline_codeOne specific code (insufficient_funds)
Idempotent replayReplays for at least 24 hoursA saved-card charge key names one charge with no time limit
Concurrent duplicate409202 with { "status": "processing" }
Consent recordNone for ordinary cardsA Mandate, which you can revoke. It is recorded when the card is saved; see Saving cards.

What to log

For every off-session charge, persist the Idempotency-Key, pi.id, pi.status, and pi.last_payment_error.code. Group analytics by code, not by raw error message: copy can change; codes are stable.

Powered by CX Pay