为什么发帖到 PayPal 沙箱 API 对我不起作用?
Why posting to PayPal sandbox API not working for me?
我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"}}
并在 return
收到
{"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
应该是一个对象 - currency
和 details
需要是 amount
的属性,而且你缺少必需的 total
属性
已修改 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"
}
}
请注意指定"price-numbers"(总计、小计...)它们必须是字符串并遵循有关小数位的规则
我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"}}
并在 return
收到{"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
应该是一个对象 - currency
和 details
需要是 amount
的属性,而且你缺少必需的 total
属性
已修改 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"
}
}
请注意指定"price-numbers"(总计、小计...)它们必须是字符串并遵循有关小数位的规则