Step 8: Set up Digital River fulfillments

Learn how to set up Digital River fulfillments.

When a cart is successfully submitted, an order is created in both Salesforce and Digital River. On the Digital River end, an order has a defined lifecycle with different stages. An event is created in Digital River when the order goes to a different stage in its lifecycle.

Whenever a Digital River Order is created, and the Payment has been authorized (passed fraud check), then the order.accepted event is created. This event triggers the fulfillment flow between Salesforce and Digital River. Currently, the Digital River App supports fulfillments at the line- item level except for cancellations which can be done at both the order and line-item level.

Fulfillment flow

The following sequence diagram outlines the flow during fulfillment.

The following list shows the sequence of steps in the fulfillment flow:

  1. On successful Digital River order creation and payment authorization, an order.accepted event is created at the Digital River end.

    • This will send a notification to Salesforce by making a call to the following registered webhook endpoint exposed through the Digital River B2B App: <>/services/apexrest/digitalriverv2/ DROFIOrderMgmNotification/

    • This notification has all the relevant information like the type of event and the data associated with the event.

    • The app creates a Digital River fulfillment record in Salesforce with the Digital River order identifier. OFI Received flag on this record will be set to TRUE.

    • Clients should start their fulfillment process only after the OFI Received flag is checked on the Digital River fulfillment record for the order as this indicates that Digital River was able to authorize the payment and it has passed the fraud check.

  2. Whenever a line item is fulfilled at the client-side, they need to update the Digital River Order Item State field on CC Order Item to fulfilled.

    • This will create a Digital River Line Item Fulfillment Record for this line item.

    • The Digital River Line Item Fulfillment Record will have all the relevant information like CC Order Item Id, Digital River Line Item ID, Line Item Quantity, Parent Digital River Fulfillment Record Id, and other information required to send fulfillment information to Digital River. Currently, the app does not support partial fulfillment.

    • EFN OrderItem Status field will be Open when this record is initially created.

    • The fulfillment job runs on a schedule and picks up all Digital River Line Item Fulfillment records whose EFN OrderItem Status is either Open or Pending.

      • EFN OrderItem Status will be set to Pending if there is a failure while sending fulfillment information to Digital River.

      • EFN OrderItem Status will be set to Completed when the fulfillment information is successfully sent to Digital River.

  3. Digital River Order will be moved to Completed state, when fulfillment information is sent for all the line items in that order and funds are captured.

    • This will create an order.complete event at the Digital River end.

    • On creation of this event, a notification will be sent to the following registered webhook endpoint: <>/services/apexrest/digitalriverv2/ DROrderCompleteNotification/

    • The app sets the OCN Received flag on the Digital River Fulfillment record to true.

    • The Digital River Order state field on CC Order is updated to complete.

Note: See Step 8e Set up Webhooks for Fulfillment using Postman for instructions on registering a Webhook URL.

Cancellation flow between Salesforce and Digital River

You can request a cancellation at the order as well as at the line-item level. However, you can only cancel at the order level when none of the line items in the order are previously fulfilled. The following list explains the conditions when you can cancel a CC Order:

  • The Digital River Order State on CC Order is accepted or pending_payment or in_review or blocked.

  • The Digital River Order Item state on CC Order Items is either created or cancelled.

If the above conditions are not satisfied, then an error will occur when trying to cancel the CC order.

Order-level cancellation flow

The following list shows the sequence of steps between Salesforce and Digital River during an order-level cancellation:

  1. Set the Digital River Order State field on CC Order to cancelled.

  2. The CC Order Trigger in the Digital River App will update the Digital River Order State field on the Digital River Fulfillment record for this Order to cancelled.

  3. The Order Level Fulfillment job runs on a schedule and picks up all Digital River fulfillment records whose EFN Status is Open or Pending and Digital River Order State is cancelled.

  4. The Order Level Fulfillment job will take care of sending cancellation requests for all the line items in the order.

  5. The EFN Status on the Digital River Fulfillment record will be updated to Completed once the cancellation information is successfully sent to Digital River.

  6. The OCN Received flag on the Digital River Fulfillment record will not be updated to true for order-level cancellations.

Line-item level cancellation flow

This flow is exactly similar to the steps mentioned in the Fulfillment flow. The only difference is in Step 2 where you need to update the Digital River Order Item State field on the CC Order Item to cancelled instead of fulfilled. The remainder of the flow will remain the same.

For order-level cancellation, you should only set the Digital River Order State field on CC Order to cancelled. The Digital River Order Item State field on CC Order Items should be set to cancelled only when you create a line-item level cancellation.

Step 8a: Create a connected app

To create a connected app for Digital River fulfillments, complete the following steps:

  1. Sign in to Salesforce Org.

  2. Click App Manager in the search results.

  3. Click New Connected App.

  4. Provide your API name and your email address.

  5. Select Enable OAuth Settings.

  6. Select the Require Secret for Web Server Flow check box.

  7. Capture the Client Id and Client Secret information. They will be used while setting up webhooks for Fulfillment.

