【问题标题】:Facilitating PayPal Payment Gateway transactions between users on a site促进网站用户之间的 PayPal 支付网关交易
【发布时间】: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


    【解决方案1】:

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

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

    【讨论】:

    • 您好,希望您一切顺利。我曾尝试使用 paypalrestsdk 收款人方法向用户付款,但它返回 null 而不是收款人的 tokenId。有什么可以帮我的。我也在这里分享代码。
    • PayPal API 端点不返回 null。您需要调试 API 调用。
    • 我已经添加了上面的代码你能告诉我是什么问题吗,我会很感激的
    猜你喜欢
    • 1970-01-01
    • 2013-05-14
    • 2012-08-16
    • 2012-06-23
    • 2014-04-02
    • 2011-05-29
    • 2013-11-02
    • 2018-08-22
    • 2013-05-18
    相关资源
    最近更新 更多