【发布时间】:2020-07-15 21:26:09
【问题描述】:
我正在制作一个网站,网站的用户可以在其中像 fiver、Upwork 和其他平台一样在现场相互付款。
我想为此目的使用 PayPal 支付网关。并在后端使用 Django-rest-framework。
你们有什么教程或文档可以参考吗?
这是我尝试使用 payee 方法向 Paypal 发送请求时的代码。
class PaymentP2P(APIView):
permission_classes = ()
# authentication_classes = (SessionAuthentication, TokenAuthentication)
def post(self,request):
email_request=request.data['payee']
price_to_pay = str(request.data['price'])
payment = paypalrestsdk.Payment(self.build_request_body(email_request,price_to_pay))
print(payment)
if payment.create():
print("Payment created successfully")
else:
print(payment.error)
return Response({'paymentID':payment.id},status=200)
@staticmethod
def build_request_body(email_user="payee@email.com",price="220.00"):
"""Method to create body with a custom PAYEE (receiver)"""
return \
{
"intent": "AUTHORIZE",
"purchase_units": [
{
"amount": {
"total": price,
"currency": "USD"
},
"payee": {
"email_address": "sb-loe4o1374588@personal.example.com"
},
},
]
}
【问题讨论】:
标签: paypal django-rest-framework payment-gateway paypal-ipn paypal-rest-sdk