我正在尝试使用 Adaptive Payments 的 PreApproval。具体来说,要经过 the documentation on Preapproval 中的四个步骤.
我卡在了 第 1 步:使用 curl 命令设置预批准
:
$ curl -s --insecure \
-H "X-PAYPAL-SECURITY-USERID: myuserid.gmail.com" \
-H "X-PAYPAL-SECURITY-PASSWORD: mypass" \
-H "X-PAYPAL-SECURITY-SIGNATURE: mysignaturestring" \
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV" \
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" \
-H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" \
https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval -d \
"cancelUrl=http://www.yourdomain.com/cancel.html
¤cyCode=USD
&endingDate=2014-09-10T22:00:00Z
&maxAmountPerPayment=200.00
&maxNumberOfPayments=30
&maxTotalAmountOfAllPayments=1500.00
&pinType=NOT_REQUIRED
&requestEnvelope.errorLanguage=en_US
&returnUrl=http://www.yourdomain.com/success.html
&startingDate=2014-08-10T22:00:00Z"
我收到的不是 preapprovalKey
,而是错误。我知道我发送的数据有问题,但我不知道是什么:
esponseEnvelope.timestamp=2014-08-05T01:24:55.289-07:00
&responseEnvelope.ack=Failure
&responseEnvelope.correlationId=7c6db7beda57a
&responseEnvelope.build=11853342
&error(0).errorId=580001
&error(0).domain=PLATFORM
&error(0).subdomain=Application
&error(0).severity=Error
&error(0).category=Application
&error(0).message=Invalid request: Data validation warning(line -1, col 0): 2014-09-10T22:00:00Z
&error(0).parameter(0)=Data validation warning(line -1, col 0): 2014-09-10T22:00:00Z
请注意:
- 我的 API 凭据没问题,我已经在来自 the documentation 的
Express Checkout
上成功测试了它们 - 一些字段根据documentation而其他人则与粘贴的文档副本中的完全一样:
startingDate
是将来的日期,文档说不是今天的日期(发布日期)或结束日期之后。endingDate - startingDate
是一个月,不到文档中所说的一年。- 我也试过使用 https://apigee.com/console/paypal以防我在 curl 上做错了什么
最佳答案
该死的,由于我在 SO 上的缩进,我发现它对你们来说看起来很漂亮。这是因为在 -d\"cancelUrl=... ¤cyCode=USD & ..."
中输入了空格 (\n
's)。
谢谢,所以这里供引用的正确的是:
$ curl -s --insecure \
-H "X-PAYPAL-SECURITY-USERID: myuserid.gmail.com" \
-H "X-PAYPAL-SECURITY-PASSWORD: mypass" \
-H "X-PAYPAL-SECURITY-SIGNATURE: mysignaturestring" \
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV" \
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" \
-H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" \
https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval -d \
"cancelUrl=http://www.yourdomain.com/cancel.html¤cyCode=USD&endingDate=2014-09-10T22:00:00Z&maxAmountPerPayment=200.00&maxNumberOfPayments=30&maxTotalAmountOfAllPayments=1500.00&pinType=NOT_REQUIRED&requestEnvelope.errorLanguage=en_US&returnUrl=http://www.yourdomain.com/success.html&startingDate=2014-08-10T22:00:00Z"
关于 Paypal 预批无效请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25134794/