我希望用户使用 paypal 接受信用卡付款。所以我已经从应用程序授权用户并按照此链接中所述进行调用 https://developer.paypal.com/webapps/developer/docs/integration/direct/accept-credit-cards/
这是我从本地机器发出的 curl 请求
curl -v https://api.sandbox.paypal.com/v1/payments/payment \
-H "Content-Type:application/json" \
-H "Authorization:Bearer 22SKUmLAeeKccfG-FmJdFiT97FLQnjSbeDHDN0hHdEQ" \
-d '{
"intent":"sale",
"payer":{
"payment_method":"credit_card",
"funding_instruments":[
{
"credit_card":{
"number":"4417119669820331",
"type":"visa",
"expire_month":11,
"expire_year":2018,
"cvv2":"874",
"first_name":"Joe",
"last_name":"Shopper",
"billing_address":{
"line1":"52 N Main ST",
"city":"Johnstown",
"country_code":"US",
"postal_code":"43210",
"state":"OH"
}
}
}
]
},
"transactions":[
{
"amount":{
"total":"7.47",
"currency":"USD",
"details":{
"subtotal":"7.41",
"tax":"0.03",
"shipping":"0.03"
}
},
"description":"This is the payment transaction description."
}
]
}'
我收到以下错误“401 Unauthorized”
任何人都可以帮助我在上面的电话中缺少什么。或进行信用卡付款需要任何其他范围。
最佳答案
尝试获取新的访问 token 并将其用作调用的一部分: https://developer.paypal.com/webapps/developer/docs/integration/direct/make-your-first-call/#get-an-access-token
401 通常意味着您没有正确的访问 token 或它已过期。
关于oauth-2.0 - 使用 Paypal 信用卡付款时出现 401 Unauthorized 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18888293/