0

我无法弄清楚我的PreapprovalHTTP POST 请求发生了什么。我只是想对 PayPal 的Adaptive Payments API进行基本调用,特别是Preapproval调用。并且 PayPal 错误580001“无效请求”本身并没有太大帮助。

请求标头(基于我的 Sandbox 的帐户凭据,我将其更改为xxx):

{
  'X-PAYPAL-REQUEST-DATA-FORMAT': 'JSON',
  'X-PAYPAL-SECURITY-PASSWORD': 'xxx',
  'X-PAYPAL-RESPONSE-DATA-FORMAT': 'JSON',
  'X-PAYPAL-SECURITY-SIGNATURE': 'xxx',
  'X-PAYPAL-SECURITY-USERID': 'xx',
  'X-PAYPAL-APPLICATION-ID': 'APP-80W284485P519543T'
}

我的请求负载(HTTP POST,以 JSON 编码的正文):

{
  "requireInstantFundingSource": "TRUE", 
  "returnUrl": "http://www.google.com/?paypal=ok", 
  "maxTotalAmountOfAllPayments": 1002, 
  "maxNumberOfPaymentsPerPeriod": 1, 
  "endingDate": "2014-03-14T16:49:36+0000", 
  "requestEnvelope.errorLanguage": "en_US", 
  "clientDetails.applicationId": "XXX", 
  "cancelUrl": "http://www.google.com/paypal=cancel", 
  "startingDate": "2013-09-15T16:49:36+0000", 
  "feesPayer": "PRIMARYRECEIVER", 
  "currencyCode": "SEK"
}

上面的 POST 正文发布到:

https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval

Paypal 的回应(“美化”以便理解):

{
  "responseEnvelope": {
    "ack": "Failure", 
    "timestamp": "2013-09-10T09:56:43.031-07:00", 
    "build": "6941298", 
    "correlationId": "26d55e6bfcaa0"
  }, 
  "error": [
    {
      "category": "Application", 
      "domain": "PLATFORM", 
      "severity": "Error", 
      "message": "Invalid request: {0}", 
      "subdomain": "Application", 
      "errorId": "580001"
    }
  ]
}

任何反馈表示赞赏。

4

1 回答 1

3

好的固定。如何?

修复 #1

参数requestEnvelope.errorLanguageclientDetails.applicationId需要自己“JSONified”成对象,例如:

"requestEnvelope": {
    "errorLanguage": "en_US"
}, 

"clientDetails": {
    "applicationId": "APP-XXXXXXXXXXXXX"
}, 

分别。

修复 #2

日期格式;日期格式应该是形式2014-03-15T20:14:38.007+00:00,而不是2014-03-14T20:14:38+0000像我通过的那样。请注意毫秒,以及 utc 偏移量中带有冒号的时区。

下次Invalid request出现时,我传递的参数将是首先要看的东西。

于 2013-09-11T20:23:34.977 回答