Web: ProcessOut.js

Integrate and customize Dynamic Checkout using our client-side Javascript SDK

ProcessOut.js enables the integration of Dynamic Checkout on Web, by importing our SDK hosted on our CDN. After creating your Dynamic Checkout configuration using our Dashboard or API you can enable the end-to-end Dynamic Checkout payment flow by importing the script on your website.

To set up the Dynamic Checkout Web SDK you will need to retrieve these parameters from your application’s backend:

  • Project ID
  • Invoice ID
  • Client secret (optional). The client secret is not required if you do not want to let users save and re-use payment methods.

Setup

To be able to use the Dynamic Checkout utilities from our Web SDK, you need to attach the ProcessOut.js script to your HTML file and create a HTML element that will act as the mounting point for Dynamic Checkout:

<div id="dynamic-checkout-container"></div>

<script src="https://js.processout.com/processout.js"></script>

After linking the script your code will have access to the global ProcessOut instance. This will help you to set up ProcessOut Client using the invoice ID, project ID, and optionally the client secret:

const client = new ProcessOut.ProcessOut('{projectId}');

const dynamicCheckout = client.setupDynamicCheckout({
  invoiceId: '{invoiceId}',
  projectId: '{projectId}',
  clientSecret: '{clientSecret}' // Optional.
});

dynamicCheckout.mount("#dynamic-checkout-container");

After that you should see the Dynamic Checkout widget displayed on your website:

Basic Dynamic Checkout implementation

Simple Dynamic Checkout implementation

Reacting to payment flow events

Dynamic Checkout dispatches browser events on every important step of the payment. This enables you to react on them however you like. To react on events you need to add event listeners—for example:

window.addEventListener("processout_dynamic_checkout_payment_success", function (event) {
  // Handle the event.
});

Every event has information about it attached. You can see it by accessing event.detailproperty.

EventDescription
processout_dynamic_checkout_loadingWidget is loading
processout_dynamic_checkout_readyWidget is loaded and ready to perform the payment flow
processout_dynamic_checkout_invoice_fetching_errorError when fetching the invoice details
processout_dynamic_checkout_tokenize_payment_successCard successfully tokenized
processout_dynamic_checkout_tokenize_payment_errorCard tokenization error
processout_dynamic_checkout_payment_errorPayment error
processout_dynamic_checkout_payment_successPayment success

Localization

You can localize all of the text displayed in Dynamic Checkout widget by passing the locale property when setting up Dynamic Checkout:

const dynamicCheckout = client.setupDynamicCheckout({
  invoiceId: '{invoiceId}',
  projectId: '{projectId}',
  clientSecret: '{clientSecret}',
  locale: 'pl'
});

The currently supported locales are en, es, fr, pt, pl. Please get in touch with your ProcessOut account manager to request support for new locales.

Customization

You can configure the theme of the widget by passing additional arguments when setting up Dynamic Checkout:

const dynamicCheckout = client.setupDynamicCheckout({
  invoiceId: '{invoiceId}',
  projectId: '{projectId}',
  clientSecret: '{clientSecret}'
}, {
  payButtonColor: "red",
  payButtonTextColor: "white"
});

Supported theme properties:

PropertyDescriptionFormat
payButtonColorBackground color of the submit buttonCSS color
payButtonTextColorText color of the submit buttonCSS color

What’s Next

After the payment is successfully authorized you can proceed to capture the payment on your server.