购买单位币种更改后,贝宝会以“ CANNOT_MIX_CURRENCIES”回应

问题描述

我要卖的商品的价格和币种因送货地址而异。

如果用户有两个地址,一个在美国,另一个在英国,则可以通过PayPal更改收货地址。当用户将地区从美国更改为英国时,PayPal会通知我的网站,该地区已经发生更改,并且会回复新的币种和价格,从345美元更改为305英镑。

当PayPal收到此更新时,PayPal向客户显示错误。在网络标签中,您可以找到更多的见解,并且可以发现以下错误:CANNOT_MIX_CURRENCIES。但是,项目价格和总价格都都转换为所需的货币,因此没有货币的“混合”。下面是产生错误的请求和相应的响应。

请求:PATCH-> www.sandbox.paypal.com/smart/api/order/890595684S747592L/patch

{
    "data":{
        "patch":[
            {
                "op":"replace","path":"/purchase_units/@reference_id=='xxx'","value":{
                    "reference_id":"xxx","invoice_id":"xxx","custom_id":1,"description":"xxx","amount":{
                        "currency_code":"GBP","value":"305.00","breakdown":{
                            "item_total":{
                                "currency_code":"GBP","value":"305.00"
                            },"shipping":{
                                "currency_code":"GBP","value":"0.00"
                            },"tax_total":{
                                "currency_code":"GBP","discount":{
                                "currency_code":"GBP","value":"0.00"
                            }
                        }
                    },"items":[
                        {
                            "name":"xxx","sku":"xxx","currency":"GBP","quantity":1,"category":"PHYSICAL_GOODS","unit_amount":{
                                "currency_code":"GBP","value":"305.00"
                            }
                        }
                    ]
                }
            }
        ]
    }

}

响应:

{
  "ack":"contingency","contingency":"UNPROCESSABLE_ENTITY","data": {
    "name":"UNPROCESSABLE_ENTITY","details":[{ 
      "location":"body","issue":"CANNOT_MIX_CURRENCIES","description":"CANNOT_MIX_CURRENCIES"
    }],"message":"The requested action could not be performed,semantically incorrect,or failed business validation.","debug_id":"xxx","links":[{
      "href":"https://developer.paypal.com/docs/api/orders/v2/#error-CANNOT_MIX_CURRENCIES","rel":"information_link","method":"GET"
    }]
  },"meta":{"calc":"xxx","rlog":"xxx"},"server":"xxx"
}

以下是在上方创建购买单位的请求(和响应)。

请求:POST-> POST-> www.sandbox.paypal.com/v2/checkout/orders

{
    "intent":"CAPTURE","purchase_units":[
        {
            "reference_id":"xxx","amount":{
                "currency_code":"USD","value":"345.00","breakdown":{
                    "item_total":{
                        "currency_code":"USD","value":"345.00"
                    },"shipping":{
                        "currency_code":"USD","value":"0.00"
                    },"tax_total":{
                        "currency_code":"USD","discount":{
                        "currency_code":"USD","value":"0.00"
                    }
                }
            },"items":[
                {
                    "name":"xxx","currency":"USD","unit_amount":{
                        "currency_code":"USD","value":"345.00"
                    }
                }
            ]
        }
    ],"application_context":{
        "shipping_preference":"GET_FROM_FILE"
    }
}

响应:

{
    "id":"xxx","status":"CREATED","links":[
        {
            "href":"https://api.sandbox.paypal.com/v2/checkout/orders/xxx","rel":"self","method":"GET"
        },{
            "href":"https://www.sandbox.paypal.com/checkoutnow?token=xxx","rel":"approve",{
            "href":"https://api.sandbox.paypal.com/v2/checkout/orders/xxx","rel":"update","method":"PATCH"
        },{
            "href":"https://api.sandbox.paypal.com/v2/checkout/orders/xxx/capture","rel":"capture","method":"POST"
        }
    ]
}

我正在通过PayPal Orders API v2 npm软件包使用react-paypal-button-v2

“ CANNOT_MIX_CURRENCIES”文档提到购买单位中的所有货币必须相同,但没有提到不可能更改购买单位货币。令人困惑的是,我在Billing Agreements API v1中只能提及此错误(“ CANNOT_MIX_CURRENCIES”)。

CANNOT_MIX_CURRENCIES

货币代码无效。所有货币代码都非常匹配。对所有金额对象使用相同的货币代码。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)