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

NameTypeDescriptionRequired or Optional
checksumStringSpecifies 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
expiryYearStringThe year the payment method expires.Optional
This field is required for the card payment method.
expiryMonthStringThe month the payment method expires.Optional
This field is required for the card payment method.
extendedPaymentMethodTypeStringThe actual payment method type for extended APM/Wallet scenarios.Optional
This field is required if the type is extd_wallet or extd_apm_type.
gatewayTokenStringAn 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.
gatewayReferenceStringA reference to the saved payment owner at the payment gateway. For example, a Stripe customer ID.Required
merchantAccountIdStringThe Salesforce Payments merchant account ID.Required
nameStringThe name of the saved payment method.Required
paymentGatewayIdStringThe 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
processingModeStringSpecifies the origin of the saved payment method. Possible values are:
  • External–Set when importing an existing token using the SPM sObject API.
  • Salesforce–Set when creating an SPM record using Commerce CCS APIs.
Optional
Specify this field value as External when making the SPM sObject API call.
referenceOwnerIdStringThe ID of the Account or Contact record that owns the payment method.Required
statusStringThe status of the saved payment method. Possible values are:
  • Active
  • AwaitingPayment
  • Errored—Failed
  • Expired
Required
typeStringThe type of saved payment method. Possible values are:
  • au_becs_debit
  • bacs_debit
  • bancontact
  • card
  • ideal
  • sepa_debit
  • us_bank_account–ACH Direct Debit
Required
usageTypeStringDetermines whether the payment method is used on or off session. Possible values are:
  • OffSession
  • OnSession
  • RestrictedOffSession
Required

Response body

The API returns the newly generated Salesforce Saved Payment Method ID of the imported record.

Sample JSON response

NameTypeDescription
idStringThe ID of the saved payment method record.
successStringIndicates whether the saved payment method record was created successfully.
errorsStringSpecifies 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