LogoLogo
Partner Integrations
Salesforce Lightning B2B Commerce App 1.5
Salesforce Lightning B2B Commerce App 1.5
  • Salesforce Lightning B2B Commerce App 1.5
  • Introduction
    • How it works
    • What's new in version 1.5
  • Upgrading to version 1.5
  • Integrate the Salesforce Lightning app
    • Step 1: Install the Digital River app
    • Step 2: Configure the Digital River app
    • Step 3: Register external services
    • Step 4: Configure DCM logs
    • Step 5: Add custom fields to the page layouts
    • Step 6: Enable email deliverability
    • Step 7: Import ECCN codes, tax groups, and tax types
    • Step 8: Configure and synchronize the products
    • Step 9: Schedule backend jobs
    • Step 10: Set up integration between Salesforce and Digital River
    • Step 11: Set up webhooks
    • Step 12: Configure landed cost
    • Step 13: Manage permission sets
    • Step 14: Configure shipping integration
    • Step 15: Integrating refunds
    • Step 16: Configure the From email address
    • Step 17 (alternative): Integrate the Digital River components into an asynchronous checkout flow
      • Custom components used in the checkout subflows
      • Subflow configuration
        • Configure the delivery method subflow
        • Configure the Checkout Summary subflow
        • Configure the Payment and Billing Address subflow
          • Edit the Payment Method screen
          • Edit the decision elements
          • Link screen components
        • Configure the shipping address subflow
          • Configure the shipping address screen
      • Configure the main checkout flow
    • Step 18 (alternative): Integrate the Digital River components into a synchronous checkout flow
      • Deploy flows using Salesforce Workbench
      • Update the flow nodes in the synchronous checkout flow
        • Create custom variables
        • Delete nodes
        • Connect nodes
        • Modify nodes
        • Add nodes
      • Configure screens for a customized synchronous flow
        • Add custom components to screens in the synchronous checkout flow
        • Configure the Shipping Options screen
        • Configure the Delivery Method Screen
        • Configure the Checkout Summary screen
        • Configure the Payment And Billing Address screen
        • Configure the Place Order Confirmation screen
    • Step 19: Add custom components to pages
      • Drag and drop (custom) components
    • Step 20: Test the Salesforce Lightning app integration
  • Extend the Salesforce Lightning app
    • Extend the Ship From address
    • Extend the webhook framework
    • Configure subscriptions
    • Shipping choice extension point
    • Customer credit
      • addCustomerCreditSourceToCheckout
      • deattachPaymentToCheckout
      • getAmountRemainingforCheckout
      • getCartDetailsById
      • Publishing connector events
    • Tax calculation
    • Overriding Digital River CSS
    • Customizing the Lightning web components
      • Designer attributes
      • Components
        • Buyer info component
        • Tax certificate component
        • DR util component
        • DR Terms component
        • Checkout summary component
        • Hide checkout summary component
        • Order Summary component
        • Place order component
        • Payments component
        • Payment details component
        • Tax identifier component
        • DR compliance component
        • Address details component
  • User guide
    • Regulatory fees
    • Tax certificates
    • Tax identifiers
    • My wallet
    • Customer credit
    • Checkout and order creation
    • Fulfillment/cancellation flow
    • Refunds
    • Invoices and credit memos
  • Support
  • Appendix
    • Custom fields and objects
    • Contact point address
    • Multi-currency support
Powered by GitBook
On this page
  • Tax integration service
  • Payment Service
  1. Integrate the Salesforce Lightning app

Step 3: Register external services

Learn how to register external services.

Register external services for Tax Calculation and Payment Services. You can run these scripts from the Developer Console in an Execute Anonymous window or by the method of your choice when you register other services as part of the site setup before starting the connector setup.

Tax integration service

If you have not registered the external service for tax integration:

  1. Use the following script to insert the Tax Calculation Apex class that comes with the package into RegisteredExternalService. To use the script, simply modify the <<storeName>> variable before running.

    // WebStore query values
    String webstoreName = 'DR Sync Store'; // Enter your webstore name
     
    // ApexClass query values
    String apexClassname = 'DRB2B_CartTaxCalculations';
    String status = 'Active';
     
    // RegisteredExternalService insert values
    String registeredProviderType = 'Tax';
    String registeredDevName = 'COMPUTE_TAXES';
    String registeredLabel = registeredDevName;
     
    // StoreIntegratedService insert values
    String devname = registeredDevName;
    String prefix = registeredProviderType;
    String prefixedName = prefix + '__' + devname;
     
    // locate webstore
    WebStore webStore = Database.query('SELECT Id FROM WebStore WHERE Name = :webstoreName LIMIT 1');
    String webStoreId = webStore.Id;
    System.debug('webStoreId:' + webStoreId);
     
    // locate apex class Id
    ApexClass apexClass = Database.query('SELECT Id FROM ApexClass WHERE Status=:status AND Name=:apexClassname LIMIT 1');
    String apexClassId = apexClass.Id;
    System.debug('apexClassId:' + apexClassId);
     
     
    // locate apex in RegisteredExternalService
    String registeredIntegrationId = null;
    try {
        RegisteredExternalService registeredExternalService = Database.query('SELECT Id FROM RegisteredExternalService WHERE ExternalServiceProviderId=:apexClassId AND DeveloperName=:registeredDevName AND ExternalServiceProviderType=:registeredProviderType LIMIT 1');
        registeredIntegrationId = registeredExternalService.Id;
        System.debug('apex class registration: FOUND ' + registeredIntegrationId);
        //delete registeredExternalService; // optionally remove     if needed    
    } 
    catch (QueryException q) {
        System.debug('apex class registration: MISSING ' + apexClassId);
        insert new RegisteredExternalService(DeveloperName = registeredDevName, MasterLabel = registeredLabel, ExternalServiceProviderId = apexClassId, ExternalServiceProviderType = registeredProviderType);
        RegisteredExternalService registeredExternalService = Database.query('SELECT Id FROM RegisteredExternalService WHERE     ExternalServiceProviderId = :apexClassId  LIMIT 1');
        registeredIntegrationId = registeredExternalService.Id;
        System.debug('apex class registration: INSERTED ' +     registeredIntegrationId);
    }
  2. Verify that the Tax Calculation Apex class ID is registered with thesoqlquery below. The ExternalServiceProviderId should match the Tax Calculation Apex Class DRB2B_CartTaxCalculations ID in the org.

    Select Id, ExternalServiceProviderId, ExternalServiceProviderType, DeveloperName From RegisteredExternalService Where ExternalServiceProviderType = 'Tax'

