Skip to main content

Checkout with expiration using the signature in InLine Cart

Checkout with expiration using the signature in InLine Cart

Last updated: 29-Feb-2024
Rate this article:

Overview

Use the expiration key to define the validity of a buy-link. The expiration needs to be signed before using the checkout in InLine Cart. In case the expiration is overdue, then the signature is considered invalid.

Use case

  1. Add an HTML link or button on your page like the one below.
  2. Create a JavaScript click handler to execute the Inline Client desired methods.
  3. In order to set expiration, use the TwoCoInlineCart.cart.setExpiration(TIMESTAMP) method.
  4. Use the TwoCoInlineCart.products.add({code, quantity, options, price}) method or the TwoCoInlineCart.products.addMany(products) method to prepare your product(s).
  5. Below it is a signature token request payload for this example. A success response contains a JSON with the property “signature“ which needs to be used to the next step to set the signature using the TwoCoInlineCart method.
{
  "merchant": "AVLRNG",
  "currency": "USD",
  "expiration": 2524608000,
  "products": [
    {
      "code": "74B8E17CC0"
    }
  ]
}

In this example we used a timestamp for January 1st, 2050 as an example. The signature obtained is 16ef22d988d356356ee2437d26114370e29e6293fb4f2e8b58cefad31020950d.

6. Use the TwoCoInlineCart.cart.setExpiration(2524608000) method to set the expiration.

7. Use the TwoCoInlineCart.cart.setSignature('16ef22d988d356356ee2437d26114370e29e6293fb4f2e8b58cefad31020950d') method to set the signature. It is important that you employ the TwoCoInlineCart.cart.removeAll() method just before the TwoCoInlineCart.products.addMany(products) or TwoCoInlineCart.products.add(product) to clear the products, as the signature is based on the products' definition, or simply request a new signature.

8. Use the TwoCoInlineCart.cart.checkout() method to show the cart on your page.

Sample request

HTML

<a href="#" class="btn btn-success" id="buy-button">Buy bundle now!</a>

JavaScript

window.document
  .getElementById('buy-button')
  .addEventListener('click', function() {
  TwoCoInlineCart.cart.setExpiration(2524608000);
  TwoCoInlineCart.products.add({
    code: "74B8E17CC0"
  });
  TwoCoInlineCart.cart.setSignature('16ef22d988d356356ee2437d26114370e29e6293fb4f2e8b58cefad31020950d');
  TwoCoInlineCart.cart.checkout();
});

Demo

Rate this article:

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo