bysquare 1.3.3 → 2.0.0

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/lib/types.d.ts CHANGED
@@ -1,15 +1,8 @@
1
1
  /**
2
- * The bit sequence is split into 5 bit chunks which are mapped onto the
3
- * characters
4
- *
5
- * @see 3.13. Table 9 – Encoding table
2
+ * Selection of one or more months on which payment occurs. This is enabled
3
+ * only if periodicity is set to one of the following value: “Weekly,
4
+ * Biweekly, Monthly, Bimonthly”. Otherwise it must not be specified.
6
5
  */
7
- export declare const SUBST = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
8
- export declare enum PaymentOptions {
9
- PaymentOrder = 1,
10
- StandingOrder = 2,
11
- DirectDebit = 4
12
- }
13
6
  export declare enum MonthClassifier {
14
7
  January = 1,
15
8
  February = 2,
@@ -24,7 +17,13 @@ export declare enum MonthClassifier {
24
17
  November = 1024,
25
18
  December = 2048
26
19
  }
27
- export declare enum PeriodicityClassifier {
20
+ /**
21
+ * Periodicity of the payment. All valid options are „Daily“, „Weekly“,
22
+ * „Biweekly“, „Monthly“, „Bimonthly“, „Quarterly“, „Annually“,
23
+ * „Semiannually“. To find out which periodicity types are supported by the
24
+ * banks see the following web site: http://www.sbaonline.sk/sk/
25
+ */
26
+ export declare enum Periodicity {
28
27
  Daily = "d",
29
28
  Weekly = "w",
30
29
  Biweekly = "b",
@@ -34,294 +33,187 @@ export declare enum PeriodicityClassifier {
34
33
  Semiannually = "s",
35
34
  Annually = "a"
36
35
  }
37
- export declare enum DirectDebitType {
38
- OneOff = 0,
39
- Recurrent = 1
36
+ /**
37
+ * This is the payment day. It‘s meaning depends on the periodicity, meaning
38
+ * either day of the month (number between 1 and 31) or day of the week
39
+ * (1=Monday,2=Tuesday, …, 7=Sunday).
40
+ *
41
+ * Max length 2
42
+ */
43
+ 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;
44
+ export declare enum PaymentOptions {
45
+ PaymentOrder = 1,
46
+ StandingOrder = 2,
47
+ DirectDebit = 4
40
48
  }
49
+ /**
50
+ * In section „encoding BankAccounts“ we provide further recommendations for
51
+ * encoding bank account
52
+ */
53
+ export type BankAccount = {
54
+ /**
55
+ * Max length 34
56
+ */
57
+ iban: string;
58
+ /**
59
+ * Format ISO 9362 (swift)
60
+ * 8 or 11 characters long
61
+ */
62
+ bic?: string;
63
+ };
64
+ /**
65
+ * If DirectDebitScheme value is 1, which is „SEPA“ than encoded direct
66
+ * debit follows SEPA direct debit scheme which means that fields MandateID,
67
+ * CreditorID and optional ContractID are used. If direct debit scheme is 0,
68
+ * which is „OTHER“ this means no specific direct debit scheme and following
69
+ * rules do apply:
70
+ *
71
+ * a. Creditor is identified via bank accounts
72
+ *
73
+ * b. Contract between debtor and creditor is identified using one of the
74
+ * following two ways: 1. by two optional fields SpecificSymbol and
75
+ * VariableSymbol. 2. by one optional field OriginatorsReferenceInformation.
76
+ * If SpecificSymbol and VariableSymbol fields or
77
+ * OriginatorsReferenceInformation field is filled in DirectDebitExt then
78
+ * these fields do apply for the direct debit.
79
+ */
41
80
  export declare enum DirectDebitScheme {
42
81
  Other = 0,
43
82
  Sepa = 1
44
83
  }
45
84
  /**
46
- * Table 15. PAY by square sequence data model (page 30.)
85
+ * Can be „one­off“ for one time debit or „recurrent“ for repeated debit
86
+ * until cancelled.
87
+ *
88
+ * Max length 1
47
89
  */
48
- export interface Model {
90
+ export declare enum DirectDebitType {
91
+ OneOff = 0,
92
+ Recurrent = 1
93
+ }
94
+ export type Beneficiary = {
49
95
  /**
50
- * Max length 10
96
+ * Belongs to the N-th payment
97
+ *
98
+ * Max length 70
51
99
  */
52
- InvoiceID?: string;
100
+ name?: string;
53
101
  /**
54
- * Appendix E extended beneficiary fields
55
- * Table 16 PAY by square extended fields for bulk payment order
102
+ * Belongs to the N-th payment
103
+ * Commonly used street and street number
56
104
  *
57
- * Number of payments
105
+ * Max length 70
58
106
  */
59
- Payments: number;
107
+ street?: string;
60
108
  /**
61
- * Max length 1
109
+ * Belongs to the N-th payment
110
+ * Commonly used for City
111
+ *
112
+ * Max length 70
62
113
  */
63
- PaymentOptions: PaymentOptions;
114
+ city?: string;
115
+ };
116
+ export type SimplePayment = {
64
117
  /**
65
118
  * Encoded with amount payable. This field is not required and can be left
66
119
  * blank in cases payment amount is not known ­such as donations.
67
120
  *
68
121
  * Decimal, max length 15
69
122
  */
70
- Amount?: number;
123
+ amount?: number;
71
124
  /**
72
- * 3 letter, payment currency code according to ISO 4217
125
+ * 3 letter, payment currency code according to ISO-4217
73
126
  */
74
- CurrencyCode: keyof typeof CurrencyCode;
127
+ currencyCode: keyof typeof CurrencyCodeEnum;
75
128
  /**
76
129
  * Format YYYYMMDD
77
130
  */
78
- PaymentDueDate?: string;
131
+ paymentDueDate?: string;
79
132
  /**
80
133
  * Max length 10
81
134
  */
82
- VariableSymbol?: string;
135
+ variableSymbol?: string;
83
136
  /**
84
137
  * Max length 4
85
138
  */
86
- ConstantSymbol?: string;
139
+ constantSymbol?: string;
87
140
  /**
88
141
  * Max length 10
89
142
  */
90
- SpecificSymbol?: string;
143
+ specificSymbol?: string;
91
144
  /**
92
145
  * Max length 35
93
146
  */
94
- OriginatorsReferenceInformation?: string;
147
+ originatorRefInfo?: string;
95
148
  /**
96
149
  * Optional field. In previous section we provide further recommendations
97
150
  * for encoding payment note.
98
151
  *
99
152
  * Max length 140
100
153
  */
101
- PaymentNote?: string;
102
- /**
103
- * In section „encoding BankAccounts“ we provide further recommendations for
104
- * encoding bank account
105
- */
106
- BankAccounts: number;
107
- /**
108
- * Max length 34
109
- */
110
- IBAN: string;
111
- /**
112
- * Format ISO 9362, 8 or 11 characters long
113
- *
114
- * Max length 11
115
- */
116
- BIC?: string;
117
- /**
118
- * Max length 1
119
- */
120
- StandingOrderExt?: 0 | 1;
121
- /**
122
- * This is the payment day. It‘s meaning depends on the periodicity, meaning
123
- * either day of the month (number between 1 and 31) or day of the week
124
- * (1=Monday,2=Tuesday, …, 7=Sunday).
125
- *
126
- * Max length 2
127
- * */
128
- Day?: number;
129
- /**
130
- * Selection of one or more months on which payment occurs. This is enabled
131
- * only if periodicity is set to one of the following value: “Weekly,
132
- * Biweekly, Monthly, Bimonthly”. Otherwise it must not be specified.
133
- *
134
- * Max length 4
135
- */
136
- Month?: MonthClassifier;
137
- /**
138
- * Periodicity of the payment. All valid options are „Daily“, „Weekly“,
139
- * „Biweekly“, „Monthly“, „Bimonthly“, „Quarterly“, „Annually“,
140
- * „Semiannually“. To find out which periodicity types are supported by the
141
- * banks see the following web site: http://www.sbaonline.sk/sk/
142
- *
143
- * Max length 1
144
- */
145
- Periodicity?: PeriodicityClassifier;
154
+ paymentNote?: string;
155
+ bankAccounts: BankAccount[];
156
+ beneficiary?: Beneficiary;
157
+ };
158
+ export type PaymentOrder = SimplePayment & {
159
+ type: PaymentOptions.PaymentOrder;
160
+ };
161
+ export type StandingOrder = SimplePayment & {
162
+ type: PaymentOptions.StandingOrder;
163
+ day?: Day;
164
+ month?: MonthClassifier;
165
+ periodicity?: Periodicity;
146
166
  /**
147
167
  * Defines the day of the last payment of the standing order. After this
148
168
  * date, standing order is cancelled.
149
169
  *
150
170
  * Format YYYYMMDD
151
171
  */
152
- LastDate?: string;
153
- /**
154
- * Max length 1
155
- */
156
- DirectDebitExt?: 0 | 1;
157
- /**
158
- * If DirectDebitScheme value is 1, which is „SEPA“ than encoded direct
159
- * debit follows SEPA direct debit scheme which means that fields MandateID,
160
- * CreditorID and optional ContractID are used. If direct debit scheme is 0,
161
- * which is „OTHER“ this means no specific direct debit scheme and following
162
- * rules do apply:
163
- *
164
- * a. Creditor is identified via bank accounts
165
- *
166
- * b. Contract between debtor and creditor is identified using one of the
167
- * following two ways: 1. by two optional fields SpecificSymbol and
168
- * VariableSymbol. 2. by one optional field OriginatorsReferenceInformation.
169
- * If SpecificSymbol and VariableSymbol fields or
170
- * OriginatorsReferenceInformation field is filled in DirectDebitExt then
171
- * these fields do apply for the direct debit.
172
- *
173
- * Max length 1
174
- */
175
- DirectDebitScheme?: DirectDebitScheme;
176
- /**
177
- * Can be „one­off“ for one time debit or „recurrent“ for repeated debit
178
- * until cancelled.
179
- *
180
- * Max length 1
181
- */
182
- DirectDebitType?: DirectDebitType;
183
- /**
184
- * Max length 10
185
- */
186
- VariableSymbol_?: string;
187
- /**
188
- * Max length 10
189
- */
190
- SpecificSymbol_?: string;
191
- /**
192
- * Max length 35
193
- */
194
- OriginatorsReferenceInformation_?: string;
172
+ lastDate?: string;
173
+ };
174
+ export type DirectDebit = SimplePayment & {
175
+ type: PaymentOptions.DirectDebit;
176
+ directDebitScheme?: DirectDebitScheme;
177
+ directDebitType?: DirectDebitType;
195
178
  /**
196
179
  * Max length 35
197
180
  */
198
- MandateID?: string;
181
+ mandateId?: string;
199
182
  /**
200
183
  * Max length 35
201
184
  */
202
- CreditorID?: string;
185
+ creditorId?: string;
203
186
  /**
204
187
  * Max length 35
205
188
  */
206
- ContractID?: string;
189
+ contractId?: string;
207
190
  /**
208
191
  * Optional field. As most users prefer to set up some maximum amount for
209
192
  * the direct debit, this can be pre­-filled for them.
210
193
  *
211
194
  * Decimal, max length 15
212
195
  */
213
- MaxAmount?: number;
196
+ maxAmount?: number;
214
197
  /**
215
198
  * Defines the day after which direct debit is cancelled.
216
199
  *
217
200
  * Max length 8
218
201
  * Format YYYYMMDD
219
202
  */
220
- ValidTillDate?: string;
203
+ validTillDate?: string;
204
+ };
205
+ export type Payment = PaymentOrder | StandingOrder | DirectDebit;
206
+ export type DataModel = {
221
207
  /**
222
- * Belongs to the first payment
223
- *
224
- * Max length 70
225
- */
226
- BeneficiaryName?: string;
227
- /**
228
- * Belongs to the first payment
229
- *
230
- * Max length 70
231
- */
232
- BeneficiaryAddressLine1?: string;
233
- /**
234
- * Belongs to the first payment
235
- *
236
- * Max length 70
208
+ * Max length 10
237
209
  */
238
- BeneficiaryAddressLine2?: string;
239
- }
240
- export interface ParsedModel {
241
- invoiceId: Model["InvoiceID"];
242
- payments: Array<{
243
- amount: Model["Amount"];
244
- currencyCode: Model["CurrencyCode"];
245
- paymentDueDate?: Model["PaymentDueDate"];
246
- variableSymbol?: Model["VariableSymbol"];
247
- constantSymbol?: Model["ConstantSymbol"];
248
- specificSymbol?: Model["SpecificSymbol"];
249
- originatorsReferenceInformation?: Model["OriginatorsReferenceInformation"];
250
- paymentNote?: Model["PaymentNote"];
251
- bankAccounts: Array<{
252
- iban: Model["IBAN"];
253
- bic?: Model["BIC"];
254
- }>;
255
- standingOrder?: {
256
- day?: Model["Day"];
257
- month?: Model["Month"];
258
- periodicity?: Model["Periodicity"];
259
- lastDate?: Model["LastDate"];
260
- };
261
- directDebit?: {
262
- directDebitScheme?: Model["DirectDebitScheme"];
263
- directDebitType?: Model["DirectDebitType"];
264
- variableSymbol?: Model["VariableSymbol"];
265
- specificSymbol?: Model["SpecificSymbol"];
266
- originatorsReferenceInformation?: Model["OriginatorsReferenceInformation_"];
267
- mandateId?: Model["MandateID"];
268
- creditorId?: Model["CreditorID"];
269
- contractId?: Model["ContractID"];
270
- maxAmount?: Model["MaxAmount"];
271
- validTillDate?: Model["ValidTillDate"];
272
- };
273
- beneficiary?: {
274
- name?: Model["BeneficiaryName"];
275
- addressLine1?: Model["BeneficiaryAddressLine1"];
276
- addressLine2?: Model["BeneficiaryAddressLine2"];
277
- };
278
- }>;
279
- }
280
- /**
281
- * Atributes must follow specific order
282
- * Based on Table 15. PAY by square sequence data model (page 30.)
283
- *
284
- * @see{./docs/specification_v1.1.0.pdf}
285
- */
286
- export declare enum SequenceOrder {
287
- InvoiceID = 0,
288
- Payments = 1,
289
- PaymentOptions = 2,
290
- Amount = 3,
291
- CurrencyCode = 4,
292
- PaymentDueDate = 5,
293
- VariableSymbol = 6,
294
- ConstantSymbol = 7,
295
- SpecificSymbol = 8,
296
- OriginatorsReferenceInformation = 9,
297
- PaymentNote = 10,
298
- BankAccounts = 11,
299
- IBAN = 12,
300
- BIC = 13,
301
- StandingOrderExt = 14,
302
- Day = 15,
303
- Month = 16,
304
- Periodicity = 17,
305
- LastDate = 18,
306
- DirectDebitExt = 19,
307
- DirectDebitScheme = 20,
308
- DirectDebitType = 21,
309
- VariableSymbol_ = 22,
310
- SpecificSymbol_ = 23,
311
- OriginatorsReferenceInformation_ = 24,
312
- MandateID = 25,
313
- CreditorID = 26,
314
- ContractID = 27,
315
- MaxAmount = 28,
316
- ValidTillDate = 29,
317
- BeneficiaryName = 30,
318
- BeneficiaryAddressLine1 = 31,
319
- BeneficiaryAddressLine2 = 32
320
- }
210
+ invoiceId?: string;
211
+ payments: Payment[];
212
+ };
321
213
  /**
322
- * Currency codes based on ISO 4217
214
+ * Currency codes based on ISO-4217
323
215
  */
324
- export declare enum CurrencyCode {
216
+ export declare enum CurrencyCodeEnum {
325
217
  AED = "United Arab Emirates Dirham",
326
218
  AFN = "Afghanistan Afghani",
327
219
  ALL = "Albania Lek",