PayPal Rest 首次通话不会出现在沙盒交易中

Posted

技术标签:

【中文标题】PayPal Rest 首次通话不会出现在沙盒交易中【英文标题】:PayPal Rest first call won't appear in sandbox transactions 【发布时间】:2015-04-21 06:29:26 【问题描述】:

我想要一个已完成的事务,并在我的开发人员沙盒中看到它。我认为以下交易已完成,但不在我的沙盒交易列表中。我按照贝宝网站上的说明使用其余 API 进行了第一次调用。

这是我使用我的凭据和返回的访问令牌的两个 curl 命令。我收到了我的state:created 付款。但交易不在我的沙盒交易中。需要多长时间才能出现?

我做错了什么?

谢谢, 哈利

curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
>   -H "Accept: application/json" \
>   -H "Accept-Language: en_US" \
>   -u ".....:....." \
>   -d "grant_type=client_credentials"
* About to connect() to api.sandbox.paypal.com port 443 (#0)
*   Trying 173.0.82.78... connected
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Request CERT (13):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
*    subject: C=US; ST=California; L=San Jose; O=PayPal, Inc.; OU=PayPal Production; CN=api.sandbox.paypal.com
*    start date: 2012-12-06 00:00:00 GMT
*    expire date: 2016-12-06 23:59:59 GMT
*    subjectAltName: api.sandbox.paypal.com matched
*    issuer: C=US; O=VeriSign, Inc.; OU=VeriSign Trust Network; OU=Terms of use at https://www.verisign.com/rpa (c)10; CN=VeriSign Class 3 Secure Server CA - G3
*    SSL certificate verify ok.
* Server auth using Basic with user '......'
> POST /v1/oauth2/token HTTP/1.1
> Authorization: Basic .......... =
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: api.sandbox.paypal.com
> Accept: application/json
> Accept-Language: en_US
> Content-Length: 29
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 29out of 29 bytes
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< PROXY_SERVER_INFO: host=slcsbplatformapiserv3001.slc.paypal.com;threadId=384
< Paypal-Debug-Id: de62039a5a244
< SERVER_INFO: identitysecuretokenserv:v1.oauth2.token&CalThreadId=47502&TopLevelTxnStartTime=14b83d4e3f0&Host=slcsbidensectoken502.slc.paypal.com&pid=6295
< Date: Fri, 13 Feb 2015 16:45:42 GMT
< Content-Type: application/json
< Content-Length: 461
< 
* Connection #0 to host api.sandbox.paypal.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
"scope":"https://uri.paypal.com/services/subscriptions https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card https://uri.paypal.com/services/applications/webhooks https://uri.paypal.com/services/invoicing https://uri.paypal.com/payments/payouts https://api.paypal.com/v1/vault/credit-card/.*","access_token":"A0151dMXKPrBCWFFucj132Nvw87sS5NFntFDhhfF8la3Wsg","token_type":"Bearer","app_id":"APP-80W284485P519543T","expires_in":28800

$ 
$ curl -v https://api.sandbox.paypal.com/v1/payments/payment \
> -H 'Content-Type: application/json' \
> -H 'Authorization: Bearer A0151dMXKPrBCWFFucj132Nvw87sS5NFntFDhhfF8la3Wsg' \
> -d '
>   "intent":"sale",
>   "redirect_urls":
>     "return_url":"http://example.com/your_redirect_url.html",
>     "cancel_url":"http://example.com/your_cancel_url.html"
>   ,
>   "payer":
>     "payment_method":"paypal"
>   ,
>   "transactions":[
>     
>       "amount":
>         "total":"7.47",
>         "currency":"USD"
>       
>     
>   ]
> '
* About to connect() to api.sandbox.paypal.com port 443 (#0)
*   Trying 173.0.82.78... connected
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Request CERT (13):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
*    subject: C=US; ST=California; L=San Jose; O=PayPal, Inc.; OU=PayPal Production; CN=api.sandbox.paypal.com
*    start date: 2012-12-06 00:00:00 GMT
*    expire date: 2016-12-06 23:59:59 GMT
*    subjectAltName: api.sandbox.paypal.com matched
*    issuer: C=US; O=VeriSign, Inc.; OU=VeriSign Trust Network; OU=Terms of use at https://www.verisign.com/rpa (c)10; CN=VeriSign Class 3 Secure Server CA - G3
*    SSL certificate verify ok.
> POST /v1/payments/payment HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: api.sandbox.paypal.com
> Accept: */*
> Content-Type: application/json
> Authorization: Bearer A0151dMXKPrBCWFFucj132Nvw87sS5NFntFDhhfF8la3Wsg
> Content-Length: 324
> 
* upload completely sent off: 324out of 324 bytes
< HTTP/1.1 201 Created
< Server: Apache-Coyote/1.1
< PROXY_SERVER_INFO: host=slcsbplatformapiserv3001.slc.paypal.com;threadId=19925
< Paypal-Debug-Id: d2b2c56f78e41
< SERVER_INFO: paymentsplatformserv:v1.payments.payment&CalThreadId=196&TopLevelTxnStartTime=14b83d6cc6a&Host=slcsbpaymentsplatformserv3002.slc.paypal.com&pid=13409
< Content-Language: *
< Date: Fri, 13 Feb 2015 16:47:47 GMT
< Content-Type: application/json
< Content-Length: 740
< 
* Connection #0 to host api.sandbox.paypal.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
"id":"PAY-3XB52861RA479681CKTPCVMY","
create_time":"2015-02-13T16:47:47Z",
"update_time":"2015-02-13T16:47:47Z",
"state":"created",
"intent":"sale",
"payer":"payment_method":"paypal",
"payer_info":"shipping_address":,
"transactions":["amount":"total":"7.47","currency":"USD","details":   "subtotal":"7.47","related_resources":[]],"links":["href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-3XB52861RA479681CKTPCVMY","rel":"self","method":"GET","href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-39015200YL315920D","rel":"approval_url","method":"REDIRECT","href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-3XB52861RA479681CKTPCVMY/execute","rel":"execute","method":"POST"]

【问题讨论】:

【参考方案1】:

"payment_method":"paypal"

这意味着用户(您的客户)必须(这些是上面缺少的步骤):

从您的应用程序重定向到 Paypal 到响应中返回的 approval_url(他们对您上次 curl 调用的响应)。 用户将/必须“批准”您的请求 用户将被发送回您的站点/应用程序到您在return_url 中设置的 url 之后您需要execute 付款。

参考:Accept a PayPal payment

这实质上映射到 Classic API 中的“快速结帐”。

第..

【讨论】:

谢谢你,EdSF。我以为我在做 Accept a Credit Card 请求,并且应该一步完成。你让我走上正轨!

以上是关于PayPal Rest 首次通话不会出现在沙盒交易中的主要内容,如果未能解决你的问题,请参考以下文章

已批准的 PayPal SDK 付款不会出现在沙盒仪表板上

在沙盒帐户中模拟 PayPal 错误

Paypal IPN 在沙盒 ipn sinulator 中有效,但在交易中无效

PayPal Rest API (PHP SDK) webhook 未显示在沙盒事件列表中

为啥 setLandingPageType("billing") 在沙盒中工作,但在 PAYPAL PHP REST API SDK WebProfile 中的实时版本中不工作

Paypal 不会在沙盒中的 BILLING.SUBSCRIPTION.CANCELLED 上触发 webhook