Not every section will apply — skip sections for features you don’t use.
Package and imports
- Web
- Android
- iOS
For Web-specific framework patterns (React, Vue, Svelte, Angular), see the Framework Migration Guide.New:
Installation
Import changes
Legacy:Type imports
If you use TypeScript, the type names have changed:Initialization
- Web
- Android
- iOS
Accessing the SDK
- Web
- Android
- iOS
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
ThePrimerJS 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
- Web
- Android
- iOS
The new SDK uses DOM events as the primary API for payment lifecycle handling. This replaces the callback-based approach from the legacy SDK.New:The New:New:New:
Migration table
Payment success
Legacy: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:Pre-payment validation (intercepting payments)
The legacyonBeforePaymentCreate 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: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:Configuration and theming
- Web
- Android
- iOS
Options changes
Options that work the same
These options are identical in both SDKs:locale— Language/region code (e.g.,'en-GB'). Falls back toen-GBif 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 thecheckout-complete slot (declarative)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)custom-styles attribute (JSON string with camelCase keys)custom-styles attribute: --primer-color-brand → primerColorBrand (remove --, convert kebab-case to camelCase).Option 3: Inline CSSKey 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-smallthrough--primer-size-xxxlarge - Animation —
--primer-animation-duration,--primer-animation-easing - Border width —
--primer-width-defaultand 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 legacyrequireCvv and requireCardholderName top-level options no longer exist. Use the cardholderName sub-object instead.
Legacy:
primer.setCardholderName('name') instead of updating the options.
Apple Pay
The Apple Pay options have been restructured. The legacymerchantId and merchantName are handled server-side, not in client options.
Legacy:
merchantIdandmerchantName— removed from client options (configured server-side).captureBillingAddress— deprecated. UsebillingOptions.requiredBillingContactFieldsinstead. The only supported billing field is'postalAddress'.- Shipping fields — use
'phone'(not'phoneNumber') and'email'(not'emailAddress'). - Button styling — new
buttonOptionsobject withtypeandbuttonStyle.
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:merchantIdandmerchantName— 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 noklarna.locale option — the Klarna locale is derived from the top-level locale option.
Legacy:
See the SDK Options Reference for all Klarna options.
PayPal
PayPal options have been restructured with astyle sub-object.
Legacy:
- Button properties moved into
stylesub-object and shortened (buttonColor→style.color). - Default color is
'gold', not'blue'. buttonSizeremoved — usestyle.heightwith a pixel value.paymentFlow: 'PREFER_VAULT'→vault: true.
See the PayPal reference for all options.
Vault changes
Configuration
Legacy:visible→enabled(renamed, required).deletionDisabled— no longer a client-side option. Deletion capability is managed through the vault UI or programmatically viaprimer.vault.delete().- New:
headlessmode for building fully custom vault UIs. - New:
showEmptyStateto show a message when the user has no saved methods.
Vault API methods
The new SDK provides programmatic vault management: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:Vault payment submission
For vault payments, dispatchprimer: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 theprimer:state-change event to enable/disable your custom button:
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 requirebubbles: true and composed: true.
See the Events Reference for full payload types and usage examples.
Migration checklist
- Web
- Android
- iOS
Verify your migration is complete:
- Replaced package — Uninstalled
@primer-io/checkout-web, installed@primer-io/primer-js - Updated imports — Using
loadPrimerand new type names - Updated initialization — Using
<primer-checkout>element withsetAttribute('client-token', ...)and.options = {} - Updated to events — Using
primer:payment-success,primer:payment-failureevents - Updated pre-payment validation — Using
primer:payment-startwithpreventDefault() - 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.enabledand vault events - Updated custom submit — Dispatching
primer:card-submit/primer:vault-submitevents - Tested in your framework — See Framework Migration Guide
Next steps
- Web
- Android
- iOS
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