gpt4 book ai didi

dart - Paypal 订单v2创建响应:请求的操作无法执行,语义上不正确或业务验证失败

转载 作者:行者123 更新时间:2023-12-03 04:42:31 24 4
gpt4 key购买 nike

我正在尝试使用dart和PayPal API Orders V2创建付款订单
这是我在url https://api.sandbox.paypal.com/v2/checkout/orders上所做的请求
header 正确。这是 body :

{
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": "EUR",
"value": "5.0"
},
"items": [{
"name": "First time",
"unit_amount": {
"currency_code": "EUR",
"value": "2.0"
},
"quantity": "1"
},
{
"name": "Second item",
"unit_amount": {
"currency_code": "EUR",
"value": "3.0"
},
"quantity": "1"
}]
}
]
}
我收到此错误:

The requested action could not be performed, semantically incorrect,or failed business validation


如果我从正文中删除 items数组,则请求可以正常工作。

最佳答案

传递项目时,您的金额需要一个breakdown对象,如此处所述:https://developer.paypal.com/docs/api/orders/v2/#definition-amount_with_breakdown
一个例子:

                "purchase_units": [{
"description": "Stuff",
"amount": {
"value": "20.00",
"currency_code": "USD",
"breakdown": {
"item_total": {
"currency_code": "USD",
"value": "20.00"
},
}
},
"items": [
{
"unit_amount": {
"currency_code": "USD",
"value": "10.00"
},
"quantity": "1",
"name": "Item 1",
},
{
"unit_amount": {
"currency_code": "USD",
"value": "10.00"
},
"quantity": "1",
"name": "Item 2",
},
],
}]

关于dart - Paypal 订单v2创建响应:请求的操作无法执行,语义上不正确或业务验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62951775/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com