showUniversalCheckout(
clientToken: string,
options: UniversalCheckoutOptions
): Promise<PrimerCheckout>
import { Primer } from "@primer-io/checkout-web";
const checkout = await Primer.showUniversalCheckout(clientToken, {
container: "#container",
onCheckoutComplete(...args) {
console.log("onCheckoutComplete", ...args);
},
});
Hide child attributes
showUniversalCheckout
you can provide Drop-In Checkout with some configuration options. These
options range from callbacks notifying you of the current payment’s status, to styling options for certain UI
elements.Hide child attributes
'2.4'
.'legacy'
if you encounter compatibility issues with the latest API version and wish to revert to the previous stable behavior.Hide Payment lifecycle callbacks
handler
must be used to then abort or continue with payment creation.
Primer will continue with payment creation if onBeforePaymentCreate
is not implemented.Hide Parameters
Hide Properties
onBeforePaymentCreate
is implemented.return handler.abortPaymentCreation();
return handler.continuePaymentCreation();
Hide Parameters
Hide Properties
Hide Parameters
Hide Properties
handler
is undefined
, the SDK does not expect anything from you.If handler
exists, you MUST call one of the functions of the handler.import { Primer } from "@primer-io/checkout-web";
const checkout = await Primer.showUniversalCheckout(clientToken, {
container: "#container",
onCheckoutComplete(...args) {
console.log("onCheckoutComplete", ...args);
},
onCheckoutFail(error, data, handler) {
if (!handler) {
return;
}
// Show a default error message
return handler.showErrorMessage();
// Or show a custom error message
// return handler.showErrorMessage('This is my custom message');
},
});
Hide Client session lifecycle callbacks
Hide Event callbacks
Hide Parameters
Hide Properties
Hide Payment methods options
Hide Properties
Hide Properties
Hide Properties
Hide Properties
Hide Properties
Hide Properties
Hide Properties
Hide Properties
Hide Properties
Hide Properties
Hide Properties
Hide Properties
Hide Vault options
Hide Properties
false
to skip the retrieval of the vault and speed up the loading of the checkout.Default value is true
.Hide Customization options
const options = {
/* Other options ... */
submitButton: {
useBuiltInButton: false, // Default to true
// Callback for receiving the submit button's visible state in the current scene
onVisible(isVisible, context: { currentSceneId }) {
// Show or hide your custom submit button
},
// Callback for receiving the submit button's disabled state in the current scene
onDisable(isDisabled, context: { currentSceneId }) {
// Disable or enable your custom submit button
},
// Callback for receiving the submit button's loading state in the current scene
onLoading(isLoading, context: { currentSceneId }) {
// Show your submit button in a loading state
},
// Callback for receiving the submit button's content in the current scene
onContentChange(content, context: { currentSceneId }) {
// Set your submit button's content with either the content provided or your own custom content
},
},
};
Hide Properties
Hide Callbacks
Hide context
Hide context
Hide context
Hide Properties
Hide Properties
successScreen
to modify the default behavior of the success scene.Remove the success screen:const options = {
/* Other options ... */
successScreen: false,
};
const options = {
/* Other options ... */
successScreen: {
type: "CHECK",
title: "This is a custom success message!",
},
};
Hide Manual payment handling
paymentHandling
option defines how the SDK should handle payment creation and resume.The default is AUTO
, set paymentHandling
to MANUAL
to turn off automatic payment handling. This disables the callbacks onBeforePayment
and onCheckoutComplete
.Two callbacks must be implemented:onTokenizeSuccess()
to create payments with the paymentMethodToken
.onResumeSuccess()
to resume payments with resumeToken
.PrimerCheckout
, but the same concepts apply to PrimerHeadlessCheckout
.paymentHandling
to MANUAL
, implementing this is mandatory.Hide Parameters
Hide Properties
Hide Properties
Hide Properties
AUTH_SUCCESS
: The authentication was successful.AUTH_FAILED
: The authentication process failed.SKIPPED
: The authentication was skipped.CHALLENGE
: A challenge was issued during the authentication process.true
: A challenge was issued.false
: No challenge was issued.APPLE_PAY
CARD_OFF_SESSION_PAYMENT
GOOGLE_PAY
KLARNA_CUSTOMER_TOKEN
OFF_SESSION_PAYMENT
PAYMENT_CARD
PAYPAL_BILLING_AGREEMENT
PAYPAL_ORDER
Hide Properties
AUTH_SUCCESS
: The authentication was successful.AUTH_FAILED
: The authentication process failed.SKIPPED
: The authentication was skipped.CHALLENGE
: A challenge was issued during the authentication process.true
: A challenge was issued.false
: No challenge was issued.paymentMethodToken
in onTokenizeSuccess()
.paymentMethodToken
to your backend
handler.handleSuccess()
in order to display a success screen
handler.handleFailure(errorMessage)
to display an error or failure message
clientToken
for additional steps (in the requiredActions
on the response). In this case, call handler.continueWithNewClientToken(clientToken)
to continue with the payment flow
PrimerClientError
data to display an error message.paymentHandling
to MANUAL
, handling onResumeSuccess()
is required to fully support 3DS and the majority of payment methods.Hide Parameters
Hide Properties
resumeToken
via the onResumeSuccess()
callback if applicable
resumeToken
handler.handleSuccess()
in order to display a success screen
handler.handleFailure(errorMessage)
to display an error or failure message
clientToken
for additional steps. In this case, call handler.continueWithNewClientToken(clientToken)
again
PrimerClientError
data to display an error message.Hide Parameters
paymentMethodType
property, one of PaymentMethodType.true
to continue or false
to abort.reason
as a string.Hide Parameters
TOKENIZATION_SHOULD_NOT_START
: tokenization was interrupted returning false
from onTokenizeShouldStart
.
TOKENIZATION_DISABLED
: tokenization was disabled using setIsTokenizationEnabled
or setPaymentCreationEnabled
.
Hide Client session caching
true
it’s recommended to reach out to Primer support for additional verification since there are edge cases where it’s not advised.true
, responses from the server will be cached on the client side, allowing for faster subsequent
access to the same data within the cache duration. When set to false
, every request to the server will be
processed without utilizing any client-side cache, ensuring that the client always receives the most up-to-date data.Hide child attributes