LogoLogo
Partner Integrations
Salesforce Lightning B2B Commerce App 2.0
Salesforce Lightning B2B Commerce App 2.0
  • Salesforce Lightning B2B Commerce App 2.0
  • Introduction
    • How it works
    • What's new in version 2.0
  • Upgrading to version 2.0
  • 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: Integrate the Digital River components into the Commerce storefront
      • Integrate the Digital River components into the B2B Commerce LWR template
        • Add components to the Checkout page
        • Add custom components outside of checkout
      • 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
      • 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
      • Add custom components to pages (Aura)
        • Drag and drop (custom) components
    • Step 18: Test the Salesforce Lightning app integration
    • Step 19: Consider recommended extensions
  • Extend the Salesforce Lightning app
    • Customizing the Lightning web components
      • Designer attributes
        • Designer attributes for LWR
        • Designer attributes for Aura
      • Components
        • Buyer info component
        • DR util component
        • DR Terms component
        • Checkout summary component
        • Order Summary component
        • Place order component
        • Payments component
        • Payment details component
        • Tax identifier component
        • DR compliance component
        • Address details component
        • Offline refund component
        • Hide checkout summary component (Aura only)
    • 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
    • Mapping custom fields (LWR only)
    • Add a spinner component (LWR only)
  • User guide
    • Regulatory fees
    • Tax certificates
    • Tax identifiers
    • My wallet
    • Customer credit
    • Checkout and order creation
    • Fulfillment/cancellation flow
    • Refunds
    • Offline refunds
    • Invoices and credit memos
  • Support
  • Appendix
    • Custom fields and objects
    • Contact point address
    • Multi-currency support
Powered by GitBook
On this page
  • Refresh components
  1. Extend the Salesforce Lightning app

Tax calculation

Learn about how tax calculation works when you use the Salesforce Lightning app.

PreviousPublishing connector eventsNextOverriding Digital River CSS

Last updated 1 year ago

In some use cases, you need to trigger the tax calculation integration from your custom component. Read this section to learn how to trigger tax calculation. If you are using the LWR template, you can trigger the tax calculation in two ways.

  1. Use the to update either the deliveryAddress or the deliveryMethodId.

    • Each time this API call is made, a tax will be calculated, resulting in additional API calls to Digital River. Optimize your code only to call the endpoint from your front-end components a minimal number of times.

  2. Call the Digital River tax calculation service directly. Continue reading below to understand how to trigger tax calculations from a custom apex class (which can be called from a custom LWC).

Tax calculation in the Salesforce Lightning app is segregated into two separate layers. The inner layer, the DRB2B_CartTaxCalculations class, contains both the API connector and messaging functionality.

Use the outer layer, DRB2B_TaxCalculationService class, as a global service that can be used as a stand-alone integration. This service has a startCartProcessAsyncmethod which takes CartId (id)and sfdc_checkout.IntegrationInfo which returns a ResponseModelcustom apex object.

After making the API call to Digital River, the service uses the checkout service to store the response in the CartTax object. The DRB2B_TaxCalculationService service is used in the Aura checkout flows and the LWR tax integration.

Refer to the following example to understand how to use tax calculation in an asynchronous checkout (Aura) context:

You can call the tax calculation routine as an alternative to the previous example. Refer to the following example to understand how the service can be called in a stand-alone use case. You can use the example for LWR or for any use case where you are triggering tax outside the integration service.

@AuraEnabled
public static String startTaxCalc(string cartId) {
	String result;
	Map<String, String> responseMap = new Map<String, String>();
	try {
		digitalriverv3.DRB2B_TaxCalculationService.ResponseModel response =  digitalriverv3.DRB2B_TaxCalculationService.startCartProcessAsync(cartId, null);
		if(response != null){              
			responseMap.put('status', response.status);
			responseMap.put('message', response.message);
			result = JSON.serialize(responseMap);
		}
		 if(response != null && response.status =='Error'){
		   //handle error as desired
		 }
	}
	catch (Exception e) {
		throw new AuraHandledException(e.getMessage());
		
	} 
	return result;
 }

The following table provides details on the input parameters used in tax calculations:

Input variable name
Description

cartId

Type: Id

Identifies the cart in the checkout session.

jobInfo

Type: sfdc_checkout.IntegrationInfo

Used in cases of an asynchronous checkout process used to load exceptions and related messages into a session. This can be NULL when used as a stand-alone process.

The following table provides information on the output parameters used in tax calculations:

Variable name
Description

ResponseModel.status

Type: String

Possible values:

“Error” – This is passed when an exception or validation error occurs because the tax calculation cannot completed.

“Success” – This is passed when tax calculation was success.

ResponseModel.message

Type: String

Provides the response string message passed on when there is an exception.

Refresh components

After triggering tax calculation, refresh many components on the page with the updated data. Be sure to refresh any custom components you have on the page. Refresh the Digital River components by triggering the calculateTaxRefresh event. This is described in the section.

Buyer Info component
Commerce Webstore Checkout REST API endpoint