我是 Django Rest 框架的新手,我想将 Django 中使用外部端点(flutterwave 端点)的付款视图转换为端点。我已经阅读了官方 Django Rest Framework 文档,但其中的大多数示例都使用模型来创建列表、详细信息、删除和更新端点。如果我能解决我的问题,我会很高兴。PS:我已经删除了我的密钥Views.pyfrom django.shortcuts import renderimport requests# Create your views here.# PAYSTACK VERIFICATIONdef verify_paystack_payment(request): url = "https://api.paystack.co/transaction/verify/262762380" payload = { "email": "myemail@yahoo.com", "amount": "10000", "currency": "NGN", "reference": "262762380", "metadata": { "custom_fields": [ { "display_name": "Mobile Number", "variable_name": "mobile_number", "value": "+2348012345678" } ] } } files = {} # The Bearer can either be an account or sub-account, but the default is account headers = { 'Authorization': 'Bearer {{SECRET_KEY}}', 'Content-Type': 'application/json' } response = requests.request("GET", url, headers=headers, data= payload, files=files) print(response.text.encode('utf8')) return render(request, "transaction/pay.html")
添加回答
举报
0/150
提交
取消