Payment wallets
The payment wallet object and the allowed CRUD operations on the related resource endpoint
A payment wallet stores a vaulted payment instrument — such as a tokenized credit card — on behalf of a customer, enabling faster checkout by reusing saved payment details across multiple payment sessions. Each wallet is associated with a payment setting that supports vaulting.
A wallet is obtained in one of two ways:
You create it directly, which stores the instrument without charging the customer.
Commerce Layer creates it from a successful charge when the paying session asks for vaulting.
Token references
A wallet stores two references, payment_token and customer_token. Both can be passed explicitly when creating the wallet. For whichever one you omit, Commerce Layer attempts to obtain it automatically, but how that happens — and whether omitting it is realistic — differs by gateway:
Adyen has no stored customer profile of its own — Commerce Layer identifies the shopper using its own customer data instead.
payment_token— Gateway-returned: produced when Commerce Layer stores the payment method with Adyen.customer_token— Commerce Layer-derived by default: the customer's ownshopper_reference, sent to Adyen to identify the shopper. Adyen never generates or returns this value.
Braintree also ties the payment method to a customer profile, but associates the two in a single step rather than a separate attach call.
payment_token— Gateway-returned: produced when Commerce Layer vaults the payment method with Braintree.customer_token— Gateway-returned: Commerce Layer reuses the customer's Braintree customer profile from a previous wallet on the same payment setting, or first creates one, and stores its ID. The payment method is associated with it as part of the same vaulting request.
Checkout.com also ties the payment method to a customer profile, similar to Braintree and Stripe.
payment_token— Client-side: a card token from Checkout.com's Frames.js or mobile SDKs, submitted by the client.customer_token— Gateway-returned: if you don't supply one, Commerce Layer first creates a Checkout.com customer profile and stores its ID. The payment method is vaulted as an instrument associated with it as part of the same request.
PayPal's flow starts with a client-side setup token rather than a payment method identifier, with the customer identifier traveling alongside it as a separate value.
payment_token— Two-step exchange (full flow here): the client collects a setup token via the PayPal SDK and submits it through_payment_details— Commerce Layer exchanges it for a permanent payment token.customer_token— Commerce Layer-derived by default: the customer's own identifier, sent to PayPal alongside the setup token in that same exchange request. It's a separate input, not part of the token exchange itself.
Stripe ties every vaulted payment method to a customer profile — Commerce Layer handles that attach step for you as part of the vaulting request.
payment_token— Client-side: a payment method identifier from Stripe.js/Elements, submitted by the client.customer_token— Gateway-returned: if you don't supply one, Commerce Layer creates a Stripe customer profile and stores its ID. Either way, Commerce Layer attaches the payment method to that profile as part of the same vaulting request.
For external gateways, both values come from your own vaulting endpoint's response, though customer_token is optional.
payment_token— Gateway-returned: read from your vaulting endpoint's response.customer_token— Gateway-returned, if your integration chooses to provide it, from the same response — otherwise left blank.
Lifecycle
A payment wallet transitions through the following statuses:
pending
Wallet creation has been initiated.
requires_action
Customer action is required to complete vaulting (e.g., a 3DS challenge).
processing
The vault request is being processed.
succeeded
The payment instrument has been successfully vaulted.
canceled
The wallet was canceled and its payment instrument removed from the provider.
Expiry
Wallets track an optional expires_at date derived from the vaulted payment instrument's expiry (e.g., card expiry month/year). Expired wallets cannot be used for new payment sessions.
Handling 3DS and customer action
For payment providers that require Strong Customer Authentication (SCA/3DS), the wallet may transition to requires_action after creation. The customer must complete the challenge, after which the client must update the wallet and pass the _payment_details trigger attribute to finalize vaulting. Once in succeeded status, the wallet can be linked to a payment session to pay without re-collecting payment details.
Wallets created by a payment session
Everything above describes creating a wallet directly, which stores the instrument without charging the customer.
A wallet can also be obtained as a by-product of a payment: when a payment session sets its vaulting attribute, the request to store the instrument travels with the charge itself, and the instrument is stored only if that payment succeeds. You don't create this wallet — Commerce Layer does, from the token returned with the charge, already in succeeded status and linked to that session.
Cancelling a wallet
A wallet that has been used by a payment session or an order subscription cannot be deleted — the request is rejected with a 423 Locked error — so that the payment data those payments rely on is never lost. Cancel it instead, by updating the wallet with the _cancel trigger attribute: Commerce Layer removes the stored instrument from the payment provider and moves the wallet to canceled, keeping it — and its payment data — linked to the payments it made.
Gateway options
At creation time, a payment wallet accepts an options object whose values are passed straight through to the underlying payment provider, following the same rules as payment sessions.
Triggers
A payment wallet supports the following trigger attributes:
_refresh— syncs wallet data with the provider._cancel— cancels the wallet._internal_version— forces a specific supported internal payload version for this wallet's creation request.
Last updated