【问题标题】:PayPal curl error response at step3 when following "Make your first call" steps遵循“拨打您的第一个电话”步骤时,步骤 3 中的 PayPal curl 错误响应
【发布时间】:2014-10-07 05:25:49
【问题描述】:

我在 PayPal 的指导下关注文档 https://developer.paypal.com/webapps/developer/docs/integration/direct/make-your-first-call/

Step2>获取访问令牌

我可以得到如下结果;

"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 openid https://uri.paypal.com/services/invoicing https://api.paypal.com/v1/vault/credit-card/.*","access_token":"A015ztUtcRfI8HOkkpwAFdAnhpZcbC7YSothwMzgiavKeZ0","token_type":"Bearer","app_id":"APP-80W284485P519543T","expires_in":28800}

Step3>当我尝试发送如下交易时没有确认交易

-H 'Content-Type: application/json'
-H 'Authorization: Bearer A015ztUtcRfI8HOkkpwAFdAnhpZcbC7YSothwMzgiavKeZ0'
-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"
      }
    }
  ]
}'

我保存为错误输出的是

Warning: data2.txt:1: warning: '-H' uses unquoted white space in the line that 
Warning: may cause side-effects!
Warning: data2.txt:2: warning: '-H' uses unquoted white space in the line that 
Warning: may cause side-effects!
Warning: data2.txt:4: warning: '"intent"' is unknown
Warning: data2.txt:5: warning: '"redirect_urls"' is unknown
Warning: data2.txt:6: warning: '"return_url"' is unknown
Warning: data2.txt:7: warning: '"cancel_url"' is unknown
Warning: data2.txt:8: warning: '},' is unknown
Warning: data2.txt:9: warning: '"payer"' is unknown
Warning: data2.txt:10: warning: '"payment_method"' is unknown
Warning: data2.txt:11: warning: '},' is unknown
Warning: data2.txt:12: warning: '"transactions"' is unknown
Warning: data2.txt:13: warning: '{' is unknown
Warning: data2.txt:14: warning: '"amount"' is unknown
Warning: data2.txt:15: warning: '"total"' is unknown
Warning: data2.txt:16: warning: '"currency"' is unknown
Warning: data2.txt:17: warning: '}' is unknown
Warning: data2.txt:18: warning: '}' is unknown
Warning: data2.txt:19: warning: ']' is unknown
Warning: data2.txt:20: warning: '}'' is unknown
* Hostname was NOT found in DNS cache
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 173.0.82.78...
* Connected to api.sandbox.paypal.com (173.0.82.78) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: C:\Jnj\Web\PayPal\curl_X64_ssl\curl-ca-bundle.crt
  CApath: none
