自定义 ID 未显示在 paypal webhook 中

问题描述 投票:0回答:1

因此,我尝试在我的 paypal 订单中放入自定义 id(订单 id),以便它在我的 paypal webhook 中返回给我,但我在 webhook 中找不到它。 这是我的订单代码。

payment = paypalrestsdk.Payment({
        "intent":"sale",
        "payer":{
            "payment_method":"paypal"
        },
        "redirect_urls":{
            "return_url":"http://localhost:3000/order/success",
            "cancel_url":"http://localhost:3000/order/cancel"
        },
        "transactions":[{
            "item_list":{
                "items":items
            },
            "amount":{
                "total":price,
                "currency":"EUR"
            },
            "description":"This is the payment transaction description.",
            "custom_id": order_data["products"][0]['order']
        }]
    })
    if payment.create():
        return JsonResponse({'status': 'success', "url": payment.links[1].href})
    else:
        return JsonResponse({'status': 'error'})

这段代码中的所有内容都有效,除了自定义 id 之外,我没有在 webhook 中取回该 id。我是不是错过了什么?

额外说明。刚刚尝试过这个。

payment = paypalrestsdk.Payment({
        "intent":"sale",
        "payer":{
            "payment_method":"paypal"
        },
        "redirect_urls":{
            "return_url":"http://localhost:3000/order/success",
            "cancel_url":"http://localhost:3000/order/cancel"
        },
        "transactions":[{
            "item_list":{
                "items":items
            },
            "amount":{
                "total":price,
                "currency":"EUR"
            },
            "description":"This is the payment transaction description."
        }],
        "custom_id": order_data["products"][0]['order']
    })
    if payment.create():
        return JsonResponse({'status': 'success', "url": payment.links[1].href})
    else:
        return JsonResponse({'status': 'error'})

我将自定义 ID 从

transactions
键中移出,这是我的疏忽,但现在我的付款不会在我收到
{status: error}
而不是 paypal 的付款网址的浏览器中创建。非常感谢所有帮助

django paypal paypal-rest-sdk
1个回答
0
投票

在撰写本文时,所有 PayPal REST SDK 均已弃用,不应用于新的集成。此外,v1/付款 API 已弃用,不应用于任何新功能。请参阅当前的标准集成指南:https://developer.paypal.com/docs/checkout/standard/integrate/。返回 JSON 的 2 个后端示例路由显示在 Node.js 中,但可以在任何环境中实现,包括 Python/Django。

© www.soinside.com 2019 - 2024. All rights reserved.