You’ll need your clientToken to initialize Primer Checkout. See our Client Session guide on how to create a client session and retrieve a clientToken first.
The SDK requires ES2020 support. Minimum supported browser versions:
Browser
Minimum Version
Chrome
80+
Edge
80+
Firefox
79+
Safari
14+
iOS Safari
14+
Opera
67+
Samsung Internet
13.0+
Legacy browsers like Internet Explorer 11 aren’t officially supported due to their non-standard DOM behavior and lack of support for modern Web Component features and ES2020 syntax that this SDK is built on.
A token retrieved from the Client Session endpoint. Authenticates the checkout session and contains configuration for available payment methods.
Add the checkout to your Composable:
@Composablefun CheckoutScreen(clientToken: String) { val checkout = rememberPrimerCheckoutController( clientToken = clientToken, ) val state by checkout.state.collectAsStateWithLifecycle() LaunchedEffect(state) { when (state) { is PrimerCheckoutState.Success -> { /* Navigate to confirmation */ } is PrimerCheckoutState.Failure -> { /* Error is shown in the UI */ } else -> Unit } } PrimerCheckoutSheet(checkout = checkout)}
Add the checkout view to your screen with a clientToken and an onCompletion callback:
struct CheckoutView: View { let clientToken: String var body: some View { PrimerCheckout( clientToken: clientToken, onCompletion: { state in switch state { case .success(let result): print("Payment succeeded: \(result.paymentId)") case .failure(let error): print("Payment failed: \(error.errorId)") case .dismissed: print("Checkout dismissed") default: break } } ) }}
Parameter
Type
Description
clientToken
String
A token retrieved from the Client Session endpoint. Authenticates the checkout session and contains configuration for available payment methods.
onCompletion
(PrimerCheckoutState) -> Void
Callback invoked when the checkout reaches a terminal state (success, failure, or dismissed).
Server-Side RenderingIf you’re using Next.js, Nuxt, SvelteKit, or any SSR framework, you must load Primer only on the client side. The Web Components API doesn’t exist in Node.js.
No framework-specific setup is needed. The SDK integrates directly with Jetpack Compose.
No framework-specific setup is needed. PrimerCheckout integrates directly with SwiftUI.For UIKit apps, use PrimerCheckoutPresenter to present the checkout from a UIViewController.