通过 PHP API 的 PayPal 智能按钮补丁订单

PayPal Smart buttons patch order via PHP API

我正在实施带有快速结帐功能的智能按钮,因此客户可以 select Paypal 弹出窗口中的送货地址。与 Paypal 支持达成一致,我通过 PHP 而不是 Javascript 与 Paypal 服务器进行通信。因此,在 onShippingChange 事件中,我调用我的服务器来计算运费并修改订单,以便 Paypal 更新运费。成功路径工作正常,我需要您对错误案例的帮助。 补丁请求应该如何让 Paypal 显示我的网上商店未交付到 selected 位置的警告? (在 Javascript 上实施时,这是 onShippingChange 中的 return actions.reject。)

谢谢!

这是成功补丁的补丁请求:

{
    "path": "/v2/checkout/orders/xxxxxxxxxxxxxxxxxxxxx?",
    "body": [
        {
            "op": "replace",
            "path": "/intent",
            "value": "CAPTURE"
        },
        {
            "op": "replace",
            "path": "/purchase_units/@reference_id=='default'/amount",
            "value": {
                "currency_code": "GBP",
                "value": 265.95,
                "breakdown": {
                    "item_total": {
                        "currency_code": "GBP",
                        "value": 236
                    },
                    "shipping": {
                        "currency_code": "GBP",
                        "value": 29.95
                    }
                }
            }
        }
    ],
    "verb": "PATCH",
    "headers": {
        "Content-Type": "application/json"
    }
}

in the onShippingChange event, I'm calling my server to calculate the delivery price and patch the order

太棒了。但是,如果该地址不受支持,您的服务器必须 return 响应该调用的失败状态。根据该响应,onShippingChange 必须 return actions.reject() 到调用 PayPal JS。