Как сохранить информацию о доставке при оплате в шлюзе Django Razorpay?
Я пытаюсь отправить данные в базу данных всякий раз, когда клиент платит через платежный шлюз Razorpay, но я могу нажать на кнопку платежного шлюза Razorpay и сумма отражается на моем тестовом счете Razorpay. Но данные о доставке не сохраняются в моей базе данных, пожалуйста, помогите мне решить эту проблему.
Вот мой views.py
файл...
def place_order(request,total= 0,quantity = 0):
cart = Cart.objects.get(cart_id = _cart_id(request))
cart_items = CartItem.objects.filter(cart = cart, status = True)
# cart_items = CartItem.objects.filter(user= current_user)
cart_count = cart_items.count()
if cart_count <= 0:
return redirect('login')
tax= 0
grant_total = 0
for item in cart_items:
total += (item.product.sale_price * item.quantity)
quantity += item.quantity
tax = (3*total)/100
grant_total = total+tax
if request.method == "POST":
order_number = request.POST.get('order_number')
full_name = request.POST.get('full_name')
mobile = request.POST.get('mobile')
email = request.POST.get('email')
address_line1 = request.POST.get('address_line1')
address_line2 = request.POST.get('address_line2')
country = request.POST.get('country')
state = request.POST.get('state')
city = request.POST.get('city')
order_note = request.POST.get('order_note')
tax = request.POST.get('tax')
grant_total = int(request.POST.get('order_total'))*100
status = request.POST.get('status')
amount = int(request.POST.get('amount')) * 100
# Create Rezorpay Client
client = razorpay.Client(auth=('rzp_test_ertermiaBf1212','ertgghg56Qp27UYlPEsghtedfes'))
# Create Order
callback_url = 'http://'+ str(get_current_site(request))+"/payment/handlerequest/"
response_payment = client.order.create(dict(amount=amount,
currency="INR")
)
order_id = response_payment['id']
order_status = response_payment['status']
if order_status == 'created':
order = Order(
order_number = order_number,
full_name = full_name,
mobile = mobile,
email = email,
address_line1 = address_line1,
address_line2 = address_line2,
country = country,
state = state,
city = city,
order_total = grant_total,
order_note = order_note,
amount =amount,
status = status,
tax =tax,
order_id = order_id,
)
order.save()
form = Order(request.POST or None)
return render(request, 'frontend/store/payment.html', {'form':form, 'pay':response_payment,'callback_url':callback_url})
form = OrderForm()
return render(request, 'frontend/store/payment.html', {'form':form})
вот мой checkout.html
файл...
<button type="submit" class="btn btn-fill-out" id="rzp-button1"><span class="icon icon-check_circle"></span>Place Order</button>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
total= "{{ grant_total }}"
final_total = Number(total)*100
var options = {
"key": "rzp_test_ertermiaBf1212", // Enter the Key ID generated from the Dashboard
"amount": final_total, // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise
"currency": "INR",
"name": "Ecom",
"description": "Next Level Quality",
"order_id": "{{order_id}}", //This is a sample Order ID. Pass the `id` obtained in the response of Step 1
"callback_url": "{{callback_url}}",
"image":"http://127.0.0.1:8000/static/images/logo.png",
"prefill": {
"name": "{{request.user.first_name}}",
"email": "{{request.user.email}}",
"contact": "+91" + "{{request.user.mobile}}"
},
"notes": {
"address": "Razorpay Corporate Office"
},
"theme": {
"color": "#2BA977"
}
};
var rzp1 = new Razorpay(options);
document.getElementById('rzp-button1').onclick = function (e) {
rzp1.open();
e.preventDefault();
}
приведенный выше код оплачивает общую сумму, но я не могу сохранить информацию о заказе в моей базе данных, пожалуйста, помогите мне, где я ошибаюсь.