@misterhomer1992/miit-bot-payment 1.0.1 → 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 (40) hide show
  1. package/README.md +262 -146
  2. package/dist/index.d.ts +2 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +2 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/modules/invoice/const.d.ts +4 -0
  7. package/dist/modules/invoice/const.d.ts.map +1 -0
  8. package/dist/modules/invoice/const.js +8 -0
  9. package/dist/modules/invoice/const.js.map +1 -0
  10. package/dist/modules/invoice/index.d.ts +5 -0
  11. package/dist/modules/invoice/index.d.ts.map +1 -0
  12. package/dist/modules/invoice/index.js +21 -0
  13. package/dist/modules/invoice/index.js.map +1 -0
  14. package/dist/modules/invoice/repository.d.ts +34 -0
  15. package/dist/modules/invoice/repository.d.ts.map +1 -0
  16. package/dist/modules/invoice/repository.js +68 -0
  17. package/dist/modules/invoice/repository.js.map +1 -0
  18. package/dist/modules/invoice/service.d.ts +29 -0
  19. package/dist/modules/invoice/service.d.ts.map +1 -0
  20. package/dist/modules/invoice/service.js +61 -0
  21. package/dist/modules/invoice/service.js.map +1 -0
  22. package/dist/modules/invoice/types.d.ts +14 -0
  23. package/dist/modules/invoice/types.d.ts.map +1 -0
  24. package/dist/modules/invoice/types.js +3 -0
  25. package/dist/modules/invoice/types.js.map +1 -0
  26. package/dist/modules/logger/types.d.ts +4 -4
  27. package/dist/modules/logger/types.d.ts.map +1 -1
  28. package/dist/modules/payments/index.d.ts +5 -0
  29. package/dist/modules/payments/index.d.ts.map +1 -0
  30. package/dist/modules/payments/index.js +21 -0
  31. package/dist/modules/payments/index.js.map +1 -0
  32. package/dist/modules/payments/repository.d.ts +1 -4
  33. package/dist/modules/payments/repository.d.ts.map +1 -1
  34. package/dist/modules/payments/repository.js +46 -84
  35. package/dist/modules/payments/repository.js.map +1 -1
  36. package/dist/modules/payments/service.d.ts +65 -0
  37. package/dist/modules/payments/service.d.ts.map +1 -0
  38. package/dist/modules/payments/service.js +132 -0
  39. package/dist/modules/payments/service.js.map +1 -0
  40. package/package.json +1 -1
@@ -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":""}
@@ -1,8 +1,8 @@
1
1
  interface Logger {
2
- info: (message: string) => void;
3
- warning: (message: string) => void;
4
- error: (message: string) => void;
5
- debug: (message: string) => void;
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
6
  }
7
7
  export { Logger };
8
8
  //# sourceMappingURL=types.d.ts.map
@@ -1 +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,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
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,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"}
@@ -1,21 +1,18 @@
1
1
  import { FieldValue } from 'firebase-admin/firestore';
2
2
  import { PaymentEntity, PaymentFieldPath } from './types';
3
3
  import { AppNamespace } from '../app/types';
4
- import { Logger } from '../logger/types';
5
4
  export type UpdateDBPaymentFields = [PaymentFieldPath, FieldValue | string | number | boolean | Date | [] | {}][];
6
5
  /**
7
6
  * PaymentRepository class handles all database operations related to payments.
8
7
  * Implements repository pattern for payment data access.
9
8
  */
