LogoLogo
Connectors
Salesforce B2B Commerce App 2.1.1
Salesforce B2B Commerce App 2.1.1
  • Salesforce B2B Commerce App 2.1.1
  • Introduction
    • How it works
    • What's new in version 2.1.1
    • Requirements
  • Integrating the Digital River Salesforce B2B Commerce App
    • Step 1: Install the Digital River App for Salesforce B2B
    • Step 2: Create page labels
    • Step 3: Configure the Salesforce B2B Commerce App
    • Step 4: Add custom Salesforce B2B Commerce App fields to page layouts
    • Step 5: Enable email deliverability
    • Step 6: Import ECCN codes, tax groups, and tax types
    • Step 7. Update the Product Sync settings
    • Step 8: Set up Digital River fulfillments
    • Step 9: Set up webhooks
    • Step 10: Configure CC Admin settings
    • Step 11: Configure landed cost
    • Step 12: Schedule backend jobs
    • Step 13: Manage permission sets
    • Step 14: Configure the Salesforce B2B Commerce app logs
    • Step 15: Test the Digital River Salesforce B2B Commerce app integration
  • Extending the Digital River Salesforce B2B Commerce App
    • Extend the Ship from address
    • Extend the App Webhook Framework
  • Support
  • Version number
  • Appendix
    • Fulfillment and cancellation flow
    • Issuing refunds
    • Managing regulatory fees
    • Managing subscriptions
    • Salesforce B2B Commerce App logs
    • Uploading tax certificates (US TEMS)
    • Global tax identifiers
    • VAT invoices
Powered by GitBook
On this page
  1. Extending the Digital River Salesforce B2B Commerce App

Extend the App Webhook Framework

Learn how to extend the App Webhook Framework.

PreviousExtend the Ship from addressNextSupport

Last updated 4 years ago

The Salesforce B2B Commerce—Digital River Connector App comes with a Webhook framework that is capable of accepting and consuming any webhook that can be configured in the DR Dashboard. OOTB (Out of the box), the App currently provides an implementation for the Webhook events order.accepted, order.complete and order.invoice.created. You can always extend this framework to implement custom code that will fire upon receipt of a from Digital River.

Extend the webhook framework

To implement custom business logic for your Organization, you can write subscriber code that extends the default Webhook Framework Extension point class digitalriverv2.DRB2B_WebhookHandler.

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

  1. In your Organization, create an Apex class that extends the extension point class digitalriverv2.DRB2B_WebhookHandler global with sharing class DRB2B_RefundPendingWebhook extends digitalriverv2.DRB2B_WebhookHandler { }

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

    global class DRB2B_RefundPendingWebhook extends digitalriverv2.DRB2B_WebhookHandler {
        
        global override void processWebhookEvent(RestResponse response, String webhookEventPayload, List<digitalriverv2.DCM_ApplicationLog> appLogList) {
            // Custom Implementation
        }
     
    }

  3. Inside your method override, add your custom business logic. Make sure the RestResponse status code is set to 200 as shown in the sample implementation for the refund.pending webhook event below.

    global class DRB2B_RefundPendingWebhook  extends digitalriverv2.DRB2B_WebhookHandler {
     
        global override void processWebhookEvent(RestResponse response, String webhookEventPayload, List<digitalriverv2.DCM_ApplicationLog> appLogList) {
            String methodName = 'processWebhookEvent';
            // Log the event to Application log object
            appLogList.add(new digitalriverv2.DCM_ApplicationLog(System.LoggingLevel.INFO, 'Digital River', 'Webhook Event',
                                                        'DRB2B_RefundPendingWebhook', methodName, null,
                                                        'Refund Pending Webhook Event Payload: ' + webhookEventPayload, 'Event: refund.pending',
                                                        '', null, null, '', true));
            
            // Send Email
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            email.setSubject('Process Webhook for event: refund.pending');
            email.setToAddresses(new List<String> { 'test@example.com' });
            email.setHtmlBody(webhookEventPayload + '<br/> <br/>');
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
            
            response.statusCode = 200;
        }
     
    }
  4. Save your class and resolve any compilation errors.

  5. Your Apex class needs to 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 digitalriverv2__DR_Webhook_Configuration__mdt and click Manage Records.

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

      1. Label: Refund Pending Webhook Handler Name.

      2. DR Webhook Configuration Name: Refund_Pending_Webhook_Handler_Name.

      3. Config Name: refund.pending (This is the Event Type).

      4. Config Value: DRB2B_RefundPendingWebhook (this will be the Custom Class Name).

      5. Click Save.

  6. Set up the Webhook for the Event Type refund.pending in Digital River .

    1. Log in to the Digital River Dashboard.

    2. Configure the Webhook for this event by going to Webhooks and clicking on the Webhooks endpoint configured for your Organization for order.invoice.created (registered in ). It will have an address of <<SF_My_Domain_Name>>/services/apexrest/digitalriverv2/webhooks/

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

Webhook
Dashboard
Step 9