我正在使用Odoo 12.0版,使用其API开发退款销售交易流程。我已经从以下链接中获取了参考:https://developer.paypal.com/docs/api/payments/v1/#sale_refund
但是他们的退款交易API存在一些授权问题。
我有示例请求/响应参数,如下所示:
import requests
headers = {'Content-Type': 'application/json','Authorization': 'Bearer Access-Token'}
data = '{\n "amount": {\n "total": "2.34",\n "currency": "USD"\n },\n "invoice_number": "INV-1234567"\n}'
response = requests.post('https://api.sandbox.paypal.com/v1/payments/sale/2MU78835H4515710F/refund', headers=headers, data=data)
它给了我以下答复:
{'message': 'Authentication failed due to invalid authentication credentials or a missing Authorization header.', 'links': [{'rel': 'information_link', 'href': 'https://developer.paypal.com/docs/api/overview/#error'}], 'name': 'AUTHENTICATION_FAILURE'}
有人可以帮助我解决此问题吗?
以及如何使用PayPal Payment API生成不记名令牌?
答案 0 :(得分:2)
private lazy var settingSwitch: UISwitch = {
let swt: UISwitch = UISwitch()
// set border color when isOn is false
swt.tintColor = .cloudyBlueTwo
// set border color when isOn is true
swt.onTintColor = .greenishTeal
// set background color when isOn is false
swt.backgroundColor = .cloudyBlueTwo
// create a mask view to clip background over the size you expected.
let maskView = UIView(frame: swt.frame)
maskView.backgroundColor = .red
maskView.layer.cornerRadius = swt.frame.height / 2
maskView.clipsToBounds = true
swt.mask = maskView
// set the scale to your expectation, here is around height: 34, width: 21.
let scale: CGFloat = 2 / 3
swt.transform = CGAffineTransform(scaleX: scale, y: scale)
swt.addTarget(self, action: #selector(switchOnChange(_:)), for: .valueChanged)
return swt
}()
@objc
func switchOnChange(_ sender: UISwitch) {
if sender.isOn {
// set background color when isOn is true
sender.backgroundColor = .greenishTeal
} else {
// set background color when isOn is false
sender.backgroundColor = .cloudyBlueTwo
}
}
标头需要在单词Authorization
后包含一个 actual 访问令牌。发送字符串'Bearer '
无效。
以下是获取实际访问令牌的方法:https://developer.paypal.com/docs/api/overview/#get-an-access-token