LogoLogo
Connectors
Salesforce Lightning B2B Commerce App 1.2.1
Salesforce Lightning B2B Commerce App 1.2.1
  • Salesforce Lightning B2B Commerce App 1.2.1
  • Introduction
    • How it works
    • What's new in version 1.2.1
  • Upgrading to version 1.2.1
  • 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
  • Extending the webhook
  • DRB2B_RefundPendingWebhook
  • Configuring the Apex class
  • DRB2B_RefundCompleteWebhook
  1. Extend the Salesforce Lightning app

Extend the webhook framework

Learn how to extend the webhook framework.

PreviousExtend the Ship From addressNextConfigure subscriptions

Last updated 2 years ago

The Salesforce Lightning—Digital River Connector App comes with a webhook framework that is capable of accepting and consuming any webhook that can be configured in the Digital River . For OOTB (out-of-the-box) webhook events, see .

You can always extend this framework to implement custom code that will fire upon receipt of a from Digital River. The event needs to be added to the previously-created webhook in the Digital River .

Extending the webhook

To implement the custom business logic for your organization, write the subscriber code that extends the default Webhook Framework Extension point class **** digitalriverv3.DRB2B_WebhookHandler.

For example, suppose you want to implement custom business logic for the event refund.pending

  • In your organization, create an Apex class that extends the extension point class digitalriverv3.DRB2B_WebhookHandler global with sharing class DRB2B_RefundPendingWebhook extends the digitalriverv3.DRB2B_WebhookHandler { }

  • Inside the class definition, override the method processWebhookEvent of the extension point class digitalriverv3.DRB2B_WebhookHandler. This method will have the Event Payload as one of its Input parameters.

global class DRB2B_RefundPendingWebhook extends 
digitalriverv3.DRB2B_WebhookHandler {
    
    global override void processWebhookEvent(RestResponse response, 
    String webhookEventPayload) {
        // Custom Implementation
    }
 
}
  • Inside your method override, add your custom business logic. Ensure the RestResponse status code is set to 200 as shown in the sample implementation for the refund.pending webhook event below.

DRB2B_RefundPendingWebhook

global class DRB2B_RefundPendingWebhook extends 
digitalriverv3.DRB2B_WebhookHandler {
 
private static final digitalriverv3.DCM_Logger 
logger = digitalriverv3.DCM_Logger.getInstance('Webhook Event');
        
    global override void processWebhookEvent(RestResponse response, 
    String 
    webhookEventPayload) {
       // Log the event to DCM Application log object
       logger.debug('Event: refund.pending; Refund Pending Webhook 
Event Payload: ' + webhookEventPayload);
       
        Messaging.SingleEmailMessage email = new 
        Messaging.SingleEmailMessage();
        email.setSubject('Process Webhook for event: refund.pending');
        email.setToAddresses(new List<String> 
        { 'example@digitalriver.com'});
        email.setHtmlBody(webhookEventPayload + '<br/> <br/>');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] 
        { email });
        
        response.statusCode = 200;
    }
 
}

Save your class and resolve any compilation errors.

Configuring the Apex class

Your Apex class must be configured so that the Connector is aware and executes this Custom Webhook handler implementation whenever it receives the event refund.pending from Digital River.

  1. Go to the Custom Metadata Type digitalriverv3_DR_Webhook_Configuration_

    • Label: Refund Pending Webhook Handler

    • DR Webhook Configuration Name: Refund_Pending_Webhook_Handler

    • Webhook Handler Name: DRB2B_RefundPendingWebhook (Custom Class Name)

  2. Click Save.

  3. Select the event refund.pending for the Webhook Endpoint selected in the previous step.

DRB2B_RefundCompleteWebhook

The following example shows how to extend the webhook framework, this time for the refund.complete event. In this example, an email is sent with the event payload.

   global class DRB2B_RefundCompleteWebhook extends 
   digitalriverv3.DRB2B_WebhookHandler {
 
    private static final digitalriverv3.DCM_Logger logger = 
    digitalriverv3.DCM_Logger.getInstance('Webhook Event');
        
    global override void processWebhookEvent(RestResponse response, 
    String webhookEventPayload) {// Log the event to Application log object
    logger.debug('Event: refund.complete; Refund Complete Webhook Event 
    Payload: ' + webhookEventPayload);

     // Send Email
      Messaging.SingleEmailMessage email = 
      new Messaging.SingleEmailMessage();
      email.setSubject('Process Webhook for event: refund.complete');
      email.setToAddresses(new List<String> 
      { 'example@digitalriver.com' });
      email.setHtmlBody(webhookEventPayload + '<br/> <br/>');
      Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
        
        response.statusCode = 200;
    }
 
}

mdt and click Manage Records.

Create a new Metadata Type Record for the DR Webhook Configuration.

Webhook Event Name: refund.pending (This is the of the webhook.)

Set up the webhook for the Event Type refund.pending in the .

Go to Webhooks and click the webhook endpoint that you for your organization. The endpoint URL is: https://<<SF_My_Domain_Name>>/services/apexrest/digitalriverv3/webhooks

Continue with the steps detailed in to complete the configuration of the webhook extension.

Dashboard
Set up webhooks
Webhook
Dashboard
event type
Dashboard
Configuring the Apex class
previously configured