Authorization
Generate the authorization token for Qliro Checkout API calls.
Authorization token
Every API call to Qliro Checkout must have an authorization token in the request header. The authentication scheme is Qliro.
To generate the token:
- Create the input string. Append the MerchantAPISecret key to the JsonPayload.
- Hash the string with SHA256.
- Encode the hash in base64.
The result is the token for the authorization header.
If you send no JsonPayload, use an empty string in its place in step 1.
The Authorization header contains the authentication scheme and the token, in this syntax: Authorization: Qliro token.
Notifications do not support authentication. Supply a generated URL that is only valid for a short period of time.

The JsonPayload
The JsonPayload consists of several parameters. The example below shows a possible JsonPayload. For the exact specification of the parameters, see the API Reference.
{
"MerchantReference": "MerchantUniqueReference",
"Currency": "SEK",
"Country": "SE",
"Language": "sv-se",
"MerchantConfirmationUrl": "http://Merchant.com/confirmation/",
"MerchantTermsUrl": "http://Merchant.com/terms/",
"PrimaryColor": "#00FF00",
"CallToActionColor": "#0000FF",
"OrderItems": [
{
"MerchantReference": "XXX",
"Description": "ZZZ",
"Quantity": 4,
"PricePerItemIncVat": 450,
"PricePerItemExVat": 450
}
],
"MerchantApiKey": "MERCHANTKEY"
}MerchantAPISecret
Authentication also requires a key called MerchantAPISecret. If you do not have one, contact your Onboarding agent or email integration@qliro.com.
How-to
Use one of the following examples to generate a token.
var generateToken = function () {
var payload = request.data;
console.log("Payload: ", payload);
var secret = postman.getEnvironmentVariable("ApiSecret");
var input = '';
if (payload && Object.keys(payload).length > 0) {
input += payload;
}
input += secret;
var token = CryptoJS.SHA256(input).toString(CryptoJS.enc.Base64);
return "Qliro " + token;
};public string CreateAuthorizationToken(string jsonPayoload, string apiSecret)
{
using (var algorithm = new SHA256Managed())
{
var data = jsonPayload + apisecret;
var bytes = Encoding.UTF8.GetBytes(data);
var hash = algorithm.ComputeHash(bytes);
return string.Format("Qliro {0}", Convert.ToBase64String(hash));
}
}$json = json_encode(array (
'MerchantReference' => 'MerchantUniqueReference',
'Currency' => 'SEK',
'Country' => 'SE',
'Language' => 'sv-se',
'MerchantConfirmationUrl' => 'http://Merchant.com/confirmation/',
'MerchantTermsUrl' => 'http://Merchant.com/terms/',
'PrimaryColor' => '#00FF00',
'CallToActionColor' => '#0000FF',
'OrderItems' =>
array (
0 =>
array (
'MerchantReference' => 'XXX',
'Description' => 'ZZZ',
'Quantity' => 4,
'PricePerItemIncVat' => 450,
'PricePerItemExVat' => 450,
),
),
'MerchantApiKey' => 'API-KEY',
));
print $json;
echo "<br>";
echo "Authentication Header = <br>";
print 'Qliro '.base64_encode(hex2bin(hash('sha256', $json.'<API-SECRET>')));Error codes
If a call fails, you get an HTTP status code in the range 400-599.
The following authentication error can occur:
401 Unauthorized
The error has a content body in the following format.
Error response parameters
| Name | Type | Description |
|---|---|---|
| ErrorCode | String | Unique error code |
| ErrorMessage | String | Detailed error message |
| ErrorReference | String | A tracking ID from Qliro Checkout |
Error response body example
{
"ErrorCode": "SYSTEM_ERROR",
"ErrorMessage": "Details about the error",
"ErrorReference": "GUID-CorelationId"
}For more on errors, see the API Reference.