クライアントの支払いシステムを実装しようとしていますが、障害があります。
Paypal サンドボックスをカールしようとするときは、https ://developer.paypal.com/webapps/developer/docs/integration/direct/accept-credit-cards/ のドキュメントに従っています。
これが私が使用している正確なコマンドです:
curl -v -k https://api.sandbox.paypal.com/v1/payments/payment -H "Content-Type:application/json" -H "Authorization:Bearer DdtHNNeMmv9Jb5K9fXLC50vxUkIrF6MihT.IJUefGlo" --connect-timeout 30 -d {"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"number":"4417119669820331","type":"visa","expire_month":11,"expire_year":2018,"cvv2":"874","first_name":"Joe","last_name":"Shopper","billing_address":{"line1":"52 N Main ST","city":"Johnstown","country_code":"US","postal_code":"43210","state":"OH"}}}]},"transactions":[{"amount":{"total":"7.47","currency":"USD","details":{"subtotal":"7.41","tax":"0.03","shipping":"0.03"}},"description":"This is the payment transaction description."}]}
(明らかに、以前に取得したものに基づいてアクセストークンを変更しています。これにより、Paypal をカールできることも確認できます)
これを行うと、「リクエスト JSON の形式が正しくありません」という MALFORMED_REQUEST エラーが発生します。ここに私の詳細なデバッグ情報があります:
c:\>curl -v -k https://api.sandbox.paypal.com/v1/payments/payment -H "Content-Type:application/json" -H "Authorization:Bearer DdtHNNeMmv9Jb5K9fXLC50vxUkIrF6MihT.IJUefGlo" --connect-timeout 30 -d {"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"number":"4417119669820331","type":"visa","expire_month":11,"expire_year":2018,"cvv2":"874","first_name":"Joe","last_name":"Shopper","billing_address":{"line1":"52 N Main ST","city":"Johnstown","country_code":"US","postal_code":"43210","state":"OH"}}}]},"transactions":[{"amount":{"total":"7.47","currency":"USD","details":{"subtotal":"7.41","tax":"0.03","shipping":"0.03"}},"description":"This is the payment transaction description."}]}
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x1d6d2f0) send_pipe: 1, recv_pipe: 0
* About to connect() to api.sandbox.paypal.com port 443 (#0)
* Trying 173.0.82.78...
* Connected to api.sandbox.paypal.com (173.0.82.78) port 443 (#0)
* 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 Production; CN=api.sandbox.paypal.com
* start date: 2012-12-06 00:00:00 GMT
* expire date: 2016-12-06 23:59:59 GMT
* 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 result: self signed certificate in certificate chain (19), continuing anyway.
> POST /v1/payments/payment HTTP/1.1
> User-Agent: curl/7.31.0
> Host: api.sandbox.paypal.com
> Accept: */*
> Content-Type:application/json
> Authorization:Bearer DdtHNNeMmv9Jb5K9fXLC50vxUkIrF6MihT.IJUefGlo
> Content-Length: 444
>
* upload completely sent off: 444 out of 444 bytes
< HTTP/1.1 400 Bad Request
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Date: Sun, 23 Jun 2013 18:07:54 GMT
< Connection: close
< PayPal-Debug-Id: 2f3f584e8050e
< Content-Type: application/json
< Content-Length: 200
< Connection: close
<
{"name":"MALFORMED_REQUEST","message":"The request JSON is not well formed.","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST","debug_id":"2f3f584e8050e"}* Closing connection 0* SSLv3, TLS alert, Client hello (1):
JSON リント ( http://jsonlint.com/ )を介して実行しても、JSON が正しく形成されていることを繰り返し確認しました。そして、もちろん、Paypal の JSON 応答で提供されたリンクはどこにも行きません。私はこの 1 週間、Paypal の誰かにこのことを説明してもらうことに費やしました。
任意の入力をいただければ幸いです。