gpt4 book ai didi

rest - 为什么发布到 PayPal 沙盒 API 对我不起作用?

转载 作者:太空宇宙 更新时间:2023-11-03 16:21:45 25 4
gpt4 key购买 nike

我 POST(使用合适的 Authorization: header )到 https://api.sandbox.paypal.com/v1/payments/payment

{"intent": "sale", "payer": {"payment_method": "paypal"}, "transactions": [{"amount": 10.0, "currency": "USD", "details": {"subtotal": 10.0, "shipping": 0.0, "tax": 0.0}, "description": "Item 1"}], "redirect_urls": {"return_url": "https://example.com", "cancel_url": "https://example.com"}}

并得到返回

{"name":"MALFORMED_REQUEST","message":"Incoming JSON request does not map to API request","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST","debug_id":"815ed32bcd78e"}

为什么会出错?我的错误是什么?

最佳答案

请查看paypal documentation

请参阅右侧的示例。 amount 应该是一个对象 - currencydetails 需要是 amount 的属性,而且你还缺少必需的总计属性

重做的 JSON

{
"intent":"sale",
"payer":{
"payment_method":"paypal"
},
"transactions":[
{
"amount":{
"total":"10.00",
"currency":"USD",
"details":{
"subtotal":"10.00",
"shipping":"0.00",
"tax":"0.00"
}
},
"description":"Item 1"
}
],
"redirect_urls":{
"return_url":"https://example.com",
"cancel_url":"https://example.com"
}
}

在指定“价格数字”(总计、小计...)时请小心,它们必须是字符串并遵循有关小数位的规则

关于rest - 为什么发布到 PayPal 沙盒 API 对我不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52689278/

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