Extend the App Webhook Framework
Learn how to extend the App Webhook Framework.
Last updated
Learn how to extend the App Webhook Framework.
Last updated
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 Webhook from Digital River.
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
:
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 { }
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.
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.
Save your class and resolve any compilation errors.
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.
Go to the Custom Metadata Type digitalriverv2__DR_Webhook_Configuration__mdt
and click Manage Records
.
Create a new Metadata Type Record for DR Webhook Configuration.
Label: Refund Pending Webhook Handler Name.
DR Webhook Configuration Name: Refund_Pending_Webhook_Handler_Name
.
Config Name: refund.pending
(This is the Event Type).
Config Value: DRB2B_RefundPendingWebhook (this will be the Custom Class Name).
Click Save.
Set up the Webhook for the Event Type refund.pending
in Digital River Dashboard.
Log in to the Digital River Dashboard.
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 Step 9). It will have an address of <<SF_My_Domain_Name>>/services/apexrest/digitalriverv2/webhooks/
Select the event refund.pending
for the Webhook Endpoint selected in the previous step.