Overview
With version 2 of our Web SDK, Universal Checkout automatically creates and handles Payments by default. This greatly reduces the complexity and amount of boilerplate required to integrate Primer. For backward compatibility reasons, it is still possible to manually create and resume payments. Follow this guide to setup Universal Checkout so that you handle the payment lifecycle.Flow

Manual payment creation flow
- Generate a
clientTokenon your backend by creating a Client Session with - Initialize Universal Checkout with the
clientTokento render the UI. - Universal Checkout will generate a
paymentMethodTokenwhen the customer submits their payment data, or when they select particular payment methods. - Create a payment using the
paymentMethodTokenvia the Payments API - If the response indicates a
requiredAction, you’ll get a newclientToken. - Pass the
clientTokenback to Universal Checkout to render next steps, like 3DS, and get aresumeToken. - Call with the
resumeTokento resume the payment and wrap things up. (If a newrequiredActionis returned, you’ll have to go back to step 5.)
Generate a Client Token
Get an API Key
Ensure you have an API key configured. Make sure to set the following scopes for your API Key:client_tokens:writetransactions:authorize
Generate a Client Session
Follow the instructions here to create a client session, which will be used to initialize the checkout.Set up Universal Checkout
- Web
- Android - Kotlin
- Android - Java
- iOS
- React Native
Step 1. Turn off automatic payment creation
The Universal Checkout optionpaymentHandling defines how the SDK should handle payment creation and resume.Set paymentHandling to MANUAL to turn off automatic payment handling.This disables the callbacks onBeforePayment and onCheckoutComplete.Typescript
Step 2. Handle callbacks for creating and resuming payments
Two callbacks must be implemented:onTokenizeSuccess()to create payments withpaymentMethodTokenonResumeSuccess()to resume payments withresumeToken
Typescript
Handle onTokenizeSuccess() callback
- When a customer submits their payment data, the payment details are tokenized and you’ll receive a
paymentMethodTokeninonTokenizeSuccess() - Create a payment request with the
paymentMethodToken - If the payment is successful, call
handler.handleSuccess()in order to display a success screen. - If the payment is unsuccessful, call
handler.handleFailure(errorMessage)to display an error / failed message. - Payments API may return a new
clientTokenfor additional steps (in therequiredActionson the response). In this case, callhandler.continueWithNewClientToken(clientToken)to the checkout.
Handle onResumeSuccess() callback
Handling
onResumeSuccess() is required to fully support 3DS and the majority of payment methods.- You will receive a
resumeTokenvia theonResumeSuccess()callback if applicable - Send a resume payment request with the
resumeToken - If the payment is successful, call
handler.handleSuccess()in order to display a success screen. - If the payment is unsuccessful, call
handler.handleFailure(errorMessage)to display an error / failed message. - Payments API may again return a new
clientTokenfor additional steps. In this case, callhandler.continueWithNewClientToken(clientToken)again.