2Checkout PHP Library

This library provides developers with a simple set of bindings to the 2Checkout Payment API, Hosted Checkout, Instant Notification Service and Admin API.
To use, download or clone the repository.
git clone https://github.com/2Checkout/2checkout-php.git
Require in your php script.
require_once("/path/to/2checkout-php/lib/Twocheckout.php");
All methods return an Array by default or you can set the format to 'json' to get a JSON response. Example:
Twocheckout::format('json');

Credentials and Options

Methods are provided to set the following credentials and options.
// Your sellerId(account number) and privateKey are required to make the Payment API Authorization call.
Twocheckout::privateKey('BE632CB0-BB29-11E3-AFB6-D99C28100996');
Twocheckout::sellerId('901248204');

// Your username and password are required to make any Admin API call.
Twocheckout::username('testlibraryapi901248204');
Twocheckout::password('testlibraryapi901248204PASS');

// If you want to turn off SSL verification (Please don't do this in your production environment)
Twocheckout::verifySSL(false); // this is set to true by default

// To use your sandbox account set sandbox to true
Twocheckout::sandbox(true);

// All methods return an Array by default or you can set the format to 'json' to get a JSON response.
Twocheckout::format('json');

Example Payment API Usage

Example Request:
Twocheckout::privateKey('BE632CB0-BB29-11E3-AFB6-D99C28100996');
Twocheckout::sellerId('901248204');

try {
    $charge = Twocheckout_Charge::auth(array(
        "sellerId" => "901248204",
        "merchantOrderId" => "123",
        "token" => 'MjFiYzIzYjAtYjE4YS00ZmI0LTg4YzYtNDIzMTBlMjc0MDlk',
        "currency" => 'USD',
        "total" => '10.00',
        "billingAddr" => array(
            "name" => 'Testing Tester',
            "addrLine1" => '123 Test St',
            "city" => 'Columbus',
            "state" => 'OH',
            "zipCode" => '43123',
            "country" => 'USA',
            "email" => 'testingtester@2co.com',
            "phoneNumber" => '555-555-5555'
        ),
        "shippingAddr" => array(
            "name" => 'Testing Tester',
            "addrLine1" => '123 Test St',
            "city" => 'Columbus',
            "state" => 'OH',
            "zipCode" => '43123',
            "country" => 'USA',
            "email" => 'testingtester@2co.com',
            "phoneNumber" => '555-555-5555'
        )
    ));
    $this->assertEquals('APPROVED', $charge['response']['responseCode']);
} catch (Twocheckout_Error $e) {
    $this->assertEquals('Unauthorized', $e->getMessage());
}

Example Response:
Array
(
    [validationErrors] =>
    [exception] =>
    [response] => Array
        (
            [type] => AuthResponse
            [lineItems] => Array
                (
                    [0] => Array
                        (
                            [options] => Array
                                (
                                )

                            [price] => 10.00
                            [quantity] => 1
                            [recurrence] =>
                            [startupFee] =>
                            [productId] =>
                            [tangible] => N
                            [name] => 123
                            [type] => product
                            [description] =>
                            [duration] =>
                        )

                )

            [transactionId] => 205181140830
            [billingAddr] => Array
                (
                    [addrLine1] => 123 Test St
                    [addrLine2] =>
                    [city] => Columbus
                    [zipCode] => 43123
                    [phoneNumber] => 555-555-5555
                    [phoneExtension] =>
                    [email] => testingtester@2co.com
                    [name] => Testing Tester
                    [state] => OH
                    [country] => USA
                )

            [shippingAddr] => Array
                (
                    [addrLine1] => 123 Test St
                    [addrLine2] =>
                    [city] => Columbus
                    [zipCode] => 43123
                    [phoneNumber] =>
                    [phoneExtension] =>
                    [email] =>
                    [name] => Testing Tester
                    [state] => OH
                    [country] => USA
                )

            [merchantOrderId] => 123
            [orderNumber] => 205181140821
            [recurrentInstallmentId] =>
            [responseMsg] => Successfully authorized the provided credit card
            [responseCode] => APPROVED
            [total] => 10.00
            [currencyCode] => USD
            [errors] =>
        )

)
valid thru