尝试使用 Braintree 创建事务时出现以下错误。在沙盒中它工作得很好。我的服务器是带有 SSL (TLS 1.2) 负载均衡器的 AWS Beanstalk 设置。
这是来自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
这是实际的服务器端 PHP 代码:
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
]
]);
上面代码的 ::sale 部分给了我上面的错误。我试着做一个 exit(); 在包含 Braintree.php 文件和所有配置选项后,它按预期退出,因此该错误肯定是由代码的 ::sale 部分引起的。
在 Sandbox 中一切正常,nonce 似乎在客户端正确生成,然后发送。
我什至不确定从哪里开始调试。任何建议都会有所帮助!