bysquare 2.12.5 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -1
- package/lib/classifier.d.ts +34 -0
- package/lib/classifier.js +50 -0
- package/lib/crc32.d.ts +3 -0
- package/lib/crc32.js +4 -55
- package/lib/encode.js +16 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/types.d.ts +86 -37
- package/lib/types.js +1 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -104,6 +104,7 @@ const qrstring = encode({
|
|
|
104
104
|
import {
|
|
105
105
|
CurrencyCode,
|
|
106
106
|
encode,
|
|
107
|
+
Month,
|
|
107
108
|
PaymentOptions,
|
|
108
109
|
Periodicity,
|
|
109
110
|
} from "bysquare";
|
|
@@ -116,6 +117,7 @@ const qrstring = encode({
|
|
|
116
117
|
variableSymbol: "654321",
|
|
117
118
|
currencyCode: CurrencyCode.EUR, // "EUR"
|
|
118
119
|
day: 15,
|
|
120
|
+
month: Month.January, // Single month
|
|
119
121
|
periodicity: Periodicity.Monthly, // "m"
|
|
120
122
|
bankAccounts: [
|
|
121
123
|
{ iban: "SK9611000000002918599669" },
|
|
@@ -125,6 +127,63 @@ const qrstring = encode({
|
|
|
125
127
|
});
|
|
126
128
|
```
|
|
127
129
|
|
|
130
|
+
#### Standing Order with Multiple Months
|
|
131
|
+
|
|
132
|
+
For standing orders that should execute in specific months, you can combine
|
|
133
|
+
multiple months using bitwise OR operators:
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
import {
|
|
137
|
+
CurrencyCode,
|
|
138
|
+
encode,
|
|
139
|
+
encodeOptions,
|
|
140
|
+
Month,
|
|
141
|
+
PaymentOptions,
|
|
142
|
+
Periodicity,
|
|
143
|
+
} from "bysquare";
|
|
144
|
+
|
|
145
|
+
const qrstring = encode({
|
|
146
|
+
payments: [
|
|
147
|
+
{
|
|
148
|
+
type: PaymentOptions.StandingOrder,
|
|
149
|
+
amount: 100.0,
|
|
150
|
+
variableSymbol: "654321",
|
|
151
|
+
currencyCode: CurrencyCode.EUR,
|
|
152
|
+
day: 15,
|
|
153
|
+
// Execute in January, July, and October only
|
|
154
|
+
month: Month.January | Month.July | Month.October, // Results in 577
|
|
155
|
+
periodicity: Periodicity.Monthly,
|
|
156
|
+
lastDate: "20251231",
|
|
157
|
+
bankAccounts: [
|
|
158
|
+
{ iban: "SK9611000000002918599669" },
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Alternative: Use the utility function to encode multiple months
|
|
165
|
+
const monthsToEncode = [Month.January, Month.July, Month.October];
|
|
166
|
+
const encodedMonths = encodeOptions(monthsToEncode);
|
|
167
|
+
|
|
168
|
+
const qrstring2 = encode({
|
|
169
|
+
payments: [
|
|
170
|
+
{
|
|
171
|
+
type: PaymentOptions.StandingOrder,
|
|
172
|
+
amount: 100.0,
|
|
173
|
+
variableSymbol: "654321",
|
|
174
|
+
currencyCode: CurrencyCode.EUR,
|
|
175
|
+
day: 15,
|
|
176
|
+
month: encodedMonths, // Same result: 577
|
|
177
|
+
periodicity: Periodicity.Monthly,
|
|
178
|
+
lastDate: "20251231",
|
|
179
|
+
bankAccounts: [
|
|
180
|
+
{ iban: "SK9611000000002918599669" },
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
128
187
|
### HTML example
|
|
129
188
|
|
|
130
189
|
This example shows how to generate a payment QR code and display it in a web
|
|
@@ -150,7 +209,7 @@ page:
|
|
|
150
209
|
type: PaymentOptions.PaymentOrder,
|
|
151
210
|
amount: 123.45,
|
|
152
211
|
variableSymbol: "987654",
|
|
153
|
-
|
|
212
|
+
currencyCode: CurrencyCode.EUR,
|
|
154
213
|
bankAccounts: [
|
|
155
214
|
{ iban: "SK9611000000002918599669" }
|
|
156
215
|
],
|
|
@@ -212,6 +271,29 @@ const qrstring = encode(data);
|
|
|
212
271
|
const model = decode(qrstring);
|
|
213
272
|
```
|
|
214
273
|
|
|
274
|
+
## Classifier Utilities
|
|
275
|
+
|
|
276
|
+
The library provides utility functions for working with multiple classifier
|
|
277
|
+
options as specified in the PAY by Square standard. These functions are
|
|
278
|
+
particularly useful for handling multiple month selections in standing orders.
|
|
279
|
+
|
|
280
|
+
### Encoding Multiple Options
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
import {
|
|
284
|
+
encodeOptions,
|
|
285
|
+
Month,
|
|
286
|
+
} from "bysquare";
|
|
287
|
+
|
|
288
|
+
// Encode multiple months into a single value
|
|
289
|
+
const monthsArray = [Month.January, Month.July, Month.October];
|
|
290
|
+
const encoded = encodeOptions(monthsArray);
|
|
291
|
+
console.log(encoded); // 577 (1 + 64 + 512)
|
|
292
|
+
|
|
293
|
+
// This matches the specification example:
|
|
294
|
+
// January=1, July=64, October=512, sum=577
|
|
295
|
+
```
|
|
296
|
+
|
|
215
297
|
## CLI
|
|
216
298
|
|
|
217
299
|
```sh
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for handling multiple classifier value options using summed
|
|
3
|
+
* classifiers as specified in the PAY by Square specification.
|
|
4
|
+
*
|
|
5
|
+
* Supports Month Classifier (Table 10) and other classifiers that use summed
|
|
6
|
+
* values.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Encodes multiple classifier options into a single number by summing their
|
|
10
|
+
* values.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Encode January + July + October months
|
|
14
|
+
* const encoded = encodeOptions([Month.January, Month.July, Month.October]);
|
|
15
|
+
* // Result: 577 (1 + 64 + 512)
|
|
16
|
+
*
|
|
17
|
+
* @param options Array of classifier values to sum
|
|
18
|
+
* @returns Sum of classifier values
|
|
19
|
+
*/
|
|
20
|
+
export declare function encodeOptions(options: number[]): number;
|
|
21
|
+
/**
|
|
22
|
+
* Decodes a summed classifier value back into individual options.
|
|
23
|
+
* Uses the classifier decomposition algorithm from the specification.
|
|
24
|
+
* Automatically detects the range based on the highest bit set.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Decode months: January=1, July=64, October=512 sum to 577
|
|
28
|
+
* const decoded = decodeOptions(577);
|
|
29
|
+
* // Result: [512, 64, 1] (October, July, January)
|
|
30
|
+
*
|
|
31
|
+
* @param sum The summed classifier value to decode
|
|
32
|
+
* @returns Array of individual classifier values in descending order
|
|
33
|
+
*/
|
|
34
|
+
export declare function decodeOptions(sum: number): number[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for handling multiple classifier value options using summed
|
|
3
|
+
* classifiers as specified in the PAY by Square specification.
|
|
4
|
+
*
|
|
5
|
+
* Supports Month Classifier (Table 10) and other classifiers that use summed
|
|
6
|
+
* values.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Encodes multiple classifier options into a single number by summing their
|
|
10
|
+
* values.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Encode January + July + October months
|
|
14
|
+
* const encoded = encodeOptions([Month.January, Month.July, Month.October]);
|
|
15
|
+
* // Result: 577 (1 + 64 + 512)
|
|
16
|
+
*
|
|
17
|
+
* @param options Array of classifier values to sum
|
|
18
|
+
* @returns Sum of classifier values
|
|
19
|
+
*/
|
|
20
|
+
export function encodeOptions(options) {
|
|
21
|
+
return options.reduce((sum, option) => sum + option, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Decodes a summed classifier value back into individual options.
|
|
25
|
+
* Uses the classifier decomposition algorithm from the specification.
|
|
26
|
+
* Automatically detects the range based on the highest bit set.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Decode months: January=1, July=64, October=512 sum to 577
|
|
30
|
+
* const decoded = decodeOptions(577);
|
|
31
|
+
* // Result: [512, 64, 1] (October, July, January)
|
|
32
|
+
*
|
|
33
|
+
* @param sum The summed classifier value to decode
|
|
34
|
+
* @returns Array of individual classifier values in descending order
|
|
35
|
+
*/
|
|
36
|
+
export function decodeOptions(sum) {
|
|
37
|
+
const classifiers = [];
|
|
38
|
+
if (sum === 0)
|
|
39
|
+
return [];
|
|
40
|
+
// Find the position of the highest bit set
|
|
41
|
+
const totalOptions = Math.floor(Math.log2(sum)) + 1;
|
|
42
|
+
for (let i = 1; i <= totalOptions; i++) {
|
|
43
|
+
const next = Math.pow(2, totalOptions - i);
|
|
44
|
+
if (next <= sum) {
|
|
45
|
+
sum = sum - next;
|
|
46
|
+
classifiers.push(next);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return classifiers;
|
|
50
|
+
}
|
package/lib/crc32.d.ts
CHANGED
package/lib/crc32.js
CHANGED
|
@@ -1,58 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// for (let j = 0; j < 8; j++) {
|
|
6
|
-
// crc = (crc >>> 1) ^ (0xEDB88320 * (crc & 1));
|
|
7
|
-
// }
|
|
8
|
-
// CRC32_TABLE[i] = crc;
|
|
9
|
-
// }
|
|
10
|
-
// dprint-ignore
|
|
11
|
-
const CRC32_TABLE = [
|
|
12
|
-
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
|
13
|
-
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
|
14
|
-
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
|
15
|
-
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
|
16
|
-
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
|
17
|
-
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
|
18
|
-
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
|
19
|
-
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
|
20
|
-
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
|
|
21
|
-
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
|
22
|
-
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
|
|
23
|
-
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
|
24
|
-
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
|
|
25
|
-
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
|
26
|
-
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
|
27
|
-
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
|
28
|
-
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
|
|
29
|
-
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
|
30
|
-
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
|
|
31
|
-
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
|
32
|
-
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
|
33
|
-
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
|
34
|
-
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
|
|
35
|
-
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
|
36
|
-
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
|
37
|
-
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
|
38
|
-
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
|
|
39
|
-
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
|
40
|
-
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
|
41
|
-
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
|
42
|
-
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
|
|
43
|
-
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
|
44
|
-
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
|
|
45
|
-
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
|
46
|
-
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
|
47
|
-
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
|
48
|
-
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
|
|
49
|
-
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
|
50
|
-
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
|
|
51
|
-
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
|
52
|
-
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
|
|
53
|
-
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
|
54
|
-
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
|
55
|
-
];
|
|
1
|
+
import { CRC32_TABLE } from "lzma1";
|
|
2
|
+
/**
|
|
3
|
+
* Computes the CRC32 checksum of a given string.
|
|
4
|
+
*/
|
|
56
5
|
export function crc32(data) {
|
|
57
6
|
let crc = 0 ^ (-1);
|
|
58
7
|
const encoded = new TextEncoder().encode(data);
|
package/lib/encode.js
CHANGED
|
@@ -2,7 +2,7 @@ import { compress } from "lzma1";
|
|
|
2
2
|
import * as base32hex from "./base32hex.js";
|
|
3
3
|
import { crc32 } from "./crc32.js";
|
|
4
4
|
import { deburr } from "./deburr.js";
|
|
5
|
-
import { PaymentOptions, Version, } from "./types.js";
|
|
5
|
+
import { Month, PaymentOptions, Version, } from "./types.js";
|
|
6
6
|
import { validateDataModel } from "./validations.js";
|
|
7
7
|
export const EncodeErrorMessage = {
|
|
8
8
|
/**
|
|
@@ -134,16 +134,30 @@ export function serialize(data) {
|
|
|
134
134
|
serialized.push(ba.iban);
|
|
135
135
|
serialized.push(ba.bic);
|
|
136
136
|
}
|
|
137
|
+
// Handle standing order extension
|
|
138
|
+
// check if payment type is standing order
|
|
137
139
|
if (p.type === PaymentOptions.StandingOrder) {
|
|
138
140
|
serialized.push("1");
|
|
139
141
|
serialized.push(p.day?.toString());
|
|
140
|
-
|
|
142
|
+
// Handle month classifier
|
|
143
|
+
// check if it's a number, use it directly, otherwise convert key to number
|
|
144
|
+
const monthValue = p.month;
|
|
145
|
+
if (typeof monthValue === "string") {
|
|
146
|
+
// Convert month key to its numeric value
|
|
147
|
+
serialized.push(Month[monthValue]?.toString());
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// Use numeric value directly (already encoded classifier sum)
|
|
151
|
+
serialized.push(monthValue?.toString());
|
|
152
|
+
}
|
|
141
153
|
serialized.push(p.periodicity);
|
|
142
154
|
serialized.push(p.lastDate);
|
|
143
155
|
}
|
|
144
156
|
else {
|
|
145
157
|
serialized.push("0");
|
|
146
158
|
}
|
|
159
|
+
// Handle direct debit extension
|
|
160
|
+
// check if payment type is direct debit
|
|
147
161
|
if (p.type === PaymentOptions.DirectDebit) {
|
|
148
162
|
serialized.push("1");
|
|
149
163
|
serialized.push(p.directDebitScheme?.toString());
|
package/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright Filip Seman
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
export { decodeOptions, encodeOptions } from "./classifier.js";
|
|
6
7
|
export { decode, detect, parse } from "./decode.js";
|
|
7
8
|
export { encode, generate } from "./encode.js";
|
|
8
9
|
export { validateDataModel, ValidationErrorMessage } from "./validations.js";
|
package/lib/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright Filip Seman
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
export { decodeOptions, encodeOptions } from "./classifier.js";
|
|
6
7
|
export { decode, detect, parse } from "./decode.js";
|
|
7
8
|
export { encode, generate } from "./encode.js";
|
|
8
9
|
export { validateDataModel, ValidationErrorMessage } from "./validations.js";
|
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mapping semantic version to encoded version number, header 4-
|
|
3
|
-
*
|
|
2
|
+
* Mapping semantic version to encoded version number, header 4-bit.
|
|
4
3
|
* It's a bit silly to limit the version number to 4-bit, if they keep
|
|
5
4
|
* increasing the version number, the latest possible mapped value is 16
|
|
6
5
|
*/
|
|
@@ -58,11 +57,13 @@ export declare const Periodicity: {
|
|
|
58
57
|
};
|
|
59
58
|
export type Periodicity = typeof Periodicity[keyof typeof Periodicity];
|
|
60
59
|
/**
|
|
61
|
-
* This is the payment day. It
|
|
60
|
+
* This is the payment day. It's meaning depends on the periodicity, meaning
|
|
62
61
|
* either day of the month (number between 1 and 31) or day of the week
|
|
63
62
|
* (1=Monday,2=Tuesday, …, 7=Sunday).
|
|
64
63
|
*
|
|
65
|
-
* @
|
|
64
|
+
* @description Payment day value range from 1 to 31
|
|
65
|
+
* @minimum 1
|
|
66
|
+
* @maximum 31
|
|
66
67
|
*/
|
|
67
68
|
export type Day = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31;
|
|
68
69
|
/**
|
|
@@ -93,20 +94,23 @@ export type PaymentOptions = typeof PaymentOptions[keyof typeof PaymentOptions];
|
|
|
93
94
|
*/
|
|
94
95
|
export type BankAccount = {
|
|
95
96
|
/**
|
|
96
|
-
* Medzinárodné číslo bankového účtu vo formáte IBAN.
|
|
97
|
+
* Medzinárodné číslo bankového účtu vo formáte IBAN.
|
|
97
98
|
*
|
|
98
|
-
* @
|
|
99
|
-
* @
|
|
99
|
+
* @description International Bank Account Number in IBAN format
|
|
100
|
+
* @example "SK8209000000000011424060"
|
|
100
101
|
* @pattern [A-Z]{2}[0-9]{2}[A-Z0-9]{0,30}
|
|
102
|
+
* @minLength 15
|
|
103
|
+
* @maxLength 34
|
|
101
104
|
*/
|
|
102
105
|
iban: string;
|
|
103
106
|
/**
|
|
104
107
|
* Medzinárodný bankový identifikačný kód (z ang. Bank Identification Code).
|
|
105
108
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
109
|
+
* @description Bank Identification Code in ISO 9362 format (SWIFT)
|
|
108
110
|
* @example "TATRSKBX"
|
|
109
111
|
* @pattern [A-Z]{4}[A-Z]{2}[A-Z\d]{2}([A-Z\d]{3})?
|
|
112
|
+
* @minLength 8
|
|
113
|
+
* @maxLength 11
|
|
110
114
|
*/
|
|
111
115
|
bic?: string;
|
|
112
116
|
};
|
|
@@ -150,19 +154,22 @@ export type Beneficiary = {
|
|
|
150
154
|
/**
|
|
151
155
|
* Rozšírenie o meno príjemcu
|
|
152
156
|
*
|
|
153
|
-
* @
|
|
157
|
+
* @description Beneficiary name
|
|
158
|
+
* @maxLength 70
|
|
154
159
|
*/
|
|
155
160
|
name?: string;
|
|
156
161
|
/**
|
|
157
162
|
* Rozšírenie o adresu príjemcu
|
|
158
163
|
*
|
|
159
|
-
* @
|
|
164
|
+
* @description Beneficiary street address
|
|
165
|
+
* @maxLength 70
|
|
160
166
|
*/
|
|
161
167
|
street?: string;
|
|
162
168
|
/**
|
|
163
169
|
* Rozšírenie o adresu príjemcu (druhý riadok)
|
|
164
170
|
*
|
|
165
|
-
* @
|
|
171
|
+
* @description Beneficiary city
|
|
172
|
+
* @maxLength 70
|
|
166
173
|
*/
|
|
167
174
|
city?: string;
|
|
168
175
|
};
|
|
@@ -172,63 +179,79 @@ export type SimplePayment = {
|
|
|
172
179
|
* oddelená bodkou. Môže ostať nevyplnené, napríklad pre dobrovoľný
|
|
173
180
|
* príspevok (donations).
|
|
174
181
|
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* @
|
|
182
|
+
* @description Payment amount in decimal format
|
|
183
|
+
* @example 1000
|
|
184
|
+
* @example 1.99
|
|
185
|
+
* @example 10.5
|
|
186
|
+
* @example 0.08
|
|
187
|
+
* @minimum 0
|
|
188
|
+
* @maximum 999999999999999
|
|
180
189
|
*/
|
|
181
190
|
amount?: number;
|
|
182
191
|
/**
|
|
183
192
|
* Mena v [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) formáte (3 písmená).
|
|
184
193
|
*
|
|
194
|
+
* @description Currency code in ISO 4217 format
|
|
185
195
|
* @example "EUR"
|
|
186
196
|
* @pattern [A-Z]{3}
|
|
197
|
+
* @minLength 3
|
|
198
|
+
* @maxLength 3
|
|
187
199
|
*/
|
|
188
200
|
currencyCode: string | keyof typeof CurrencyCode;
|
|
189
201
|
/**
|
|
190
202
|
* Dátum splatnosti vo formáte [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) `"RRRR-MM-DD"`.
|
|
191
203
|
* Vprípade trvalého príkazu označuje dátum prvej platby.
|
|
192
204
|
*
|
|
193
|
-
*
|
|
205
|
+
* @description Payment due date in ISO 8601 format
|
|
206
|
+
* @format date
|
|
207
|
+
* @example "2024-12-31"
|
|
208
|
+
* @pattern \d{4}-\d{2}-\d{2}
|
|
194
209
|
*/
|
|
195
210
|
paymentDueDate?: string;
|
|
196
211
|
/**
|
|
197
212
|
* Variabilný symbol je maximálne 10 miestne číslo.
|
|
198
213
|
*
|
|
199
|
-
* @
|
|
214
|
+
* @description Variable symbol up to 10 digits
|
|
200
215
|
* @pattern [0-9]{0,10}
|
|
216
|
+
* @maxLength 10
|
|
201
217
|
*/
|
|
202
218
|
variableSymbol?: string;
|
|
203
219
|
/**
|
|
204
|
-
* Konštantný symbol je 4
|
|
220
|
+
* Konštantný symbol je 4 číselný identifikátor platby definovaný NBS.
|
|
205
221
|
*
|
|
206
|
-
* @
|
|
222
|
+
* @description Constant symbol - 4 digit payment identifier defined by NBS
|
|
207
223
|
* @pattern [0-9]{0,4}
|
|
224
|
+
* @maxLength 4
|
|
208
225
|
*/
|
|
209
226
|
constantSymbol?: string;
|
|
210
227
|
/**
|
|
211
228
|
* Špecifický symbol je maximálne 10 miestne číslo.
|
|
212
229
|
*
|
|
213
|
-
* @
|
|
230
|
+
* @description Specific symbol up to 10 digits
|
|
214
231
|
* @pattern [0-9]{0,10}
|
|
232
|
+
* @maxLength 10
|
|
215
233
|
*/
|
|
216
234
|
specificSymbol?: string;
|
|
217
235
|
/**
|
|
218
236
|
* Referenčná informácia prijímateľa podľa SEPA.
|
|
219
237
|
*
|
|
220
|
-
* @
|
|
238
|
+
* @description Originator's reference information according to SEPA
|
|
239
|
+
* @maxLength 35
|
|
221
240
|
*/
|
|
222
241
|
originatorsReferenceInformation?: string;
|
|
223
242
|
/**
|
|
224
243
|
* Správa pre prijímateľa. Údaje o platbe, na základe ktorých príjemca bude
|
|
225
244
|
* môcť platbu identifikovať.
|
|
226
245
|
*
|
|
227
|
-
* @
|
|
246
|
+
* @description Payment note for beneficiary identification
|
|
247
|
+
* @maxLength 140
|
|
228
248
|
*/
|
|
229
249
|
paymentNote?: string;
|
|
230
250
|
/**
|
|
231
251
|
* Zoznam bankových účtov.
|
|
252
|
+
*
|
|
253
|
+
* @description List of bank accounts
|
|
254
|
+
* @minItems 1
|
|
232
255
|
*/
|
|
233
256
|
bankAccounts: BankAccount[];
|
|
234
257
|
beneficiary?: Beneficiary;
|
|
@@ -242,23 +265,37 @@ export type PaymentOrder = SimplePayment & {
|
|
|
242
265
|
export type StandingOrder = SimplePayment & {
|
|
243
266
|
type: typeof PaymentOptions.StandingOrder;
|
|
244
267
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
268
|
+
* Určuje deň, v ktorom bude trvalý platobný príkaz spracovaný v určených
|
|
269
|
+
* mesiacoch.
|
|
270
|
+
*
|
|
271
|
+
* @description Payment day for standing order execution
|
|
272
|
+
* @minimum 1
|
|
273
|
+
* @maximum 31
|
|
248
274
|
*/
|
|
249
275
|
day?: number | Day;
|
|
250
276
|
/**
|
|
251
|
-
*
|
|
277
|
+
* Určuje mesiace, v ktorých sa má vykonať platba trvalého platobného
|
|
278
|
+
* príkazu.
|
|
279
|
+
*
|
|
280
|
+
* @description Months for standing order execution
|
|
281
|
+
* @example Month.January
|
|
282
|
+
* @example Month.January | Month.July | Month.October
|
|
283
|
+
* @example 577
|
|
252
284
|
*/
|
|
253
285
|
month?: keyof typeof Month | number;
|
|
254
286
|
/**
|
|
255
287
|
* Opakovanie (periodicita) trvalého príkazu.
|
|
288
|
+
*
|
|
289
|
+
* @description Standing order periodicity
|
|
256
290
|
*/
|
|
257
291
|
periodicity: keyof typeof Periodicity | string;
|
|
258
292
|
/**
|
|
259
|
-
* Dátum poslednej platby v
|
|
293
|
+
* Dátum poslednej platby v rámci trvalého platobného príkazu.
|
|
260
294
|
*
|
|
261
|
-
*
|
|
295
|
+
* @description Last payment date for standing order
|
|
296
|
+
* @format date
|
|
297
|
+
* @pattern \d{8}
|
|
298
|
+
* @example "20241231"
|
|
262
299
|
*/
|
|
263
300
|
lastDate?: string;
|
|
264
301
|
};
|
|
@@ -272,32 +309,40 @@ export type DirectDebit = SimplePayment & {
|
|
|
272
309
|
/**
|
|
273
310
|
* Identifikácia mandátu medzi veriteľom a dlžníkom podľa SEPA.
|
|
274
311
|
*
|
|
275
|
-
* @
|
|
312
|
+
* @description Mandate identification between creditor and debtor according to SEPA
|
|
313
|
+
* @maxLength 35
|
|
276
314
|
*/
|
|
277
315
|
mandateId?: string;
|
|
278
316
|
/**
|
|
279
317
|
* Identifikácia veriteľa podľa SEPA.
|
|
280
318
|
*
|
|
281
|
-
* @
|
|
319
|
+
* @description Creditor identification according to SEPA
|
|
320
|
+
* @maxLength 35
|
|
282
321
|
*/
|
|
283
322
|
creditorId?: string;
|
|
284
323
|
/**
|
|
285
324
|
* Identifikácia zmluvy medzi veriteľom a dlžníkom podľa SEPA.
|
|
286
325
|
*
|
|
287
|
-
* @
|
|
326
|
+
* @description Contract identification between creditor and debtor according to SEPA
|
|
327
|
+
* @maxLength 35
|
|
288
328
|
*/
|
|
289
329
|
contractId?: string;
|
|
290
330
|
/**
|
|
291
331
|
* Maximálna čiastka inkasa.
|
|
292
332
|
*
|
|
293
|
-
* @
|
|
333
|
+
* @description Maximum direct debit amount
|
|
334
|
+
* @minimum 0
|
|
335
|
+
* @maximum 999999999999999
|
|
294
336
|
*/
|
|
295
337
|
maxAmount?: number;
|
|
296
338
|
/**
|
|
297
339
|
* Dátum platnosti inkasa. Platnosť inkasa zaníka dňom tohto dátumu.
|
|
298
340
|
*
|
|
299
|
-
* @
|
|
300
|
-
*
|
|
341
|
+
* @description Direct debit validity date
|
|
342
|
+
* @format date
|
|
343
|
+
* @pattern \d{8}
|
|
344
|
+
* @maxLength 8
|
|
345
|
+
* @example "20241231"
|
|
301
346
|
*/
|
|
302
347
|
validTillDate?: string;
|
|
303
348
|
};
|
|
@@ -310,12 +355,16 @@ export type DataModel = {
|
|
|
310
355
|
* Číslo faktúry v prípade, že údaje sú súčasťou faktúry, alebo
|
|
311
356
|
* identifikátor pre intérne potreby vystavovateľa.
|
|
312
357
|
*
|
|
313
|
-
* @
|
|
358
|
+
* @description Invoice ID or internal identifier
|
|
359
|
+
* @maxLength 10
|
|
314
360
|
*/
|
|
315
361
|
invoiceId?: string;
|
|
316
362
|
/**
|
|
317
363
|
* Zoznam jednej alebo viacerých platieb v prípade hromadného príkazu.
|
|
318
364
|
* Hlavná (preferovaná) platba sa uvádza ako prvá.
|
|
365
|
+
*
|
|
366
|
+
* @description List of payments (preferred payment should be first)
|
|
367
|
+
* @minItems 1
|
|
319
368
|
*/
|
|
320
369
|
payments: Payment[];
|
|
321
370
|
};
|
package/lib/types.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mapping semantic version to encoded version number, header 4-
|
|
3
|
-
*
|
|
2
|
+
* Mapping semantic version to encoded version number, header 4-bit.
|
|
4
3
|
* It's a bit silly to limit the version number to 4-bit, if they keep
|
|
5
4
|
* increasing the version number, the latest possible mapped value is 16
|
|
6
5
|
*/
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "bysquare",
|
|
3
3
|
"description": "It's a national standard for payment QR codes adopted by Slovak Banking Association (SBA)",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.13.1",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"funding": "https://github.com/sponsors/xseman",
|
|
8
8
|
"homepage": "https://github.com/xseman/bysquare#readme",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"fmt": "dprint fmt",
|
|
23
23
|
"fmt:check": "dprint check",
|
|
24
24
|
"typecheck": "tsc --noEmit",
|
|
25
|
-
"test": "bun test --coverage
|
|
25
|
+
"test": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov",
|
|
26
26
|
"test:watch": "bun test --watch --coverage ."
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"lzma1": "0.
|
|
30
|
-
"validator": "^13.
|
|
29
|
+
"lzma1": "0.2.0",
|
|
30
|
+
"validator": "^13.15.15"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/bun": "^1.2.
|
|
34
|
-
"@types/node": "^24.1
|
|
33
|
+
"@types/bun": "^1.2.20",
|
|
34
|
+
"@types/node": "^24.2.1",
|
|
35
35
|
"@types/validator": "^13.15.2",
|
|
36
36
|
"dprint": "~0.50.0",
|
|
37
37
|
"typescript": "~5.8.3"
|