LogoLogo
Partner Integrations
Salesforce Lightning B2B Commerce App 1.6
Salesforce Lightning B2B Commerce App 1.6
  • Salesforce Lightning B2B Commerce App 1.6
  • Introduction
    • How it works
    • What's new in version 1.6
  • Upgrading to version 1.6
  • 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
        • Offline refund component
  • User guide
    • Regulatory fees
    • Tax certificates
    • Tax identifiers
    • My wallet
    • Customer credit
    • Checkout and order creation
    • Fulfillment/cancellation flow
    • Refunds
    • Offline refunds
    • Invoices and credit memos
  • Support
  • Appendix
    • Custom fields and objects
    • Contact point address
    • Multi-currency support
Powered by GitBook
On this page
  • Sending a request
  • Receiving a response
  • Calling the global method from a custom component
  1. Extend the Salesforce Lightning app
  2. Customer credit

addCustomerCreditSourceToCheckout

Learn how to add a Customer Credit source to checkout.

PreviousCustomer creditNextdeattachPaymentToCheckout

Last updated 2 years ago

Use this global method to create a customer credit payment source and attach it to checkout.

The identifier and will be derived from the cart if multicurrency is enabled in org. Otherwise, the currency code will be derived from the user’s default currency.

Before creating a payment source, use this method to verify that the amount specified by the shopper is less than or equal to the amountRemainingToBeContributed. If the amount passed into the method is greater than amountRemainingToBeContributed, it will throw an error.

This global method will set the amountContributed and amountRemainingToBeContributed values in the .

Sending a request

This method accepts parameters in JSON string format and can be called outside the managed package. You need to pass the cartId and the amount applied to this method.

Parameter
Required/Optional
Determine

cartId

Required

The Salesforce ID for the cart object.

amount

Required

The amount specified by the shopper to use for the customer credit source.

paymentName

Optional

You can pass the paymentName if you want to provide a different label (for example, GiftCard123) for the payment on the payment detail component. The paymentName appears in the Display Name field for a DR_Transaction_Payment__c object.

If this parameter is not provided, the label "CustomerCredit" will be used by default.

Request body example
“{
                 "cartId":CartId, 
                 "paymentName": "GiftCard123",
                 "amount”: "50", 
}”

Receiving a response

You'll see the following parameters in the response.

Parameter
Description

isSuccess

This global method returns a Boolean value where:

  • true–indicates the source was successfully created and applied to checkout.

  • false–indicates an error occurred while creating or attaching the source to checkout. The system returns an error message when an error occurs, and the Boolean value is false.

errorMessage

If the system returns an error and the value for isSuccess is false, this parameter displays one of the following error messages:

  • Missing or invalid input parameters specified: One of the input parameters are missing or invalid.

  • Invalid amount specified: The value specified for the amount is invalid.

  • DR API error: An error message that comes from the Digital River API.

sourceId

The unique identifier of the customer credit source.

Response body example
{
    "isSuccess":{{boolean_value}},
    "errorMessage": {{error_msg}}, //in case of error
    "sourceId":{{sourceId}}   //in case of success
}

Calling the global method from a custom component

Import the addCustomerChreditSourceToCheckout method into your custom component javascript file with digialriverv3 as the namespace as shown below.

Import example
import addCustomerCreditSourceToCheckout from 
"@salesforce/apex/digitalriverv3.DRB2B_CustomerCreditService.addCustomerCreditSourceToCheckout";

Call the global method from a custom JavaScript file by passing the cartId, amount, and (optionally) paymentName arguments as shown below.

handleAddCustomerCredit(event){
        addCustomerCreditSourceToCheckout({
            inputData : JSON.stringify({
                cartId : this.webcartId,//cart Id
                amount: amount 
            })
          }).then((result) => {
               // implement logic here in case of success
            })
            .catch((error) => {
               // implement logic here in case of error
            });
    }
payment session
currency code
Cart object