If you are developing a 2CO-compatible shopping cart, the following code samples will show you some ways to create some common purchase links that do not require manually entering your products in the 2CO database.
You may use whatever custom parameters you like, as long as our basic requirements are met. To learn more about these, please refer to the third-party cart parameter set articles in the 2CO Knowledge Base.
The Acme Online Books account is always in demo mode, so you won't be charged for any purchases.
This is a simple product purchase. Clicking the purchase button will add the product to your shopping cart.
Price: $10.00
<form action="https://www.2checkout.com/checkout/purchase" method="post">
<p>
<input type="hidden" name="c_prod" value="73453" />
<input type="hidden" name="c_name" value="My fancy product." />
<input type="hidden" name="c_description" value="My fancy product description." />
<input type="hidden" name="c_price" value="10.00" />
<input type="hidden" name="id_type" value="1" />
<input type="hidden" name="cart_order_id" value="example_cart_order_id_abc_123" />
<input type="hidden" name="total" value="10.00" />
<input type="hidden" name="sid" value="1303908" />
<input type="submit" class="submit" name="purchase" value="Buy from 2CO" />
</p>
</form>
This purchase form will allow the customer to define the total price of the purchase. This can be useful for hourly charges, or any other type of variable price purchase.
<form action="https://www.2checkout.com/checkout/purchase" method="post">
<p>
<input type="hidden" name="c_prod" value="73453" />
<input type="hidden" name="c_name" value="My fancy product." />
<input type="hidden" name="c_description" value="My fancy product description." />
<span class="price">Price: $<input type="text" name="total" value="" /></span>
<input type="hidden" name="id_type" value="1" />
<input type="hidden" name="cart_order_id" value="example_cart_order_id_abc_123" />
<input type="hidden" name="sid" value="1303908" />
<input type="submit" class="submit" name="purchase" value="Buy from 2CO" />
</p>
</form>
This purchase form will allow a custom parameter to be sent along with the purchase, which will be returned to the vendor after the sale.
Price: $24.95
<form action="https://www.2checkout.com/checkout/purchase" method="post">
<p>
<input type="hidden" name="sid" value="1303908" />
<input type="hidden" name="product_id" value="4" />
<label for="sign-this-to">Sign this book to:</label>
<input id="sign-this-to" type="text" name="sign_this_to" size="17" value="" />
<input type="submit" class="submit" name="purchase" value="Buy from 2CO" />
</p>
</form>
This purchase form will create a purchase with multiple products with different quantities and the product names and descriptions passed in by the form.
Price: $230.00
<form action="https://www.2checkout.com/checkout/purchase" method="post">
<p>
<input type="hidden" name="c_prod_1" value="1,7" />
<input type="hidden" name="c_name_1" value="science fiction book." />
<input type="hidden" name="c_price_1" value="10.00" />
<input type="hidden" name="c_description_1" value="This is a science fiction book, 276 pages, second edition." />
<input type="hidden" name="c_prod_2" value="2,2" />
<input type="hidden" name="c_price_2" value="20.00" />
<input type="hidden" name="c_name_2" value="non-fiction book" />
<input type="hidden" name="c_description_2" value="This is a non-fiction book, 335 pages, first edition." />
<input type="hidden" name="c_prod_3" value="3,4" />
<input type="hidden" name="c_price_3" value="30.00" />
<input type="hidden" name="c_name_3" value="technical book" />
<input type="hidden" name="c_description_3" value="This is a technical book, 442 pages, third edition." />
<input type="hidden" name="id_type" value="1" />
<input type="hidden" name="cart_order_id" value="example_cart_order_id_abc_123" />
<input type="hidden" name="total" value="230.00" />
<input type="hidden" name="sid" value="1303908" />
<input type="submit" class="submit" name="purchase" value="Buy from 2CO" />
</p>
</form>