PayPal’s NVP API - sample Python wrapper
I was unable to find any Python samples for using the PayPal NVP API, so I went to work writing a helper class for my needs. Hopefully this should be enough to help get others started at least.
This is not a complete reference! Be sure to understand what this class is doing before you try it on production servers! …use it at your own peril.
http://python.pastebin.com/f782d48d9
Also be sure to check the complete reference doc for any error codes returned, as the doc is very helpful.
Update April 3rd, 2008: I’m pleased to discover that this has made its way around the internet:
The Freesound Project based out of Belgium is reimplementing their site in Python and they are using my reference.
A Google Code project called PyPayPal is using it as a reference.
GoCept, a German based company, seems to have implemented it in their content management system.
This post is filed under Computer Science, LowSingle, Miscellaneous. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
April 3rd, 2008 at 12:56 pm
hello mike,
I was just experimenting with your code and successfully did my first “sandbox” payment. I believe that in SetExpressCheckout there is a small error fixed by:
return urllib.unquote(response_token)
in that very function (the tokens have a url escaped dash in them, mybe not when you wrote the function so the next functions double-quote it)
Anyway, it all works and I’m happy with it.
I was wondering if you could be convinced in showing your python logic for the retun dics from GetExpressCheckoutDetails and DoExpressCheckoutPayment. Do you just check for ACK: Success or do you check more fields.
Kindest,
- Bram