Extend the webhook framework
Learn how to extend the webhook framework.
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 Dashboard. For OOTB (out-of-the-box) webhook events, see Set up webhooks.
You can always extend this framework to implement custom code that will fire upon receipt of a Webhook from Digital River. The event needs to be added to the previously-created webhook in the Digital River Dashboard.
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 classdigitalriverv3.DRB2B_WebhookHandler
. This method will have the Event Payload as one of its Input parameters.
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 therefund.pending
webhook event below.
DRB2B_RefundPendingWebhook
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.
Go to the Custom Metadata Type
digitalriverv3_DR_Webhook_Configuration_
Label:
Refund Pending Webhook Handler
DR Webhook Configuration Name:
Refund_Pending_Webhook_Handler
Webhook Event Name:
refund.pending
(This is the event type of the webhook.)Webhook Handler Name:
DRB2B_RefundPendingWebhook
(Custom Class Name)
Click Save.
Set up the webhook for the Event Type
refund.pending
in the Dashboard.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.
Continue with the steps detailed in Configuring the Apex class to complete the configuration of the webhook extension.
Last updated