Get Url Parameters In Django
Posted
by
picomon
on Stack Overflow
See other posts from Stack Overflow
or by picomon
Published on 2013-11-12T09:29:46Z
Indexed on
2013/11/12
9:54 UTC
Read the original article
Hit count: 173
I want to get current transaction id in url. it should be like this
www.example.com/final_result/53432e1dd34b3
.
I wrote the below codes, but after successful payment, I'm redirected to Page 404.
(www.example.com/final_result//)
Views.py
@csrf_exempt
def pay_notif(request, v_transaction_id):
if request.method=='POST':
v_transaction_id=request.POST.get('transaction_id')
endpoint='https://testpay.com/?v_transaction_id={0}&type=json'
req=endpoint.format(v_transaction_id)
last_result=urlopen(req).read()
if 'Approved' in last_result:
session=Pay.objects.filter(session=request.session.session_key).latest('id')
else:
return HttpResponse(status=204)
return render_to_response('final.html',{'session':session},context_instance=RequestContext(request))
Urls.py
url(r'^final_result/(?P<v_transaction_id>[-A-Za-z0-9_]+)/$', 'digiapp.views.pay_notif', name="pay_notif"),
Template:
<input type='hidden' name='v_merchant_id' value='{{newpayy.v_merchant_id}}' />
<input type='hidden' name='item_1' value='{{ newpayy.esell.up_name }}' />
<input type='hidden' name='description_1' value='{{ newpayy.esell.up_description }}' />
<input type='hidden' name='price_1' value='{{ newpayy.esell.up_price }}' />
#page to be redirected to after successful payment
<input type='hidden' name='success_url' value='http://127.0.0.1:8000/final_result/{{newpayy.v_transaction_id}}/' />
How can I go about this?
© Stack Overflow or respective owner