DigitalRiverCheckout object

Learn about the functionality exposed by the DigitalRiverCheckout object

Once you initialize DigitalRiverCheckout.js, you can use the DigitalRiverCheckout object to:

Create an instance of a Prebuilt Checkout

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 either completing checkout or closing the window.

The function accepts a checkout session identifier and a configuration object.

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 and opens Prebuilt Checkout in a modal window
   drCheckout.createModal(checkoutSessionId, config);
})

embed(checkoutSessionId, config)

This function creates an Inline Frame element and adds Prebuilt Checkout to it, thereby 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.

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);
});

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 that allows a customer 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.

Last updated