dtkf64283 2016-06-24 13:19
浏览 51
已采纳

braintreegateway未被捕获的例外

I am using braintreegateway with the following code in sandbox mode.

Code is used from developer site

require_once 'braintree/lib/Braintree.php';

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('marchentid');
Braintree_Configuration::publicKey('publickey');
Braintree_Configuration::privateKey('privatekey');

$result = Braintree_Transaction::sale([
            'amount' => '100.00',
            'orderId' => '123',
            'merchantAccountId' => 'marchentid',
            'paymentMethodNonce' => 'nonceFromTheClient',
            'customer' => [
                'firstName' => 'kapil',
                'lastName' => 'Smith',
                'company' => 'mycompany',
                'phone' => '1234567890',
                'website' => 'http://mywebsite.com',
                'email' => 'myemail'
            ],
            'billing' => [
                'firstName' => 'kapil',
                'lastName' => 'Smith',
                'company' => 'mycompany',
                'streetAddress' => 'address',
                'extendedAddress' => 'Suite 403',
                'locality' => 'India',
                'region' => 'IN',
                'postalCode' => 'zipcode',
                'countryCodeAlpha2' => 'IN'
            ],
            'shipping' => [
                'firstName' => 'kapil',
                'lastName' => 'Smith',
                'company' => 'mycompany',
                'streetAddress' => 'address',
                'extendedAddress' => 'Suite 403',
                'locality' => 'India',
                'region' => 'IN',
                'postalCode' => 'zipcode',
                'countryCodeAlpha2' => 'IN'
            ],
            'options' => [
                'submitForSettlement' => true
            ]
        ]);

if ($result->success) {
    print_r("success!: " . $result->transaction->id);
} else if ($result->transaction) {
    print_r("Error processing transaction:");
    print_r("
  code: " . $result->transaction->processorResponseCode);
    print_r("
  text: " . $result->transaction->processorResponseText);
} else {
    print_r("Validation errors: 
");
    print_r($result->errors->deepAll());
}

and the result is

Fatal error: Uncaught exception 'Braintree\Exception\Authorization' in /var/www/html/api/braintree/lib/Braintree/Util.php:61 Stack trace: #0 /var/www/html/api/braintree/lib/Braintree/Http.php(47): Braintree\Util::throwStatusCodeException(403) #1 /var/www/html/api/braintree/lib/Braintree/TransactionGateway.php(443): Braintree\Http->post('/merchants/dmmt...', Array) #2 /var/www/html/api/braintree/lib/Braintree/TransactionGateway.php(49): Braintree\TransactionGateway->_doCreate('/transactions', Array) #3 /var/www/html/api/braintree/lib/Braintree/TransactionGateway.php(268): Braintree\TransactionGateway->create(Array) #4 /var/www/html/api/braintree/lib/Braintree/Transaction.php(494): Braintree\TransactionGateway->sale(Array) #5 /var/www/html/api/payment.php(58): Braintree\Transaction::sale(Array)

6 {main} thrown in /var/www/html/api/braintree/lib/Braintree/Util.php on line 61

what's wrong here?

  • 写回答

2条回答 默认 最新

  • dtpwra8456 2016-06-28 14:29
    关注

    Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

    Like @mfahadi mentioned, one potential problem may be that that your code doesn't have your keys in the Braintree_Configuration calls, but you should never post your keys to StackOverflow, even for sandbox accounts. So if it was intentionally filtered: well done. If not, check out the guide to get your client keys.

    The second problem is you did not replace 'nonceFromTheClient' in the line below with an actual client nonce:

    'paymentMethodNonce' => 'nonceFromTheClient',
    

    You can find a test nonce in the testing reference guide.

    And replace the line above with the line below to fix your second problem:

    'paymentMethodNonce' => 'fake-valid-nonce',
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置