Glase Invoice Service introduction
This page describes how QR codes for Glase Invoice Service should be constructed by issuers. Issuer is a company who wishes to distribute QR codes in an invoice among their consumers scanning of which starts the payment process of an invoice associated with the QR code.
Please become familiar with guidelines for printing Glase QR codes attached to this document.
Before integrating with Glase Invoice service contact Glase to obtain:
- Issuer name
- Secret key for the issuer
Glase Invoice Service QR code
An example QR code for Invoice Service looks as follows:
QRCode contains URL containing single query parameter labaled as “j”.
The rules governing the creation of a QR code are summarized in a table below.
QR code element | Mandatory | Description |
---|---|---|
HTTP://SEQR.SE/000/invoice? | Y | This part is compulsory and a QR code must start with it. |
j={JWT} | Y | JSON Web Token data. |
This parameter is so called JSON Web Token (JWT). More on that standard can be obtained from website: http://jwt.io. Value of this parameter must conform to JWT standard. Usage of one of many implementations proposed on jwt.io website is suggested.
JWT contains 2 parts that must be taken care of: header and payload. Both should be prepared as JSON data with following fields.
JWT Header
JSON field | Mandatory | Description |
---|---|---|
alg: "HS256" | Y | Algorithm used for JWT signature. It should always stay HS256. This value is filled automatically by most JWT implementation libraries. |
typ: "JWT" | Y | Type of an object. In our case it's always JWT. This value is filled automatically by most JWT implementation libraries. |
iss: <issuer_id> | Y | Issuer name provided by Glase. |
JWT Payload
JSON field | Mandatory | Description |
---|---|---|
d: <description> | Y |
Max 50-characters long description of the invoice. Allowed characters: alphanumeric, white spaces, braces, dash, slash, comma, dot, single and double quotes.
([A-Za-z\w.,\(\)-\\\\/\"\'])+. |
a: <amount> | Y | Amount to be paid, numerical value with a precision up to 2 decimal points, eg. 100.00 (with a dot '.' being the decimal seperator). |
c: <currency> | Y | 3-characters long currency. |
r: <issuers_reference> | Y |
Max 30-characters long unique reference of the invoice. It is set up by an issuer. Allowed characters: alphanumeric, white spaces, braces, dash, slash, comma, dot, single and double quotes.
([A-Za-z\w.,\(\)-\\\\/\"\'])+. |
o: <true|false> | Y | If set to true the invoice can be paid only once; default value: false - it means that invoice identified by the same reference can be paid several times. |
Example
Let’s assume our issuer name and secret are:
Param name | Param value |
---|---|
Issuer Name | example |
Secret | 5ecr3t |
Our header should be represented by JSON like:
We want to issue invoice with following data:
Param name | Param value |
---|---|
amount | 29.99 |
currency | SEK |
description | Test invoice |
reference | R820919 |
once | false |
Our payload should be represented by JSON like:
Secret code must be encoded using SHA-256 before use. In our example it’s value for ‘5ecr3t’ should be:
Encoding type | Encoded value |
---|---|
base64 hash | v7omClW4RuJEC8SUBCaL6E5q7R5wFPbHC7uN/J56U48 |
hex hash | bfba260a55b846e2440bc49404268be84e6aed1e7014f6c70bbb8dfc9e7a538f |
We present both representations, raw value encoded by base64 and hexadecimal value. On jwt.io website you can verify your JWT using first option (base64 hash) after checking “secret base64 encoded”.
For testing purposes one can use on-line SHA-256 calculator available at: http://approsto.com/sha-generator.
Generated JWT should be:
And finally URL in QRCode:
Below we present implementations in some popular programming languages using one of libraries suggested on jwt.io website.
JavaScript with jsrsasign
PHP using Firebase
Python using jwcrypto
Ruby using jwt
Invoice reports
To fetch a report one needs to call a RESTful API using HTTP GET method.
For integration/testing purpose please use below service URL:
https://invoice-int.seqr.com/api/report/
The parameters of a call are as follows:
Param name | Param type | Description |
---|---|---|
startDate | QUERY | give me reports newer than startDate (inclusive), format: ddMMyyyy |
endDate | QUERY | give me reports older than endDate (inclusive), format: ddMMyyyy |
issuer | QUERY | issuer name; the same value that is used in generated QR codes |
X-Auth-Token | HTTP HEADER | SHA-256 hash constructed out of the following string: <issuer name> + <secret string for issuer used for invoice QR code generation>. |
All these parameters are mandatory.
Example
Let us assume that issuer name is abc and secret string is SECRET_STRING_FOR_ISSUER. Hence, the input string for hash calculation is
which results in the following SHA-256 hash
Hence, the call to fetch a report from 1st June to 30th June 2015 is
Report content
Report consists of the following fields in the specified order:
- ID - unique identifier of an invoice in Glase
- DESCRIPTION - description of an invoice provided by an issuer. Double quotes and new lines are escaped.
- AMOUNT - amount paid, format 123.45 ('.' as a decimal separator)
- CURRENCY - 3-characters logs currency of an amount, eg. EUR
- STATUS - status of invoice; at the moment only PAID invoices are returned
- REFERENCE - identifier of an invoice provided by an issuer
- ERS_REFERENCE - identifier of a transaction in Glase which paid the invoice
- PURCHASE_TIME - datetime when invoice was paid, format: YYYY-MM-DDThh:mm:ssTZD, eg. 1997-07-16T19:20:30+01:00 (described in WC3 Date and Time Formats)
- PAYER_MSISDN - MSISDN of payer if issuer requested it
- PAYER_FIRST_NAME - first name of payer if issuer requested delivery address of payer
- PAYER_LAST_NAME - last name of payer if issuer requested delivery address of payer
- PAYER_STREET - street of payer if issuer requested delivery address of payer
- PAYER_CITY - city of payer if issuer requested delivery address of payer
- PAYER_ZIP - ZIP code fo payer if issuer requested delivery address of payer
- PAYER_COUNTRY - country code of payer if issuer requested delivery address of payer
Notifications
After successfull payment Glase Invoice Service will call RESTful API exposed by issuer. Please check Glase Invoice Service API for more details.
Verification
The easiest way to verify your QRCodes is downloading and setting Glase app up. Please follow instructions from Glase test app then just scan your QRCode to find out whether it is valid or not.
Certification
For certification purpose we will send you couple sets of parametrs. You should generate Glase Invoice Service QR codes based on these parameters and send generated QR codes back to us for validation.
After validation we will try to use them for payment and will check if your notification service exposed to Glase Invoice Service returns HTTP 200.
We will also ask you to get few reports using our API.