I am now developing my site using django. In integrating my site with paypal, I use pluggable application "http://github.com/johnboxall/django-paypal". Although the document is very clear for "Using PayPal Payments Pro (WPP)", but I still have some questions, especially the relationship between "returnurl" and "confirm_template".
#views.py
from paypal.pro.views import PayPalPro
def buy_my_item(request):
item = {"amt": "10.00", # amount to charge for item
"inv": "inventory", # unique tracking variable paypal
"custom": "tracking", # custom tracking variable for you
"cancelurl": "http://...", # Express checkout cancel url
"returnurl": "http://..."} # Express checkout return url
kw = {"item": item, # what you're selling
"payment_template": "payment.html", # template name for payment
"confirm_template": "confirmation.html", # template name for confirmation
"success_url": "/success/"} # redirect location after success
ppp = PayPalPro(**kw)
return ppp(request)
When clicking the "continue" button on paypal site, it redirects me back to "returnurl". Here, is my problem, I don't know how to deal with this returnurl. In my opinion, I should also write a function to make it render confirmation.html. Am I right? If so, how to write this function. Really grateful for any help and instructions.
The documentation isn't great for django-paypal. The short answer is that your
returnurl
should be whatever URL points to your methodbuy_my_item
. Here's a few examples taken from something I have working IRL. Note that I use PayPal's "useraction=commit" option to reduce the number of steps in their Express Checkout.In your urls.py:
In your views.py:
You may have a bunch of other questions, like "how can I tell the difference between an EC and a WPP payment when I get to the payment confirmation page?", but I'll save that until it's asked! django-paypal isn't bad, but it can be pretty frustrating making it work, particularly when you want to pass additional values to your templates, and the documentation (even on the forks I've seen) isn't much good.
Note that this example refers to HTTP rather than HTTPS URLs. In production, using WPP, you'll almost certainly want to be using HTTPS. Also, the main distribution of the product is out of date, and you'll need to patch the IPN endpoint with
@csrf_exempt
to make it work.Hi guys i'm with the same problem, according to this http://uswaretech.com/blog/2008/11/using-paypal-with-django/ we need to write a view that handle response from paypal, so i use confirm.html template but it doesn't render anything...