If you have already registered the external service for tax integration:

  1. Run the following script to update the Tax Integration service to point to the Tax Calculation integration class from the Salesforce Lightning app.

    // Configure Tax Calculation Service
    RegisteredExternalService taxServiceRegistration = [
            SELECT Id
            FROM RegisteredExternalService
            WHERE ExternalServiceProviderType = 'Tax'
            LIMIT 1
    ];
    
    ApexClass taxCalculationService = [
            SELECT Id
            FROM ApexClass
            WHERE Name = 'DRB2B_CartTaxCalculations'
            LIMIT 1
    ];
    
    
    taxServiceRegistration.ExternalServiceProviderId = 
    taxCalculationService.Id;update taxServiceRegistration;
  2. Verify that the Tax Calculation Apex class ID is registered by making the below soql query. The ExternalServiceProviderId should match the Tax Calculation Apex Class DRB2B_CartTaxCalculations ID in the org.

    Select Id, ExternalServiceProviderId, ExternalServiceProviderType, 
    DeveloperName  From RegisteredExternalService Where 
    ExternalServiceProviderType = 'Tax'

Payment Service

Register Payment Service by the following steps:

  1. Capture the WebStore Id. This will be used in the script in step 4.

  2. Create a Named Credential for Digital River with the following details:

    • Label: Digital River API

    • Name: Digital_River_API

    • URL: https://api.digitalriver.com

    • Identity Type: Named Principal

    • Authentication Protocol: No Authentication

  3. Create a Payment Gateway Provider:

    • Sign in to Workbench from your commerce org.

    • Go to the Data tab and select Insert.

    • Go to the Object Type and select PaymentGatewayProvider.

    • Select Single Record and click Next.

    • Fill in the fields using your Payment Gateway Adapter information.

      Field name
      Example

      ApexAdapterId

      ID of Payment Gateway Adapter Apex class DRB2B_PaymentGatewayAdapter

      DeveloperName

      DR_PaymentGateway

      IdempotencySupported

      Yes

      MasterLabel

      DR Payment Gateway

      Comments

      Digital River Payment Gateway Provider

  4. Set up Payment Gateway and insert a StoreIntegratedService record for payment by executing the below script. Be sure to update the WebstoreID to the one captured in step 1 of this section.

String webstoreId = '<WebstoreId>';
PaymentGatewayProvider paymentGatewayProvider = [SELECT Id FROM PaymentGatewayProvider Where DeveloperName = 'DR_PaymentGateway' LIMIT 1];
NamedCredential namedCredential = [SELECT Id FROM NamedCredential WHERE DeveloperName = 'Digital_River_API' LIMIT 1];

String paymentGatewayId = '';

List<PaymentGateway> paymentGatewayList = [SELECT Id,MerchantCredentialId,PaymentGatewayName,PaymentGatewayProviderId FROM PaymentGateway WHERE PaymentGatewayProviderId = :paymentGatewayProvider.Id Limit 1];
if(null != paymentGatewayList && paymentGatewayList.size() > 0) {
	PaymentGateway paymentGateway = paymentGatewayList.get(0);
	paymentGatewayId = paymentGateway.Id;
	}
else{
	PaymentGateway paymentGateway = new PaymentGateway(
			PaymentGatewayName = 'Digital River Payment Gateway',
			MerchantCredentialId = namedCredential.Id,
			PaymentGatewayProviderId = paymentGatewayProvider.Id,
			Status = 'Active'
	);
	insert paymentGateway;
	paymentGatewayId = paymentGateway.Id;
	
}

List<StoreIntegratedService> storeIntegratedServiceList = [SELECT Id FROM StoreIntegratedService WHERE ServiceProviderType = 'Payment' and StoreId = :webstoreId Limit 1];

if(null != storeIntegratedServiceList && storeIntegratedServiceList.size() > 0) {
    StoreIntegratedService storeIntegratedService = storeIntegratedServiceList.get(0);
    storeIntegratedService.Integration = paymentGatewayId;
    update storeIntegratedServiceList;
}
else {
    StoreIntegratedService storeIntegratedService = new StoreIntegratedService(
        StoreId = webstoreId,
        Integration = paymentGatewayId,
        ServiceProviderType = 'Payment'
    );
    insert storeIntegratedService;
	
}
PreviousStep 2: Configure the Digital River appNextStep 4: Configure DCM logs

Last updated 2 years ago

Generate Authorization Header: false

Click Confirm Insert.