我是 Django Rest 框架的新手,我想將 Django 中使用外部端點(diǎn)(flutterwave 端點(diǎn))的付款視圖轉(zhuǎn)換為端點(diǎn)。我已經(jīng)閱讀了官方 Django Rest Framework 文檔,但其中的大多數(shù)示例都使用模型來創(chuàng)建列表、詳細(xì)信息、刪除和更新端點(diǎn)。如果我能解決我的問題,我會(huì)很高興。PS:我已經(jīng)刪除了我的密鑰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")
添加回答
舉報(bào)
0/150
提交
取消