cURL examples

cURL is one of the most basic tools that allow to send requests to APIs. The usage is very simple, you can call it in a terminal with access and request data.

Here’s a simple example – let’s perform a test card payment. We use the transaction information from our examples; you can copy the code below, but remember to provide your own test account user name and password.

curl --request POST 'https://your_login:your_password@direct.paylane.com/rest/cards/sale' \
     --data '{"sale": {"amount":19.99, "currency":"EUR", "description":"Product #1"}, "customer":{"name":"John Doe", "email":"john@doe.com", "ip":"127.0.0.1", "address":{"street_house":"1600 Pennsylvania Avenue Northwest", "city":"Washington", "state":"DC", "zip":"500", "country_code":"US"}}, "card":{"card_number":"4200000000000000", "expiration_month":"03", "expiration_year":"2017", "name_on_card":"John Doe", "card_code":"123"}}'
You can also add other (optional) parameters to the request above, like for example --i or
--header 'Content-type:application/json' (see the cURL manual for more details).

If everything goes ok, you should see a response similar to this:

{"success":true,"id_sale":1234567}

Now let’s try to use the received sale ID number to get information about the transaction. We’ll need to call the sales/info method:

curl --request GET 'https://your_login:your_password@direct.paylane.com/rest/sales/info' \
     --data '{"id_sale":1234567}'

You should now see something similar to this:

{"success":true, "id_sale":1234567, "status":"PERFORMED", "is_refund":false, "is_chargeback":false, "is_reversal":false, "amount":"19.99", "currency":"EUR", "description":"Product #1", "customer":{"name":"John Doe", "email":"john@doe.com"}, "card":{"name":"John Doe", "number":"4200...0000"}}

As you see, you just have to call a certain API method (specifying the HTTP method) and provide the request data.