deattachPaymentToCheckout

Learn how to delete the customer credit payment source from checkout.

Use this global method to delete the customer credit payment source from checkout.

In addition to deleting the source from the checkout, this method will delete the Digital River Transition Payment Object corresponding to the sourceId and will update the values for amountRemainingToBeContributed and amountContributed in the cart object.

Sending a request

This method accepts parameters in JSON string format. You need to pass the cartId and the sourceId with this method.

Request body example
“{
      "cartId”:CartId, 
      “sourceId”: “sourceId”
}”

Receiving a response

You'll see the following parameters in the response.

Response body example
{
   "isSuccess":{{Boolean_Value}},  
   "errorMessage":{{error_msg}} // In case of error
}

Calling the global method from a custom component

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

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

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

handleRemoveCustomerCredit(event){
        var sourceId = event.target.name;
        deattachPaymentToCheckout({
            inputData : JSON.stringify({
                cartId : this.webcartId, // Cart Id
                sourceId : sourceId  // source Id
            })
        }).then((result) => {
             // implement logic here in case of success
            })
            .catch((error) => {
            // implement logic here in case of error
            });
    }

Last updated