1
How to use Braintree payment gateway library 3.5 on php 5.3 Server it gives error : Parse error: syntax error, unexpected '[' on Braintree/OAuthGateway.php on line 64


require_once('braintree-php/lib/Braintree.php'); 
Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('h9xhpt9b5zjgbkpj');
Braintree_Configuration::publicKey('4yfx77c9cns49y9d');
Braintree_Configuration::privateKey('54bbbab22711240ddb3d40e19ff6a13d');

Above is the sandbox payment mode of braintree payment gateway i want to use it on godaddy server. it was rising above error so , any one can help me to implement this restrictions

1 Answers1

3

The Reson of this error is not because of the Braintree API but because of the vesion of PHP you are running.

In PHP 5.3 Array decleration syntax is :

$names = array('Steve Jobs', 'Steve Wozniak','Ronald Wayne');

However php 5.4 Supports the array syntax as :

$names = ['Steve Jobs', 'Steve Wozniak','Ronald Wayne'];

Braintree 3.5 is probably written for php 5.4 or above, So they have used the second syntax for array declaration which is not recognized by older version of PHP and is interpreted as Syntax Error.

To resolve This you may have to upgrade the PHP version or downgrade the Braintree Library to support your current PHP Version.


EDIT

You can check on their Documentation in this link: https://developers.braintreepayments.com/ios+php/start/hello-server

it's clearly mentioned :

Requires PHP version 5.4.0 or higher and the PHP cURL extension

Mohan
  • 4,677
  • 7
  • 42
  • 65
  • 1
    Angry Coder is correct. As of version 3.0.0, the library requires PHP 5.4 or higher. You can [read the changelog here](https://github.com/braintree/braintree_php/blob/master/CHANGELOG.md#300) – BladeBarringer Sep 24 '15 at 14:50