For integration guidance — where to listen, which events to combine, and real-world implementation patterns — see the Events Guide.
Quick navigation
| Category | Items |
|---|---|
| Initialization Events | primer:ready, primer:methods-update |
| State Events | primer:state-change |
| Card Form Events | primer:bin-data-available, primer:bin-data-loading-change, primer:card-success, primer:card-error |
| Payment Events | primer:payment-start, primer:payment-success, primer:payment-failure, primer:payment-cancel |
| Vault Events | primer:vault-methods-update, primer:vault-selection-change, primer:show-other-payments-toggled |
| Triggerable Events | primer:card-submit, primer:vault-submit, primer:show-other-payments-toggle |
| PrimerJS Instance Methods | refreshSession(), getPaymentMethods(), setCardholderName(), vault.* |
| Type Definitions | All TypeScript interfaces |
Event lifecycle
1
Initialization
SDK loads, connects to the session, and signals readiness.
SDK →
PrimerJS instanceprimer:readySDK →
available methodsprimer:methods-updateSDK →
saved methodsprimer:vault-methods-updateAccess SDK methods and pre-fill fields via PrimerJS
2
User Interaction
User enters card details; SDK detects BIN data and card network in real time.
SDK →
loading: trueprimer:bin-data-loading-changeSDK →
BIN data + networkprimer:bin-data-availableSDK →
loading: falseprimer:bin-data-loading-changeUpdate UI with card brand logo and issuer info
3
Payment Processing
User submits; SDK creates the payment and communicates with the server.
APP →
(or button click)primer:card-submitSDK →
intercept with preventDefault()primer:payment-startSDK →
isProcessing: trueprimer:state-changeShow spinner, disable submit button
4
Outcome
Server responds; SDK dispatches success or failure.
Success
primer:payment-success
state-change → isSuccessful: true
Failure
primer:payment-failure
state-change → paymentFailure: {...}
Handle primer:payment-success to redirect, or show error
DOM events
All Primer events areCustomEvent objects dispatched with bubbles: true and composed: true, allowing them to propagate through shadow DOM boundaries.
Initialization events
primer:ready
Dispatched once when the SDK is fully initialized. Payload:PrimerJS instance
The PrimerJS instance is the primary interface for invoking SDK methods. See PrimerJS Instance Methods for the full surface.
primer:methods-update
Dispatched when available payment methods are loaded. Also re-dispatched afterrefreshSession().
Payload: InitializedPaymentMethod[]
The payload is an array of available payment methods.
State events
primer:state-change
Dispatched when SDK state changes during the payment lifecycle. Fires multiple times during a single payment flow. Payload:SdkState
| Property | Type | Description |
|---|---|---|
isLoading | boolean | SDK is loading resources |
isProcessing | boolean | Payment is in progress |
isSuccessful | boolean | Payment succeeded |
primerJsError | Error | null | SDK-level error (network, configuration) |
paymentFailure | PaymentFailure | null | Payment failure details |
Card form events
primer:bin-data-available
Dispatched when BIN data is detected from user input in the card number field. Provides card network information, co-badged network alternatives, and additional issuer details when available. Payload:BinDataAvailableEvent
| Property | Type | Description |
|---|---|---|
preferred | BinDataDetails | undefined | Recommended network based on orderedAllowedCardNetworks, or undefined if no network is allowed |
alternatives | BinDataDetails[] | All detected networks excluding preferred, including disallowed ones |
status | 'complete' | 'partial' | complete when full BIN data is available (8+ digits), partial for local-only detection |
firstDigits | string | undefined | The first digits (BIN prefix) of the card number, when available |
primer:bin-data-loading-change
Dispatched when BIN data retrieval starts or finishes. Use this to show a loading indicator while card information is being fetched from Primer’s servers. Payload:BinDataLoadingChangeEvent
| Property | Type | Description |
|---|---|---|
loading | boolean | true when BIN data retrieval starts, false when it completes |
primer:card-success
Dispatched when card form submission succeeds. Payload:CardSubmitSuccessPayload
| Property | Type | Description |
|---|---|---|
result.success | boolean | Submission succeeded |
result.token | string | Payment token |
result.paymentId | string | Payment ID |
primer:card-error
Dispatched when card form validation fails on submission. Payload:CardSubmitErrorsPayload
| Property | Type | Description |
|---|---|---|
errors | InputValidationError[] | Validation errors for each invalid field |
Payment events
primer:payment-start
Dispatched when payment creation begins. Useevent.preventDefault() to intercept the payment flow for validation.
Payload: PaymentStartData
| Property | Type | Description |
|---|---|---|
paymentMethodType | string | Payment method being used (e.g., "PAYMENT_CARD") |
abortPaymentCreation | () => void | Call to cancel payment creation |
continuePaymentCreation | (data?) => void | Call to proceed with payment (optionally with idempotencyKey) |
timestamp | number | Unix timestamp (seconds) |
primer:payment-success
Dispatched when payment completes successfully. Payload:PaymentSuccessData
| Property | Type | Description |
|---|---|---|
payment | PaymentSummary | PII-filtered payment data |
paymentMethodType | string | e.g., "PAYMENT_CARD", "APPLE_PAY" |
timestamp | number | Unix timestamp (seconds) |
primer:payment-failure
Dispatched when payment fails. Payload:PaymentFailureData
| Property | Type | Description |
|---|---|---|
error | { code: string; message: string; diagnosticsId?: string | null; data?: Record<string, unknown> } | Structured error information |
payment | PaymentSummary | undefined | Payment data, if available at time of failure |
paymentMethodType | string | Payment method used |
timestamp | number | Unix timestamp (seconds) |
primer:payment-cancel
Dispatched when a payment is cancelled by the user (e.g., dismissing Apple Pay or closing a payment popup). Payload:PaymentCancelData
| Property | Type | Description |
|---|---|---|
paymentMethodType | string | Payment method that was being used |
timestamp | number | Unix timestamp (seconds) |
Vault Events
primer:vault-methods-update
Dispatched when vaulted payment methods are loaded or updated. Payload:VaultedMethodsUpdateData
| Property | Type | Description |
|---|---|---|
vaultedPayments | VaultedPaymentMethodSummary[] | Array of vaulted methods |
cvvRecapture | boolean | Whether CVV re-entry is required |
timestamp | number | Unix timestamp (seconds) |
primer:vault-selection-change
Dispatched when a vaulted payment method is selected or deselected. Payload:VaultSelectionChangeData
| Property | Type | Description |
|---|---|---|
paymentMethodId | string | null | ID of the selected method, or null if deselected |
timestamp | number | Unix timestamp (seconds) |
primer:show-other-payments-toggled
Dispatched when the “show other payments” toggle state changes. Payload:ShowOtherPaymentsToggledPayload
| Property | Type | Description |
|---|---|---|
expanded | boolean | Current toggle state |
Triggerable events
These events can be dispatched by your code to control the SDK. All triggerable events must be dispatched withbubbles: true and composed: true to cross shadow DOM boundaries.
primer:card-submit
Triggers card form submission programmatically.primer:vault-submit
Triggers vault payment submission programmatically.primer:show-other-payments-toggle
Toggles the “other payment methods” section.PrimerJS instance methods
ThePrimerJS instance is received from the primer:ready event.
refreshSession()
Synchronizes the client-side SDK with server-side session updates. Triggers a newprimer:methods-update event.
| Parameter | Type | Description |
|---|---|---|
| (none) | — | — |
| Returns | Promise<void> | Resolves when sync is complete |
getPaymentMethods()
Returns the cached list of available payment methods.| Parameter | Type | Description |
|---|---|---|
| (none) | — | — |
| Returns | PaymentMethodInfo[] | Available payment methods |
setCardholderName()
Sets the cardholder name field programmatically. Must be called afterprimer:ready.
| Parameter | Type | Description |
|---|---|---|
name | string | Cardholder name |
| Returns | void | — |
Vault API
vault.createCvvInput()
Creates a CVV input element for CVV recapture in headless mode.| Parameter | Type | Description |
|---|---|---|
options.cardNetwork | string | Card network (e.g. 'VISA') |
options.container | string | CSS selector for the container element |
options.placeholder | string | Placeholder text |
| Returns | Promise<CvvInputInstance> | The created CVV input |
vault.startPayment()
Initiates payment with the selected vaulted method.| Parameter | Type | Description |
|---|---|---|
paymentMethodId | string | ID of the vaulted payment method |
options | object | Optional payment options |
options.cvv | string | CVV value for card payments requiring re-capture |
| Returns | Promise<void> | Resolves when payment flow is initiated |
vault.delete()
Deletes a vaulted payment method.| Parameter | Type | Description |
|---|---|---|
paymentMethodId | string | ID of the vaulted payment method |
| Returns | Promise<void> | Resolves when deletion is complete |