Using cURL

cURL is a command line tool that can be used for sending requests to a REST API.

cURL can be used to send an HTTPS request to Paysafe that contains a method (POST for a payment request and GET to retrieve data), request headers (with authentication details), and a request body (with the API request details in JSON format). Paysafe responds with a status code (e.g., 200 OK), response headers, and a response body.

Below is an example of a cURL request for the Paysafe API:

curl -X POST https://api.test.paysafe.com/cardpayments/v1/accounts/89987201/auths \
  -u devcentre322:B-qa2-0-53625f86-302c021476f52bdc9deab7aea876bb28762e62f92fc6712d0214736abf501e9675e55940e83ef77f5c304edc7968 \
  -H 'Content-Type: application/json' \
  -d ' {
         "merchantRefNum" : "demo-1",
         "amount" : 10098,
         "settleWithAuth":true,
         "card" : {
           "cardNum" : "4111111111111111",
           "cardExpiry":{
             "month":2,
             "year":2027
            },
            "cvv":123
          },
          "billingDetails":{
             "street":"100 Queen Street West",
             "city":"Toronto",
             "state":"ON",
             "country":"CA",
             "zip":"M5H 2N2"
          }
        } '

The table below provides details of the parameters that can be defined in the cURL request.

Parameter Description Example
curl The cURL request includes the URL or API endpoint you are connecting to as the final parameter. On the Paysafe payment platform, the API endpoint depends on the type of request. curl -x POST https://api.test.paysafe.com/cardpayments/v1/accounts/89987201/auths
-x POST This is the HTTP method to use. The Paysafe APIs use GET, POST, PUT, and DELETE

-x POST

-H Specify an HTTP header and its content. This is typically used to set the Content-Type header, which is always application/json or application/json; charset=utf-8 (for UTF8 content) for Paysafe REST API requests.

-H 'Content-Type: application/json'

-u

Specify authentication details in the format <username>:<password>. These are your API key details.

Note the colon separating the user name and password.

-u devcentre322:B-qa2-0-53625f86-302c021476f52bdc9deab7aea876bb28762e62f92fc6712d0214736abf501
e9675e55940e83ef77f5c304edc7968

–d

Specifies the payload or message body to be included in the request. For the Paysafe REST APIs this is a set of JSON parameters.

-d ' {
"merchantRefNum": "demo-1",
"amount": 10098,
"settleWithAuth": true,
"card": {
    "cardNum": "4111111111111111",
    "cardExpiry": {
        "month": 2,
        "year": 2017
    },
    "cvv": 123
},
"billingDetails": {
    "street": "100 Queen Street West",
    "city": "Toronto",
    "state": "ON",
    "country": "CA",
    "zip": "M5H 2N2"
}
'
  • We recommend you use the Python json.tool from the shell to pretty-print the JSON response. From a Unix command line, this can be achieved as follows:

    curl -X GET https://api.test.paysafe.com/cardpayments/monitor | python -mjson.tool

  • In the examples in this guide, the backslash symbol \ is included to indicate to cURL to ignore the line break formatting. Note that \ is recognized on Unix or MAC command‐line clients only and is not supported on Windows clients. To use cURL from the Windows Command Line, see: https://help.zendesk.com/hc/en-us/articles/229136847-Installing-and-using-cURL
  • We recommend putting the requests in files using @. If you start the data with the @ character, the rest should be a file name to read the data from. Posting data from a file named 'foobar' would thus be done with ‐d @foobar.
Did you find this page useful?