10
9
  export declare class PaymentRepository {
11
- private readonly logger;
12
10
  private readonly db;
13
11
  private readonly collectionName;
14
12
  /**
15
13
  * Creates an instance of PaymentRepository.
16
- * @param logger - Application logger instance for logging operations
17
14
  */
18
- constructor(logger: Logger);
15
+ constructor();
19
16
  /**
20
17
  * Retrieves a payment by its order reference.
21
18
  * @param orderReference - The unique order reference identifier
@@ -1 +1 @@
1
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,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"}
@@ -10,11 +10,9 @@ const const_1 = require("./const");
10
10
  class PaymentRepository {
11
11
  /**
12
12
  * Creates an instance of PaymentRepository.
13
- * @param logger - Application logger instance for logging operations
14
13
  */
15
- constructor(logger) {
14
+ constructor() {
16
15
  this.collectionName = 'payments';
17
- this.logger = logger;
18
16
  this.db = (0, firestore_1.getFirestore)();
19
17
  }
20
18
  /**
@@ -23,23 +21,16 @@ class PaymentRepository {
23
21
  * @returns Promise resolving to PaymentEntity or null if not found
24
22
  */
25
23
  async getByOrderReference(orderReference) {
26
- try {
27
- const querySnapshot = await this.db
28
- .collection(this.collectionName)
29
- .where('orderReference', '==', orderReference)
30
- .limit(1)
31
- .get();
32
- if (querySnapshot.empty) {
33
- this.logger.info(`Payment not found for orderReference: ${orderReference}`);
34
- return null;
35
- }
36
- const doc = querySnapshot.docs[0];
37
- return this.mapDocumentToEntity(doc);
38
- }
39
- catch (error) {
40
- this.logger.error(`Error getting payment by orderReference: ${orderReference}. Error: ${JSON.stringify(error)}`);
24
+ const querySnapshot = await this.db
25
+ .collection(this.collectionName)
26
+ .where('orderReference', '==', orderReference)
27
+ .limit(1)
28
+ .get();
29
+ if (querySnapshot.empty) {
41
30
  return null;
42
31
  }
32
+ const doc = querySnapshot.docs[0];
33
+ return this.mapDocumentToEntity(doc);
43
34
  }
44
35
  /**
45
36
  * Retrieves all payments for a specific user.
@@ -51,25 +42,18 @@ class PaymentRepository {
51
42
  */
52
43
  async getByUserId(params) {
53
44
  const { userId, appNamespace, status } = params;
54
- try {
55
- let query = this.db
56
- .collection(this.collectionName)
57
- .where('platform', '==', appNamespace)
58
- .where('userId', '==', userId);
59
- if (status) {
60
- query = query.where('status', '==', status);
61
- }
62
- const querySnapshot = await query.get();
63
- if (querySnapshot.empty) {
64
- this.logger.info(`No payments found for userId: ${userId}, appNamespace: ${appNamespace}`);
65
- return [];
66
- }
67
- return querySnapshot.docs.map((doc) => this.mapDocumentToEntity(doc));
45
+ let query = this.db
46
+ .collection(this.collectionName)
47
+ .where('platform', '==', appNamespace)
48
+ .where('userId', '==', userId);
49
+ if (status) {
50
+ query = query.where('status', '==', status);
68
51
  }
69
- catch (error) {
70
- this.logger.error(`Error getting payments by userId: ${userId}. Error: ${JSON.stringify(error)}`);
52
+ const querySnapshot = await query.get();
53
+ if (querySnapshot.empty) {
71
54
  return [];
72
55
  }
56
+ return querySnapshot.docs.map((doc) => this.mapDocumentToEntity(doc));
73
57
  }
74
58
  /**
75
59
  * Creates a new payment record in the database.
@@ -78,25 +62,18 @@ class PaymentRepository {
78
62
  * @throws Error if payment creation fails
79
63
  */
80
64
  async create(paymentData) {
81
- try {
82
- const paymentEntity = {
83
- ...const_1.DEFAULT_PAYMENT_ENTITY,
84
- ...paymentData,
85
- };
86
- const docRef = await this.db.collection(this.collectionName).add(paymentEntity);
87
- if (!docRef.id) {
88
- throw new Error(`Failed to create payment for orderReference: ${paymentData.orderReference}`);
89
- }
90
- this.logger.info(`Payment created successfully with ID: ${docRef.id}, orderReference: ${paymentData.orderReference}`);
91
- return {
92
- id: docRef.id,
93
- ...paymentEntity,
94
- };
95
- }
96
- catch (error) {
97
- this.logger.error(`Error creating payment for orderReference: ${paymentData.orderReference}. Error: ${JSON.stringify(error)}`);
98
- throw error;
65
+ const paymentEntity = {
66
+ ...const_1.DEFAULT_PAYMENT_ENTITY,
67
+ ...paymentData,
68
+ };
69
+ const docRef = await this.db.collection(this.collectionName).add(paymentEntity);
70
+ if (!docRef.id) {
71
+ throw new Error(`Failed to create payment for orderReference: ${paymentData.orderReference}`);
99
72
  }
73
+ return {
74
+ id: docRef.id,
75
+ ...paymentEntity,
76
+ };
100
77
  }
101
78
  /**
102
79
  * Updates specific fields of a payment identified by order reference.
@@ -107,23 +84,16 @@ class PaymentRepository {
107
84
  */
108
85
  async updateFields(params) {
109
86
  const { orderReference, fields } = params;
110
- try {
111
- const updateObject = this.buildUpdateObject(fields);
112
- const querySnapshot = await this.db
113
- .collection(this.collectionName)
114
- .where('orderReference', '==', orderReference)
115
- .limit(1)
116
- .get();
117
- if (querySnapshot.empty) {
118
- throw new Error(`Payment not found for orderReference: ${orderReference}`);
119
- }
120
- await querySnapshot.docs[0].ref.update(updateObject);
121
- this.logger.info(`Payment updated successfully for orderReference: ${orderReference}`);
122
- }
123
- catch (error) {
124
- this.logger.error(`Error updating payment for orderReference: ${orderReference}. Error: ${JSON.stringify(error)}`);
125
- throw error;
87
+ const updateObject = this.buildUpdateObject(fields);
88
+ const querySnapshot = await this.db
89
+ .collection(this.collectionName)
90
+ .where('orderReference', '==', orderReference)
91
+ .limit(1)
92
+ .get();
93
+ if (querySnapshot.empty) {
94
+ throw new Error(`Payment not found for orderReference: ${orderReference}`);
126
95
  }
96
+ await querySnapshot.docs[0].ref.update(updateObject);
127
97
  }
128
98
  /**
129
99
  * Retrieves all pending payments that are older than specified hours.
@@ -134,24 +104,16 @@ class PaymentRepository {
134
104
  */
135
105
  async getExpiredPendingPayments(params = {}) {
136
106
  const { hoursOld = 24 } = params;
137
- try {
138
- const cutoffTime = this.calculateCutoffTime(hoursOld);
139
- const querySnapshot = await this.db
140
- .collection(this.collectionName)
141
- .where('status', '==', 'pending')
142
- .where('createdAt', '<', cutoffTime.toISOString())
143
- .get();
144
- if (querySnapshot.empty) {
145
- this.logger.info(`No expired pending payments found (older than ${hoursOld} hours)`);
146
- return [];
147
- }
148
- this.logger.info(`Found ${querySnapshot.docs.length} expired pending payments`);
149
- return querySnapshot.docs.map((doc) => this.mapDocumentToEntity(doc));
150
- }
151
- catch (error) {
152
- this.logger.error(`Error getting expired pending payments. Error: ${JSON.stringify(error)}`);
107
+ const cutoffTime = this.calculateCutoffTime(hoursOld);
108
+ const querySnapshot = await this.db
109
+ .collection(this.collectionName)
110
+ .where('status', '==', 'pending')
111
+ .where('createdAt', '<', cutoffTime.toISOString())
112
+ .get();
113
+ if (querySnapshot.empty) {
153
114
  return [];
154
115
  }
116
+ return querySnapshot.docs.map((doc) => this.mapDocumentToEntity(doc));
155
117
  }
156
118
  /**
157
119
  * Maps a Firestore document to a PaymentEntity.
@@ -1 +1 @@
1
- {"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/modules/payments/repository.ts"],"names":[],"mappings":";;;AAAA,wDAAsG;AAEtG,mCAAiD;AAMjD;;;GAGG;AACH,MAAa,iBAAiB;IAK1B;;;OAGG;IACH,YAAY,MAAc;QANT,mBAAc,GAAG,UAAU,CAAC;QAOzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAY,GAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,mBAAmB,CAAC,cAAsB;QACnD,IAAI,CAAC;YACD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,EAAE;iBAC9B,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC;iBAC/B,KAAK,CAAC,gBAAgB,EAAE,IAAI,EAAE,cAAc,CAAC;iBAC7C,KAAK,CAAC,CAAC,CAAC;iBACR,GAAG,EAAE,CAAC;YAEX,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;gBACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yCAAyC,cAAc,EAAE,CAAC,CAAC;gBAC5E,OAAO,IAAI,CAAC;YAChB,CAAC;YAED,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAA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PaymentEntity } from './types';
4
+ import { AppNamespace } from '../app/types';
5
+ /**
6
+ * PaymentService class handles business logic related to payments.
7
+ * Acts as an intermediary between controllers/handlers and the repository layer.
8
+ */
9
+ export declare class PaymentService {
10
+ private readonly logger;
11
+ private readonly repository;
12
+ /**
13
+ * Creates an instance of PaymentService.
14
+ * @param logger - Application logger instance for logging operations
15
+ */
16
+ constructor(logger: Logger);
17
+ /**
18
+ * Retrieves a payment by its order reference.
19
+ * @param orderReference - The unique order reference identifier
20
+ * @returns Promise resolving to PaymentEntity or null if not found
21
+ */
22
+ getByOrderReference(orderReference: string): Promise<PaymentEntity | null>;
23
+ /**
24
+ * Retrieves all payments for a specific user.
25
+ * @param params - Query parameters
26
+ * @param params.userId - The user's unique identifier
27
+ * @param params.appNamespace - The application namespace/platform
28
+ * @param params.status - Optional payment status filter
29
+ * @returns Promise resolving to array of PaymentEntity
30
+ */
31
+ getByUserId(params: {
32
+ userId: string;
33
+ appNamespace: AppNamespace;
34
+ status?: PaymentEntity['status'];
35
+ }): Promise<PaymentEntity[]>;
36
+ /**
37
+ * Creates a new payment record in the database.
38
+ * @param paymentData - Payment data without ID (ID will be auto-generated)
39
+ * @returns Promise resolving to created PaymentEntity with ID
40
+ * @throws Error if payment creation fails
41
+ */
42
+ create(paymentData: Omit<PaymentEntity, 'id'>): Promise<PaymentEntity>;
43
+ /**
44
+ * Updates specific fields of a payment identified by order reference.
45
+ * @param params - Update parameters
46
+ * @param params.orderReference - The order reference to identify the payment
47
+ * @param params.fields - Array of field paths and values to update
48
+ * @throws Error if payment not found or update fails
49
+ */
50
+ updateFields(params: {
51
+ orderReference: string;
52
+ fields: UpdateDBPaymentFields;
53
+ }): Promise<void>;
54
+ /**
55
+ * Retrieves all pending payments that are older than specified hours.
56
+ * Used for cleaning up expired payment attempts.
57
+ * @param params - Query parameters
58
+ * @param params.hoursOld - Number of hours after which a pending payment is considered expired (default: 24)
59
+ * @returns Promise resolving to array of expired PaymentEntity
60
+ */
61
+ getExpiredPendingPayments(params?: {
62
+ hoursOld?: number;
63
+ }): Promise<PaymentEntity[]>;
64
+ }
65
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAqB,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;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;;;;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;IAiB5B;;;;;OAKG;IACU,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAiBnF;;;;;;OAMG;IACU,YAAY,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,qBAAqB,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB3G;;;;;;OAMG;IACU,yBAAyB,CAClC,MAAM,GAAE;QACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;KAChB,GACP,OAAO,CAAC,aAAa,EAAE,CAAC;CAc9B"}