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("\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 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?