account option. The SetupIntent, customer, and saved card belong to
that merchant. Use the same merchant ID on your server and in the browser.
See Save a card for later for consent options and results.
Before you begin
- Platform keys and an active connection in the intended mode.
- An active receiving merchant with payments enabled and payment activation complete. Live requests also require live payment capability. These requirements apply to saving cards through Connect even though no payment is taken.
setup_intents:writeandsetup_intents:readon both the key and connection.- A customer belonging to the selected merchant. Creating that customer also
requires
customers:write; see Connect customers. - The page’s origin registered in Connect → Payment domains for the same mode.
@ionicfi/sdk0.4.1 or later and@ionicfi/js0.2.1 or later.
Create the SetupIntent on your server
The merchant and customer must be selected by your application’s authorization logic. The SDK’saccount option sends Ionic-Account for this request:
requestKey represents an application-assigned key for this operation.
The same operation uses the same key and body within Ionic’s
idempotency window.
The create response includes id and client_secret. Secret-key retrieval
does not return the secret’s value. The browser needs the platform publishable
key, the selected merchant ID, and authorized access to that merchant’s intent
secret. Client secrets must stay out of URLs, logs, and analytics.
Mount the card form on your page
Add an empty HTML element where you want the card form to appear:client_secret returned when that merchant’s SetupIntent
was created.
"payment" for both payment collection and card saving. The
SetupIntent client secret selects card saving here. payment.mount("#payment")
displays the Block inside <div id="payment">; #payment is the CSS selector
for that element.
Mounting displays the Block. Saving the card is a separate call to confirmSetup.
Confirm the save and read its status
ionic.confirmSetup({ blocks }) submits the card details from the mounted
Block for its SetupIntent when your customer agrees to save the card.
ionic.retrieveSetupIntent(clientSecret) reads that save request’s current
status. Both calls use the connected merchant selected in loadIonic.
The merchant is fixed for the client’s lifetime. A different merchant requires
a new client and an intent belonging to that merchant. blocks.destroy() removes
the UI without canceling a submitted operation.
Ownership and result
The server retrieval endpoint takes the sameIonic-Account selection:
An application reference can collide across merchants and modes. It does not
establish ownership or authorize access to a saved card or client secret.
A lost response does not imply failure; the existing intent can be retrieved.
Save a card describes each status and
Blocks describes retry limits.
SetupIntent operations
Each endpoint accepts
Ionic-Account; the server SDK accepts { account } as
the second argument. The server confirm endpoint is the tokenization interface
for advanced card fields. Blocks confirms
through confirmSetup.
Only an intent in requires_confirmation can be canceled. Cancellation does
not revoke an already saved card. A future charge is a separate
PaymentIntent operation
for the same merchant and customer, requiring payments:write.
For live-mode setup, see Going live.
