我想将Razorpay付款与Django集成。我搜索了,但没有适当的资源。我什至查看了Razorpay官方网站。但是没有适当的文档。谁能帮我如何将Razorpay与Django集成
打开razorpay仪表板并收集KeyId和SecretKeyThis image shows where to find keyId and Secretkey
在服务器端创建客户端实例以与Razorpay进行通信。
pip安装razorpay进口razorpay客户端= razorpay.Client(auth =(“ Key_ID”,“ SECRET_KEY”))
使用“ client.order.create”方法创建订单。
order_currency = 'INR'
order_receipt = 'order_rcptid_11'
notes = {
'Shipping address': 'Bommanahalli, Bangalore'}
# CREAING ORDER
response = client.order.create(dict(amount=order_amount, currency=order_currency, receipt=order_receipt, notes=notes, payment_capture='0'))
order_id = response['id']
order_status = response['status']
将必要的参数和order_id传递到html页面。如果order_status =='created':
# Server data for user convinience
context['product_id'] = product
context['price'] = order_amount
context['name'] = name
context['phone'] = phone
context['email'] = email
# data that'll be send to the razorpay for
context['order_id'] = order_id
return render(request, 'confirm_order.html', context)
复制here!!!中的javascript并将其粘贴到您要付款的html页面中!
正在验证签名!!
def Payment_status(request):
response = request.POST
params_dict = {
'razorpay_payment_id' : response['razorpay_payment_id'],
'razorpay_order_id' : response['razorpay_order_id'],
'razorpay_signature' : response['razorpay_signature']
}
# VERIFYING SIGNATURE
try:
status = client.utility.verify_payment_signature(params_dict)
return render(request, 'order_summary.html', {'status': 'Payment Successful'})
except:
return render(request, 'order_summary.html', {'status': 'Payment Faliure!!!'})
如果您还有任何疑问!!!然后您可以继续执行此blog。在此博客中,将其与django集成的直接方向是!!!
博客:https://medium.com/@dk521/integrating-razorpay-with-django-91302dcd9adbgithub资料库:https://github.com/dk521/razorpay521
谢谢!