How it works
1
Create a setup intent
Your server calls
POST /v1/setup_intents. The intent starts in requires_confirmation and is ready to accept a client-side token.2
Tokenize the card in the browser
Ionic Hosted Card Fields sends the card details directly to the tokenization service and returns a single-use
payment_token. Your server never sees the PAN.3
Confirm the intent
Your server calls
POST /v1/setup_intents/{id}/confirm with the payment_token. On success the intent moves to succeeded and a reusable payment method (pm_…) is created.4
Attach to a customer (optional)
Call
POST /v1/payment_methods/{id}/attach to associate the saved method with a customer record for easy retrieval later.5
Charge off-session
When you need to collect payment without the buyer present, create a payment intent using the saved
pm_… and set initiated_by: merchant.npm install @ionicfi/sdk gives you typed calls for every request
below; the server SDK guide has details. Each example also
shows raw curl.
Create a setup intent
requires_confirmation status:
Create request fields
Confirm the setup intent
After your client-side card form returns apayment_token, pass it to the confirm endpoint from your server.
422 conflict once the first one is recorded;
deriving it from the single-use token scopes each key to one attempt.
On success the intent moves to succeeded and payment_method is populated:
requires_confirmation so you can retry with a fresh token from the client. A 422 response means the intent is not in a confirmable state.
Setup intent status values
Inspect the saved payment method
Retrieve the saved method to confirm the card details. The response includes brand, last four digits, and expiration — never the PAN.Payment method card fields
Attach to a customer
If you did not supply acustomer when creating the intent, attach the method to a customer now. Attachment is write-once — a method can only be attached to one customer.
Charge off-session
When you need to charge the buyer without them present, create a payment intent using the saved method. Setinitiated_by: merchant — merchant-initiated transactions require a secret key.
succeeded status. A decline returns 402 with a card_error type and the current payment intent embedded in the response body so you can inspect its status without a second request.
Off-session payment intent fields
Operational guidance
- Always send an
Idempotency-Keyon setup-intent create, confirm, and payment-intent create. Retried requests without a key can vault the same card twice or charge a buyer more than once. - Tokenize card data in the browser with Ionic Hosted Card Fields. Your server only ever receives an opaque
payment_token— never raw card details. - Store the
pm_…id in your database against the customer or subscription record after the setup intent succeeds. You will need it for every subsequent off-session charge. - Use
GET /v1/payment_methods?customer=cus_…to list all saved methods for a customer before charging, so you can handle expired or revoked cards gracefully. - A payment method’s
fingerprintis stable across multiple vaultings of the same physical card. Use it to detect duplicate cards on a customer before saving a second copy. - When an off-session charge returns
402, check the embeddedpayment_intent.status. Arequires_payment_methodstatus means the card was declined and the buyer needs to update their payment details.

