This repository has been archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 103
exception 'PayPal\Exception\PayPalConnectionException' with message 'Got Http response code 400 when accessing
Jay edited this page Jun 30, 2015
·
2 revisions
exception 'PayPal\Exception\PayPalConnectionException' with message 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.' in /Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/lib/PayPal/Core/PayPalHttpConnection.php:178
Stack trace:
#0 /Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/lib/PayPal/Transport/PayPalRestCall.php(74): PayPal\Core\PayPalHttpConnection->execute('{"intent":"sale...')
#1 /Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/lib/PayPal/Common/PayPalResourceModel.php(103): PayPal\Transport\PayPalRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL)
#2 /Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/lib/PayPal/Api/Payment.php(424): PayPal\Common\PayPalResourceModel::executeCall('/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL, Object(PayPal\Rest\ApiContext), NULL)
#3 /Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/CreatePaymentUsingPayPal.php(101): PayPal\Api\Payment->create(Object(PayPal\Rest\ApiContext))
#4 {main}
PayPal returns detailed data on every exception (except 500 INTERNAL_SERVER_ERROR), explaining what was the exact error you are seeing. You can retrieve that as follows:
- Update your exception handling to catch
PayPalConnectionException
and print$ex->getData()
as shown below:
try {
$payment->create($apiContext);
} catch (PayPal\Exception\PayPalConnectionException $ex) {
echo $ex->getCode(); // Prints the Error Code
echo $ex->getData(); // Prints the detailed error message
die($ex);
} catch (Exception $ex) {
die($ex);
}
Now, if you try again, you will see something like this:
{
"name": "VALIDATION_ERROR",
"details": [
{
"field": "transactions[0].amount",
"issue": "Transaction amount details (subtotal, tax, shipping) must add up to specified amount total"
}
],
"message": "Invalid request - see details",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR",
"debug_id": "0faff23b719d8"
}
exception 'PayPal\Exception\PayPalConnectionException' with message 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.' in /Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/lib/PayPal/Core/PayPalHttpConnection.php:178
Stack trace:
#0 /Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/lib/PayPal/Transport/PayPalRestCall.php(74): PayPal\Core\PayPalHttpConnection->execute('{"intent":"sale...')
#1 /Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/lib/PayPal/Common/PayPalResourceModel.php(103): PayPal\Transport\PayPalRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL)
#2 /Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/lib/PayPal/Api/Payment.php(424): PayPal\Common\PayPalResourceModel::executeCall('/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL, Object(PayPal\Rest\ApiContext), NULL)
#3 /Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/CreatePaymentUsingPayPal.php(101): PayPal\Api\Payment->create(Object(PayPal\Rest\ApiContext))
#4 {main}
The details provided in the exception will help you figure out what the error is. Enjoy Coding ...
Getting Started
Using Our SDK
Configurations
Extras
External Links