The DigitalRiverCheckout exposes the createModal() and embed() functions, either of which can be used to create an interface that customers use to checkout.
createModal(checkoutSessionId, config)
This function creates an instance of a checkout modal window, a graphical control element that appears in front of the other content on the page. When displayed, the user’s interaction with your content is temporarily disabled, and they must engage with the modal by completing checkout or closing the window.
document.getElementById('YOUR_CHECKOUT_BUTTON_ID').addEventListener('click',async(event)=>{ //Invokes a client defined function that creates a checkout sessionconstcheckoutSessionId=awaitcreateCheckoutSession(); // Creates and opens Prebuilt Checkout in a modal windowdrCheckout.createModal(checkoutSessionId,config);})
embed(checkoutSessionId, config)
This function creates an Inline Frame element and adds Prebuilt Checkout, allowing you to embed the entire checkout process directly into your website.
The function accepts a required checkout session identifier and an optional configuration object. However, if you want Digital River to add the iframe to a specific HTML element, you'll need to define containerElementId in the configuration object.
Creating an instance of components
The DigitalRiverCheckout object exposes components(). For details, refer to Components.
Display the checkout button
The DigitalRiverCheckout object exposes renderButton(), which displays a checkout button allowing customers to initiate the checkout process. For details, refer to Rendering a checkout button.
Determine the status of the modal
The DigitalRiverCheckout object exposes getStatus(), which returns data on a Prebuilt Checkout's current state. For details, refer to Determining the checkout's status.
document.getElementById('YOUR_CHECKOUT_BUTTON_ID').addEventListener('click', async (event) => {
//Invokes a client defined function that creates a checkout session
const checkoutSessionId = await createCheckoutSession();
// Creates a Prebuilt Checkout and adds it to an iframe
drCheckout.embed(checkoutSessionId, config);
});