Create Saved Payment Method Asynchronously
Use the asynchronous flow when payment gateways generate tokens asynchronously. You create the SPM record with a Pending status, and the token is updated later via a webhook notification.
Here’s the high-level workflow for creating a saved payment method record asynchronously.

Here are the steps to create a saved payment method asynchronously using the tokenized payment details received from a third-party payment gateway:
-
The client builds the asynchronous gateway adapater. See Building a Asynchronous Gateway Adapter.
-
The client configures a webhook endpoint to receive notifications from the payment gateway. This webhook endpoint is mapped to Salesforce Notify API through an Apex adapter to receive notifications from payment gateway about payment events.
-
The client calls the payment gateway with the payment details entered through the buyer component.
-
The gateway returns a reference number that’s later used to correlate the asynchronous update.
-
The client-side component creates the saved payment method record using the SavedPaymentMethod sObject API. It sets all required fields, including:
status=PendinggatewayToken= emptyasyncGatewayRefNumber(mandatory for async flows)
Sample JSON request
Sample JSON response
-
When the token is generated, the gateway sends a webhook to the configured endpoint with the same
AsyncGatewayRefNumber. Upon receiving this notification, the SPM record status is updated to Active, and the gateway token is stored in the SavedPaymentMethod object.
Salesforce Commerce Payments Notify API for Stripe
Resource: /commerce/payments/notify/stripe
Here’s a sample Stripe notify response:
Here’s a sample Adyen async response:
Here’s a sample user interface that shows the status of a Saved Payment Method record before and after the webhook endpoint notification is sent.
Before webhook:

After webhook:

See Also