Check if voucher code is valid
For every API request you make, you'll need to present the API access key in the HTTP Header as X-API-Key to be authenticated.
Name | Required | Value | Description |
---|---|---|---|
code | required You can pass in the voucher code either in as path parameter or query-string parameter |
string | The voucher code |
$request_url = 'https://api.frontcore.com/v2/vouchers/validate/:code';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-API-Key: {your-api-key}',
'Accept: application/json',
));
$result = curl_exec($ch);
curl_close($ch);
If the method is successful it responds with an JSON structure, as it is shown below.
{ "successful": true, "voucher": { "id": "305", "currency": "nok", "code": "c7bed231", "balance": "999.98", "is_expired": false, "is_deleted": false, "expires_at": "2024-09-16 12:51:59", "archived_at": null, "created_at": "2021-09-16 12:52:05" } }
Unsuccessful response sample:
{ "successful": false, "errors": [ { "code" => some_error_code, "message" => "A human readable error response" } ] }
unauthorized | You are not authorized to execute this operation. |
resource_not_found | 'We can not find any voucher with given code. |