Payment Services Data & Events
The Payment Services drop-in uses the event bus to emit and listen for events, enabling communication between drop-ins and external integrations.
Events reference
Section titled “Events reference”| Event | Direction | Description |
|---|---|---|
| authenticated | Listens | Fired by the User Auth drop-in when the user’s authentication state changes. Used to determine whether the shopper is a guest customer. |
| cart/data | Listens | Fired by the Cart drop-in when cart data is available or changes. Used by various payment method containers to retrieve the cart ID and other cart data. |
| checkout/initialized | Listens | Fired by the Checkout drop-in when the checkout page is first loaded. Used as a fallback by the GooglePay container when checkout/updated has not yet been received. |
| checkout/updated | Listens | Fired by the Checkout drop-in when the checkout state is updated. Read by the GooglePay container at button click time to determine the selected shipping method and billing address. |
| payment-services/initialized/checkout | Emits | Emitted when the drop-in finishes initializing for the CHECKOUT location. |
| payment-services/initialized/product-detail | Emits | Emitted when the drop-in finishes initializing for the PRODUCT_DETAIL location. |
Event details
Section titled “Event details”The following sections provide detailed information about each event, including its direction, event payload, and usage examples.
authenticated (listens)
Section titled “authenticated (listens)”Fired by the User Auth drop-in when the user’s authentication state changes. Used to determine whether the shopper is a guest customer.
Event payload
Section titled “Event payload”booleantrue when the shopper is authenticated, false when signed out.
Example
Section titled “Example”import { events } from '@dropins/tools/event-bus.js';
events.on('authenticated', (isAuthenticated) => { console.log('authenticated event received:', isAuthenticated);});cart/data (listens)
Section titled “cart/data (listens)”Fired by the Cart drop-in when cart data is available or changes. Used by various payment method containers to retrieve the cart ID and other cart data at checkout. The event must have fired at least once with a non-null payload before the shopper initiates payment (for example, clicks a payment button).
Event payload
Section titled “Event payload”CartModel | nullSee CartModel for the full type definition.
Example
Section titled “Example”import { events } from '@dropins/tools/event-bus.js';
events.on('cart/data', (payload) => { console.log('cart/data event received:', payload);});checkout/initialized (listens)
Section titled “checkout/initialized (listens)”Fired by the Checkout drop-in when the checkout page is first loaded. The GooglePay container uses this event as a fallback when checkout/updated has not yet been received — for example, when the shopper opens the Google Pay payment sheet without having interacted with the checkout form.
Event payload
Section titled “Event payload”CheckoutData | nullExample
Section titled “Example”import { events } from '@dropins/tools/event-bus.js';
events.on('checkout/initialized', (payload) => { console.log('checkout/initialized event received:', payload);});checkout/updated (listens)
Section titled “checkout/updated (listens)”Fired by the Checkout drop-in when the checkout state is updated. Used by the GooglePay container to determine the selected shipping method and billing address when the shopper clicks the Google Pay button. If checkout/updated has not yet been received, the container falls back to checkout/initialized.
At least one checkout/updated or checkout/initialized event must have been emitted on the event bus before clicking the Google Pay button.
Event payload
Section titled “Event payload”Cart | NegotiableQuote | nullSee Cart and NegotiableQuote for the full type definitions.
Example
Section titled “Example”import { events } from '@dropins/tools/event-bus.js';
events.on('checkout/updated', (payload) => { console.log('checkout/updated event received:', payload);});payment-services/initialized/checkout (emits)
Section titled “payment-services/initialized/checkout (emits)”See Payment method availability.