其他分享
首页 > 其他分享> > 自适应支付支付API错误580001

自适应支付支付API错误580001

作者:互联网

我正在使用python向Paypal自适应支付API发出PAY请求,并且得到了通用错误ID 580001,没有其他信息.

    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.有任何想法吗?

解决方法:

大概在发布十分钟后就知道了.典型.

我将请求数据格式指定为JSON,但随后使用url编码了请求数据.改变中

payload = urllib.urlencode(payload)

import cjson
payload = cjson.encode(payload)

作品!太糟糕的贝宝不会返回任何信息错误消息.

标签:error-code,paypal-adaptive-payments,python,paypal
来源: https://codeday.me/bug/20191030/1968428.html