@networksolution/sia-vpos-node 1.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/dist/types.js ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ // ─── Configuration ────────────────────────────────────────────────────────────
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.LINK_STATUS = exports.RESULT_CODES = void 0;
5
+ // ─── Result codes ────────────────────────────────────────────────────────────
6
+ exports.RESULT_CODES = {
7
+ '00': 'Success',
8
+ '01': 'Order or ReqRefNum not found',
9
+ '02': 'ReqRefNum duplicated or not valid',
10
+ '03': 'Incorrect message format, missing or incorrect field',
11
+ '04': 'Incorrect API authentication, incorrect MAC',
12
+ '05': 'Incorrect date, or period indicated is empty',
13
+ '06': 'Unforeseen error in the circuit during processing of request',
14
+ '07': 'TransactionID not found',
15
+ '08': 'Operator indicated not found',
16
+ '09': 'TRANSACTIONID does not reference the entered ORDERID',
17
+ '10': 'Amount exceeds maximum amount permitted',
18
+ '11': 'Incorrect status. Transaction not possible in the current status',
19
+ '12': 'Circuit disabled',
20
+ '13': 'Duplicated order',
21
+ '16': 'Currency not supported or not available for the merchant',
22
+ '17': 'Exponent not supported for the chosen currency',
23
+ '20': 'VBV/SecureCode/SafeKey-enabled card, redirection needed',
24
+ '21': 'Maximum time-limit for VBV request step 2 expired',
25
+ '25': 'A call to 3DS method must be performed by the Requestor',
26
+ '26': 'A challenge flow must be initiated by the Requestor',
27
+ '35': 'No payment instrument is acceptable',
28
+ '37': 'Missing CVV2',
29
+ '38': 'Pan alias not found or revoked',
30
+ '40': 'Empty XML or missing data parameter',
31
+ '41': 'XML not parsable',
32
+ '50': 'Installments not available',
33
+ '51': 'Installment number out of bounds',
34
+ '52': 'No link found with the preset search criteria',
35
+ '98': 'Application error',
36
+ '99': 'Transaction failed, see specific outcome in Data element',
37
+ };
38
+ exports.LINK_STATUS = {
39
+ '00': 'Created',
40
+ '01': 'Returned',
41
+ '02': 'Sent',
42
+ '03': 'Used',
43
+ '04': 'Paid',
44
+ '05': 'Revoked',
45
+ };
46
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,iFAAiF;;;AAkTjF,gFAAgF;AAEnE,QAAA,YAAY,GAA2B;IAClD,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,mCAAmC;IACzC,IAAI,EAAE,sDAAsD;IAC5D,IAAI,EAAE,6CAA6C;IACnD,IAAI,EAAE,8CAA8C;IACpD,IAAI,EAAE,8DAA8D;IACpE,IAAI,EAAE,yBAAyB;IAC/B,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,sDAAsD;IAC5D,IAAI,EAAE,yCAAyC;IAC/C,IAAI,EAAE,kEAAkE;IACxE,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,0DAA0D;IAChE,IAAI,EAAE,gDAAgD;IACtD,IAAI,EAAE,yDAAyD;IAC/D,IAAI,EAAE,mDAAmD;IACzD,IAAI,EAAE,yDAAyD;IAC/D,IAAI,EAAE,qDAAqD;IAC3D,IAAI,EAAE,qCAAqC;IAC3C,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,gCAAgC;IACtC,IAAI,EAAE,qCAAqC;IAC3C,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE,kCAAkC;IACxC,IAAI,EAAE,+CAA+C;IACrD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,0DAA0D;CACjE,CAAC;AAEW,QAAA,WAAW,GAA2B;IACjD,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,SAAS;CAChB,CAAC"}
@@ -0,0 +1,425 @@
1
+ import type { VposConfig, AuthorizationRequest, CreateLinkRequest, ListLinkRequest, RevokeLinkRequest, AccountingRequest, ReverseAccountingRequest, RefundRequest, OrderStatusRequest } from './types';
2
+ /**
3
+ * Generate timestamp in yyyy-MM-ddTHH:mm:ss.SSS format
4
+ */
5
+ export declare function generateTimestamp(date?: Date): string;
6
+ /**
7
+ * Generate ReqRefNum: first 8 digits = yyyyMMdd, remaining 24 = random numeric
8
+ * Total: 32 chars numeric
9
+ */
10
+ export declare function generateReqRefNum(date?: Date): string;
11
+ export declare class VposClient {
12
+ private config;
13
+ constructor(config: VposConfig);
14
+ /** Returns true if using the test environment */
15
+ get isTest(): boolean;
16
+ /** Returns true if using the production environment */
17
+ get isProduction(): boolean;
18
+ /** Returns the current API URL */
19
+ get apiUrl(): string;
20
+ private sendRequest;
21
+ authorize(data: AuthorizationRequest): Promise<{
22
+ authorization: {
23
+ paymentType: string;
24
+ authorizationType: string;
25
+ transactionId: string;
26
+ network: string;
27
+ orderId: string;
28
+ transactionAmount: string;
29
+ authorizedAmount: string;
30
+ currency: string;
31
+ exponent: string;
32
+ accountedAmount: string;
33
+ refundedAmount: string;
34
+ transactionResult: string;
35
+ timestamp: string;
36
+ authorizationNumber: string;
37
+ acquirerBIN: string;
38
+ merchantId: string;
39
+ transactionStatus: string;
40
+ responseCodeISO: string | undefined;
41
+ panTail: string | undefined;
42
+ panExpiryDate: string | undefined;
43
+ paymentTypePP: string | undefined;
44
+ rrn: string | undefined;
45
+ cardType: string | undefined;
46
+ cardholderInfo: string | undefined;
47
+ ibanCode: string | undefined;
48
+ mac: string;
49
+ } | undefined;
50
+ panAliasData: {
51
+ panAlias: string;
52
+ panAliasRev: string;
53
+ panAliasExpDate: string;
54
+ panAliasTail: string;
55
+ cRecurr: string | undefined;
56
+ mac: string;
57
+ } | undefined;
58
+ timestamp: string;
59
+ result: string;
60
+ mac: string;
61
+ data?: string;
62
+ rawXml: string;
63
+ }>;
64
+ createLink(data: CreateLinkRequest): Promise<{
65
+ linkCreated: {
66
+ completeLink: string;
67
+ token: string;
68
+ creationDate: string;
69
+ status: string;
70
+ lastUseDate: string;
71
+ expirationDate: string;
72
+ revokeDate: string;
73
+ orderId: string;
74
+ mac: string;
75
+ } | undefined;
76
+ timestamp: string;
77
+ result: string;
78
+ mac: string;
79
+ data?: string;
80
+ rawXml: string;
81
+ }>;
82
+ listLinks(data: ListLinkRequest): Promise<{
83
+ links: {
84
+ completeLink: string;
85
+ token: string;
86
+ creationDate: string;
87
+ status: string;
88
+ lastUseDate: string;
89
+ expirationDate: string;
90
+ revokeDate: string;
91
+ orderId: string;
92
+ mac: string;
93
+ }[];
94
+ timestamp: string;
95
+ result: string;
96
+ mac: string;
97
+ data?: string;
98
+ rawXml: string;
99
+ }>;
100
+ revokeLink(data: RevokeLinkRequest): Promise<{
101
+ timestamp: string;
102
+ result: string;
103
+ mac: string;
104
+ data?: string;
105
+ rawXml: string;
106
+ }>;
107
+ accounting(data: AccountingRequest): Promise<{
108
+ operation: {
109
+ transactionId: string;
110
+ timestampReq: string;
111
+ timestampElab: string;
112
+ srcType: string;
113
+ amount: string;
114
+ result: string;
115
+ status: string;
116
+ opDescr: string | undefined;
117
+ mac: string;
118
+ authorization: {
119
+ paymentType: string;
120
+ authorizationType: string;
121
+ transactionId: string;
122
+ network: string;
123
+ orderId: string;
124
+ transactionAmount: string;
125
+ authorizedAmount: string;
126
+ currency: string;
127
+ exponent: string;
128
+ accountedAmount: string;
129
+ refundedAmount: string;
130
+ transactionResult: string;
131
+ timestamp: string;
132
+ authorizationNumber: string;
133
+ acquirerBIN: string;
134
+ merchantId: string;
135
+ transactionStatus: string;
136
+ responseCodeISO: string | undefined;
137
+ panTail: string | undefined;
138
+ panExpiryDate: string | undefined;
139
+ paymentTypePP: string | undefined;
140
+ rrn: string | undefined;
141
+ cardType: string | undefined;
142
+ cardholderInfo: string | undefined;
143
+ ibanCode: string | undefined;
144
+ mac: string;
145
+ } | undefined;
146
+ } | undefined;
147
+ timestamp: string;
148
+ result: string;
149
+ mac: string;
150
+ data?: string;
151
+ rawXml: string;
152
+ }>;
153
+ reverseAccounting(data: ReverseAccountingRequest): Promise<{
154
+ operation: {
155
+ transactionId: string;
156
+ timestampReq: string;
157
+ timestampElab: string;
158
+ srcType: string;
159
+ amount: string;
160
+ result: string;
161
+ status: string;
162
+ opDescr: string | undefined;
163
+ mac: string;
164
+ authorization: {
165
+ paymentType: string;
166
+ authorizationType: string;
167
+ transactionId: string;
168
+ network: string;
169
+ orderId: string;
170
+ transactionAmount: string;
171
+ authorizedAmount: string;
172
+ currency: string;
173
+ exponent: string;
174
+ accountedAmount: string;
175
+ refundedAmount: string;
176
+ transactionResult: string;
177
+ timestamp: string;
178
+ authorizationNumber: string;
179
+ acquirerBIN: string;
180
+ merchantId: string;
181
+ transactionStatus: string;
182
+ responseCodeISO: string | undefined;
183
+ panTail: string | undefined;
184
+ panExpiryDate: string | undefined;
185
+ paymentTypePP: string | undefined;
186
+ rrn: string | undefined;
187
+ cardType: string | undefined;
188
+ cardholderInfo: string | undefined;
189
+ ibanCode: string | undefined;
190
+ mac: string;
191
+ } | undefined;
192
+ } | undefined;
193
+ timestamp: string;
194
+ result: string;
195
+ mac: string;
196
+ data?: string;
197
+ rawXml: string;
198
+ }>;
199
+ refund(data: RefundRequest): Promise<{
200
+ operation: {
201
+ transactionId: string;
202
+ timestampReq: string;
203
+ timestampElab: string;
204
+ srcType: string;
205
+ amount: string;
206
+ result: string;
207
+ status: string;
208
+ opDescr: string | undefined;
209
+ mac: string;
210
+ authorization: {
211
+ paymentType: string;
212
+ authorizationType: string;
213
+ transactionId: string;
214
+ network: string;
215
+ orderId: string;
216
+ transactionAmount: string;
217
+ authorizedAmount: string;
218
+ currency: string;
219
+ exponent: string;
220
+ accountedAmount: string;
221
+ refundedAmount: string;
222
+ transactionResult: string;
223
+ timestamp: string;
224
+ authorizationNumber: string;
225
+ acquirerBIN: string;
226
+ merchantId: string;
227
+ transactionStatus: string;
228
+ responseCodeISO: string | undefined;
229
+ panTail: string | undefined;
230
+ panExpiryDate: string | undefined;
231
+ paymentTypePP: string | undefined;
232
+ rrn: string | undefined;
233
+ cardType: string | undefined;
234
+ cardholderInfo: string | undefined;
235
+ ibanCode: string | undefined;
236
+ mac: string;
237
+ } | undefined;
238
+ } | undefined;
239
+ timestamp: string;
240
+ result: string;
241
+ mac: string;
242
+ data?: string;
243
+ rawXml: string;
244
+ }>;
245
+ orderStatus(data: OrderStatusRequest): Promise<{
246
+ authorization: {
247
+ paymentType: string;
248
+ authorizationType: string;
249
+ transactionId: string;
250
+ network: string;
251
+ orderId: string;
252
+ transactionAmount: string;
253
+ authorizedAmount: string;
254
+ currency: string;
255
+ exponent: string;
256
+ accountedAmount: string;
257
+ refundedAmount: string;
258
+ transactionResult: string;
259
+ timestamp: string;
260
+ authorizationNumber: string;
261
+ acquirerBIN: string;
262
+ merchantId: string;
263
+ transactionStatus: string;
264
+ responseCodeISO: string | undefined;
265
+ panTail: string | undefined;
266
+ panExpiryDate: string | undefined;
267
+ paymentTypePP: string | undefined;
268
+ rrn: string | undefined;
269
+ cardType: string | undefined;
270
+ cardholderInfo: string | undefined;
271
+ ibanCode: string | undefined;
272
+ mac: string;
273
+ } | undefined;
274
+ panAliasData: {
275
+ panAlias: string;
276
+ panAliasRev: string;
277
+ panAliasExpDate: string;
278
+ panAliasTail: string;
279
+ cRecurr: string | undefined;
280
+ mac: string;
281
+ } | undefined;
282
+ timestamp: string;
283
+ result: string;
284
+ mac: string;
285
+ data?: string;
286
+ rawXml: string;
287
+ }>;
288
+ /**
289
+ * Verify the MAC of a BPWXmlResponse received from SIA (webhook/URLMS notification).
290
+ * Verifies the root-level MAC (Timestamp + Result) per spec 4.2.7.
291
+ */
292
+ verifyResponseMAC(responseXml: string): boolean;
293
+ /**
294
+ * Verify the root-level response MAC (spec 4.2.7).
295
+ * MAC = Hash(timestamp&result&secretstring) for SHA-1/MD5
296
+ * MAC = HMAC(timestamp&result, secretkey) for HMAC-256
297
+ */
298
+ verifyBPWResponseMAC(timestamp: string, result: string, receivedMac: string): boolean;
299
+ /**
300
+ * Verify the Authorization element MAC (spec 4.2.9).
301
+ * Use this for verifying authorization data in webhook responses.
302
+ */
303
+ verifyAuthorizationMAC(auth: {
304
+ authorizationType: string;
305
+ transactionId: string;
306
+ network: string;
307
+ orderId: string;
308
+ transactionAmount: string;
309
+ authorizedAmount: string;
310
+ currency: string;
311
+ accountedAmount: string;
312
+ refundedAmount?: string;
313
+ transactionResult: string;
314
+ timestamp: string;
315
+ authorizationNumber: string;
316
+ acquirerBIN: string;
317
+ merchantId: string;
318
+ transactionStatus: string;
319
+ responseCodeISO?: string;
320
+ panTail?: string;
321
+ panExpiryDate?: string;
322
+ paymentTypePP?: string;
323
+ rrn?: string;
324
+ cardType?: string;
325
+ cardholderInfo?: string;
326
+ mac: string;
327
+ }): boolean;
328
+ /**
329
+ * Parse a webhook/notification XML response and return structured data.
330
+ */
331
+ parseWebhook(responseXml: string): {
332
+ authorization: {
333
+ paymentType: string;
334
+ authorizationType: string;
335
+ transactionId: string;
336
+ network: string;
337
+ orderId: string;
338
+ transactionAmount: string;
339
+ authorizedAmount: string;
340
+ currency: string;
341
+ exponent: string;
342
+ accountedAmount: string;
343
+ refundedAmount: string;
344
+ transactionResult: string;
345
+ timestamp: string;
346
+ authorizationNumber: string;
347
+ acquirerBIN: string;
348
+ merchantId: string;
349
+ transactionStatus: string;
350
+ responseCodeISO: string | undefined;
351
+ panTail: string | undefined;
352
+ panExpiryDate: string | undefined;
353
+ paymentTypePP: string | undefined;
354
+ rrn: string | undefined;
355
+ cardType: string | undefined;
356
+ cardholderInfo: string | undefined;
357
+ ibanCode: string | undefined;
358
+ mac: string;
359
+ } | undefined;
360
+ panAliasData: {
361
+ panAlias: string;
362
+ panAliasRev: string;
363
+ panAliasExpDate: string;
364
+ panAliasTail: string;
365
+ cRecurr: string | undefined;
366
+ mac: string;
367
+ } | undefined;
368
+ operation: {
369
+ transactionId: string;
370
+ timestampReq: string;
371
+ timestampElab: string;
372
+ srcType: string;
373
+ amount: string;
374
+ result: string;
375
+ status: string;
376
+ opDescr: string | undefined;
377
+ mac: string;
378
+ authorization: {
379
+ paymentType: string;
380
+ authorizationType: string;
381
+ transactionId: string;
382
+ network: string;
383
+ orderId: string;
384
+ transactionAmount: string;
385
+ authorizedAmount: string;
386
+ currency: string;
387
+ exponent: string;
388
+ accountedAmount: string;
389
+ refundedAmount: string;
390
+ transactionResult: string;
391
+ timestamp: string;
392
+ authorizationNumber: string;
393
+ acquirerBIN: string;
394
+ merchantId: string;
395
+ transactionStatus: string;
396
+ responseCodeISO: string | undefined;
397
+ panTail: string | undefined;
398
+ panExpiryDate: string | undefined;
399
+ paymentTypePP: string | undefined;
400
+ rrn: string | undefined;
401
+ cardType: string | undefined;
402
+ cardholderInfo: string | undefined;
403
+ ibanCode: string | undefined;
404
+ mac: string;
405
+ } | undefined;
406
+ } | undefined;
407
+ linkCreated: {
408
+ completeLink: string;
409
+ token: string;
410
+ creationDate: string;
411
+ status: string;
412
+ lastUseDate: string;
413
+ expirationDate: string;
414
+ revokeDate: string;
415
+ orderId: string;
416
+ mac: string;
417
+ } | undefined;
418
+ timestamp: string;
419
+ result: string;
420
+ mac: string;
421
+ data?: string;
422
+ rawXml: string;
423
+ };
424
+ }
425
+ //# sourceMappingURL=vpos-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vpos-client.d.ts","sourceRoot":"","sources":["../src/vpos-client.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,UAAU,EAGV,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,aAAa,EACb,kBAAkB,EACnB,MAAM,SAAS,CAAC;AA0BjB;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CASrD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,C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