Views.py
def checkout(request):
if request.method=="POST":
items_json = request.POST.get('itemsJson', '')
product_name = request.POST.get('product_name', '')
name = request.POST.get('name', '')
amount = request.POST.get('amount', '')
email = request.POST.get('email', '')
address = request.POST.get('address1', '') + " " + request.POST.get('address2', '')
city = request.POST.get('city', '')
state = request.POST.get('state', '')
zip_code = request.POST.get('zip_code', '')
phone = request.POST.get('phone', '')
order = Orders(items_json=items_json, product_name=product_name , name=name, email=email, address=address, city=city,
state=state, zip_code=zip_code, phone=phone, amount=amount)
order = Orders(items_json=items_json, product_name=product_name , name=name, email=email, address=address, city=city,
state=state, zip_code=zip_code, phone=phone, amount=amount)
order.save(),
update = OrderUpdate(order_id=order.order_id, update_desc="The order has been placed")
update.save()
thank = True
id = order.order_id
param_dict = {
'MID': 'My Paytm mid',
'ORDER_ID': str(order.order_id),
'TXN_AMOUNT': str(amount),
'CUST_ID': email,
'INDUSTRY_TYPE_ID': 'Retail',
'WEBSITE': 'WEBSTAGING',
'CHANNEL_ID': 'WEB',
'CALLBACK_URL':'http://127.0.0.1:8000/shop/handlerequest/',
}
param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(param_dict, MERCHANT_KEY)
return render(request, 'shop/paytm.html', {'param_dict': param_dict})
return render(request, 'shop/checkout.html')
@csrf_exempt
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 == '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})
Models.py
class Orders(models.Model):
order_id = models.AutoField(primary_key=True)
items_json = models.CharField(max_length=5000)
product_name = models.CharField(max_length=5000, default="")
amount = models.CharField(max_length=90)
name = models.CharField(max_length=90)
email = models.CharField(max_length=111)
address = models.CharField(max_length=111)
city = models.CharField(max_length=30)
state = models.CharField(max_length=30)
zip_code = models.CharField(max_length=6)
phone = models.CharField(max_length=10, default="")
class OrderUpdate(models.Model):
вот мои модели и просмотры .py файлы, пожалуйста, посмотрите Я хотел бы сохранить детали заказа после оплаты получить успех, но я действительно получаю его до оплаты, как только я нажимаю разместить заказ, мои данные сохраняются. Я хочу получить его после успешной оплаты. Пожалуйста, помогите мне в том же