Skip to content

User Account Data & Events

The User Account drop-in uses the event bus to emit and listen to events for communication between drop-ins and external integrations.

Version: 3.2.0
EventDirectionDescription
errorEmitsEmitted when a network request fails (excluding aborted requests).
account/customerPaymentTokensListensOptional display list of stored payment tokens for the PaymentMethods UI (injection only); consumed eagerly when present. Does not participate in removal.
companyContext/changedListensFired by Company Context (companyContext) when a change occurs.

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

Emitted when any GraphQL or network request made by the drop-in fails. Aborted requests (AbortError) are excluded — they are re-thrown but do not trigger this event. The event fires on the shared event bus before the error is re-thrown, so listeners receive it even when the calling code also handles the rejection.

Every API function in the drop-in (getCustomer, updateCustomer, getOrderHistoryList, createCustomerAddress, deletePaymentToken, getCustomerPaymentTokens, and others) is wired to emit this event on failure.

FieldTypeDescription
sourcestringAlways 'auth'.
typestringAlways 'network'.
errorErrorThe original caught Error object.
import { events } from '@dropins/tools/event-bus.js';
events.on('error', (payload) => {
if (payload.source === 'auth' && payload.type === 'network') {
console.error('User Account network error:', payload.error.message);
}
});

The PaymentMethods container and usePaymentMethods hook subscribe to this event. If a payload is already available on the event bus, the hook uses it instead of calling the GraphQL getCustomerPaymentTokens query. This allows you to inject a list into the UI from another drop-in (for example, Payment Services) or from tests.

Subscribe with an eager listener so any payload emitted before subscription is still received and applied (following the same pattern as cart data events).

ShapeDescription
Array of token rowsEach item matches the StoredPaymentMethodDisplay shape: publicHash, cardBrand, lastFourDigits, optional expired, optional variant.
nullExplicit empty list (same convention as cart cart/data).

Removing a stored method is not handled through this event. When a shopper selects Remove in the PaymentMethods UI, they first confirm in a removal modal. The drop-in then calls the GraphQL deletePaymentToken mutation and updates the in-memory list—regardless of whether the rows were initially sourced from the event or from getCustomerPaymentTokens. The event bus is not used for deletion. If another part of the page needs to stay in sync after removal, you can optionally emit an updated account/customerPaymentTokens payload.

The User Account drop-in still extends @adobe-commerce/event-bus with this channel, making emit and on type-safe for list injection. This payload type is not used for deletion—there is no “delete via the bus” event. Removal is handled exclusively through deletePaymentToken.

import type { StoredPaymentMethodDisplay } from '../data/models/stored-payment-method';
declare module '@adobe-commerce/event-bus' {
interface Events {
/** PaymentMethods list injection only; `null` means an empty list (same idea as cart `cart/data`). Not used for removal—use GraphQL `deletePaymentToken`. */
'account/customerPaymentTokens': StoredPaymentMethodDisplay[] | null;
}
}

This declaration is only for typing list injection; it does not introduce a bus-based delete API. Use the same StoredPaymentMethodDisplay shape as the return items from getCustomerPaymentTokens. JavaScript storefronts can ignore the .d.ts file as runtime behavior remains the same.

import { events } from '@dropins/tools/event-bus.js';
events.on(
'account/customerPaymentTokens',
(payload) => {
console.log('Stored payment tokens:', payload);
},
{ eager: true }
);

Fired by Company Context (companyContext) when a change occurs.

import { events } from '@dropins/tools/event-bus.js';
events.on('companyContext/changed', (payload) => {
console.log('companyContext/changed event received:', payload);
// Add your custom logic here
});