Last Updated: 25 April 2024 | Change Log

Create a sessions object

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

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

Using sessions.card

Use sessions.card to generate a verified token to take a payment.

Getting sessions.card

Submitting the form

To create sessions.card you must submit your customer's card details.

Here's an example of what you must do to generate sessions.card.

JavaScript sessions.card

(function () {
  var form = document.getElementById("card-form");
  var id = "your-checkout-id";
  var styles = {
    input: {
      "font-size": "14px",
      "font-family": "Arial"
    "": {
      color: "green"
    "": {
      color: "red"
  var fields = {
    pan: {
      selector: "#card-pan",
      placeholder: "Card number"
    expiry: {
      selector: "#card-expiry",
      placeholder: "MM/YY"
    cvv: {
      selector: "#card-cvv",
      placeholder: "CVV"
      id: id,
      styles: styles,
      form: "#card-form",
      fields: fields
    function(err, checkout) {
      if (err) {
        // handle init error
      form.addEventListener("submit", function(event) {
        checkout.generateSessions(function(err, sessions) {
          if (err) {
            // handle session state generation error
          // send sessions to the server
          console.log('Sessions Card : ' + sessions.card + ', Sessions CVV : '+ sessions.cvv);

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 sessions.card

To generate the sessions object you must invoke the checkout.generateSessions method to get sessions.card.

Create a Verified token

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

Next steps

Verified token