贝宝智能按钮订单 API 忽略 purchase_units 对象中的 notify_url

PayPal Smart Button Orders API Ignoring notify_url in purchase_units object

我们正在使用带有最新 JS SDK(2019 年 2 月)的 PayPal Smart Button 发送订单。我们已按照订单 API 文档中的说明在 createOrder 函数的 purchase_units 对象中设置 notify_url。

该交易仍在使用帐户中的 IPN url,而不是我们在创建交易时提供的 IPN。

我们已经按照 Whosebug 上的建议尝试了不同的键,例如 'NOTIFYURL'、'NOTIFY_URL'、'notifyurl' 和 'notify_url'。 None 其中有效。

我们已尝试从帐户设置中删除 IPN,但这是不可能的(根据文档,notify_url 应该始终覆盖它)。

paypal.Buttons({
        createOrder: function (data, actions) {
            return actions.order.create({
                intent: "CAPTURE",
                purchase_units: [{
                    amount: {
                        value: '@Model.Total.ToString("F")',
                    },
                    NOTIFYURL: "@notifyUrl"
                }]
            });
        },
        onApprove: function (data, actions) {
            return actions.order.capture().then(function (details) {
                return fetch('/umbraco/surface/PayPalPayment/process', {
                    method: 'post',
                    redirect: 'follow',
                    body: JSON.stringify({
                        OrderID: data.orderID,
                        PayerID: data.payerID,
                    }),
                    headers: {
                        'content-type': 'application/json'
                    }
                }).then(function (response) {
                    response.json().then(function (data) {
                        window.location.href = data.redirect;
                    })
                });
            }).catch(function (error) {
                window.location.href = '/umbraco/surface/PaymentFailed/PaymentFailed/?error=' + error;
            });
        }
    }).render('#paypal-button-container');

注意:变量是通过 Razor 语法添加的,我已确认在 Fiddler 中正确设置了这些值。 Post 在下方,但 IPN Url 已被编辑。

{"intent":"CAPTURE","purchase_units":[{"amount":{"value":"0.01","currency_code":"GBP"},"NOTIFYURL":"https://<REDACTED>/umbraco/surface/paypalipn/receive"}],"application_context":{}}

我们应该看到设置了通知 URL,但是当检查 IPN 历史记录中的消息 ID 时,它正在尝试使用在帐户上找到的 IPN url 而不是 notify_url 已提供。

Notify URL 不与 REST API 一起使用。他们不使用 IPN。他们使用 Webhooks。您将需要在您的 PayPal 应用程序中注册 webhooks 并相应地为这些挂钩设置一个侦听器。