Create a store credit extension and configure the webhook

To create a custom integration with a store credit payment gateway, you perform the following steps:

  1. Create the gateway extension. See Store credit extension details for information specific to this extension.
  2. Upload the extension to the administration interface.
  3. Enable the gateway for the sites that require it.
  4. Add a store credit payment option to the checkout page.
  5. Configure the Generic Payment webhook by specifying the gateway URL and the username and password. Note that webhook settings are not site-specific. The configuration you supply applies to all sites that use this webhook.

Store credit extension details

The format of a payment gateway extension is described in the Create a Credit Card Payment Gateway Integration chapter. For a store credit gateway, the gateway.json file should be similar to the following:

{
  "provider": "Store Credits Payment Gateway",
  "paymentMethodTypes": ["storeCredit"],
  "transactionTypes": {
    "storeCredit": ["balanceInquiry", "authorize", "void", "refund"]
  }
}

The config.json file should be similar to the following:

{
  "configType": "payment",
  "titleResourceId": "title",
  "descriptionResourceId": "description",
  "instances" : [
    {
      "id": "agent",
      "instanceName": "agent",
      "labelResourceId": "agentInstanceLabel"
    },
    {
      "id": "preview",
      "instanceName": "preview",
      "labelResourceId": "previewInstanceLabel"
    },
    {
      "id": "storefront",
      "instanceName": "storefront",
      "labelResourceId": "storefrontInstanceLabel"
    }
  ],
  "properties": [
    {
      "id": "paymentMethodTypes",
      "type": "multiSelectOptionType",
      "name": "paymentMethodTypes",
      "required": false,
      "helpTextResourceId": "paymentMethodsHelpText",
      "labelResourceId": "paymentMethodsLabel",
      "defaultValue": "storeCredit",
      "displayAsCheckboxes": true,
      "public": true,
      "options": [
         {
           "id": "storeCredit",
           "value": "storeCredit",
           "labelResourceId": "storeCreditPayLabel"
         }
       ]
    },
    {
      "id": "includeOrderInWebhookPayload",
      "type": "booleanType",
      "name": "includeOrderInWebhookPayload",
      "helpTextResourceId": "includeOrderHelpText",
      "labelResourceId": "includeOrderLabel",
      "defaultValue": true,
      "public": true
    }
  ]
}

Currency and store credit

Commerce requests the store credit authorization in the order currency value, but it does not convert the order currency to store credits or conversely. The merchant ERP system should return the store credit equivalent value for the requested currency amount. For example, Commerce requests the store credit authorization in $150.00, and the store credit balance is 1500. Only the merchant ERP system can decide the dollar amount of 1500 store credits and whether it is more or less than $150.00. If it is more than $150, the merchant ERP system should return a success response code along with the remaining store credit balance. Otherwise it should return a decline response code.