Create a Saved Payment Method Using the sObject API
Use SavedPaymentMethod sObject API to create Saved Payment Method (SPM) records directly in Salesforce. To import payment details previously tokenized and stored by your payment gateway, include the existing payment token and related tokenized details in your request. The API creates the SavedPaymentMethod record and returns the Salesforce-generated SPM ID, which you then use for future transactions initiated from Salesforce.
Resource
/services/data/<version>/sobjects/SavedPaymentMethod
Resource example
https://<my-domain>.salesforce.com/services/data/66.0/sobjects/SavedPaymentMethod
HTTP method
POST
Request body
The API validates the input and creates the record in the SavedPaymentMethod object.
Sample JSON request
| Name | Type | Description | Required or Optional |
|---|---|---|---|
checksum | String | Specifies the unique value provided by the payment gateway. For example, use pspReference for Adyen and fingerprint for Stripe. The Checksum field is used in conjunction with paymentgatewayId and referenceOwnerId to enforce uniqueness and prevent duplicate SPM creation. An index on these three fields supports efficient duplicate detection. | Required |
expiryYear | String | The year the payment method expires. | Optional This field is required for the card payment method. |
expiryMonth | String | The month the payment method expires. | Optional This field is required for the card payment method. |
extendedPaymentMethodType | String | The actual payment method type for extended APM/Wallet scenarios. | Optional This field is required if the type is extd_wallet or extd_apm_type. |
gatewayToken | String | An unencrypted unique token ID generated by the payment gateway to represent the card payment method during transactions. | Optional This field is required for creating an active Saved Payment Method. |
gatewayReference | String | A reference to the saved payment owner at the payment gateway. For example, a Stripe customer ID. | Required |
merchantAccountId | String | The Salesforce Payments merchant account ID. | Required |
name | String | The name of the saved payment method. | Required |
paymentGatewayId | String | The payment gateway that is used to create a gateway token. For transactions with a saved payment method in Salesforce, this field stores the payment gateway ID used in the transaction. This field is a relationship field. | Required |
processingMode | String | Specifies the origin of the saved payment method. Possible values are:
| Optional Specify this field value as External when making the SPM sObject API call. |
referenceOwnerId | String | The ID of the Account or Contact record that owns the payment method. | Required |
status | String | The status of the saved payment method. Possible values are:
| Required |
type | String | The type of saved payment method. Possible values are:
| Required |
usageType | String | Determines whether the payment method is used on or off session. Possible values are:
| Required |
Response body
The API returns the newly generated Salesforce Saved Payment Method ID of the imported record.
Sample JSON response
| Name | Type | Description |
|---|---|---|
id | String | The ID of the saved payment method record. |
success | String | Indicates whether the saved payment method record was created successfully. |
errors | String | Specifies the errors that occurred during the saved payment method creation request. |
You can use the Saved Payment Method creation process to bulk-import saved payment method records. For more information on bulk import, see Bulk API.
See Also