Note that there are some explanatory texts on larger screens.

plurals
  1. POPaypal Rest API - Creating payment using paypal account payment resource
    primarykey
    data
    text
    <p>Using python and django, I'm trying to create a payment on paypal using REST API account payment resource. Everything works when I use curl. In the Django view I get the token alright but when I try to make a payment using it, I get "HTTP Error 401: Unauthorized" error.</p> <p>Here is my curl that works:</p> <pre><code>curl -v https://api.sandbox.paypal.com/v1/payments/payment -H 'Content-Type:application/json' -H 'Authorization:Bearer ***my_token***' -d '{ "intent":"sale", "redirect_urls":{ "return_url":"http://www.myurl.com", "cancel_url":"http://www.myurl.com"}, "payer":{ "payment_method":"paypal" },"transactions":[{"amount":{ "total":"0.10", "currency":"USD"},"description":"This is the Test payment transaction description."}]}' </code></pre> <p>Here is my Django view that has a problem when :</p> <pre><code>import urllib2, base64 token = "***my_token***" values = { "intent":"sale", "redirect_urls":{ "return_url":"http://www.myurl.com", "cancel_url":"http://www.myurl.com" }, "payer":{ "payment_method":"paypal" }, "transactions":[ { "amount":{ "total":"0.10", "currency":"USD" }, "description":"This is the Test payment transaction description." } ]} data = urllib.urlencode(values) request1 = urllib2.Request("https://api.sandbox.paypal.com/v1/payments/payment") base64string = base64.encodestring('%s' % token).replace('\n', '') request1.add_header("Content-Type", "application/json") request1.add_header("Authorization", "Bearer %s" % base64string) result1 = urllib2.urlopen(request1 , data) response = result1.read() </code></pre> <p>In other words I'm trying to make the curl work in my view.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload