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}',
  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

Additional data

Use additionalData to pass gateway-specific parameters to Dynamic Checkout. These values are attached to the redirection URL as additional_data[...] query parameters, allowing you to provide extra information required by a given payment method.

const dynamicCheckout = client.setupDynamicCheckout({
  invoiceId: '{invoiceId}',
  additionalData: {
    'paypal-rest': {
      issuer_id: "1234",
    },
    everypay: {
      customer_email: "[email protected]"
    }
  },
});

Event System

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

window.addEventListener("processout_dynamic_checkout_payment_success", function (event) {
  console.log(event.detail);
});

Event reference

Event nameWhen it fires
processout_dynamic_checkout_loadingWidget starts fetching invoice details
processout_dynamic_checkout_readyPayment methods rendered; widget is interactive
processout_dynamic_checkout_invoice_fetching_errorInvoice fetch fails
processout_dynamic_checkout_no_dynamic_checkout_configurationInvoice has no payment_methods configured
processout_dynamic_checkout_payment_submittedShopper clicks the pay button
processout_dynamic_checkout_payment_pendingPayment awaits asynchronous completion (e.g. bank redirect)
processout_dynamic_checkout_payment_successPayment completes successfully
processout_dynamic_checkout_payment_errorPayment fails at any stage
processout_dynamic_checkout_payment_cancelledShopper cancels the payment (e.g. closes redirect popup)
processout_dynamic_checkout_google_pay_load_errorGoogle Pay SDK fails to initialize
processout_dynamic_checkout_apple_pay_new_sessionApple Pay session is created
processout_dynamic_checkout_apple_pay_session_errorApple Pay session creation fails
processout_dynamic_checkout_apple_pay_authorized_post_processApple Pay post-authorization processing starts
processout_dynamic_checkout_delete_payment_method_successSaved payment method deleted successfully
processout_dynamic_checkout_delete_payment_method_errorSaved payment method deletion fails

Event payloads

All events include a common set of fields. Additional fields are listed per event.

Common fields (present in every event)

FieldTypeDescription
invoice_idstringID of the invoice being paid
payment_method_namestring | nullTechnical identifier of the payment method (e.g. "card", "apple_pay", "google_pay", or the APM gateway name). null for lifecycle events not tied to a specific method.
payment_method_display_namestring | nullHuman-readable name of the payment method (e.g. "Apple Pay", "Visa"). null for lifecycle events not tied to a specific method.
return_urlstring | nullThe invoice's return_url, or null if not set.

processout_dynamic_checkout_loading

Fired when the widget starts fetching invoice details. payment_method_name and payment_method_display_name are always null.

No additional fields.


processout_dynamic_checkout_ready

Fired when payment methods have been rendered and the widget is ready for interaction. payment_method_name and payment_method_display_name are always null.

No additional fields.


processout_dynamic_checkout_invoice_fetching_error

Fired when the invoice cannot be fetched.

FieldTypeDescription
error_typestring | nullError code or type string
error_messagestring | nullHuman-readable error description

processout_dynamic_checkout_no_dynamic_checkout_configuration

Fired when the fetched invoice has no payment_methods configured.

No additional fields beyond common fields.


processout_dynamic_checkout_payment_submitted

Fired immediately when the shopper clicks the pay button, before any network request.

FieldTypeDescription
customer_token_idstring (optional)Present when the shopper is paying with a saved payment method

processout_dynamic_checkout_payment_success

Fired when the payment completes successfully.

FieldTypeDescription
card_idstring (optional)Tokenized card ID; present for card payments
customer_token_idstring (optional)Customer token created or used during this payment
authorizedboolean (optional)true if the transaction was authorized (funds reserved)
capturedboolean (optional)true if the transaction was captured (funds settled)

processout_dynamic_checkout_payment_error

Fired when the payment fails at any stage.

FieldTypeDescription
error_typestring | nullError code (e.g. "card.declined", "transaction.invalid-status")
error_messagestring | nullHuman-readable error description
card_idstring (optional)Tokenized card ID if tokenization succeeded before the failure
customer_token_idstring (optional)Customer token if one exists for this attempt
transaction_statusstring (optional)Transaction status at time of failure (e.g. "failed", "voided")
authorizedboolean (optional)true if the transaction reached an authorized state before failing
capturedboolean (optional)true if the transaction reached a captured state before failing

processout_dynamic_checkout_payment_cancelled

Fired when the shopper cancels the payment flow (e.g. closes the APM redirect popup).

FieldTypeDescription
tab_closedboolean (optional)true if the shopper dismissed the payment by closing the redirect tab or popup

processout_dynamic_checkout_payment_pending

Fired when the payment is submitted but awaits asynchronous confirmation (e.g. bank redirect, push notification).

FieldTypeDescription
card_idstring (optional)Tokenized card ID; present for card payments
customer_token_idstring (optional)Customer token created or used during this payment
authorizedboolean (optional)true if the transaction was authorized at the time of the pending state
capturedboolean (optional)true if the transaction was captured at the time of the pending state

processout_dynamic_checkout_google_pay_load_error

Fired when the Google Pay SDK fails to initialize or when isReadyToPay rejects. payment_method_name is always "google_pay".

FieldTypeDescription
error_typestring | nullError code from the Google Pay SDK
error_messagestring | nullError description

processout_dynamic_checkout_apple_pay_new_session

Fired when an Apple Pay session is successfully created. payment_method_name is always "apple_pay".

No additional fields beyond common fields.


processout_dynamic_checkout_apple_pay_session_error

Fired when Apple Pay session creation fails. payment_method_name is always "apple_pay".

FieldTypeDescription
error_typestring | nullError code from the Apple Pay SDK
error_messagestring | nullError description

processout_dynamic_checkout_apple_pay_authorized_post_process

Fired after the shopper authorizes the Apple Pay payment but before the SDK calls session.completePayment. Use this to show an intermediate loading state. payment_method_name is always "apple_pay".

No additional fields beyond common fields.


processout_dynamic_checkout_delete_payment_method_success

Fired when a saved payment method is successfully deleted by the shopper.

No additional fields beyond common fields.


processout_dynamic_checkout_delete_payment_method_error

Fired when a saved payment method deletion fails.

FieldTypeDescription
error_typestring | nullError code
error_messagestring | nullError description

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}',
  clientSecret: '{clientSecret}',
  locale: 'pl'
});

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

Customization

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

const config = {
  invoiceId: '{invoiceId}',
  clientSecret: '{clientSecret}',
  payButtonText: "Pay now",
  // ...
};

const theme = {
  payButtonColor: "red",
  payButtonTextColor: "white"
};

const dynamicCheckout = client.setupDynamicCheckout(config, theme);

Supported configuration properties:

PropertyDescriptionData type
payButtonTextChange the payment method's pay button textText
enforceSavePaymentMethodEnforces saving a payment method when client secret is providedBoolean (true/false)
hideSavedPaymentMethodsHides the customer's saved payment methods sectionBoolean (true/false)
cvcLabel , cvcPlaceholderChange the label and placeholder of the CVC input fieldText

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.