@misterhomer1992/miit-bot-payment 1.0.1 → 1.0.3

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 (76) hide show
  1. package/README.md +262 -146
  2. package/dist/index.d.ts +3 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -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/api.d.ts +34 -0
  29. package/dist/modules/payments/api.d.ts.map +1 -0
  30. package/dist/modules/payments/api.js +63 -0
  31. package/dist/modules/payments/api.js.map +1 -0
  32. package/dist/modules/payments/index.d.ts +6 -0
  33. package/dist/modules/payments/index.d.ts.map +1 -0
  34. package/dist/modules/payments/index.js +22 -0
  35. package/dist/modules/payments/index.js.map +1 -0
  36. package/dist/modules/payments/repository.d.ts +1 -4
  37. package/dist/modules/payments/repository.d.ts.map +1 -1
  38. package/dist/modules/payments/repository.js +46 -84
  39. package/dist/modules/payments/repository.js.map +1 -1
  40. package/dist/modules/payments/service.d.ts +96 -0
  41. package/dist/modules/payments/service.d.ts.map +1 -0
  42. package/dist/modules/payments/service.js +207 -0
  43. package/dist/modules/payments/service.js.map +1 -0
  44. package/dist/modules/payments/utils.d.ts +9 -0
  45. package/dist/modules/payments/utils.d.ts.map +1 -0
  46. package/dist/modules/payments/utils.js +7 -0
  47. package/dist/modules/payments/utils.js.map +1 -0
  48. package/dist/modules/subscription/const.d.ts +4 -0
  49. package/dist/modules/subscription/const.d.ts.map +1 -0
  50. package/dist/modules/subscription/const.js +10 -0
  51. package/dist/modules/subscription/const.js.map +1 -0
  52. package/dist/modules/subscription/index.d.ts +5 -0
  53. package/dist/modules/subscription/index.d.ts.map +1 -0
  54. package/dist/modules/subscription/index.js +23 -0
  55. package/dist/modules/subscription/index.js.map +1 -0
  56. package/dist/modules/subscription/repository.d.ts +91 -0
  57. package/dist/modules/subscription/repository.d.ts.map +1 -0
  58. package/dist/modules/subscription/repository.js +146 -0
  59. package/dist/modules/subscription/repository.js.map +1 -0
  60. package/dist/modules/subscription/service.d.ts +101 -0
  61. package/dist/modules/subscription/service.d.ts.map +1 -0
  62. package/dist/modules/subscription/service.js +205 -0
  63. package/dist/modules/subscription/service.js.map +1 -0
  64. package/dist/modules/subscription/subscriptionPlan.d.ts +4 -0
  65. package/dist/modules/subscription/subscriptionPlan.d.ts.map +1 -0
  66. package/dist/modules/subscription/subscriptionPlan.js +63 -0
  67. package/dist/modules/subscription/subscriptionPlan.js.map +1 -0
  68. package/dist/modules/subscription/types.d.ts +37 -0
  69. package/dist/modules/subscription/types.d.ts.map +1 -0
  70. package/dist/modules/subscription/types.js +3 -0
  71. package/dist/modules/subscription/types.js.map +1 -0
  72. package/dist/modules/subscription/utils.d.ts +5 -0
  73. package/dist/modules/subscription/utils.d.ts.map +1 -0
  74. package/dist/modules/subscription/utils.js +16 -0
  75. package/dist/modules/subscription/utils.js.map +1 -0
  76. package/package.json +3 -2
