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.
--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"}}'
--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:
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:
--data '{"id_sale":1234567}'
You should now see something similar to this:
As you see, you just have to call a certain API method (specifying the HTTP method) and provide the request data.