* SSLv3, TLS handshake, Client hello (1):
} [data not shown]
* SSLv3, TLS handshake, Server hello (2):
{ [data not shown]
* SSLv3, TLS handshake, CERT (11):
{ [data not shown]
* SSLv3, TLS handshake, Request CERT (13):
{ [data not shown]
* SSLv3, TLS handshake, Server finished (14):
{ [data not shown]
* SSLv3, TLS handshake, CERT (11):
} [data not shown]
* SSLv3, TLS handshake, Client key exchange (16):
} [data not shown]
* SSLv3, TLS change cipher, Client hello (1):
} [data not shown]
* SSLv3, TLS handshake, Finished (20):
} [data not shown]

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* SSLv3, TLS change cipher, Client hello (1):
{ [data not shown]
* SSLv3, TLS handshake, Finished (20):
{ [data not shown]
* SSL connection using TLSv1.0 / DES-CBC3-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.38.0

> Host: api.sandbox.paypal.com

> Accept: */*

> Content-Length: 2

> Content-Type: application/x-www-form-urlencoded

> 

} [data not shown]
* upload completely sent off: 2 out of 2 bytes
< HTTP/1.1 401 Unauthorized

* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1

< PROXY_SERVER_INFO: host=slcsbplatformapiserv3001.slc.paypal.com;threadId=174

< Paypal-Debug-Id: fe365dce81d22

< Content-Type: application/json

< Content-Length: 0

< Date: Tue, 07 Oct 2014 04:59:33 GMT

< 


100     2    0     0  100     2      0      1  0:00:02  0:00:01  0:00:01     1
* Connection #0 to host api.sandbox.paypal.com left intact

我的问题是

  • 这正常吗?

  • 为什么警告信息在顶部?

我正在测试 Windows 64 版本 7.38 的 cURL。 (在http://curl.haxx.se/download.html下载)

【问题讨论】:

    标签: rest curl paypal sandbox


    【解决方案1】:

    看来您发布的请求格式正确。在使用“命令提示符”发布时,我通常使用以下格式

    请求:

      C:\Users\eshan>curl -v  https://api.sandbox.paypal.com/v1/payments/payment -H "C
        ontent-Type:application/json"  -H "Authorization: Bearer A015RaaaaaJEAeQhKbLa466i
        44cI24DFqtz2uvJJ9WoCV4Ak"  -d "{\"intent\":\"sale\",\"redirect_urls\":{\"return_
        url\":\"http://www.example.com/execute-an-approved-paypal-payment.html\",\"cance
        l_url\":\"https://www.example.com/execute-paypal.html\"},\"payer\":{\"payment_me
        thod\":\"paypal\"},\"transactions\":[{\"amount\":{\"total\":\"7.47\",\"currency\
        ":\"USD\"},\"description\":\"This is the payment transaction description.\"}]}"
    

    回应:

    * Hostname was NOT found in DNS cache
    *   Trying 173.0.82.78...
    * Connected to api.sandbox.paypal.com (173.0.82.78) port 443 (#0)
    * successfully set certificate verify locations:
    *   CAfile: C:\Program Files\cURL\bin\curl-ca-bundle.crt
      CApath: none
    * 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 DES-CBC3-SHA
    * Server certificate:
    *        subject: C=US; ST=California; L=San Jose; O=PayPal, Inc.; OU=PayPal Pro
    duction; 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.35.0
    > Host: api.sandbox.paypal.com
    > Accept: */*
    > Content-Type:application/json
    > Authorization: Bearer A01asasasaEAeQhKbLa466i44cI24DFqtz2uvJJ9WoCV4Ak
    > Content-Length: 331
    >
    * upload completely sent off: 331 out of 331 bytes
    < HTTP/1.1 201 Created
    * Server Apache-Coyote/1.1 is not blacklisted
    < Server: Apache-Coyote/1.1
    < PROXY_SERVER_INFO: host=slcsbjava4.slc.paypal.com;threadId=248
    < Paypal-Debug-Id: 21c30b9f30df0
    < SERVER_INFO: paymentsplatformserv:v1.payments.payment&CalThreadId=208&TopLevel
    TxnStartTime=148ea613d1d&Host=slcsbjm3.slc.paypal.com&pid=10739
    < Content-Language: *
    < Date: Tue, 07 Oct 2014 11:31:54 GMT
    < Content-Type: application/json
    < Content-Length: 801
    <
    {"id":"PAY-62521015XSD45194GKQZ46KQ","create_time":"2014-10-07T11:31:54Z","updat
    e_time":"2014-10-07T11:31:54Z","state":"created","intent":"sale","payer":{"payme
    nt_method":"paypal","payer_info":{"shipping_address":{}}},"transactions":[{"amou
    nt":{"total":"7.47","currency":"USD","details":{"subtotal":"7.47"}},"description
    ":"This is the payment transaction description.","related_resources":[]}],"links
    ":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-625210SDXC445
    194GKQZ46KQ","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.co
    m/cgi-bin/webscr?cmd=_express-checkout&token=EC-36X39846V0760201K","rel":"approv
    al_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments
    /payment/PAY-6252101SDC445194GKQZ46KQ/execute","rel":"execute","method":"POST"}]
    }* Connection #0 to host api.sandbox.paypal.com left intact
    

    【讨论】:

      猜你喜欢
      • 2020-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多