I'm trying to implement a payment system for a client, but I'm hitting a roadblock.
When I attempt to curl the Paypal sandbox, I'm following the documentation here: https://developer.paypal.com/webapps/developer/docs/integration/direct/accept-credit-cards/
Here is the exact command I'm using:
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."}]}
(obviously, I'm changing the access token based on one that I'm getting previously, which also verifies to me that I AM able to curl Paypal)
When I do this, I get a MALFORMED_REQUEST error, stating that "The request JSON is not well formed." Here is my verbose debug info:
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):
I've verified repeatedly that the JSON is correctly formed, even running it through a JSON Lint (http://jsonlint.com/). And, of course, the link provided in Paypal's JSON response goes nowhere, and I've spent the past week trying to get somebody with Paypal to explain this to me.
Any input would be most appreciated.