@@ -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: string;
9
+ processingDate: string;
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,34 @@
1
+ import { AppNamespace } from '../app/types';
2
+ /**
3
+ * Creates a payment API URL for regular purchases via Wayforpay.
4
+ * Generates a unique order reference and creates a payment URL with the provided parameters.
5
+ *
6
+ * @param params - Payment creation parameters
7
+ * @param params.userId - The unique identifier of the user making the payment
8
+ * @param params.appNamespace - The application namespace (e.g., 'app' or 'telegram')
9
+ * @param params.productName - The name of the product being purchased
10
+ * @param params.productPrice - The price of the product
11
+ * @param params.planId - The identifier of the subscription plan
12
+ * @param params.dateNext - Optional date for the next payment in the regular purchase cycle
13
+ * @param params.currency - The currency code (e.g., 'UAH', 'USD')
14
+ * @param params.regularCount - Optional number of regular payments (defaults to 3)
15
+ * @returns Promise resolving to an object containing the payment URL and order reference, or null
16
+ * @throws Error with code 'CREATE_PAYMENT_API' if the API response is invalid or missing URL
17
+ */
18
+ declare function createPaymentAPI({ userId, appNamespace, productName, productPrice, planId, dateNext, currency, regularCount, regularMode, language, }: {
19
+ userId: string;
20
+ appNamespace: AppNamespace;
21
+ productName: string;
22
+ productPrice: number;
23
+ planId: string;
24
+ dateNext?: string;
25
+ currency: string;
26
+ regularCount?: number;
27
+ regularMode?: 'daily' | 'weekly' | 'monthly' | 'yearly';
28
+ language?: string;
29
+ }): Promise<{
30
+ url: string;
31
+ orderReference: string;
32
+ } | null>;
33
+ export { createPaymentAPI };
34
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/modules/payments/api.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAS5C;;;;;;;;;;;;;;;GAeG;AACH,iBAAe,gBAAgB,CAAC,EAC5B,MAAM,EACN,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAgB,EAChB,WAAqB,EACrB,QAAe,GAClB,EAAE;IACC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAoC1D;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createPaymentAPI = createPaymentAPI;
7
+ const moment_1 = __importDefault(require("moment"));
8
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
9
+ // @ts-ignore - Package may not have type declarations
10
+ const wayforpay_api_1 = require("@misterhomer1992/wayforpay-api");
11
+ const utils_1 = require("../../utils");
12
+ const utils_2 = require("./utils");
13
+ /**
14
+ * Creates a payment API URL for regular purchases via Wayforpay.
15
+ * Generates a unique order reference and creates a payment URL with the provided parameters.
16
+ *
17
+ * @param params - Payment creation parameters
18
+ * @param params.userId - The unique identifier of the user making the payment
19
+ * @param params.appNamespace - The application namespace (e.g., 'app' or 'telegram')
20
+ * @param params.productName - The name of the product being purchased
21
+ * @param params.productPrice - The price of the product
22
+ * @param params.planId - The identifier of the subscription plan
23
+ * @param params.dateNext - Optional date for the next payment in the regular purchase cycle
24
+ * @param params.currency - The currency code (e.g., 'UAH', 'USD')
25
+ * @param params.regularCount - Optional number of regular payments (defaults to 3)
26
+ * @returns Promise resolving to an object containing the payment URL and order reference, or null
27
+ * @throws Error with code 'CREATE_PAYMENT_API' if the API response is invalid or missing URL
28
+ */
29
+ async function createPaymentAPI({ userId, appNamespace, productName, productPrice, planId, dateNext, currency, regularCount = 3, regularMode = 'daily', language = 'UA', }) {
30
+ const orderDate = Date.now();
31
+ const formattedUtc = moment_1.default.utc().toISOString();
32
+ const orderReference = (0, utils_2.createOrderReference)({
33
+ userId,
34
+ appNamespace,
35
+ planId,
36
+ utcDate: formattedUtc,
37
+ });
38
+ const response = (await (0, wayforpay_api_1.generateRegularPurchaseUrl)({
39
+ merchantAccount: process.env.WAYFORPAY_MERCHANT_ACCOUNT,
40
+ merchantDomainName: process.env.WAYFORPAY_MERCHANT_DOMAIN,
41
+ merchantSecretKey: process.env.WAYFORPAY_MERCHANT_SECRET_KEY,
42
+ orderDate,
43
+ orderReference,
44
+ productName: [productName],
45
+ productPrice: [productPrice],
46
+ currency,
47
+ language,
48
+ serviceUrl: process.env.WAYFORPAY_SERVICE_URL,
49
+ regularMode,
50
+ regularCount,
51
+ dateNext,
52
+ }));
53
+ if (!(0, utils_1.isObject)(response) || (0, utils_1.isBadOrEmptyString)(response.url)) {
54
+ throw {
55
+ code: 'CREATE_PAYMENT_API',
56
+ };
57
+ }
58
+ return {
59
+ url: response.url,
60
+ orderReference,
61
+ };
62
+ }
63
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/modules/payments/api.ts"],"names":[],"mappings":";;;;;AAyFS,4CAAgB;AAzFzB,oDAA4B;AAC5B,6DAA6D;AAC7D,sDAAsD;AACtD,kEAA4E;AAE5E,uCAA2D;AAC3D,mCAA+C;AAO/C;;;;;;;;;;;;;;;GAeG;AACH,KAAK,UAAU,gBAAgB,CAAC,EAC5B,MAAM,EACN,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAY,GAAG,CAAC,EAChB,WAAW,GAAG,OAAO,EACrB,QAAQ,GAAG,IAAI,GAYlB;IACG,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,YAAY,GAAG,gBAAM,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;IAChD,MAAM,cAAc,GAAG,IAAA,4BAAoB,EAAC;QACxC,MAAM;QACN,YAAY;QACZ,MAAM;QACN,OAAO,EAAE,YAAY;KACxB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,0CAA0B,EAAC;QAC/C,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,0BAAoC;QACjE,kBAAkB,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAmC;QACnE,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,6BAAuC;QACtE,SAAS;QACT,cAAc;QACd,WAAW,EAAE,CAAC,WAAW,CAAC;QAC1B,YAAY,EAAE,CAAC,YAAY,CAAC;QAC5B,QAAQ;QACR,QAAQ;QACR,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,qBAA+B;QACvD,WAAW;QACX,YAAY;QACZ,QAAQ;KACX,CAAC,CAAsB,CAAC;IAEzB,IAAI,CAAC,IAAA,gBAAQ,EAAC,QAAQ,CAAC,IAAI,IAAA,0BAAkB,EAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,MAAM;YACF,IAAI,EAAE,oBAAoB;SAC7B,CAAC;IACN,CAAC;IAED,OAAO;QACH,GAAG,EAAE,QAAQ,CAAC,GAAG;QACjB,cAAc;KACjB,CAAC;AACN,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './repository';
2
+ export * from './service';
3
+ export * from './types';
4
+ export * from './const';
5
+ export * from './api';
6
+ //# 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;AACxB,cAAc,OAAO,CAAC"}
@@ -0,0 +1,22 @@
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
+ __exportStar(require("./api"), exports);
22
+ //# 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;AACxB,wCAAsB"}
@@ -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
- {"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,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,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,CAAC,CAAC;YAClC,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,4CAA4C,cAAc,YAAY,IAAI,CAAC,SA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