PayPal自适应付款 - 预批准请求会导致“无效请求”错误

时间:2013-09-11 13:28:00

标签: python paypal paypal-adaptive-payments

我无法弄清楚我的Preapproval HTTP POST请求发生了什么。我只是打算专门拨打PayPal的Adaptive Payments APIPreapproval来电。而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"
    }
  ]
}

感谢任何反馈。

1 个答案:

答案 0 :(得分: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出现时,我传递的参数将是首先要看的。