@misterhomer1992/miit-bot-payment 1.0.0 → 1.0.2

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.
Files changed (82) hide show
  1. package/README.md +262 -146
  2. package/dist/index.d.ts +2 -7
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +2 -18
  5. package/dist/index.js.map +1 -1
  6. package/dist/modules/app/types.d.ts +2 -0
  7. package/dist/modules/app/types.d.ts.map +1 -0
  8. package/dist/modules/app/types.js +3 -0
  9. package/dist/modules/app/types.js.map +1 -0
  10. package/dist/modules/cancellableAPI/utils.d.ts +17 -0
  11. package/dist/modules/cancellableAPI/utils.d.ts.map +1 -0
  12. package/dist/modules/cancellableAPI/utils.js +43 -0
  13. package/dist/modules/cancellableAPI/utils.js.map +1 -0
  14. package/dist/modules/invoice/const.d.ts +4 -0
  15. package/dist/modules/invoice/const.d.ts.map +1 -0
  16. package/dist/modules/invoice/const.js +8 -0
  17. package/dist/modules/invoice/const.js.map +1 -0
  18. package/dist/modules/invoice/index.d.ts +5 -0
  19. package/dist/modules/invoice/index.d.ts.map +1 -0
  20. package/dist/modules/invoice/index.js +21 -0
  21. package/dist/modules/invoice/index.js.map +1 -0
  22. package/dist/modules/invoice/repository.d.ts +34 -0
  23. package/dist/modules/invoice/repository.d.ts.map +1 -0
  24. package/dist/modules/invoice/repository.js +68 -0
  25. package/dist/modules/invoice/repository.js.map +1 -0
  26. package/dist/modules/invoice/service.d.ts +29 -0
  27. package/dist/modules/invoice/service.d.ts.map +1 -0
  28. package/dist/modules/invoice/service.js +61 -0
  29. package/dist/modules/invoice/service.js.map +1 -0
  30. package/dist/modules/invoice/types.d.ts +14 -0
  31. package/dist/modules/invoice/types.d.ts.map +1 -0
  32. package/dist/modules/invoice/types.js +3 -0
  33. package/dist/modules/invoice/types.js.map +1 -0
  34. package/dist/modules/logger/types.d.ts +8 -0
  35. package/dist/modules/logger/types.d.ts.map +1 -0
  36. package/dist/modules/logger/types.js +3 -0
  37. package/dist/modules/logger/types.js.map +1 -0
  38. package/dist/modules/network/utils.d.ts +9 -0
  39. package/dist/modules/network/utils.d.ts.map +1 -0
  40. package/dist/modules/network/utils.js +20 -0
  41. package/dist/modules/network/utils.js.map +1 -0
  42. package/dist/modules/payments/const.d.ts +4 -0
  43. package/dist/modules/payments/const.d.ts.map +1 -0
  44. package/dist/modules/payments/const.js +11 -0
  45. package/dist/modules/payments/const.js.map +1 -0
  46. package/dist/modules/payments/index.d.ts +5 -0
  47. package/dist/modules/payments/index.d.ts.map +1 -0
  48. package/dist/modules/payments/index.js +21 -0
  49. package/dist/modules/payments/index.js.map +1 -0
  50. package/dist/modules/payments/repository.d.ts +82 -0
  51. package/dist/modules/payments/repository.d.ts.map +1 -0
  52. package/dist/modules/payments/repository.js +153 -0
  53. package/dist/modules/payments/repository.js.map +1 -0
  54. package/dist/modules/payments/service.d.ts +65 -0
  55. package/dist/modules/payments/service.d.ts.map +1 -0
  56. package/dist/modules/payments/service.js +132 -0
  57. package/dist/modules/payments/service.js.map +1 -0
  58. package/dist/modules/payments/types.d.ts +31 -0
  59. package/dist/modules/payments/types.d.ts.map +1 -0
  60. package/dist/modules/payments/types.js +3 -0
  61. package/dist/modules/payments/types.js.map +1 -0
  62. package/dist/modules/user/userModel.d.ts +78 -0
  63. package/dist/modules/user/userModel.d.ts.map +1 -0
  64. package/dist/modules/user/userModel.js +3 -0
  65. package/dist/modules/user/userModel.js.map +1 -0
  66. package/dist/modules/user/userRepository.d.ts +22 -0
  67. package/dist/modules/user/userRepository.d.ts.map +1 -0
  68. package/dist/modules/user/userRepository.js +47 -0
  69. package/dist/modules/user/userRepository.js.map +1 -0
  70. package/dist/types/function.d.ts +3 -0
  71. package/dist/types/function.d.ts.map +1 -0
  72. package/dist/types/function.js +3 -0
  73. package/dist/types/function.js.map +1 -0
  74. package/dist/types/utilities.d.ts +10 -0
  75. package/dist/types/utilities.d.ts.map +1 -0
  76. package/dist/types/utilities.js +3 -0
  77. package/dist/types/utilities.js.map +1 -0
  78. package/dist/utils.d.ts +10 -0
  79. package/dist/utils.d.ts.map +1 -0
  80. package/dist/utils.js +45 -0
  81. package/dist/utils.js.map +1 -0
  82. package/package.json +55 -45
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_INVOICE_ENTITY = void 0;
4
+ const DEFAULT_INVOICE_ENTITY = {
5
+ currency: 'UAH',
6
+ };
7
+ exports.DEFAULT_INVOICE_ENTITY = DEFAULT_INVOICE_ENTITY;
8
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/modules/invoice/const.ts"],"names":[],"mappings":";;;AAEA,MAAM,sBAAsB,GAA2B;IACnD,QAAQ,EAAE,KAAK;CAClB,CAAC;AAEO,wDAAsB"}
@@ -0,0 +1,5 @@
1
+ export * from './types';
2
+ export * from './repository';
3
+ export * from './service';
4
+ export * from './const';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/invoice/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./repository"), exports);
19
+ __exportStar(require("./service"), exports);
20
+ __exportStar(require("./const"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/invoice/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB"}
@@ -0,0 +1,34 @@
1
+ import { InvoiceEntity } from './types';
2
+ /**
3
+ * InvoiceRepository class handles all database operations related to invoices.
4
+ * Implements repository pattern for invoice data access.
5
+ */
6
+ declare class InvoiceRepository {
7
+ private readonly db;
8
+ private readonly collectionName;
9
+ /**
10
+ * Creates an instance of InvoiceRepository.
11
+ */
12
+ constructor();
13
+ /**
14
+ * Retrieves an invoice by its order reference.
15
+ * @param orderReference - The unique order reference identifier
16
+ * @returns Promise resolving to InvoiceEntity or null if not found
17
+ */
18
+ getByOrderReference(orderReference: string): Promise<InvoiceEntity | null>;
19
+ /**
20
+ * Creates a new invoice record in the database.
21
+ * @param invoiceData - Invoice data without ID (ID will be auto-generated)
22
+ * @returns Promise resolving to created InvoiceEntity with ID
23
+ * @throws Error if invoice creation fails
24
+ */
25
+ create(invoiceData: Omit<InvoiceEntity, 'id'>): Promise<InvoiceEntity>;
26
+ /**
27
+ * Maps a Firestore document to an InvoiceEntity.
28
+ * @param doc - Firestore document snapshot
29
+ * @returns InvoiceEntity with document ID
30
+ */
31
+ private mapDocumentToEntity;
32
+ }
33
+ export { InvoiceRepository };
34
+ //# sourceMappingURL=repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/modules/invoice/repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC;;;GAGG;AACH,cAAM,iBAAiB;IACnB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAC/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAc;IAE7C;;OAEG;;IAKH;;;;OAIG;IACU,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAevF;;;;;OAKG;IACU,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAkBnF;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;CAM9B;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvoiceRepository = void 0;
4
+ const firestore_1 = require("firebase-admin/firestore");
5
+ const const_1 = require("./const");
6
+ /**
7
+ * InvoiceRepository class handles all database operations related to invoices.
8
+ * Implements repository pattern for invoice data access.
9
+ */
10
+ class InvoiceRepository {
11
+ /**
12
+ * Creates an instance of InvoiceRepository.
13
+ */
14
+ constructor() {
15
+ this.collectionName = 'invoices';
16
+ this.db = (0, firestore_1.getFirestore)();
17
+ }
18
+ /**
19
+ * Retrieves an invoice by its order reference.
20
+ * @param orderReference - The unique order reference identifier
21
+ * @returns Promise resolving to InvoiceEntity or null if not found
22
+ */
23
+ async getByOrderReference(orderReference) {
24
+ const querySnapshot = await this.db
25
+ .collection(this.collectionName)
26
+ .where('orderReference', '==', orderReference)
27
+ .limit(1)
28
+ .get();
29
+ if (querySnapshot.empty) {
30
+ return null;
31
+ }
32
+ const doc = querySnapshot.docs[0];
33
+ return this.mapDocumentToEntity(doc);
34
+ }
35
+ /**
36
+ * Creates a new invoice record in the database.
37
+ * @param invoiceData - Invoice data without ID (ID will be auto-generated)
38
+ * @returns Promise resolving to created InvoiceEntity with ID
39
+ * @throws Error if invoice creation fails
40
+ */
41
+ async create(invoiceData) {
42
+ const invoiceEntity = {
43
+ ...const_1.DEFAULT_INVOICE_ENTITY,
44
+ ...invoiceData,
45
+ };
46
+ const docRef = await this.db.collection(this.collectionName).add(invoiceEntity);
47
+ if (!docRef.id) {
48
+ throw new Error(`Failed to create invoice for orderReference: ${invoiceData.orderReference}`);
49
+ }
50
+ return {
51
+ id: docRef.id,
52
+ ...invoiceEntity,
53
+ };
54
+ }
55
+ /**
56
+ * Maps a Firestore document to an InvoiceEntity.
57
+ * @param doc - Firestore document snapshot
58
+ * @returns InvoiceEntity with document ID
59
+ */
60
+ mapDocumentToEntity(doc) {
61
+ return {
62
+ id: doc.id,
63
+ ...doc.data(),
64
+ };
65
+ }
66
+ }
67
+ exports.InvoiceRepository = InvoiceRepository;
68
+ //# sourceMappingURL=repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/modules/invoice/repository.ts"],"names":[],"mappings":";;;AAAA,wDAA0F;AAE1F,mCAAiD;AAEjD;;;GAGG;AACH,MAAM,iBAAiB;IAInB;;OAEG;IACH;QALiB,mBAAc,GAAG,UAAU,CAAC;QAMzC,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAY,GAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,mBAAmB,CAAC,cAAsB;QACnD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,EAAE;aAC9B,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC;aAC/B,KAAK,CAAC,gBAAgB,EAAE,IAAI,EAAE,cAAc,CAAC;aAC7C,KAAK,CAAC,CAAC,CAAC;aACR,GAAG,EAAE,CAAC;QAEX,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,WAAsC;QACtD,MAAM,aAAa,GAA8B;YAC7C,GAAG,8BAAsB;YACzB,GAAG,WAAW;SACjB,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAEhF,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,gDAAgD,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC;QAClG,CAAC;QAED,OAAO;YACH,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,GAAG,aAAa;SACnB,CAAC;IACN,CAAC;IAED;;;;OAIG;IACK,mBAAmB,CAAC,GAA0B;QAClD,OAAO;YACH,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,GAAG,GAAG,CAAC,IAAI,EAAE;SACC,CAAC;IACvB,CAAC;CACJ;AAEQ,8CAAiB"}
@@ -0,0 +1,29 @@
1
+ import { Logger } from '../logger/types';
2
+ import { InvoiceEntity } from './types';
3
+ /**
4
+ * InvoiceService class handles business logic related to invoices.
5
+ * Acts as an intermediary between controllers/handlers and the repository layer.
6
+ */
7
+ export declare class InvoiceService {
8
+ private readonly logger;
9
+ private readonly repository;
10
+ /**
11
+ * Creates an instance of InvoiceService.
12
+ * @param logger - Application logger instance for logging operations
13
+ */
14
+ constructor(logger: Logger);
15
+ /**
16
+ * Creates a new invoice.
17
+ * @param invoiceData - Invoice data without ID
18
+ * @returns Promise resolving to created InvoiceEntity
19
+ * @throws Error if invoice creation fails
20
+ */
21
+ create(invoiceData: Omit<InvoiceEntity, 'id'>): Promise<InvoiceEntity>;
22
+ /**
23
+ * Retrieves an invoice by order reference.
24
+ * @param orderReference - The unique order reference identifier
25
+ * @returns Promise resolving to InvoiceEntity or null if not found
26
+ */
27
+ getByOrderReference(orderReference: string): Promise<InvoiceEntity | null>;
28
+ }
29
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/invoice/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;;GAGG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAE/C;;;OAGG;gBACS,MAAM,EAAE,MAAM;IAK1B;;;;;OAKG;IACU,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAgBnF;;;;OAIG;IACU,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;CAc1F"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvoiceService = void 0;
4
+ const repository_1 = require("./repository");
5
+ /**
6
+ * InvoiceService class handles business logic related to invoices.
7
+ * Acts as an intermediary between controllers/handlers and the repository layer.
8
+ */
9
+ class InvoiceService {
10
+ /**
11
+ * Creates an instance of InvoiceService.
12
+ * @param logger - Application logger instance for logging operations
13
+ */
14
+ constructor(logger) {
15
+ this.logger = logger;
16
+ this.repository = new repository_1.InvoiceRepository();
17
+ }
18
+ /**
19
+ * Creates a new invoice.
20
+ * @param invoiceData - Invoice data without ID
21
+ * @returns Promise resolving to created InvoiceEntity
22
+ * @throws Error if invoice creation fails
23
+ */
24
+ async create(invoiceData) {
25
+ try {
26
+ return await this.repository.create(invoiceData);
27
+ }
28
+ catch (error) {
29
+ this.logger.error({
30
+ message: 'Error in invoice service create',
31
+ payload: {
32
+ orderReference: invoiceData.orderReference,
33
+ error: JSON.stringify(error),
34
+ },
35
+ });
36
+ throw error;
37
+ }
38
+ }
39
+ /**
40
+ * Retrieves an invoice by order reference.
41
+ * @param orderReference - The unique order reference identifier
42
+ * @returns Promise resolving to InvoiceEntity or null if not found
43
+ */
44
+ async getByOrderReference(orderReference) {
45
+ try {
46
+ return await this.repository.getByOrderReference(orderReference);
47
+ }
48
+ catch (error) {
49
+ this.logger.error({
50
+ message: 'Error in invoice service getByOrderReference',
51
+ payload: {
52
+ orderReference,
53
+ error: JSON.stringify(error),
54
+ },
55
+ });
56
+ return null;
57
+ }
58
+ }
59
+ }
60
+ exports.InvoiceService = InvoiceService;
61
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/modules/invoice/service.ts"],"names":[],"mappings":";;;AACA,6CAAiD;AAGjD;;;GAGG;AACH,MAAa,cAAc;IAIvB;;;OAGG;IACH,YAAY,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,8BAAiB,EAAE,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,WAAsC;QACtD,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBACd,OAAO,EAAE,iCAAiC;gBAC1C,OAAO,EAAE;oBACL,cAAc,EAAE,WAAW,CAAC,cAAc;oBAC1C,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;iBAC/B;aACJ,CAAC,CAAC;YAEH,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,mBAAmB,CAAC,cAAsB;QACnD,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;QACrE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBACd,OAAO,EAAE,8CAA8C;gBACvD,OAAO,EAAE;oBACL,cAAc;oBACd,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;iBAC/B;aACJ,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CACJ;AAtDD,wCAsDC"}
@@ -0,0 +1,14 @@
1
+ type InvoiceEntity = {
2
+ id: string;
3
+ merchantAccount: string;
4
+ orderReference: string;
5
+ merchantSignature: string;
6
+ reasonCode: number;
7
+ reason: string;
8
+ createdDate: number;
9
+ processingDate: number;
10
+ currency: string;
11
+ amount: number;
12
+ };
13
+ export type { InvoiceEntity };
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/invoice/types.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,YAAY,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/invoice/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ interface Logger {
2
+ info: (message?: Record<string, unknown>) => void;
3
+ warning: (message?: Record<string, unknown>) => void;
4
+ error: (message?: Record<string, unknown>) => void;
5
+ debug: (message?: Record<string, unknown>) => void;
6
+ }
7
+ export { Logger };
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/logger/types.ts"],"names":[],"mappings":"AAAA,UAAU,MAAM;IACZ,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAClD,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACrD,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACnD,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACtD;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/logger/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ declare function mockTimeoutResponse({ timeout, rejectedCode, }?: {
2
+ timeout?: number;
3
+ rejectedCode?: string;
4
+ }): {
5
+ promise: Promise<never>;
6
+ cleanUp: () => void;
7
+ };
8
+ export { mockTimeoutResponse };
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/network/utils.ts"],"names":[],"mappings":"AAAA,iBAAS,mBAAmB,CAAC,EAEzB,OAAiB,EACjB,YAAiC,GACpC;;;CAAK,GAAG;IACL,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACxB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB,CAcA;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockTimeoutResponse = mockTimeoutResponse;
4
+ function mockTimeoutResponse({
5
+ // timeout = 12000,
6
+ timeout = 1002000, rejectedCode = 'RESPONSE_TIMEOUT', } = {}) {
7
+ let timeoutId;
8
+ const promise = new Promise(function (_, reject) {
9
+ timeoutId = setTimeout(() => {
10
+ reject({
11
+ code: rejectedCode,
12
+ });
13
+ }, timeout);
14
+ });
15
+ return {
16
+ promise,
17
+ cleanUp: () => clearTimeout(timeoutId),
18
+ };
19
+ }
20
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/modules/network/utils.ts"],"names":[],"mappings":";;AAuBS,kDAAmB;AAvB5B,SAAS,mBAAmB,CAAC;AACzB,mBAAmB;AACnB,OAAO,GAAG,OAAO,EACjB,YAAY,GAAG,kBAAkB,GACpC,GAAG,EAAE;IAIF,IAAI,SAAS,CAAC;IACd,MAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,UAAU,CAAC,EAAE,MAAM;QAClD,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YACxB,MAAM,CAAC;gBACH,IAAI,EAAE,YAAY;aACrB,CAAC,CAAC;QACP,CAAC,EAAE,OAAO,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO;QACH,OAAO;QACP,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC;KACzC,CAAC;AACN,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { PaymentEntity } from './types';
2
+ declare const DEFAULT_PAYMENT_ENTITY: Partial<PaymentEntity>;
3
+ export { DEFAULT_PAYMENT_ENTITY };
4
+ //# sourceMappingURL=const.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,QAAA,MAAM,sBAAsB,EAAE,OAAO,CAAC,aAAa,CAKlD,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_PAYMENT_ENTITY = void 0;
4
+ const DEFAULT_PAYMENT_ENTITY = {
5
+ status: 'pending',
6
+ provider: 'wayforpay',
7
+ platform: 'telegram',
8
+ currency: 'UAH',
9
+ };
10
+ exports.DEFAULT_PAYMENT_ENTITY = DEFAULT_PAYMENT_ENTITY;
11
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/modules/payments/const.ts"],"names":[],"mappings":";;;AAEA,MAAM,sBAAsB,GAA2B;IACnD,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,KAAK;CAClB,CAAC;AAEO,wDAAsB"}
@@ -0,0 +1,5 @@
1
+ export * from './repository';
2
+ export * from './service';
3
+ export * from './types';
4
+ export * from './const';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./repository"), exports);
18
+ __exportStar(require("./service"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ __exportStar(require("./const"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/payments/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB"}
@@ -0,0 +1,82 @@
1
+ import { FieldValue } from 'firebase-admin/firestore';
2
+ import { PaymentEntity, PaymentFieldPath } from './types';
3
+ import { AppNamespace } from '../app/types';
4
+ export type UpdateDBPaymentFields = [PaymentFieldPath, FieldValue | string | number | boolean | Date | [] | {}][];
5
+ /**
6
+ * PaymentRepository class handles all database operations related to payments.
7
+ * Implements repository pattern for payment data access.
8
+ */
9
+ export declare class PaymentRepository {
10
+ private readonly db;
11
+ private readonly collectionName;
12
+ /**
13
+ * Creates an instance of PaymentRepository.
14
+ */
15
+ constructor();
16
+ /**
17
+ * Retrieves a payment by its order reference.
18
+ * @param orderReference - The unique order reference identifier
19
+ * @returns Promise resolving to PaymentEntity or null if not found
20
+ */
21
+ getByOrderReference(orderReference: string): Promise<PaymentEntity | null>;
22
+ /**
23
+ * Retrieves all payments for a specific user.
24
+ * @param params - Query parameters
25
+ * @param params.userId - The user's unique identifier
26
+ * @param params.appNamespace - The application namespace/platform
27
+ * @param params.status - Optional payment status filter
28
+ * @returns Promise resolving to array of PaymentEntity
29
+ */
30
+ getByUserId(params: {
31
+ userId: string;
32
+ appNamespace: AppNamespace;
33
+ status?: PaymentEntity['status'];
34
+ }): Promise<PaymentEntity[]>;
35
+ /**
36
+ * Creates a new payment record in the database.
37
+ * @param paymentData - Payment data without ID (ID will be auto-generated)
38
+ * @returns Promise resolving to created PaymentEntity with ID
39
+ * @throws Error if payment creation fails
40
+ */
41
+ create(paymentData: Omit<PaymentEntity, 'id'>): Promise<PaymentEntity>;
42
+ /**
43
+ * Updates specific fields of a payment identified by order reference.
44
+ * @param params - Update parameters
45
+ * @param params.orderReference - The order reference to identify the payment
46
+ * @param params.fields - Array of field paths and values to update
47
+ * @throws Error if payment not found or update fails
48
+ */
49
+ updateFields(params: {
50
+ orderReference: string;
51
+ fields: UpdateDBPaymentFields;
52
+ }): Promise<void>;
53
+ /**
54
+ * Retrieves all pending payments that are older than specified hours.
55
+ * Used for cleaning up expired payment attempts.
56
+ * @param params - Query parameters
57
+ * @param params.hoursOld - Number of hours after which a pending payment is considered expired (default: 24)
58
+ * @returns Promise resolving to array of expired PaymentEntity
59
+ */
60
+ getExpiredPendingPayments(params?: {
61
+ hoursOld?: number;
62
+ }): Promise<PaymentEntity[]>;
63
+ /**
64
+ * Maps a Firestore document to a PaymentEntity.
65
+ * @param doc - Firestore document snapshot
66
+ * @returns PaymentEntity with document ID
67
+ */
68
+ private mapDocumentToEntity;
69
+ /**
70
+ * Builds an update object from field tuples.
71
+ * @param fields - Array of field paths and values
72
+ * @returns Object with field paths as keys and values to update
73
+ */
74
+ private buildUpdateObject;
75
+ /**
76
+ * Calculates the cutoff time for expired payments.
77
+ * @param hoursOld - Number of hours to subtract from current time
78
+ * @returns Date object representing the cutoff time
79
+ */
80
+ private calculateCutoffTime;
81
+ }
82
+ //# sourceMappingURL=repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAkD,MAAM,0BAA0B,CAAC;AACtG,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG,CAAC,gBAAgB,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AAElH;;;GAGG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAC/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAc;IAE7C;;OAEG;;IAKH;;;;OAIG;IACU,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAevF;;;;;;;OAOG;IACU,WAAW,CAAC,MAAM,EAAE;QAC7B,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,YAAY,CAAC;QAC3B,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAqB5B;;;;;OAKG;IACU,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAkBnF;;;;;;OAMG;IACU,YAAY,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,qBAAqB,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB3G;;;;;;OAMG;IACU,yBAAyB,CAClC,MAAM,GAAE;QACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;KAChB,GACP,OAAO,CAAC,aAAa,EAAE,CAAC;IAkB3B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;CAK9B"}