Loading
Feature degradation | Gmail Email delivery failureRead More
Salesforce Order Management
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Configure a Payment Gateway for Order on Behalf Of (B2C Only)

          Configure a Payment Gateway for Order on Behalf Of (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

          Important
          Important If you’re using OOBO, 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.
          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
          Example

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

          // Script to add a connection between the webstore 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;
          }
           
          Loading
          Salesforce Help | Article