Skip to main content

Checkout catalog products with custom prices using the signature in InLine Cart

Checkout catalog products with custom prices using the signature in InLine Cart

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

Overview

Use the Product object to set the custom price and add it to the InLine Cart by calling the click event handler. In order to use the product custom prices, you first need to generate a signature for the InLine Checkout. The generated signature is then used for checkout.

 

Recommended resources

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 the currency, use the TwoCoInlineCart.cart.setCurrency(currency-code) method.
  4. Use the TwoCoInlineCart.products.add({code, quantity, options, price}) method or the TwoCoInlineCart.products.addMany(products) method to prepare your catalog product(s).
  5. Use the "price" property within the Product object to set the custom price.
  6. You can see below a signature token request payload for this example. A success response contains a JSON with the property “signature“ which needs to be used at the next step to set the signature using the TwoCoInlineCart method.
{
  "merchant": "AVLRNG",
  "currency": "USD",
  "products": [
    {
      "code": "74B8E17CC0",
      "custom-price": {
        "EUR": 8,
        "USD": 10
      }
    }
  ]
}

The above payload will generate the signature ffe213450a70cdf8e45617dde6331a766e184e02b450e1a537e2b52ef0e4d07e.

7. Use the TwoCoInlineCart.cart.setSignature('ffe213450a70cdf8e45617dde6331a766e184e02b450e1a537e2b52ef0e4d07e') method to set the signature. It is important that you employ TwoCoInlineCart.cart.removeAll() just before the TwoCoInlineCart.products.addMany(products) or TwoCoInlineCart.products.add(product) methods to remove previous products as the signature is based on the products' definition.

8. Use the TwoCoInlineCart.cart.checkout() method to display 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() {
    // Sign the
    TwoCoInlineCart.products.removeAll();
    TwoCoInlineCart.products.addMany([
      {
        code: "74B8E17CC0",
        price: {
          EUR: 8,
          USD: 10
        }
      }
    ]);
    TwoCoInlineCart.cart.setCurrency('USD');
    TwoCoInlineCart.cart.setSignature('ffe213450a70cdf8e45617dde6331a766e184e02b450e1a537e2b52ef0e4d07e');
    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