Configuring Prebuilt Checkout
Gain a better understanding of the functionality that exists within the Prebuilt Checkout modal's configuration object
The createModal()
and embed()
functions, which are exposed by DigitalRiverCheckout
, accept an optional configuration object that allows you to define:
Designating a container for an Inline Frame
If you implement embed()
and want Digital River to add the iframe
which displays a Prebuilt Checkout to a specific HTML element, then assigns that element's identifier to containerElementId
.
Defining the checkout experience
In options
, you can control the appearance and behavior of a Prebuilt Checkout. Specifically, you can use options
to:
Set display mode
In options
, the displayMode
, whose value can either be standard
(default) or fullPage
, controls the size of the checkout window.
A standard
value results in a window whose dimensions are less than those of the browser window while fullPage
expands the window to the edges of the browser window.
Stylize the modal
Set style.experience
in options
to alter the checkout window's logo, theme, borders, text fields, and fonts. For details, refer to Defining experience.
Localize the experience
Digital River localizes the Prebuilt Checkout window by default based on the customer’s browser settings. But if you want to control the language of the experience, set language
in options
.
If you do define options.language
, then Digital River assigns the same value to language
in the checkout-session.
For a list of accepted values, refer to Supported languages.
Customize order confirmation
By setting thankYouPage
in options
, you can configure the order confirmation stage.
Custom page: To redirect customers to your own fully customized order confirmation page, pass the appropriate web address.
Default window: To display Digital River's default order confirmation, omit
thankYouPage
. You can customize this default confirmation by callingreplaceDefaultMessage()
, which is exposed byactions.thankYouPage
.Close window: If you want the Prebuilt Checkout window to immediately close after customers place an order, set
thankYouPage
tonone
.
Restrict shipping and billing countries
By setting shipToCountries
and/or billToCountries
in options
, you can restrict the values displayed in the drop-down menus that customers use to select a country in the name and address collection stage.
The values you pass must be formatted as two-letter Alpha-2 country codes as described in the ISO 3166 international standard.
Modify the text of the country drop-down menu's label
By adding labelText.country.*
in options
, you can modify the text of the country drop-down menu's label in both the shipping and billing information collection stage.
If a country.*
matches language
, then Digital River updates the label's text.
Define the payment experience
In Prebuilt Checkout's configuration object, you can use paymentMethod
to control the appearance and behavior of the payment collection stage. Specifically, paymentMethod
allows you to style:
You can also use paymentMethod
to:
Drop-in payments also use the paymentMethod
object; the only difference is that it's named paymentMethodConfiguration
.
Style the overall payment experience
To capture secure payment details, Prebuilt Checkout wraps elements with a predetermined style. But you can customize their look and feel by defining style
.
For details, refer to Styling an element container.
Style credit cards
To configure how credit cards are displayed, define one or more of the nested objects in creditCard
.
style:
For details, refer to Styling an element container.mask
: A boolean that determines whether card numbers and security codes get masked after they've been entered by users.cardNumberPlaceholderText
: The placeholder that is shown in the card number field.cardExpirationPlaceholderText
: The placeholder that is shown in the card expiration date field.cardCvvPlacholderText
: The placeholder that is shown in the card security code field.
The values you assign to cardNumberPlaceholderText
, cardExpirationPlaceholderText
, and cardCvvPlacholderText
are not localized.
Style Google Pay
For details on googlePay.style
, refer to Google Pay element styles and customization.
Style Apple Pay
For details on applePay.style
, refer to Apple Pay styles and customization.
Style PayPal
All the properties of payPay.style
, which styles the PayPal button, are optional.
Style online banking
To configure the appearance of the online banking payment method, define one or more of the nested objects in onlineBanking
.
style:
For details, refer to Styling an element container.placeholderText
: The placeholder that appears in the online banking selector.
Link to TreviPay enrollment form
Use msts.enrollmentUrl
to add a link to the TreviPay enrollment URL.
Enable and disable payment methods
To display and hide specific payment methods, provide a list of enabledPaymentMethods
and disabledPaymentMethods
.
For details on how to format these values, refer to Source types.
If you don't populate either of these arrays, then, by default, Prebuilt Checkout displays all transaction-applicable payment methods. If enabledPaymentMethods
contains a value that doesn't meet this precondition, then it's not presented as an option to customers.
Responding to front-end events
In the Prebuilt Checkout configuration object, you can define methods and assign them to its onInit
, onReady
, onAddressComplete
, onDeliveryComplete
, onCheckoutComplete
, onClose
, and onError
properties.
As events occur during the checkout process, these methods are executed.
onInit
onInit
The onInit
method, which accepts checkoutSession
and actions
, executes when Prebuilt Checkout initializes.
onReady
onReady
The onReady
method executes when the checkout-session is created, and the Prebuilt Checkout is loaded and ready for customer interaction.
onAddressComplete
onAddressComplete
The onAddressComplete
method, which accepts an optional address
and actions
, executes when customers successfully submit their shipping and/or billing information and the checkout-session's shipTo
and/or billTo
is updated.
If passed, then onAddressComplete
returns address
, which contains the customer’s billing
and shipping
data.
onDeliveryComplete
onDeliveryComplete
The onDeliveryComplete
method, which optionally accepts shippingMethod
, executes when customers submit their shipping method choice, and the checkout-session's shippingChoice
is successfully updated.
If passed, then onDeliveryComplete
returns a shippingMethod
that contains the customer’s selection, along with its calculated taxAmount
.
onCheckoutComplete
onCheckoutComplete
The onCheckoutComplete
method, which optionally accepts order
, executes when customers provide payment and submit the order, and Digital River adds sources[]
to the checkout-session and creates the order.
If passed, then onCheckoutComplete
returns the order
.
onClose
onClose
The onClose
method, which optionally accepts checkoutCompleted
, executes when customers close Prebuilt Checkout.
If passed, checkoutCompleted
returns a boolean that indicates whether it closed before the checkout process is completed. If true
, customers close the window in the order confirmation stage. If false
, it was closed in an earlier stage.
onError
onError
The onError
method, which optionally accepts error
, executes when a problem occurs during the checkout process.
If passed, then onError
returns an error
that contains a type
and an array of errors[]
, each element of which provides more details on the triggering event.
Last updated