Skip to main content
This guide covers the key changes when migrating from the legacy SDK to the new Primer Checkout Components. Select your platform to see platform-specific migration steps.
Not every section will apply — skip sections for features you don’t use.

Package and imports

For Web-specific framework patterns (React, Vue, Svelte, Angular), see the Framework Migration Guide.

Installation

Import changes

Legacy:
New:

Type imports

If you use TypeScript, the type names have changed:

Initialization

The initialization pattern changes from a single function call to a multi-step process involving a Web Component and event listeners.

Legacy pattern

New pattern

Or declare the element in HTML:

Key differences

Component properties vs SDK options — these are different and cannot be mixed.
  • Component properties (client-token, custom-styles, loader-disabled): Use setAttribute().
  • SDK options (locale, card, vault, applePay, etc.): Assign directly to .options.
Using setAttribute('options', ...) will not work. See the SDK Options guide for details.

Accessing the SDK

Some SDK methods require access to the PrimerJS instance. This instance is provided via the primer:ready event, which fires when the checkout is fully initialized.

Getting the instance

Storing for later use

If you need to call SDK methods outside of the event handler (e.g., in response to user actions or after a session expires), store the reference:

Available methods

The PrimerJS instance provides:
Most integrations don’t need to access the PrimerJS instance directly. The primary use cases are session refresh, programmatic cardholder name updates, and headless vault implementations.

Result handling

The new SDK uses DOM events as the primary API for payment lifecycle handling. This replaces the callback-based approach from the legacy SDK.

Migration table

Payment success

Legacy:
New:
The PaymentSummary contains partial card data (last 4 digits, network, cardholder name) but not full PII like customer email or full card number. Use server-side webhooks for complete payment data.

Payment failure

Legacy:
New:

Pre-payment validation (intercepting payments)

The legacy onBeforePaymentCreate callback is replaced by the primer:payment-start event. Use event.preventDefault() to intercept the payment flow, then call continuePaymentCreation() or abortPaymentCreation() from event.detail.Legacy:
New:
If you don’t call event.preventDefault(), the payment continues automatically. Only use preventDefault() when you need to run validation or async checks before payment creation.

Session refresh

This is no longer a callback. It’s a method you call when you need to sync the SDK with server-side session changes.Legacy:
New:

Configuration and theming

Options changes

Options that work the same

These options are identical in both SDKs:
  • locale — Language/region code (e.g., 'en-GB'). Falls back to en-GB if the locale is not supported.
  • merchantDomain — Your website domain (used for Apple Pay validation).
  • submitButton.useBuiltInButton — Show or hide the built-in submit button.
  • submitButton.amountVisible — Display the payment amount on the button.

Options that changed

New options

Success screen replacement

The legacy SDK had a built-in success screen. The new SDK gives you two options:Option 1: Use the checkout-complete slot (declarative)
Option 2: Handle via event (imperative)

Styling changes

The styling system has fundamentally changed from JavaScript objects to CSS custom properties.

Legacy: CSS-in-JS objects

New: CSS custom properties

Option 1: CSS stylesheet (recommended)
Option 2: custom-styles attribute (JSON string with camelCase keys)
The conversion rule for the custom-styles attribute: --primer-color-brandprimerColorBrand (remove --, convert kebab-case to camelCase).Option 3: Inline CSS

Key differences

Design token categories

The new SDK organizes styling into token categories:
  • Colors--primer-color-brand, --primer-color-text-primary, --primer-color-background-primary, and more
  • Typography--primer-typography-brand (font family), --primer-typography-body-medium-size, etc.
  • Spacing--primer-space-xxsmall (2px) through --primer-space-xlarge (20px)
  • Border radius--primer-radius-xsmall (2px) through --primer-radius-large (12px)
  • Sizing--primer-size-small through --primer-size-xxxlarge
  • Animation--primer-animation-duration, --primer-animation-easing
  • Border width--primer-width-default and state variants
See the Styling Variables Reference for the complete list of available tokens.
Don’t attempt a 1:1 mapping from your legacy CSS-in-JS styles. Instead, start with your brand color (--primer-color-brand) and font (--primer-typography-brand), then use browser DevTools to inspect which tokens affect which elements and adjust from there.

Web-specific details

The following sections apply to Web only. iOS and Android handle these concerns through the composable views and slots described above.

Payment method options

Card form

