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 area of the 2Checkout Control Panel, you can generate trial links such as the one below, which points to the trial.php page:
Trial links using the trial.php page cannot be used to build mixt regular product and trial links.
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.
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
Secret Key
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 (https://secure.2checkout.com/cpanel/account_settings.php). The secret key is listed in the Instant Payment Notification area (scroll down toward the bottom of the page).
The secret key is required to calculate the HMAC_SHA signature. A HMAC_SHA signature is calculated and applied to the request, using a BASE STRING in tandem with the SECRET KEY generated by 2Checkout (view secret key).
YES
PRODS
Product IDs for which the order will be processed, separated by comma (,), with no blanks. Example: PRODS=1234567,1234568. Each product added / imported into the 2Checkout platform is automatically assigned a system generated unique numeric (int) identifier. Example: Product ID = 1234567.
In the Control Panel, click to edit a product, and select the Information tab. The Product ID of the item you're editing is available at the top of the General area under Information.
Note: Product IDs are different than Product Codes, also available in this area, but which you control.
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]
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.
Note: For trial only flow use TPERIOD instead of TPERIOD[Product ID].
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 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.
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
Using the parameters above, you get the following sequence PRODS=5566778&PRICES5566778[USD]=0&TPERIOD=30.
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.
For the purpose of this demo, let's assume that your secret key is SECRET_KEY.
Use the secret key and the base string to calculate the HMAC-SHA HASH. The result (valid exclusively for this example) should be:
Build your complete link, adding the following elements together for:
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
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
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):
The steps required to build a mixt regular product and trial Buy Link are detailed below.
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)
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
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
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:
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.
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
Last updated
Was this helpful?