> For the complete documentation index, see [llms.txt](https://docs.2checkout.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.2checkout.com/shopping-carts/inline/use-cases/checkout-with-expiration-using-the-signature-in-inline-cart.md).

# Checkout with expiration using the signature in InLine Cart

## 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.
6. Use the TwoCoInlineCart.cart.setExpiration(2524608000) method to set the expiration.<br>

   ```javascript
   {
     "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**.
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

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

### JavaScript

```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

{% embed url="<https://codepen.io/2checkout-documentation/pen/LYpbpOe>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.2checkout.com/shopping-carts/inline/use-cases/checkout-with-expiration-using-the-signature-in-inline-cart.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
