This guide is only relevant for the Web integration.

Handling redirects is required for Payment Methods like iDeal that present a webpage for the customer to enter their credentials and validate their payment.

When the user selects such a Payment Method, Universal Checkout will first attempt to show the webpage in a popup or a browser tab to maintain the context, and will then safely bring the user back to the initial page to continue the flow.

This however does not work properly in the following scenario:

  • The Payment Method opens a third-party banking app like Revolut through deep linking

Set up redirects

If creating a popup or tab is not possible, Universal Checkout will automatically redirect the user back to the returnUrl provided in the checkout options.

const options = {    // Other options     redirect: {        returnUrl: 'https://mystore.com/checkout',    },} Primer.showUniversalCheckout(clientToken, options)

Feel free to pass additional query parameters to the returnUrl. They will be automatically forwarded when the user is brought back.

Handle redirects

When the user is redirected back to returnUrl, a clientToken is passed as a query parameter:


Grab the clientToken from the query parameters and use it to render Universal Checkout. The checkout will automatically continue the payment flow.

// Grab all the query parameters using raw JSconst queryParameters = Object.fromEntries(new URLSearchParams(window.location.search).entries()) // If a client token is available in the query parameters, grab it// Otherwise, fetch a client token from your backend to start a new client sessionlet clientTokenif (queryParameters.clientToken) {    clientToken = queryParameter.clientToken()} else {    // clientToken = await getClientToken();} // Initialize Primer as usualPrimer.showUniversalCheckout(clientToken, options)

Universal Checkout will automatically resume the payment. If the payment was successfully completed, the callback onCheckoutComplete will be called like for any other payment methods.

If the payment failed, or if the user cancelled their payment, an error message will be shown and Universal Checkout will once again present the configured payment methods to the user. At this point, the flow has been restarted and the user will be able to attempt another payment with a payment method of their choice.

You can use onCheckoutFail to listen to the cancellation and restore your UI to its initial state.


For testing purposes, you can force a redirect by setting redirect.forceRedirect to true.

const options = {    // Other options     redirect: {        returnUrl: 'https://mystore.com/checkout',        forceRedirect: true,    },} Primer.showUniversalCheckout(clientToken, options)

Make sure this is disabled in production to provide the best experience to your user. Universal Checkout will seamless fallback to a redirect if needed!