Simple Integration
This is a simplified way to integrate with the api.
The client just need to send in all data in a post request, and we figure out how to talk with the actual rest api
All request in these documents are written as raw http request, and you convert that to what ever language
We provide an open api v3 schema.
You can find it here: https://prod.rr.apis.stefna.is/openapi-payment-schema.json
Visit data needed by the api are
- Vehicle plate
- Vehicle owner kennitala
- Vehicle registration date
- Visit started on
2022-04-27 15:41:00
- Visit ended on
2022-04-27 15:41:00
can be the same as started on
sequenceDiagram actor Customer participant "Location" participant "Rental Relay" Customer->"Location": Pay for service "Location"->"Rental Relay": Send payment and vehicle info "Rental Relay"-->"Location":Returns message and status "Location"-->Customer:Payment complete
GET https://baseUrl/payment
Authorization: Bearer {{TOKEN}}
Response
{
"location": "4347885e-67c6-46bf-be27-45111bc11645",
"vehicle": {
"owner": "6511740239",
"plate": "plate",
"acquiredOn": "2022-05-25"
},
"visit": {
"startedOn": "2022-05-25 12:00:00",
"endedOn": "2022-05-25 12:30:00"
},
"payment": {
"amount": 1000,
"currency": "ISK"
}
}
const visit = {
"location": "4347885e-67c6-46bf-be27-45111bc11645",
"vehicle": {
"owner": "6511740239", // should be rental company kennitala
"plate": "plate",
"acquiredOn": "2022-05-25"
},
"visit": {
"startedOn": "2022-05-25 12:00:00",
"endedOn": "2022-05-25 12:30:00"
},
"payment": {
"amount": 1000,
"currency": "ISK"
}
};
createPayment(visit);
async function createPayment(visit) {
const result = await sendToApi('/payment', visit);
if (result.id) {
// success
}
else {
// error
console.log(result.message);
}
}
const baseUrl = 'https://baseurl';
const apiToken = 'your api token';
async function sendToApi(endpoint, payload)
{
const response = await fetch(baseUrl + endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + apiToken,
},
body: JSON.stringify(payload) // body data type must match "Content-Type" header
});
return response.json();
}