Last Updated: 25 April 2024 | Change Log

Create sessionState

Create a sessionState by sending your customer's card details.


A sessionState is a unique identifier for your customer's card details, which is generated by the SDK.

Using the sessionState

Once you've received the sessionState, use the sessionState to generate a verified token to take a payment.

Getting the sessionState

Submitting the form

To create a sessionState you need to submit your customer's card details.

Here's an example of what you must do to generate a sessionState.


Prevent default submit

  function (error, checkout) {
    if (error) {

    form.addEventListener("submit", function (event) {

      checkout.generateSessionState(function (error, sessionState) {
        if (error) {
        // session state for card details

Event listener

The form.addEventListener("wp:field:change", function (event)... function waits for your customer to click the submit button.

The event.preventDefault() stops the form from being submitted. Invoking this action is optional.

Generate sessionState

To generate a sessionState you must invoke the checkout.generateSessionState method.

Create a Verified token

Once you've received a sessionState you must create a verified token to take a payment.

Next steps

Verified token