Newer Version Available
Set Up an Asynchronous Payment Gateway Adapter in Salesforce
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 Site.
- Register a site and set the site domain.
- From Setup, in the Quick Find box, enter Sites, and then select Sites. Go to the Sites list and click New.
- Enter a label and select Active.
- Enter a unique value for the default web address.
- Select Guest Access to the Payments API, and then save your changes.
- Create your payment gateway adapter Apex classes. Asynchronous payment gateways require Salesforce to implement both an asynchronous adapter and a synchronous adapter. For more information on building gateway adapters in Apex, review Building an Asynchronous Gateway Adapter and Building a Synchronous Gateway Adapter.
-
Create a Named Credential in Salesforce UI.
- From Setup, in the Quick Find box, enter NamedCredential, and then select New Named Credential.
- Enter the username, password, and URL for your payment gateway, and then save your changes.
-
Create a payment gateway provider. The payment gateway provider is an object that stores
details about the payment gateway that Salesforce communicates with when processing a
transaction. As of Salesforce Summer ’20, you can create a payment gateway provider record only
through Workbench.
- Log in to Workbench, and then select REST Explorer.
-
Set the method to Post, and then enter the following URL, replacing
[version] with your desired API version. The payment gateway provider
entity is available in Salesforce API v48.0 and later.
services/data/[version]/tooling/sobjects/PaymentGatewayProvider
-
Enter your payload, replacing VALUE with your desired value.
-
Create a payment gateway record. This object stores information that Salesforce uses to
communicate with the payment gateway. The record requires the following field values.
- Name: We recommend using the same name as the external payment gateway that will be communicating with Salesforce.
- Merchant Credential ID: Enter the ID of the named credential that you created in Step 2.
- Payment Gateway Provider: Enter the ID of the payment gateway provider that you created in Step 3.
- Status: Active
-
External payment gateways use webhooks to send notification information as HTTP POST
messages to your Salesforce asynchronous payment gateway adapter. You can create a webhook by
providing a URL in the standard notification transport settings of your external payment
gateway. Create your URL by combining your Salesforce site endpoint from Step 1 with the ID of
the payment gateway provider that you created in step 4.
-
Your endpoint will be the following address, replacing domain with your
domain from Step 1A, and replacing subdomain with the default web address
that you provided in Step 1D.
https://MyDomainName.my.salesforce-sites.com/subdomain/services/data/v49.0/commerce/payments/notify
-
Find the ID of the payment gateway provider that you created in Step 4, and add
?provider=ID to the end of your endpoint.
For example, https://MyDomainName.my.salesforce-sites.com/solutionsusers/services/data/v49.0/commerce/payments/notify?provider=0cJR00000004CEhMAM
- Enter the webhook in your external payment gateway’s standard notification settings.
-
Your endpoint will be the following address, replacing domain with your
domain from Step 1A, and replacing subdomain with the default web address
that you provided in Step 1D.