Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve a 400 bad request error using the paypal rest api?

Tags:

paypal

I am currently testing credit card payments using the PayPal payments pro Rest API.

I keep getting the following error:

Exception in HttpConnection Execute: Invalid HTTP response The remote server returned an error: (400) Bad Request. ---> 

I created and activated my PayPal test account and as following:

Credit card
Credit card number:
ccnumber here
Credit card type:
Visa
Expiration date:
3/2019

When I enter the above information in my payment form and submit I keep getting the 400 bad request error.

I have gotton this to work before with the PayPAl joe shopper account but lost the test cc number.

I am 100% sure I have authenticated with the oauth2 credentials

What is the likely cause of this error?:

I am entering a random payer first name and last name .

Does the name have to exsist?

What could be causing the error

like image 651
Milligran Avatar asked Mar 13 '14 23:03

Milligran


1 Answers

If anything goes wrong in the data given, paypal api will return a 400 - Bad request error.

When I got the error(PHP SDK), I caught the exception and $ex->getData() returned a json which contains the details about the bad request, in my case the currency code I given was wrong.

    try {
        $payment->create($apiContext);
    } catch (PayPal\Exception\PPConnectionException $ex) {
        var_dump(json_decode($ex->getData()));
        exit(1);
    }
like image 74
Jithin Avatar answered Oct 13 '22 12:10

Jithin