Step 8b: Update Sharing Settings in Client Org

To update the Sharing Settings for the fulfillment flow, complete the following steps:

  1. From Setup, enter Sharing Settings in the Quick Find field, and then select Sharing Settings.

  2. Select CC Order from the Manage sharing settings for dropdown list.

  3. For the CC Transaction Payment object, you must select Public Read Only from the Default Internal Access dropdown list.

Step 8c: Create a profile and Fulfillment Integration User

To create a profile and assign it to a Fulfillment Integration User, complete the following steps:

  1. Create a new profile:

    • Type DRB2B Connector API User in the Profile Name field. You're essentially cloning the Standard User profile to this new profile.

    • Click Save.

  2. Set the password policy for this profile to never expire:

    • Under Administration, expand Users, and click Profiles.

    • Click the DRB2B Connector API User link under the Name column on the Profiles page.

    • Click Edit.

    • Click Save.

  3. Create a Fulfillment Integration User and assign the user to this profile.

    • Under Administration, expand Users, and click Profiles.

    • Click the DRB2B Connector API User link under the Name column on the Profiles page.

    • Click Assigned Users.

    • Click New User.

    • Assign a Fulfillment Integration User to this profile, complete the required fields, and click Save.

Step 8d: Assign the Fulfillment Integration User to Digital River Salesforce B2B Commerce Fulfillment Permission Set

To add the new user to the Digital River Salesforce B2B Commerce App permission set:

  1. From Setup, enter permission sets in the Quick Find field and press Enter.

  2. Click Permission Sets. The Permission Sets page appears.

  3. Select the permission set DRB2B Fulfillment Permission Set.

  4. Click Add Assignments and add the Fulfillment Integration user Digital River created in Step 8c Create a profile and Fulfillment Integration User to the permission set.

Step 8e: Set up webhooks for fulfillment using Postman

Digital River uses webhooks to notify the app when events occur. As part of the fulfillment process, the app looks for two events: order.accepted and order.complete.

The order.accepted event occurs whenever a Digital River order is submitted, and the payment is Authorized (funds are not captured yet).

The order.complete event occurs whenever an order is both fulfilled and captured (funds are captured).

Follow the steps below to register webhook URLs for your Digital River site so that Digital River can notify the app when the order.accepted and order.complete events occur.

Prerequisites

You will need the following information before you set up the webhook URLs.

  • Username of Fulfillment Integration User.

  • Password of Fulfillment Integration User.

  • Client Id of Connected App DigitalRiver B2B Fulfillment created in step 8a.

  • Client Secret of Connected App DigitalRiver B2B Fulfillment created in step 8a.

  • Security Token of Fulfillment Integration User.

Register the Webhook URL for the order.accepted event

  1. Open Postman.

  2. Set the HTTP method to POST.

  3. Set the URL as https://api.digitalriver.com/webhooks.

  4. Set the HTTP body as shown in the following example:

{
    "types": [
        "order.accepted"
    ],
    "address": "<<SF_My_Domain_Name>>/services/apexrest/digitalriverv2/DROFIOrderMgmNotification/",
    "apiVersion": "default",
    "enabled": true,
    "transportType": "OAUTH",
    "oauth": {
        "tokenEndPoint": "<<SF_OAuth_Access_Token_Endpoint>",
        "userName": "<<Fulfillment_User_SF_Username>>",
        "password": "<<Fulfillment_User_SF_Password+SecurityToken>>",
        "clientID": "<<Fulfillment_ConnectedApp_Client_Id>>",
        "clientSecret": "<<Fulfillment_ConnectedApp_Client_Secret>>",
        "grantType": "password"
    }
} 

Note: The URL for the tokenEndpointis “https://test.salesforce.com/services/oauth2/token” for the sandbox and “https://login.salesforce.com/services/oauth2/token” for production.

Register the webhook URL for the order.complete event

  1. Open Postman.

  2. Set the HTTP method to POST.

  3. Set the URL as https://api.digitalriver.com/webhooks.

  4. Set the HTTP body as shown in the following example:


    "types": [
        "order.complete"
    ],
    "address": "<<SF_My_Domain_Name>>/services/apexrest/digitalriverv2/DROrderCompleteNotification/",
    "apiVersion": "default",
    "enabled": true,
    "transportType": "OAUTH",
    "oauth": {
        "tokenEndPoint": "<<SF_OAuth_Access_Token_Endpoint>",
        "userName": "<<Fulfillment_User_SF_Username>>",
        "password": "<<Fulfillment_User_SF_Password+SecurityToken>>",
        "clientID": "<<Fulfillment_ConnectedApp_Client_Id>>",
        "clientSecret": "<<Fulfillment_ConnectedApp_Client_Secret>>",
        "grantType": "password"
    }
} 

A successful request returns a 200 OK response. Once configured, you can see these webhooks in the Digital River Dashboard.

Last updated