---
schema_version: "1"
id: a07ff0750b7150ed9ea60f8628923b79bdfc8f3516626a220331878e828fcb20
title: Configure a Payment Gateway for Exchanges RMA (B2C Only)
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/commerce/264-0-0/om_manually_configure_payment_gateway_exchanges_rma.md
canonical_url: https://help.salesforce.com/s/articleView?id=commerce.om_manually_configure_payment_gateway_exchanges_rma.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 4a89e8f97710f7daf4ba0ea3bc6be7ab4d51b91f0ab401433892484d008a2b36
description: If you don’t use Salesforce Payments, you can configure a payment gateway to manage payments. Payment packages for some vendors are available on AppExchange.
products:
  - Commerce
  - Salesforce Order Management
release: "264"
---
# Configure a Payment Gateway for Exchanges RMA (B2C Only)

If you don’t use Salesforce Payments, you can configure a payment gateway to manage payments. Payment packages for some vendors are available on AppExchange.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=commerce.om_editions.htm&amp;language=en_US" target="_blank">View supported editions</a>.</td></tr></tbody></table>

![Important](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-commerce-om_order_management-264-0-0-production-enus/4c4844e3-a194-4a65-95b7-17291a6dbefa/images/icon_important.png)

Important If you’re using exchanges with B2B or D2C Commerce, steps 1-4 are already configured during the Order Management implementation. Go straight to step 5.

1. Create a payment gateway adapter class using the Salesforce Apex connector framework.
    
    To help you get started, see these [reference classes](https://github.com/forcedotcom/Core-Payments-Reference-Gateway-Integration-Adapters).
2. Create a payment gateway provider record that points to the adapter class that you created.
3. In Setup, define a named credential that contains the gateway provider’s authentication and login information. The adapter class callout definition calls the named credential.
4. Link the payment gateway provider record and the named credential by creating a payment gateway record.
5. Associate the payment gateway to the webstore record.

![Example](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-commerce-om_order_management-264-0-0-production-enus/4c4844e3-a194-4a65-95b7-17291a6dbefa/images/icon_example.png)

Example

To associate the payment gateway to the web store record, use a script like this

```
// Script to add a connection between the web store and the payment gateway for B2C Commerce stores
String webStoreName = 'SiteGenesis';
String paymentGatewayName = 'SalesforceAdapter';

// obtain webstoreid
List<WebStore> webstores = [SELECT Id, Name FROM WebStore WHERE Name = :webStoreName];
System.debug('Webstores: ' + webstores);
if(webstores.isEmpty()){
    System.debug('Error obtaining webstore with name ' + webStoreName);
}
String webStoreId = webstores[0].Id;
System.debug('WebStoreId: ' + webStoreId);

// obtain payment gateway id from the payment gateway name
List<PaymentGateway> paymentGateways = [SELECT Id, PaymentGatewayName FROM PaymentGateway WHERE PaymentGatewayName = :paymentGatewayName];
System.debug('paymentGateways: ' + paymentGateways);
if(paymentGateways.isEmpty()){
    System.debug('Error obtaining payment gateway with name ' + paymentGatewayName);
}
String paymentGatewayId = paymentGateways[0].Id;
System.debug('paymentGatewayId: ' + paymentGatewayId);

// If a StoreIntegratedService already exists for Payment on the WebStore then update the Integration field with the paymentGatewayId
List<StoreIntegratedService> storeServices = [SELECT Id FROM StoreIntegratedService WHERE StoreId = :webStoreId AND ServiceProviderType ='Payment' ];
System.debug('storeServices: ' + storeServices);
if(storeServices.isEmpty()){
    StoreIntegratedService storeService = new StoreIntegratedService(
        StoreId = webStoreId,
        Integration = paymentGatewayId,
        ServiceProviderType ='Payment');
    insert storeService;
} else {
    StoreIntegratedService existingStoreService = storeServices[0];
    existingStoreService.Integration = paymentGatewayId;
    update existingStoreService;
}
```

#### See Also

- [Exchanges with RMA Setup](https://help.salesforce.com/s/articleView?id=commerce.om_exchanges_rma_setup.htm&release=264.0.0&type=5 "After you have installed and configured either an Order Management, B2B Commerce, or D2C Commerce org, configure Exchanges with RMA Returns.")
- [Exchanges with RMA Returns Overview](https://help.salesforce.com/s/articleView?id=commerce.om_exchanges_rma_overview.htm&release=264.0.0&type=5 "An exchange with an RMA return provides a more robust exchange experience for customers. Unlike a simple exchange, which only allows for same-cost variant exchanges, an exchange with RMA processes the return of the previous product before letting a customer service representative (CSR) order a new item, enter a new delivery address, and select a shipping method, all on behalf of the user. Finally, the CSR can process any refund or additional funds needed from the customer.")