def handleRequest(request): global a, rollno obj = Fee() #Paytm will send you post request here print(666) form = request.POST response_dict = {} for i in form.keys(): response_dict[i] = form[i] if i == 'CHECKSUMHASH': Checksum = form[i] verify = checksum.verify_checksum(response_dict, MERCHANT_KEY, Checksum) if verify: obj.rollno = rollno obj.class_id = a obj.amount = response_dict['TXNAMOUNT'] obj.orderId = response_dict['ORDERID'] obj.txnId = response_dict['TXNID'] obj.bankTxnId = response_dict['BANKTXNID'] obj.txnDate = response_dict['TXNDATE'] obj.mode = 'Online' obj.status = response_dict['RESPMSG'] obj.save() print(response_dict['ORDERID']) print(a) if response_dict['RESPCODE'] == '01': print('order successful') else: print('order was not successful because' + response_dict['RESPMSG']) return render(request, 'paymentstatus.html', {'response': response_dict})
def handlerequest(request): form=request.POST response_dict={} for i in form.keys(): response_dict[i]=form[i] if i == 'CHECKSUMHASH': checksum1=form[i] verify=checksum.verify_checksum(response_dict, MERCHANT_KEY, checksum1) if verify: if response_dict['RESPCODE']=='01': print("order successful") else: print("order was not successful because" + response_dict['RESPMSG']) return render(request,'shop/paymentstatus.html',{'response':response_dict})
def handle_paytm_request(request): form = request.POST response_dict = {} for i in forms.keys(): response_dict[i] = form[i] if i == "CHECKSUMHASH": cheksum = form[i] verify = checksum.verify_checksum(response_dict, MERCHANT_KEY, checksum) if verify: if response_dict['RESPONSE'] == '01': print('successful') else: print('ordr was not successfull because' + response_dict['RESPMSG']) return render(request,"paytm/payment_status.html", {'response':response_dict})
def payment_handler(request): form = request.POST global response_dict response_dict={} for i in form.keys(): response_dict[i] = form[i] if i =='CHECKSUMHASH': Checksum = form[i] verify=checksum.verify_checksum(response_dict,Merchant_key,Checksum) if verify: if response_dict['RESPCODE'] =='01': print('order success') status = True else: print('order is not success' +response_dict['RESPMSG']) return render(request,'homeshop/success.html',{'response_dict':response_dict})
def PytmResponse(request): # paytm will send you post request here form = request.POST response_dict = {} for i in form.keys(): response_dict[i] = form[i] if i == 'CHECKSUMHASH': Checksum = form[i] pass verify = checksum.verify_checksum(response_dict, MERCHANT_KEY, Checksum) if verify: if response_dict['RESPCODE'] == '01': print('order successful') else: print('order was not successful because' + response_dict['RESPMSG']) return render(request, 'account/response.html', {'response': response_dict})
def handlepayment(request): form = request.POST response_dict = {} for i in form.keys(): response_dict[i] = form[i] if i == 'CHECKSUMHASH': CheckSum = form[i] verify = checksum.verify_checksum(response_dict, MERCHANT_KEY, CheckSum) if verify: if response_dict['RESPCODE'] == '01': print('order successful') else: print('order was not successful because' + response_dict['RESPMSG']) return render(request, 'uploadFiles/paymentstatus.html', {'response': response_dict})
def handelrequest(request): # paytm will sdoneend you post request here Checksum = 0 form = request.POST response_dict = {} for i in form.keys(): response_dict[i] = form[i] if (i == 'CHECKSUMHASH'): Checksum = form[i] verify = checksum.verify_checksum(response_dict, MERCHANT_KEY, Checksum) if verify: if response_dict['RESPCODE'] == '01': print("Order Successful") else: print('Order was not Successful because' + response_dict['RESPMSG']) return render(request, "shop/paymentstatus.html", {'response': response_dict})
def handlerequest(request): #paytm will send you post request here form = request.POST response_dict = {} for i in form.keys(): response_dict[i] = form[i] if i == 'CHECKSUMSASH': checksum = form[i] verify = checksum.verify_checksum(response_dict, MERCHANT_KEY, checksum) if verify: if response_dict['RESPCODE'] == '01': print('order successful') else: print('order was not successful beacause' + response_dict['RESPMSG']) return render(request, 'eshop/paymentstatus.html', {'response': response_dict})
def trans_status(request): if request.method != "POST": return HttpResponseBadRequest(content="<h1>Bad request 400</h1> <br/>invalid request") form = request.POST response = {} for i in form.keys(): response[i] = form[i] code = checksum.verify_checksum(response, settings.MERCHANT_KEY, form['CHECKSUMHASH']) order = Order.objects.get(pk=form["ORDERID"]) if not code: return HttpResponseBadRequest(content="Transaction failed due to Hash missmatch") elif form['RESPCODE'] == '01': order.transaction_success = True order.user.profile.wallet_balance += order.amount order.user.profile.save() order.save() else: return HttpResponse("unkown error contact us") return render(request, "accounts/payment_status.html", response)
def response(request): if request.method == 'GET': return render(request, 'paytm/home.html') elif request.method == "POST": data_dict = {} for key in request.POST: data_dict[key] = request.POST[key] verify = checksum.verify_checksum(data_dict, settings.PAYTM_MERCHANT_KEY, data_dict['CHECKSUMHASH']) if verify: for key in request.POST: if key == "BANKTXNID" or key == "RESPCODE": if request.POST[key]: data_dict[key] = int(request.POST[key]) else: data_dict[key] = 0 elif key == "TXNAMOUNT": data_dict[key] = float(request.POST[key]) PaymentHistory.objects.create(user=request.user, **data_dict) return render(request, "paytm/response.html", {"paytm": data_dict}) else: return HttpResponse("checksum verify failed") return HttpResponse(status=200)
def paytm_gateway(request): MERCHANT_KEY = '89tbzmH&2RlSIKL#' form = request.POST response_dict = {} for i in form.keys(): response_dict[i] = form[i] if i == 'CHECKSUMHASH': Checksum = form[i] paid_registration = registration.objects.get( id=int(response_dict['ORDERID'])) verify = checksum.verify_checksum(response_dict, MERCHANT_KEY, Checksum) if verify: if response_dict['RESPCODE'] == '01': paid_registration = registration.objects.get( id=int(response_dict['ORDERID'])) paid_registration.mi_id = response_dict['MID'] paid_registration.transaction_id = response_dict['TXNID'] paid_registration.participant_id = response_dict['ORDERID'] paid_registration.save() event_registered = events.objects.get(name=paid_registration.event) current_date_revenue = date_revenue.objects.filter( event_key=event_registered.id, day=datetime.today().date()) if not paid_registration.paid: if not current_date_revenue: new_date_revenue = date_revenue() new_date_revenue.event_key = events.objects.get( name=paid_registration.event) new_date_revenue.day = datetime.today().date() new_date_revenue.no_of_participants = 1 new_date_revenue.revenue = int(paid_registration.cost) new_date_revenue.save() else: current_date_revenue[0].no_of_participants += 1 current_date_revenue[0].revenue += int( paid_registration.cost) current_date_revenue[0].save() paid_registration.paid = True paid_registration.save() text = "Hey, {name}\nYou have been registered for {event_name}.\nYour participant ID is: {participant_id}.\n" text = text.format(name=paid_registration.name, event_name=paid_registration.event, participant_id=paid_registration.participant_id) yag = yagmail.SMTP(user=event_registered.email, password=event_registered.password) yag.send(to=paid_registration.email, subject=paid_registration.event + " Registration", contents=text) state = events.objects.get( name=paid_registration.event).select_state return render(request, 'paytm_status.html', { 'result': True, 'details': paid_registration, 'state': state }) else: paid_registration.coupon += response_dict['RESPCODE'] paid_registration.save() state = events.objects.get( name=paid_registration.event).select_state return render(request, 'paytm_status.html', { 'result': False, 'state': state })