Newer Version Available

This content describes an older version of this product. View Latest

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.

  1. Create a Site.
    1. Register a site and set the site domain.
    2. From Setup, in the Quick Find box, enter Sites, and then select Sites. Go to the Sites list and click New.
    3. Enter a label and select Active.
    4. Enter a unique value for the default web address.
    5. Select Guest Access to the Payments API, and then save your changes.
  2. 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.
  3. Create a Named Credential in Salesforce UI.
    1. From Setup, in the Quick Find box, enter NamedCredential, and then select New Named Credential.
    2. Enter the username, password, and URL for your payment gateway, and then save your changes.
  4. 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.
    1. Log in to Workbench, and then select REST Explorer.
    2. 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
    3. Enter your payload, replacing VALUE with your desired value.
      1{
      2 "ApexAdapterId": "{{VALUE}}",
      3 "DeveloperName": "{{VALUE}}",
      4 "MasterLabel": "VALUE",
      5 "IdempotencySupported": "VALUE",
      6 "Comments": "VALUE",
  5. 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
  6. 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.
    1. 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

      If you’re not using enhanced domains, your org’s Salesforce Sites URL is different. For details, see My Domain URL Formats in Salesforce Help.

      Note

    2. 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
    3. Enter the webhook in your external payment gateway’s standard notification settings.