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
clientToken
on your backend by creating a Client Session with - Initialize Universal Checkout with the
clientToken
to render the UI. - Universal Checkout will generate a
paymentMethodToken
when the customer submits their payment data, or when they select particular payment methods. - Create a payment using the
paymentMethodToken
via the Payments API - If the response indicates a
requiredAction
, you’ll get a newclientToken
. - Pass the
clientToken
back to Universal Checkout to render next steps, like 3DS, and get aresumeToken
. - Call with the
resumeToken
to resume the payment and wrap things up. (If a newrequiredAction
is 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:write
transactions: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
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 withpaymentMethodToken
onResumeSuccess()
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
paymentMethodToken
inonTokenizeSuccess()
- 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
clientToken
for additional steps (in therequiredActions
on 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
resumeToken
via 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
clientToken
for additional steps. In this case, callhandler.continueWithNewClientToken(clientToken)
again.