我在尝试使用Braintree创建事务时遇到以下错误。在沙盒中,它工作得很好。我的服务器是一个带有负载均衡器的AWS Beanstalk设置,带有SSL (TLS 1.2)。
下面是来自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部分就是上面的错误所在。在包含Braintree.php文件和所有配置选项之后,我尝试执行一个exit();,它按预期退出,因此错误肯定是由代码的::sale部分引起的。
在沙盒中一切工作正常,并且nonce似乎正确地生成了客户端,然后发送。
我甚至不确定从哪里开始调试。任何建议都会有帮助!
发布于 2017-03-26 21:04:01
原来我的客户申请被拒绝了。
这里的关键术语是authorization-它不同于authentication (它与密钥相关,这是正确的)。
https://stackoverflow.com/questions/42902855
复制相似问题