Skip to content

Charge_Direct

Jacob McConnell edited this page Jun 10, 2014 · 4 revisions

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.

##Method

###direct

Use to create pass a sale to the Inline Checkout iframe. You must pass in the buyers name, email and billing address to go through inline checkout.

####Arguments

  • array parameters
  • Array composed of sale parameters. Parameters -> Hosted Parameter Set
  • string type
  • Defines button text. If 'auto' is passed the form will submit automatically using JavaScript. Default: 'Checkout'

####Returns

Returns an HTML form from the parameters passed in with your defined button text or auto submits and includes the Inline Checkout library below the form.

####Example Usage:

<?php

        $params = array(
            'sid' => '1817037',
            'mode' => '2CO',
            'li_0_name' => 'Test Product',
            'li_0_price' => '0.01',
            'card_holder_name' => 'Testing Tester',
            'email' => '[email protected]',
            'street_address' => '123 test st',
            'city' => 'Columbus',
            'state' => 'Ohio',
            'zip' => '43123',
            'country' => 'USA'
        );

        Twocheckout_Charge::direct($params, 'Click Here!');

####Example Response:

<form id="2checkout" action="https://www.2checkout.com/checkout/purchase" 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="hidden" name="card_holder_name" value="Testing Tester"/>
<input type="hidden" name="email" value="[email protected]"/>
<input type="hidden" name="street_address" value="123 test st"/>
<input type="hidden" name="city" value="Columbus"/>
<input type="hidden" name="state" value="Ohio"/>
<input type="hidden" name="zip" value="43123"/>
<input type="hidden" name="country" value="USA"/>
<input type="submit" value="Click Here!" />
</form>
<script src="https://www.2checkout.com/static/checkout/javascript/direct.min.js"></script>';
Clone this wiki locally