Using the Web Service

Each request is composed of the following elements:
  • a requested URL (or "endpoint”)
  • a method
  • headers
  • the details (or “body”)

The endpoint

The endpoint (root-endpoint) of the API is: https://secure.lyra.com/sdd.

Several resources, each associated with a different path, are provided:

Action Method URl
Import an existing mandate POST /mandates
Import several existing mandates POST /multimandates
View mandate details GET /mandates/:id
Download a mandate GET /mandates/:id
Update a mandate PUT /mandates/:id
Delete a mandate DELETE /mandates/:id

( : ) in the path indicates a variable. You must replace this variable by a real value when you send your request. In our case, you must replace  :id by the ID of the mandate that you want to use.

The method

Each resource is accessible via a specific method. This method translates the action that you want to perform (see table below).

  • GET This request is used to obtain a resource via the server.
  • POST This request is used to create a new resource.
  • PUT This request is used to update a resource.
  • DELETE This request is used to delete a resource.

The headers

The HTTP headers are key-value pairs separated by “ : ”.

They are used for transmitting authentication details and information about the contents of the request.

The headers used in this API are described in the chapter Identifying yourself when exchanging with the payment gateway.

The details (or “body”)

The details (also referred to as “body” or “message”) contains the information that you want to pass to the server. It is used only in the POST and PUT requests.

The details are transmitted, both in requests and responses, in JSON (Javascript Object Notation) format. In this format, each property and value is framed by double quotes:

 {
	"property1" : "value1",
	"property2" : "value2"
 }

Test the web service with cURL

This part implies that you have already installed cURL.

In order to use cURL, enter curl followed by the endpoint that you would like to interrogate.

Example with a call to our root-endpoint:

 curl https://secure.lyra.com/sdd

Once you validate, you will obtain the response below:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /sdd was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

To obtain the list of mandates registered for your shop, change the line of the previous order specifying the “ /mandates ” endpoint:

 curl https://secure.lyra.com/sdd/mandates

You will obtain the response below:

 {
  "name" : "ERROR",
  "message" : "Service error",
  "details" : "RESTEASY001545: No resource method found for GET, return 405 with Allow header"
 }

You get this response as you are not authenticated.

Now it is time to discover how to authenticate using HTTP headers.