Issue with Django paypal -
am using django paypal e-commerce site , payments working correctly,but once payment done not redirected site.am using paypal ipn in localhost.is because running in local machine,following code sending data paypal.
def checkout(request,name): product=products.objects.get(name=name) print "producttttttttttttttttttttt",product # want button do. paypal_dict = { "business": settings.paypal_receiver_email, "amount": product.price, "item_name": product.name, "invoice": "unique-invoice-id", "notify_url": "192.168.5.108:8000" + reverse('paypalipn'), "return_url": "192.168.5.108:8000/payment-complete/", "cancel_return": "192.168.5.108:8000", } form = paypalpaymentsform(initial=paypal_dict) context = {"form": form} return render_to_response("payment.html", context)
following view getting data paypal ipn:
def paypalipn(request,item_check_callable=none): ''' django paypal view store ipn . notify url excecutes view. ''' print "haaaaaaaaaaaaaaaaaaaaaaaaaaiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" """ paypal ipn endpoint (notify_url). used both paypal payments pro , payments standard confirm transactions. http://tinyurl.com/d9vu9d
paypal ipn simulator: https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session """ #todo: clean code don't need set none here , have lot # of if checks determine if flag set. flag = none ipn_obj = none # clean data paypal sends weird values such "n/a" # also, need cope custom encoding, stored in body (!). # assuming tolerate parsing of querydict , ascii-like encoding, # such windows-1252, latin1 or utf8, following work: encoding = request.post.get('charset', none) if encoding none: flag = "invalid form - no charset passed, can't decode" data = none else: try: data = querydict(request.body, encoding=encoding) except lookuperror: data = none flag = "invalid form - invalid charset" if data not none: date_fields = ('time_created', 'payment_date', 'next_payment_date', 'subscr_date', 'subscr_effective') date_field in date_fields: if data.get(date_field) == 'n/a': del data[date_field] form = paypalipnform(data) if form.is_valid(): try: #when commit = false, object returned without saving db. ipn_obj = form.save(commit=false) except exception, e: flag = "exception while processing. (%s)" % e else: flag = "invalid form. (%s)" % form.errors if ipn_obj none: ipn_obj = paypalipn() #set query params , sender's ip address ipn_obj.initialize(request) if flag not none: #we save errors in flag field ipn_obj.set_flag(flag) else: # secrets should used on ssl. if request.is_secure() , 'secret' in request.get: ipn_obj.verify_secret(form, request.get['secret']) else: ipn_obj.verify(item_check_callable) ipn_obj.save() return httpresponse("okay")
plese help???
the issue happened because working on localhost,when moved development server worked me.the page redirected site.
Comments
Post a Comment