# Trial and regular products in the same shopping cart

## Overview

2Checkout supports scenarios in which you sell one or more regular products and offer one or more free/paid trials (with payment details - mandatory) in the same shopping cart to your customers.

## Availability

All 2Checkout accounts.

## Requirements

Products for which you're offering evaluation versions must meet the following criteria:

* They must be free or paid trials for which you're collecting payment details from customers by using the Request payment details and customize your trial option.
* They must support electronic delivery as the shipping class.
* They can only be standalone offerings, not bundles.
* They cannot match any of the regular products added to cart (Note: Customers won't be able to access the trial and purchase the regular version of a product using the same shopping cart session).

## Scenarios covered

* One product and one paid/free trial (with payment details) in the same cart
* Multiple products and one paid/free trial (with payment details) in the same cart
* One product and multiple paid/free trials (with payment details) in the same cart
* Multiple products and multiple paid/free trials (with payment details) in the same cart

## Use checkout.php trial links

Using the [Sales Links](https://secure.avangate.com/cpanel/integration.php) area of the 2Checkout Control Panel, you can generate trial links such as the one below, which points to the **trial.php** page:

```json
https://secure.2checkout.com/order/trial.php?PRODS=5566778&PAY_TYPE=CCVISAMC&PRICES5566778[USD]=0&TPERIOD=30&PHASH=sha256.1f24f5c938adf4c125ddfe67242d958a
```

{% hint style="warning" %}
Trial links using the **trial.php** page cannot be used to build mixt regular product and trial links.
{% endhint %}

You need to build your own trial links, pointing to the **checkout.php** page, instead of trial.php, and use them to create mixt regular product and trial links.

| checkout.php trial links                                                                    | trial.php trial links                                                               |
| ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| Build links using **checkout.php**                                                          | Trial links generated automatically use **trial.php**                               |
| Trial period is defined in the link using the **TPERIOD** parameter as such: **TPERIOD=30** | Trial period is defined in the link using the TPERIOD parameter as such: TPERIOD=30 |
| HASH signature needs to be generated manually                                               | HASH signature is generated automatically along with the link                       |

## Required parameters&#x20;

| Parameter                          | Info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Mandatory             |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| **Secret Key**                     | <p>The secret key is communicated to you when your account with 2Checkout is opened. You can always retrieve the secret key information from the "Account settings" section in the Control Panel (<a href="https://secure.avangate.com/cpanel/account_settings.php"><https://secure.2checkout.com/cpanel/account_settings.php></a>). The secret key is listed in the Instant Payment Notification area (scroll down toward the bottom of the page).</p><p>The secret key is required to calculate the HMAC\_SHA signature. A HMAC\_SHA signature is calculated and applied to the request, using a <strong>BASE STRING</strong> in tandem with the <strong>SECRET KEY</strong> generated by 2Checkout (<a href="https://secure.avangate.com/cpanel/account_settings.php">view secret key</a>).</p> | YES                   |
| **PRODS**                          | <p>Product IDs for which the order will be processed, separated by comma (,), with no blanks. <strong>Example: </strong><em><strong>PRODS=</strong></em>1234567<em><strong>,</strong></em>1234568. Each product added / imported into the 2Checkout platform is automatically assigned a system generated unique numeric (int) identifier. Example: Product ID = 1234567.</p><p>In the Control Panel, click to edit a product, and select the <strong>Information</strong> tab. The Product ID of the item you're editing is available at the top of the <strong>General</strong> area under <strong>Information</strong>.</p><p><em><strong>Note:</strong></em> Product IDs are different than Product Codes, also available in this area, but which you control.</p>                             | YES                   |
| **PRICES\[Product ID]\[Currency]** | Required parameter to set the price for product default currency. For example, for a product with the 2Checkout product ID: 123456, the currency EUR, and the price 99.99, this parameter would look like: *PRICES123456\[EUR]=99.99*. If not sent for other billing currencies, 2Checkout will convert based on the submitted default price.                                                                                                                                                                                                                                                                                                                                                                                                                                                      | YES (only for trials) |
| **TPERIOD\[Product ID]**           | <p>Trial period must be at least 7 days. For example enter TPERIOD\[Product ID]=7 for a 7-day trial, or TPERIOD\[Product ID]=30 for a 30-day evaluation period. Needs to be used as in the following example: TPERIOD1234567=7, with 1234567 representing the product ID.</p><p><em><strong>Note</strong>: For trial only flow use <strong>TPERIOD</strong> instead of TPERIOD\[Product ID].</em></p>                                                                                                                                                                                                                                                                                                                                                                                              | YES                   |
| **PHASH**                          | Required HMAC\_SHA signature in order to prevent the request from being exploited.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | YES                   |

## Build a checkout.php trial Buy Link

For this example, let's assume that we need a trial link for the evaluation version of a product with the ID 5566778. The trial is free and the evaluation period is 30 days. We'll use the parameters listed above.

As already mentioned, system-generated trial links via the [Sales Links](https://secure.avangate.com/cpanel/integration.php) area of the 2Checkout Control Panel work only for scenarios in which the trial is also the only item in the shopping cart, but not for mixt regular product and trial scenarios. This is why links as the one below should not be used.

```json
https://secure.2checkout.com/order/trial.php?PRODS=5566778&PAY_TYPE=CCVISAMC&PRICES5566778[USD]=0&TPERIOD=30&PHASH=sha256.1f24f5c938adf4c125ddfe67242d958a
```

Instead, you need to build another type of trial link, pointing to **checkout.php**, and using the **PRODS**, **PRICES\[Product ID]\[Currency]**, **TPERIOD** and **PHASH** parameters. In this specific case:

* PRODS=5566778
* PRICES5566778\[USD]=0
* TPERIOD=30

1. Using the parameters above, you get the following sequence **PRODS=5566778\&PRICES5566778\[USD]=0\&TPERIOD=30**.
2. Next, you need to prefix (prepend) the length of the character sequence to calculate the hash, namely **45**. The resulting **BASE STRING** is **45PRODS=5566778\&PRICES5566778\[USD]=0\&TPERIOD=30**.
3. For the purpose of this demo, let's assume that your secret key is **SECRET\_KEY**.
4. Use the secret key and the base string to calculate the HMAC-SHA HASH. The result (valid exclusively for this example) should be:
5. Build your complete link, adding the following elements together for:

{% stepper %}
{% step %}

### Step

Using the parameters above, you get the following sequence:

PRODS=5566778\&PRICES5566778\[USD]=0\&TPERIOD=30
{% endstep %}

{% step %}

### Step

Prefix (prepend) the length of the character sequence to calculate the hash. The length is 45. The resulting BASE STRING is:

45PRODS=5566778\&PRICES5566778\[USD]=0\&TPERIOD=30

In case of using the QTY parameter in the buy-link, this key-value string should also be included in the hash (example: QTY=1). In this case, the resulting BASE STRING would be:

51PRODS=5566778\&QTY=1\&PRICES5566778\[USD]=0\&TPERIOD=30
{% endstep %}

{% step %}

### Step

For the purpose of this demo, assume your secret key is SECRET\_KEY.
{% endstep %}

{% step %}

### Step

Use the secret key and the base string to calculate the HMAC-SHA HASH. The result (valid exclusively for this example) should be:

* f2fdbc766c6dd162f6a3fd63a05a9a173052e0eabd45fb4d0b129669a99d4e8a (SHA2)
* 04fe358d6aadd01f1e4cefdf73853efeb231007182f8e71108ab8fd5b7d0dc3d (SHA3)
  {% endstep %}

{% step %}

### Step

Build your complete link by appending the PHASH parameter to the checkout.php URL.

* SHA2 example:

<https://secure.2checkout.com/order/checkout.php?PRODS=5566778\\&PRICES5566778\\[USD]=0\\&TPERIOD=30\\&PHASH=sha256.f2fdbc766c6dd162f6a3fd63a05a9a173052e0eabd45fb4d0b129669a99d4e8a>

* SHA3 example:

<https://secure.2checkout.com/order/checkout.php?PRODS=5566778\\&PRICES5566778\\[USD]=0\\&TPERIOD=30\\&PHASH=sha3-256.04fe358d6aadd01f1e4cefdf73853efeb231007182f8e71108ab8fd5b7d0dc3d>
{% endstep %}
{% endstepper %}

Use this link in the process described below, under the Alternative workflow section.

## Build a mix of regular products and trial Buy Links

Mixt Buy Links containing both regular products and trials have to be created manually, and need to point users directly to Checkout.

Example generated links (separate):

```json
https://secure.2checkout.com/order/checkout.php?PRODS=1234567&CART=1&CARD=2
```

```json
https://secure.2checkout.com/order/trial.php?PRODS=5566778&PAY_TYPE=CCVISAMC&PRICES5566778[USD]=0&TPERIOD=30&PHASH=sha256.ae929a5009ca5737d50c5f929d34650c
```

The steps required to build a mixt regular product and trial Buy Link are detailed below.

{% stepper %}
{% step %}

### Step

Make sure the mandatory information necessary to build the link is available:

* The secret key for your 2Checkout account (necessary for the hash calculation)
* The following parameters: PRODS, PRICES\[Product ID]\[Currency] (with value — can be 0), and TPERIOD\[Product ID] (with value — duration in days)
  {% endstep %}

{% step %}

### Step

Build the link from the checkout base URL:

* <https://secure.2checkout.com/order/checkout.php>?
* or <https://secure.YourStore.com/order/checkout.php>? if using a custom domain
  {% endstep %}

{% step %}

### Step

In this example, parameters and values:

* PRODS=1234567,5566778
* PRICES5566778\[USD]=0
* TPERIOD5566778=30
  {% endstep %}

{% step %}

### Step

Using the parameters above, you get the following sequence:

PRODS=1234567,5566778\&PRICES5566778\[USD]=0\&TPERIOD5566778=30

Prefix the length of this character sequence (60). The resulting BASE STRING is:

60PRODS=1234567,5566778\&PRICES5566778\[USD]=0\&TPERIOD5566778=30

If using QTY in the buylink, include it in the hash (example: QTY=1,1). Example BASE STRING:

68PRODS=1234567,5566778\&QTY=1,1\&PRICES5566778\[USD]=0\&TPERIOD5566778=30
{% endstep %}

{% step %}

### Step

For the purpose of this demo, assume your secret key is SECRET\_KEY.
{% endstep %}

{% step %}

### Step

Use the secret key and the base string to calculate the HMAC-SHA HASH. The result (valid exclusively for this example) should be:

* 849c5a6ff5e453600225ee675bd27037f81383c24769a2152eb4bf8e1a4bc6a9 (SHA2)
* a815a304725c54ea0eac2fd7214f654bb8b6cd1ce2245ee65769d765745f3f7a (SHA3)
  {% endstep %}

{% step %}

### Step

Build your complete link by appending the PHASH parameter to the checkout.php URL.

* SHA2 example:

<https://secure.2checkout.com/order/checkout.php?PRODS=1234567,5566778\\&PRICES5566778\\[USD]=0\\&TPERIOD5566778=30\\&PHASH=sha256.849c5a6ff5e453600225ee675bd27037f81383c24769a2152eb4bf8e1a4bc6a9>

* SHA3 example:

<https://secure.2checkout.com/order/checkout.php?PRODS=1234567,5566778\\&PRICES5566778\\[USD]=0\\&TPERIOD5566778=30\\&PHASH=sha3-256.a815a304725c54ea0eac2fd7214f654bb8b6cd1ce2245ee65769d765745f3f7a>
{% endstep %}
{% endstepper %}

## Alternative workflow

To allow your customers to buy one or multiple products while also accessing free/paid trials in the same shopping cart (during the same browser session) follow these steps:

{% stepper %}
{% step %}

### Step

Generate the buy link for the regular product(s). Use the links on the purchase call to action on your online shop, such as the **Buy** buttons.
{% endstep %}

{% step %}

### Step

Build the trial links as per the example above. Use the links on the call to actions designed to enable access to trials on your online shop, such as the **Download trial** buttons.

Make sure your trial links use **checkout.php** and NOT **trial.php**, otherwise this alternative workflow would fail. Use the link built in the Build a checkout.php trial Buy Link section.
{% endstep %}

{% step %}

### Step

Shoppers will click on the buy link for a regular product and add it to the cart.
{% endstep %}

{% step %}

### Step

Shoppers continue the purchase process and click on the link to download a trial.
{% endstep %}

{% step %}

### Step

The trial gets added to the same shopping cart as the regular product, provided that the browser session is still valid.
{% endstep %}

{% step %}

### Step

Shoppers go through the steps of the purchase process to acquire the regular product as well as access the trial added to cart.
{% endstep %}
{% endstepper %}

Trial links using the **trial.php** page cannot be used to build mixt regular product and trial links. This is because **trial.php** links open a new browser session and generate a new cart for shoppers. As such, when adding a trial on top of a regular product already in the cart, the trial would simply replace the offering. Vice versa, when adding a regular product on top of a trial already in the cart, the regular product would replace the trial.

## Limitations

Make sure your trial links use **checkout.php** and NOT **trial.php**, otherwise this alternative workflow would fail. Use this link in the process described under the Build a checkout.php trial Buy Link section.

The following scenario is not supported: both the regular and the trial versions of a product added to the same shopping cart. Customers can buy a product or access its evaluation version, but not both simultaneously in the same cart.

Scenarios:

* Product A and Trial for Product A in the same cart
  * Customers add Product A to cart
  * Customers add Trial for Product A to cart during the same browser session
  * Result: Trial for Product A replaces Product A in the cart. Customers can access Trial for Product A but will need to buy Product A in a different shopping cart / via a new browser session.
* Trial for Product A and Product A in the same cart
  * Customers add Trial for Product A to cart
  * Customers add Product A to cart during the same browser session
  * Result: Product A replaces Trial for Product A in the cart. Customers can buy Product A but will need to access Trial for Product A in a different shopping cart / via a new browser session.

## Promotions/discounts

Discount coupons for **Regular** and **Multi-product** promotions used by shoppers acquiring a regular product and accessing a trial in the same shopping cart will only impact the trial when the evaluation period comes to an end and it's converted to a full product. Essentially, discounts are offered to shoppers for the first transaction marking the conversion of the trial to a regular product, equivalent to a new purchase, and not when the trial is first accessed. If, following the evaluation period the trial is not converted to a regular subscription, no discount is offered.

Order promotions will discount the total value of the initial order containing both regular products and trials. Order promotion discounts will no longer impact the transaction associated with the conversion of the trial to a full product.

## Payment methods

Shoppers who access trials while concomitantly purchasing regular products will be able to use a number of payment methods supporting recurring billing such as credit/debit cards, PayPal and DirectDebit. Trials are set to auto-renew by default, and customers can opt out of a purchase during the evaluation period in order to not be billed for the trial conversion to a regular subscription.

## Auto-renewal

The auto-renewal option doesn't impact trials, which are set to auto-renew by default. You can manually cancel new subscription purchases before trial ends.

## Upselling and cross-selling campaigns

Upselling and cross-selling campaigns will be triggered only for the regular products added to cart, but not for the trials of such offerings.

#### Related documentation

* [Set a redirect URL for default checkout flows](/payment-link/checkout-links-and-options/set-a-redirect-url-for-default-checkout-flows.md)
* [Products and subscriptions listing query parameters](https://verifone.cloud/docs/2checkout/Documentation/myAccount/Products-and-subscriptions-listing-query-parameters)
* [Subscriber management and self-service](https://verifone.cloud/docs/2checkout/Documentation/Subscription-Billing/03Subscriber-management-and-self-service)


---

# Agent Instructions: 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:

```
GET https://docs.2checkout.com/payment-link/checkout-links-and-options/trial-and-regular-products-in-the-same-shopping-cart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