The card form options have been simplified. The legacy requireCvv and requireCardholderName top-level options no longer exist. Use the cardholderName sub-object instead. Legacy:
New:
CVV is always required by the card form — there is no option to disable it. For runtime updates to the cardholder name after initialization, use primer.setCardholderName('name') instead of updating the options.

Apple Pay

The Apple Pay options have been restructured. The legacy merchantId and merchantName are handled server-side, not in client options. Legacy:
New:
Key changes:
  • merchantId and merchantName — removed from client options (configured server-side).
  • captureBillingAddress — deprecated. Use billingOptions.requiredBillingContactFields instead. The only supported billing field is 'postalAddress'.
  • Shipping fields — use 'phone' (not 'phoneNumber') and 'email' (not 'emailAddress').
  • Button styling — new buttonOptions object with type and buttonStyle.
See the Apple Pay reference for all button types and complete configuration.

Google Pay

Google Pay options are largely the same with some additions. Legacy:
New:
Key changes:
  • merchantId and merchantName — removed from client options (configured server-side).
  • New button options: buttonSizeMode, buttonRadius, buttonLocale.
  • New address capture: captureBillingAddress, captureShippingAddress, emailRequired.
  • New shipping: requireShippingMethod, shippingAddressParameters.
See the Google Pay reference for complete configuration.

Klarna

The Klarna configuration has changed significantly from the legacy SDK. There is no klarna.locale option — the Klarna locale is derived from the top-level locale option. Legacy:
New:
Set the locale at the top level instead:
See the SDK Options Reference for all Klarna options.

PayPal

PayPal options have been restructured with a style sub-object. Legacy:
New:
Key changes:
  • Button properties moved into style sub-object and shortened (buttonColorstyle.color).
  • Default color is 'gold', not 'blue'.
  • buttonSize removed — use style.height with a pixel value.
  • paymentFlow: 'PREFER_VAULT'vault: true.
See the PayPal reference for all options.

Vault changes

Configuration

Legacy:
New:
Key changes:
  • visibleenabled (renamed, required).
  • deletionDisabled — no longer a client-side option. Deletion capability is managed through the vault UI or programmatically via primer.vault.delete().
  • New: headless mode for building fully custom vault UIs.
  • New: showEmptyState to show a message when the user has no saved methods.

Vault API methods

The new SDK provides programmatic vault management:
vault.createCvvInput() takes a cardNetwork string (e.g., 'VISA', 'MASTERCARD'), not a paymentMethodId. It returns a Promise — always use await.

Vault events

The vaultedPayments payload is an array of VaultedPaymentMethodSummary objects.

Headless vault mode

Build a completely custom vault UI while retaining full vault functionality:
See the Vault Manager component reference for the complete headless vault implementation guide.

Custom submit button

The mechanism for triggering payment submission from an external button has changed from an imperative method call to a dispatched event.

Card form submission

Legacy:
New:

Vault payment submission

For vault payments, dispatch primer:vault-submit instead:
An alternative approach for card form submission: you can call cardForm.submit() directly on the <primer-card-form> element if you have a reference to it.

Button state management

Monitor the primer:state-change event to enable/disable your custom button:
For card form validation state, listen to primer:card-success and primer:card-error:
See the External Submit Button recipe for a complete example.

Events

The new SDK uses a comprehensive DOM event system as the primary API for payment lifecycle handling.

Complete event reference

Lifecycle events
Payment events
Card form events
Vault events
Triggerable events
You can dispatch these to control the SDK. Both require bubbles: true and composed: true.
See the Events Reference for full payload types and usage examples.

Migration checklist

Verify your migration is complete:
  • Replaced package — Uninstalled @primer-io/checkout-web, installed @primer-io/primer-js
  • Updated imports — Using loadPrimer and new type names
  • Updated initialization — Using <primer-checkout> element with setAttribute('client-token', ...) and .options = {}
  • Updated to events — Using primer:payment-success, primer:payment-failure events
  • Updated pre-payment validation — Using primer:payment-start with preventDefault()
  • Updated styling — Replaced CSS-in-JS objects with --primer-* CSS custom properties
  • Updated payment method config — Corrected Apple Pay, PayPal, Klarna options
  • Updated vault config — Using vault.enabled and vault events
  • Updated custom submit — Dispatching primer:card-submit / primer:vault-submit events
  • Tested in your framework — See Framework Migration Guide

Next steps

Framework Migration

React, Vue, Svelte, and Angular patterns

SDK Options Reference

Complete configuration reference

Events Reference

Full event payloads and types

Styling Variables

Complete design token reference