availability

This page is only relevant for PHP or Python integrations started before March, 2020 and Java integrations started before June, 2020. You can skip it if:

  • You are using the Ruby, .NET, or Node Braintree SDKs
  • You are starting a new PHP, Python, or Java integration using the latest Braintree SDK

Overview

Braintree makes regular updates to our server SDKs which follow semantic versioning guidelines. This page will guide you through the largest breaking changes that are specific to the language you are integrating with Braintree. Check the SDK's CHANGELOG for more information on changes.

SDK Major Version 5.x.x

PSR-4 Namespacing

Previous versions of the Braintree SDK supported class aliases with underscores, for instance Braintree_Gateway to support the PHP standard PSR-0. Version 5.x.x and onward drop support for that standard because it is deprecated, in favor of PSR-4. This may require an update if you were previously using the underscore syntax to load Braintree modules.

If you were using underscores to load modules:

PHP
$gateway = new Braintree_Gateway([
    'environment' => 'sandbox',
    'merchantId' => 'your_merchant_id',
    'publicKey' => 'your_public_key',
    'privateKey' => 'your_private_key'
]);

You should replace those with backslashes:

PHP
$gateway = new Braintree\Gateway([
    'environment' => 'sandbox',
    'merchantId' => 'your_merchant_id',
    'publicKey' => 'your_public_key',
    'privateKey' => 'your_private_key'
]);

If you were using the now unsupported class aliases, you might see errors like the following:

PHP
PHP Fatal error:  Uncaught Error: Class 'Braintree_Gateway' not found in /your/directory/YourFile.php

Further reading