如何使用Python对Paypal API进行TransactionSearch调用



我有必要的身份验证详细信息,正在尝试进行TransactionSearch。我一直收到一个错误:ACK=失败&L_ ERRORCODE0=81002&L_SHORTMESSAGE=未指定的%20方法&L_LONGMESSAGE0=方法%20指定的%20是%20不支持的%20&L_SEVERITYCODE0=错误

这是我的代码:

(timestamp, signature) = signaturegen.getAuthHeader(apiUser=settings.USERNAME, apiPass=settings.PASSWORD, accessTok=res2["token"], secTok=res2["tokenSecret"], httpMethod="POST", scriptURI="https://api-3t.sandbox.paypal.com/nvp")    
#the above operation is used to generate the timestamp and signature
headers = {"X-PAYPAL-AUTHORIZATION": "timestamp="+<timestamp>+",token="+<token>+",signature="+<signature>, "SUBJECT": settings.<API_USERNAME>}
data = {
"METHOD": "TransactionSearch",
"STARTDATE": "2012-01-01T05:38:48Z",
    }
req= urllib2.Request("https://api-3t.sandbox.paypal.com/nvp", simplejson.dumps(data), headers)
res = urllib2.urlopen(req).read()

我做错了什么。

对于商家nvp API,请使用urllib.urlencode而不是simplejson.dumps

req= urllib2.Request("https://api-3t.sandbox.paypal.com/nvp", urllib.urlencode(data), headers)

相关内容

  • 没有找到相关文章

最新更新