PHP Client Library

Download

braintree-php-2.12.5.tgz
SHA1: 96f4c5eff91bb4a2addbaf09ecbc54c8dbb01b87

Note: Requires PHP version 5.2 or higher

Updates

Current version: 2.12.5. Released February 01, 2012.

For details on what changed see the change log. If we deprecate any functionality we’ll add updating instructions to the deprecations page.

Fill out this form to receive an email when we release updates to the PHP library.



Source Code

github | tgz | zip

Integration Examples

github | tgz | zip

Bugs

If you run into a bug, email us at support@getbraintree.com or create an issue on the github issue tracker.

Quick Start Example

require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('your_merchant_id');
Braintree_Configuration::publicKey('your_public_key');
Braintree_Configuration::privateKey('your_private_key');

$result = Braintree_Transaction::sale(array(
    'amount' => '1000.00',
    'creditCard' => array(
        'number' => '5105105105105100',
        'expirationDate' => '05/12'
    )
));

if ($result->success) {
    print_r("success!: " . $result->transaction->id);
} else if ($result->transaction) {
    print_r("Error processing transaction:");
    print_r("\n  message: " . $result->message);
    print_r("\n  code: " . $result->transaction->processorResponseCode);
    print_r("\n  text: " . $result->transaction->processorResponseText);
} else {
    print_r("Message: " . $result->message);
    print_r("\nValidation errors: \n");
    print_r($result->errors->deepAll());
}