0
votes

I got experience error when proceeding to paypal payments.

Fatal error: Uncaught exception 'PayPal\Exception\PayPalConnectionException' with message 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.' in C:\xampp\htdocs\paypal\workload\third_party\vendor\paypal\rest-api-sdk-php\lib\PayPal\Core\PayPalHttpConnection.php:159 Stack trace: #0 C:\xampp\htdocs\paypal\workload\third_party\vendor\paypal\rest-api-sdk-php\lib\PayPal\Transport\PayPalRestCall.php(74): PayPal\Core\PayPalHttpConnection->execute('{"intent":"sale...') #1 C:\xampp\htdocs\paypal\workload\third_party\vendor\paypal\rest-api-sdk-php\lib\PayPal\Common\PayPalResourceModel.php(103): PayPal\Transport\PayPalRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL) #2 C:\xampp\htdocs\paypal\workload\third_party\vendor\paypal\rest-api-sdk-php\lib\PayPal\Api\Payment.php(303): PayPal\Common\PayPalResourceModel::executeCall('/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL, Object(PayPal\Rest\ApiContext), NULL) #3 C:\xampp\htdocs\paypal\workload\modules\member\librari in C:\xampp\htdocs\paypal\workload\third_party\vendor\paypal\rest-api-sdk-php\lib\PayPal\Core\PayPalHttpConnection.php on line 159

2
I don't know the problem could be Paypal is down could be something else. No one is going to be able to help you without your code though. - chris85
what are your thoughts? - user1852837
Sounds like you have an error on line 159. - chris85
4xx errors are client errors. Try ipn tester in paypal's sandbox to see if the ipn is working - Someone33

2 Answers

2
votes

You can catch the PayPalHttpConnection Exception and print the detailed message, on why it is failing. To do so, add a try catch block around your code.

try {
    $creditCard->create($apiContext);
    echo $creditCard;
}
catch (\PayPal\Exception\PayPalConnectionException $ex) {
    echo $ex->getData();
}
0
votes
 $amount    = new Amount();
 $amount->setCurrency('USD')
    ->setTotal($total)
    ->setDetails($details);

make sure your giving right currency for your account i had the same error i had set GBP and it was not working then i had put USD and it work like a charm