2Checkout Documentation


To pass a sale to your custom checkout page, you can use one of the methods provided in the Twocheckout_Charge class. This class provides you with several methods to pass the sale and the buyer to 2Checkout.



Use to create an HTML form to pass the buyer and sale to 2Checkout.


  • array parameters
  • string type

    • Defines button text. If ‘**auto**’ is passed the form will submit automatically using JavaScript. Default: ‘Checkout’


Returns an HTML form from the parameters passed in with your defined button text or auto submits.

Example Usage:

$params = array(
    'sid' => '1817037',
    'mode' => '2CO',
    'li_0_name' => 'Test Product',
    'li_0_price' => '0.01'

$form = Twocheckout_Charge::form($params, 'auto');

Example Response:

<form id="2checkout" action="" method="post">
<input type="hidden" name="sid" value="1817037"/>
<input type="hidden" name="mode" value="2CO"/>
<input type="hidden" name="li_0_name" value="Test Product"/>
<input type="hidden" name="li_0_price" value="0.01"/>
<input type="submit" value="Click here if you are not redirected automatically" />
<script type="text/javascript">document.getElementById('2checkout').submit();</script>