Newer Version Available
Set Up an Asynchronous Payment Gateway Adapter
For payments transactions, you can configure Salesforce to interface with an
asynchronous payment gateway adapter.
| Available in: Salesforce Summer ’20 and later |
| Available in: API 49.0 and later |
To access the commercepayments API, you need the PaymentPlatform org permission.
-
Create a Salesforce site. From Setup, in the Quick Find box, enter
Sites. Under Sites and Domains, select Sites see
Set Up Salesforce Sites.
Set the site’s public access settings to Guest Access to the Payments API.
- Create your payment gateway adapter Apex classes. Asynchronous payment gateways require that you implement an asynchronous and a synchronous adapter. For information about building gateway adapters in Apex, see Building an Asynchronous Gateway Adapter and Building a Synchronous Gateway Adapter.
-
Create a named credential in the UI.
- From Setup, in the Quick Find box, enter Named Credentials, and then select New.
- Complete the required fields. For the URL, enter the URL of your payment gateway.
-
Create a payment gateway provider. The PaymentGatewayProvider object stores details about
the payment gateway that Salesforce Payments communicates with when processing a transaction.
-
Generate an access token according to the instructions in Connect to Connect REST API Using
OAuth.
The response includes the access token, specified in the access_token property, and the server instance, specified in the instance_url property. Use this information to make API calls to build the payment gateway provider.
-
Execute a POST call to the resource using the domain in the instance_url. For example, https://instance_name.my.salesforce.com/services/data/vapi_version/tooling/sobjects/PaymentGatewayProvider.
Use this payload as the request body, replacing value with the correct data.
1{ 2 "ApexAdapterId": "value", 3 "DeveloperName": "value", 4 "MasterLabel": "value", 5 "IdempotencySupported": "value", 6 "Comments": "value" 7} 8 9Example: 10{ 11 "ApexAdapterId": "01pxx0000004UU8AAM", 12 "DeveloperName": "MyNewGatewayProvider", 13 "MasterLabel": "My New Gateway Provider", 14 "IdempotencySupported": "Yes", 15 "Comments": "Custom made gateway provider." 16}
-
Generate an access token according to the instructions in Connect to Connect REST API Using
OAuth.
-
Create a payment gateway record. The PaymentGateway object stores information about the
connection to an external payment gateway. The record requires these field values.
- Payment Gateway Name: Name of the external payment gateway.
- Merchant Credential ID: ID of the named credential that you created.
- Payment Gateway Provider ID: ID of the payment gateway provider that you created.
- Status: Active
-
Create a webhook by providing a URL in the standard notification transport settings of your
external payment gateway. The external payment gateway uses the webhook to send notifications,
as HTTP POST messages, to your asynchronous payment gateway adapter.
The webhook is a combination of your site endpoint with the ID of the payment gateway provider.
-
Use the following URL for your site’s endpoint, replacing domain with your site's domain and URL. For example:
https://MyDomainName.my.salesforce-sites.com/solutions/services/data/v58.0/commerce/payments/notify
- Find the ID of your payment gateway provider, and append the ?provider=ID query parameter to the endpoint. For example, https://MyDomainName.my.salesforce-sites.com/solutions/services/data/v58.0/commerce/payments/notify?provider=0cJR00000004CEhMAM
- Enter the webhook in your external payment gateway’s standard notification settings.
-
Use the following URL for your site’s endpoint, replacing domain with your site's domain and URL. For example: