Skip to content

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:

  1. Create the input string. Append the MerchantAPISecret key to the JsonPayload.
  2. Hash the string with SHA256.
  3. 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.

Authentication

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;
};

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

NameTypeDescription
ErrorCodeStringUnique error code
ErrorMessageStringDetailed error message
ErrorReferenceStringA 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.