jazzband / django-payments

Universal payment handling for Django.
https://django-payments.readthedocs.io
Other
1.04k stars 282 forks source link

[self assigned] Improve PayPal docs #178

Open NyanKiyoshi opened 6 years ago

NyanKiyoshi commented 6 years ago

A few things I will add once I have time, this may help the production/ live setup as PayPal is quite messy and buggy.

Quick explanation how to create access keys, for both sandbox and live;

I will go back on this issue once I have some time.

patrys commented 6 years ago

Does that mean you've figured out why PayPal API was timing out on you?

NyanKiyoshi commented 6 years ago

I really thought the mail failed to be sent. Aw. But yes... I think I did. Seems like invalid requests are being dropped by PayPal (not unauthorized requests, like bad API key. Only the bad endpoints and invalid requests it seems like).

e.g.:

curl https://api.paypal.com:443/v1/oauth2 -X POST -v  # this will not timeout
curl https://api.paypal.com:443/v2/ -X POST -v  # this should timeout (for example)

But I finally found the issue as the RESTful access key creation was hidden and was redirecting to the home because of a PayPal bug on firefox (CORS issue).

NyanKiyoshi commented 6 years ago

A little update @patrys, after some thinking, I remember having set up the PayPal endpoint in settings to https://api.paypal.com/, as django-payment requires the protocol (https://). Then, I had the issues (timeouts), and looked at the PayPal status and django-payment source code and saw it was doing endpoint + '/{path}' (example here). Then I rectified the endpoint to https://api.paypal.com, assuming it was the correct way to proceed for your lib.

And, now that I have a terminal in my hands, I do confirm that we should not put a path to the endpoint if there is none (/ or /other) (or not put another path since it's the lib's job to put and tell the used API version to PayPal).

So here we are...

┌─╼ [~] 
└╼ curl https://api.paypal.com//v1/oauth2/token -X POST -m 5
curl: (28) Operation timed out after 5000 milliseconds with 0 bytes received
┌─╼ [~] 
└╼ curl https://api.paypal.com/v1/oauth2/token -X POST -m 5
{"name":"AUTHENTICATION_FAILURE","message":"Authentication failed due to invalid authentication credentials or a missing Authorization header.","links":[{"href":"https://developer.paypal.com/docs/api/overview/#error","rel":"information_link"}]}┌─╼ [~] 
└────╼