自适应支付支付 API 错误 580001 [英] Adaptive Payments Pay API Error 580001
问题描述
我正在向 Python 中的 paypal 自适应支付 API 发出 PAY 请求,并得到一个没有附加信息的通用错误 ID 580001.
I'm making a PAY request to the paypal adaptive payments API in python and getting a generic error id 580001 with no additional information.
headers = {
# API credentials for the API caller business account
'X-PAYPAL-SECURITY-USERID': config.PAYPAL_API_USER_ID,
'X-PAYPAL-SECURITY-PASSWORD': config.PAYPAL_API_PASSWORD,
'X-PAYPAL-SECURITY-SIGNATURE': config.PAYPAL_API_SIGNATURE,
'X-PAYPAL-APPLICATION-ID': 'APP-80W284485P519543T',
'X-PAYPAL-REQUEST-DATA-FORMAT': 'JSON',
'X-PAYPAL-RESPONSE-DATA-FORMAT': 'JSON'
}
payload = {
"actionType": "PAY",
"currencyCode": "USD",
"receiverList": {
"receiver": [{
"amount": "1.00",
"email": "sandbox_test_user_email@gmail.com"
}]
},
# where the sender is redirected
"returnUrl": config.SUCCESS_URL,
"cancelUrl": config.SUCCESS_URL,
"requestEnvelope": {
"errorLanguage":"en_US",
# error detail level
"detailLevel":"ReturnAll"
}
}
import urllib2, urllib
payload = urllib.urlencode(payload)
request = urllib2.Request(url='https://svcs.sandbox.paypal.com/AdaptivePayments/Pay',
data=payload,
headers=headers)
f = urllib2.urlopen(request)
contents = f.read()
回复:
{"responseEnvelope":
{"timestamp":"2013-08-22T15:44:50.97507:00",
"ack":"Failure",
"correlationId":"df4f39293971f",
"build":"6941298"
},
"error"[ {"errorId":"580001",
"domain":"PLATFORM",
"subdomain":"Application",
"severity":"Error",
"category":"Application",
"message":"Invalid request: {0}"}
]
}
使用我的凭据进行卷曲有效,只是通过 urrllib 失败了.我读到其他具有相同错误代码的人意外发送了 HTTP GET,我已通过 request.get_method() 确认这确实是 POSTing.有什么想法吗?
Curling with my credentials works, it's just going through urrllib that's failing. I read others with the same error code were sending an HTTP GET by accident, I have confirmed via request.get_method() that this is indeed POSTing. Any ideas?
推荐答案
发帖十分钟后想通了.典型.
Figured it out like ten minutes after posting. Typical.
我将请求数据格式指定为 JSON,但随后是对请求数据进行 url 编码.改变
I specified the request data format as JSON, but then was url encoding the request data. Changing
payload = urllib.urlencode(payload)
到
import cjson
payload = cjson.encode(payload)
有效!太糟糕了,paypal 没有返回任何信息性错误消息.
works! Too bad paypal doesn't return any informative error message.
这篇关于自适应支付支付 API 错误 580001的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!