Volley work with PayPal server

169 views Asked by At

I am trying to implement payment to a Paypal server ,using Volley for the http requests.

I followed this tutorial : https://developer.paypal.com/docs/integration/direct/make-your-first-call/ (Please see Make an API call)

Paypal server request needs to receive this header :

'Content-Type: application/json' \
'Authorization: Bearer <Access-Token>' \

to this url : "https://api.sandbox.paypal.com/v1/payments/payment". I tested it with Postman and it works fine. But when I run it on my app, It always responds with an error message :

Unexpected response code 400 for https://api.sandbox.paypal.com/v1/payments/payment

Here are my header values :

/**
* I get the token type and access token from my server (My server get the data from Paypal server)
* The value could be : headers.put("Authorization", "Bearer A015DQgopAeVjrD6xUts1K935PfiWvp5ynk55liloolwetE");
*/
headers.put("Authorization", String.format("%s %s",
response.getResult().getToken_type(), response.getResult().getAccess_token()));

And the content type body :

@Override
public String getBodyContentType(){
    return "application/json; charset=UTF-8";
}

I used Wireshark to catch the request by sending the data to a non-https server. But I can't see anything wrong.

0

There are 0 answers