我能够获得oAuth Request&响应
https://developer.paypal.com/docs/integration/direct/make-your-first-call/
但是当我跑的时候总是给401 Unauthorized
如何在Postman中执行以下内容?
curl -v https://api.sandbox.paypal.com/v1/payments/payment \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token" \
-d '{
"intent":"sale",
"redirect_urls":{
"return_url":"http://example.com/your_redirect_url.html",
"cancel_url":"http://example.com/your_cancel_url.html"
},
"payer":{
"payment_method":"paypal"
},
"transactions":[
{
"amount":{
"total":"7.47",
"currency":"USD"
}
}
]
}'
答案 0 :(得分:3)
首先,您需要将数据部分粘贴到正文中:
{"intent": "sale",
"redirect_urls": {
"return_url": "http://example.com/your_redirect_url.html",
"cancel_url": "http://example.com/your_cancel_url.html"
},
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"total": "7.47",
"currency": "USD"
}
}]
}
然后,你必须选择raw并在Text下选择JSON(application / json)
对于授权部分,请转到标题:
[key:Content-Type, value:application/json]
[key:Authorization, value:Bearer YOUR_TOKEN]
然后点击发送,你应该获得201创建状态
答案 1 :(得分:1)
从上图中看来,您似乎没有以JSON格式发送数据。在paypal示例中,它显示了数据的JSON对象(-d)。你所要做的就是将它复制并粘贴到主体上,然后将主体更改为raw,然后在最后一列上它会显示文本和箭头,只需单击它并选择JSON(application / json)就可以了。< / p>
答案 2 :(得分:0)