Solutions QR-code API manual

4. Create QR codes using Swish QR code generator APIs

4. Create QR codes using Swish QR code generator APIs

4.0 Create QR codes using Swish QR code generator APIs

Getswish offers a solution to send a request via an API to create Swish QR-codes. The code can be delivered in three different formats; JPG, PNG and SVR.

The code can include

  1. The receiving Swish-number (required)
  2. The amount of the payment (optional)
  3. The payment information such as reference number or order ID. (optional)

It is possible to define if number 2 and/or 3 will be editable by the payer or not.

4.1.1 Prefilled

POST /api/v1/prefilled

The Http request body have to contain a Prefilled request.

Potential Http status codes returned:
200 OK: Returned when the QR code was successfully created. Will return a QR code response.
400 Bad Request: Returned when the Prefilled request operation was malformed.
415 Unsupported Media Type: Returned when Content-Type header is not “application/json”.
500 Internal Server Error: Returned if there was some unknown/unforeseen error that occurred on the server, this should normally not happen.

4.1.2 Available endpoints - Prefilled request

The JSON payload follows the schema (shall be properly JSON serialized to avoid problems with uncommoncharacters in message).


{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Swish pre-filled qr code generator",
"description": "REST interface to get a QR code that the Swish app will interpret as a pre filled code",
"definitions": {
"editable": {
"description ": "Controls if user can modify this value in Swish app or not",
"type": "object",
"properties": {
"editable": {
"type": "boolean",
"default": false
}
}
},
"swishString": {
"type": "object",
"properties": {
"value": {
"type": "string",
"maxLength": 70
}
},
"required": ["value"]
},
"swishNumber": {
"type": "object",
"properties": {
"value": {
"type": "number"
}
},
"required": ["value"]
}
},
"type": "object",
"properties": {
"format": {
"enum": ["jpg", "png", "svg"]
},
"payee": {
"description": "Payment receiver",
"allOf": [
{"$ref": "#/definitions/editable"},
{"$ref": "#/definitions/swishString"}
]
},
"amount": {
"description": "Payment amount",
"allOf": [
{"$ref": "#/definitions/editable"},
{"$ref": "#/definitions/swishNumber"}
]
},
"message": {
"description": "Message for payment",
"allOf": [
{"$ref": "#/definitions/editable"},
{"$ref": "#/definitions/swishString"}
]
},
"size": {
"description": "Size of the QR code. The code is a square, so width and height are the same. Not required is the format is svg",
"value": "number",
"minimum": 300
},
"border": {
"description": "Width of the border.",
"type": "number"
},
"transparent": {
"description": "Select background color to be transparent. Do not work with jpg format.",
"type": "boolean"
}
},
"required": ["format"],
"anyOf": [
{"required": ["payee"]},
{"required": ["amount"]},
{"required": ["message"]}
],
"additionalProperties": false,
"maxProperties": 5
}