Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

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.

Version: 4.0.0
EventDirectionDescription
authenticatedListensFired by the User Auth drop-in when the user’s authentication state changes. Used to determine whether the shopper is a guest customer.
cart/dataListensFired by the Cart drop-in when cart data is available or changes. Read by the GooglePay container at click time to supply cart items and totals to the Google Pay payment sheet.
checkout/initializedListensFired by the Checkout drop-in when the checkout state is first loaded. Used as a fallback by the GooglePay container when checkout/updated has not yet been received.
checkout/updatedListensFired by the Checkout drop-in when the checkout state is updated. Read by the GooglePay container at click time to supply billing address and shipping method to the Google Pay payment sheet.
payment-services/initialized/checkoutEmitsEmitted when the drop-in finishes initializing for the CHECKOUT location.
payment-services/initialized/product-detailEmitsEmitted when the drop-in finishes initializing for the PRODUCT_DETAIL location.

The following sections provide detailed information about each event, including its direction, event payload, and usage examples.

Fired by the User Auth drop-in when the user’s authentication state changes. Used to determine whether the shopper is a guest customer.

boolean

true when the shopper is authenticated, false when signed out.

import { events } from '@dropins/tools/event-bus.js';
events.on('authenticated', (isAuthenticated) => {
console.log('authenticated event received:', isAuthenticated);
});

Fired by the Cart drop-in when cart data is available or changes. The GooglePay container reads this event using events.lastPayload('cart/data') at the moment the shopper clicks the Google Pay button — not at render time — to populate cart items and price totals in the Google Pay payment sheet.

The cart/data payload must therefore be present on the event bus before the shopper clicks the button. For the full CartModel type definition, see the Cart events reference.

CartModel | null

See CartModel for the full type definition.

import { events } from '@dropins/tools/event-bus.js';
events.on('cart/data', (payload) => {
console.log('cart/data event received:', payload);
});

Fired by the Checkout drop-in when the checkout state 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.

CheckoutData | null
import { events } from '@dropins/tools/event-bus.js';
events.on('checkout/initialized', (payload) => {
console.log('checkout/initialized event received:', payload);
});

Fired by the Checkout drop-in when the checkout state is updated. The GooglePay container reads this event using events.lastPayload('checkout/updated') at the moment the shopper clicks the Google Pay button to populate billing address and shipping method in the Google Pay payment sheet. If checkout/updated has not yet been received, the container falls back to checkout/initialized.

Like cart/data, one of these payloads must be present on the event bus before the shopper clicks the button. For the full Cart and NegotiableQuote type definitions, see the Checkout events reference.

Cart | NegotiableQuote | null

See Cart and NegotiableQuote for the full type definitions.

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.


payment-services/initialized/product-detail (emits)

Section titled “payment-services/initialized/product-detail (emits)”

See Payment method availability.