简体   繁体   中英

Braintree Sale Error (PHP)

I'm getting the following error when trying to create a transaction with Braintree. In Sandbox it worked fine. My server is an AWS Beanstalk setup with a load balancer with SSL (TLS 1.2).

Here is the error from the error_log:

[Mon Mar 20 11:32:31.816499 2017] [:error] [pid 11335] [client XX] PHP Fatal error:  Uncaught Braintree\\Exception\\Authorization in /var/app/current/scripts/lib/Braintree/Util.php:61\nStack trace:\n#0 /var/app/current/scripts/lib/Braintree/Http.php(47): Braintree\\Util::throwStatusCodeException(403)\n#1 /var/app/current/scripts/lib/Braintree/TransactionGateway.php(477): Braintree\\Http->post('/merchants/jtd9...', Array)\n#2 /var/app/current/scripts/lib/Braintree/TransactionGateway.php(49): Braintree\\TransactionGateway->_doCreate('/transactions', Array)\n#3 /var/app/current/scripts/lib/Braintree/TransactionGateway.php(289): Braintree\\TransactionGateway->create(Array)\n#4 /var/app/current/scripts/lib/Braintree/Transaction.php(502): Braintree\\TransactionGateway->sale(Array)\n#5 /var/app/current/ajax/add_points.php(23): Braintree\\Transaction::sale(Array)\n#6 {main}\n  thrown in /var/app/current/scripts/lib/Braintree/Util.php on line 61, referer: https://XX.com/dashboard

Here is the actual server-side PHP code:

require_once('../scripts/lib/Braintree.php');
Braintree_Configuration::environment('production');
Braintree_Configuration::merchantId('xx');
Braintree_Configuration::publicKey('xx');
Braintree_Configuration::privateKey('xx');
$pym = $_POST["payment_method_nonce"];
$points = 10*1.5;

        $result = Braintree_Transaction::sale([
            'amount' => $points,
            'currency' => 'EUR',
            'paymentMethodNonce' => $pym,
            'options' => [
                'submitForSettlement' => true
            ]
        ]);

The ::sale part of the code above is what gives me the error above. I tried doing an exit(); after including the Braintree.php file and all the configuration options, and it exits as expected, so the error is definitely caused by the ::sale part of the code.

All works fine in Sandbox, and nonce seems to be correctly generated client side, and then sent.

I'm not even sure where to start debugging. Any advice would help!

It turns out that my clients application has been declined.

The key term here was authorization - which is different than authentication (which relates to API keys, that were correct).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM