我是 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": "[email protected]", "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
提交
取消
