如何更新 Paypal 订单的税务信息?
Posted
技术标签:
【中文标题】如何更新 Paypal 订单的税务信息?【英文标题】:How to update Tax info of Paypal Order? 【发布时间】:2021-04-06 12:50:39 【问题描述】:我正在使用 C# .net Core MVC,而对于 Paypal V2,我正在使用 https://github.com/paypal/Checkout-NET-SDK
在用户通过贝宝登录和批准后(在最终订单提交之前),我无法更新订单的税务信息。
我使用以下方法创建了订单
var request = new OrdersCreateRequest();
request.Prefer("return=representation");
request.RequestBody(order);
response = await client().Execute(request);
var statusCode = response.StatusCode;
Order result = response.Result<Order>();
然后控制转到 PayPal 并要求用户在 Paypal 登录。用户登录并单击 Paypal 上的“继续”,控件返回到我的应用程序。
此时,我需要按顺序更新税务信息,但不知道该怎么做。我正在查看以下链接以获取帮助。
https://developer.paypal.com/docs/checkout/integration-features/update-order-details/
https://developer.paypal.com/docs/api/orders/v2#orders_patch
所以我查看了补丁订单来更新税收。我在 c# 中使用以下补丁代码尝试了“OrdersPatchRequest”
new Patch<Object>
Op= "replace",
Path= "/purchase_units/@reference_id=='default'/amount",
Value ="\"breakdown\":\"item_total\":\"currency_code\":\"USD\",\"value\":\"1\",\"shipping\":\"currency_code\":\"USD\",\"value\":\"3\",\"tax_total\":\"currency_code\":\"USD\",\"value\":\"2\",\"currency_code\":\"USD\",\"value\":\"6\""
Patch 值的格式如下所示
"breakdown":
"item_total":"currency_code":"USD","value":"1",
"shipping":"currency_code":"USD","value":"3",
"tax_total":"currency_code":"USD","value":"2"
,
"currency_code":"USD",
"value":"6"
但由于以下错误而失败
"name":"INVALID_REQUEST","details":["field":"/purchase_units/@reference_id=='default'/amount","value":"\"breakdown\":\"item_total\":\"currency_code\":\"USD\",\"value\":\"1\",\"shipping\":\"currency_code\":\"USD\",\"value\":\"3\",\"tax_total\":\"currency_code\":\"USD\",\"value\":\"2\",\"currency_code\":\"USD\",\"value\":\"6\"","location":"body","issue":"INVALID_PARAMETER_VALUE","description":"The value of a field is invalid."],"message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"1879d34e23fc4","links":["href":"https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_PARAMETER_VALUE","rel":"information_link","method":"GET"]
知道为什么它会失败吗?请帮忙。
(*上面更新的补丁值和错误消息)
【问题讨论】:
【参考方案1】:你的补丁值:
"\"breakdown\":\"item_total\":\"currency_code\":\"USD\",\"value\":\"1\",\"tax_total\":\"USD\",\"value\":\"2\",\"shipping\":\"currency_code\":\"USD\",\"value\":\"3\",\"currency_code\":\"USD\",\"value\":\"6\""
更清晰地呈现为:
"breakdown":
"item_total":
"currency_code": "USD",
"value": "1"
,
"tax_total": "USD",
"value": "2"
,
"shipping":
"currency_code": "USD",
"value": "3"
, "currency_code": "USD", "value": "6"
如您所见,这是无效的,因此出现错误
【讨论】:
我很抱歉....但是我在之前粘贴 Patch 值和错误时犯了一些错误。我已经更新了补丁值以及我在原始帖子中收到的错误消息。请立即检查以上是关于如何更新 Paypal 订单的税务信息?的主要内容,如果未能解决你的问题,请参考以下文章
如何在magento中将订单详细信息传递给paypal express checkout?
如何将订单详细信息传递到 magento 中的 paypal-express-checkout?