【问题标题】:Adaptive Payments Pay API Error 580001自适应付款支付 API 错误 580001
【发布时间】:2013-08-25 20:59:07
【问题描述】:

我在 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() 确认这确实是 POST。有什么想法吗?

【问题讨论】:

  • 你能发布整个 python 脚本以及有效的 curl 命令吗?
  • 谢谢丹尼斯,我把答案贴在下面了。

标签: python paypal paypal-adaptive-payments error-code


【解决方案1】:

发帖十分钟后就想通了。典型的。

我将请求数据格式指定为 JSON,但随后是 url 编码请求数据。改变

payload = urllib.urlencode(payload)

import cjson
payload = cjson.encode(payload)

有效!太糟糕了,贝宝没有返回任何信息性错误消息。

【讨论】:

    猜你喜欢
    • 2013-03-29
    • 2013-05-07
    • 2015-12-07
    • 2014-12-01
    • 2016-08-07
    • 2014-07-31
    • 2016-04-02
    相关资源
    最近更新 更多