bysquare-fixed
v2.0.4
Published
![version][version] ![build][build]
Downloads
13
Maintainers
Readme
bysquare
Simple Node.js library to generate "PAY by square" QR string.
What is PAY by square?
It's a national standard for payment QR codes adopted by Slovak Banking Association in 2013. It is part of a large number of invoices, reminders and other payment regulations.
Can I generate an image?
This library is un-opinionated. Image generation from qr-code string depends on your implementation. See examples.
How it works
Install
GitHub
npm install xseman/bysquare#master
npm install xseman/bysquare#developnpm registry
npm install bysquareCLI
npm install --global bysquareAPI
generate(model: DataModel): Promise<string>
parse(qr: string): Promise<DataModel>
detect(qr: string): Booleangenerate(model: DataModel): Promise<string>
import { generate, DataModel, parse, PaymentOptions } from "bysquare"
const model: DataModel = {
invoiceId: "random-id",
payments: [
{
type: PaymentOptions.PaymentOrder,
amount: 100.0,
bankAccounts: [
{ iban: "SK9611000000002918599669" },
],
currencyCode: "EUR",
variableSymbol: "123",
}
]
}
generate(model).then((qr: string) => {
// your logic...
})parse(qr: string): Promise<DataModel>
import { parse, DataModel } from "bysquare"
const qr = "0004A00090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6C75G19O246KTT5G8LTLM67HOIATP4OOG8F8FDLJ6T26KFCB1690NEVPQVSG0"
parse(qr).then((model: DataModel) => {
// your logic...
});detect(qr: string): Boolean
import { detect } from "bysquare"
const qr = "0004A00090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6C75G19O246KTT5G8LTLM67HOIATP4OOG8F8FDLJ6T26KFCB1690NEVPQVSG0"
const isBysquare = detect(qr)CLI
You can use json file with valid model to generate qr-string.
# example.json
# {
# "invoiceId": "random-id",
# "payments": [
# {
# "type": 1,
# "amount": 100.0,
# "bankAccounts": [
# { "iban": "SK9611000000002918599669" }
# ],
# "currencyCode": "EUR",
# "variableSymbol": "123"
# }
# ]
# }
$ npx bysquare ./example.json
$ 0004A00090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6C75G19O246KTT5G8LTLM67HOIATP4OOG8F8FDLJ6T26KFCB1690NEVPQVSG0You can also use stdin.
$ bysquare <<< '{
"invoiceId": "random-id",
"payments": [
{
"type": 1,
"amount": 100.0,
"bankAccounts": [
{ "iban": "SK9611000000002918599669" }
],
"currencyCode": "EUR",
"variableSymbol": "123"
}
]
}'
$ 0004A00090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6C75G19O246KTT5G8LTLM67HOIATP4OOG8F8FDLJ6T26KFCB1690NEVPQVSG0