然后用下面的行替换上面的行,以解决第二个问题:'paymentMethodNonce' => 'fake-valid-nonce',I am using braintreegateway with the following code in sandbox mode.Code is used from developer siterequire_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("\n code: " . $result->transaction->processorResponseCode); print_r("\n text: " . $result->transaction->processorResponseText);} else { print_r("Validation errors: \n"); print_r($result->errors->deepAll());}and the result iswhat's wrong here? 解决方案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', 这篇关于braintreegateway未捕获的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-02 01:51