Publishing connector events

Learn how to trigger connector events for the customer credit feature.

To implement the customer credit feature, in addition to calling the methods described above, you must publish the events that interact with the components included in the connector. This section describes those events.

Reloading Drop-In

You should publish the event to reload Drop-in after applying or removing a partial amount from customer credit.

Publishing an event to reload the Drop-in component

Prerequisite: Publish this event after calling addCustomerCreditSourceToCheckout or deattachPaymentToCheckout methods.

To publish the event to reload the Drop-in (drb2b_dropin) component, import the DigitalRiverMessageChannel__c message channel and message service into the customer credit javascript file.

Import example
import {publish, MessageContext } from 'lightning/messageService';
import dr_lms from '@salesforce/messageChannel/ digitalriverv3__ DigitalRiverMessageChannel__c';

Declare the messageContext variable as shown in below.

messageContext example
@wire(MessageContext) messageContext; 

Publish the event. When publishing the event, use the reloadDropin value for the purpose parameter as shown in the following example:

Publish example
publish(this.messageContext, dr_lms, {
  purpose: 'reloadDropin' 
  });

Reloading the checkout summary component

Prerequisite: Publish this event after calling addCustomerCreditSourceToCheckout or deattachPaymentToCheckout methods.

Reload the checkout summary component to reflect the latest values whenever a shopper adds or removes a source from the checkout. This will update the UI with the latest values, including the amount contributed and the amount remaining to be contributed.

To publish an event to reload the checkout summary (drb2b_checkoutSummary) component, import the DigitalRiverMessageChannel__c message channel and message service into the customer credit javascript file.

If you already imported the DigitalRiverMessageChannel__c message channel and message service into the customer credit JavaScript file, you can skip this step.

Import example
import {publish, MessageContext } from 'lightning/messageService';
import dr_lms from '@salesforce/messageChannel/ digitalriverv3__ DigitalRiverMessageChannel__c';

Declare the messageContext variable as shown below.

messageContext example
 @wire(MessageContext) messageContext;

If you already declared the messageContext variable, you can skip this step.

Publish the event. When publishing the event, use the reloadCheckoutSummary value for the purpose parameter as shown in the following example:

Publish example
publish(this.messageContext, dr_lms, {
            purpose: 'reloadCheckoutSummary' 
        });

Last updated