首页 > 解决方案 > 促进网站用户之间的 PayPal 支付网关交易

问题描述

我正在制作一个网站,网站的用户可以在其中像 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"
            },
            },
        ]
        }

标签: paypaldjango-rest-frameworkpayment-gatewaypaypal-ipnpaypal-rest-sdk

解决方案


对于一个用户支付另一个用户的电子邮件,您可以使用带有变量的PayPal Checkout : https ://developer.paypal.com/docs/checkout/integration-features/custom-payee/payee

以下是基本结账的一些前端演示模式:


推荐阅读