nestjs-monobank 1.2.8

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 (250) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +18 -0
  3. package/dist/common/enums/discount.enum.d.ts +24 -0
  4. package/dist/common/enums/discount.enum.js +2 -0
  5. package/dist/common/enums/index.d.ts +1 -0
  6. package/dist/common/enums/index.js +17 -0
  7. package/dist/common/interfaces/common.interface.d.ts +177 -0
  8. package/dist/common/interfaces/common.interface.js +2 -0
  9. package/dist/common/interfaces/index.d.ts +2 -0
  10. package/dist/common/interfaces/index.js +18 -0
  11. package/dist/common/interfaces/monobank-options.interface.d.ts +15 -0
  12. package/dist/common/interfaces/monobank-options.interface.js +4 -0
  13. package/dist/core/config/monobank.constants.d.ts +1 -0
  14. package/dist/core/config/monobank.constants.js +4 -0
  15. package/dist/core/http/monobank.error.d.ts +6 -0
  16. package/dist/core/http/monobank.error.js +13 -0
  17. package/dist/core/http/monobank.http-client.d.ts +16 -0
  18. package/dist/core/http/monobank.http-client.js +66 -0
  19. package/dist/core/http/monobank.interceptor.d.ts +2 -0
  20. package/dist/core/http/monobank.interceptor.js +19 -0
  21. package/dist/index.d.ts +3 -0
  22. package/dist/index.js +19 -0
  23. package/dist/modules/invoice/enums/cancel-status.enum.d.ts +18 -0
  24. package/dist/modules/invoice/enums/cancel-status.enum.js +22 -0
  25. package/dist/modules/invoice/enums/charge-status.enum.d.ts +14 -0
  26. package/dist/modules/invoice/enums/charge-status.enum.js +18 -0
  27. package/dist/modules/invoice/enums/index.d.ts +3 -0
  28. package/dist/modules/invoice/enums/index.js +19 -0
  29. package/dist/modules/invoice/enums/invoice-status.enum.d.ts +34 -0
  30. package/dist/modules/invoice/enums/invoice-status.enum.js +38 -0
  31. package/dist/modules/invoice/interfaces/index.d.ts +2 -0
  32. package/dist/modules/invoice/interfaces/index.js +18 -0
  33. package/dist/modules/invoice/interfaces/requests/create-cancel.request.d.ts +22 -0
  34. package/dist/modules/invoice/interfaces/requests/create-cancel.request.js +2 -0
  35. package/dist/modules/invoice/interfaces/requests/create-charge.request.d.ts +42 -0
  36. package/dist/modules/invoice/interfaces/requests/create-charge.request.js +2 -0
  37. package/dist/modules/invoice/interfaces/requests/create-finalize.request.d.ts +19 -0
  38. package/dist/modules/invoice/interfaces/requests/create-finalize.request.js +2 -0
  39. package/dist/modules/invoice/interfaces/requests/create-invoice.request.d.ts +88 -0
  40. package/dist/modules/invoice/interfaces/requests/create-invoice.request.js +2 -0
  41. package/dist/modules/invoice/interfaces/requests/index.d.ts +4 -0
  42. package/dist/modules/invoice/interfaces/requests/index.js +20 -0
  43. package/dist/modules/invoice/interfaces/responses/cancel.response.d.ts +18 -0
  44. package/dist/modules/invoice/interfaces/responses/cancel.response.js +2 -0
  45. package/dist/modules/invoice/interfaces/responses/charge.response.d.ts +35 -0
  46. package/dist/modules/invoice/interfaces/responses/charge.response.js +2 -0
  47. package/dist/modules/invoice/interfaces/responses/create-cancel.response.d.ts +7 -0
  48. package/dist/modules/invoice/interfaces/responses/create-cancel.response.js +2 -0
  49. package/dist/modules/invoice/interfaces/responses/create-charge.response.d.ts +7 -0
  50. package/dist/modules/invoice/interfaces/responses/create-charge.response.js +2 -0
  51. package/dist/modules/invoice/interfaces/responses/create-finalize.response.d.ts +7 -0
  52. package/dist/modules/invoice/interfaces/responses/create-finalize.response.js +2 -0
  53. package/dist/modules/invoice/interfaces/responses/create-invoice.response.d.ts +7 -0
  54. package/dist/modules/invoice/interfaces/responses/create-invoice.response.js +2 -0
  55. package/dist/modules/invoice/interfaces/responses/finalize.response.d.ts +9 -0
  56. package/dist/modules/invoice/interfaces/responses/finalize.response.js +2 -0
  57. package/dist/modules/invoice/interfaces/responses/fiscal-checks.response.d.ts +42 -0
  58. package/dist/modules/invoice/interfaces/responses/fiscal-checks.response.js +2 -0
  59. package/dist/modules/invoice/interfaces/responses/index.d.ts +9 -0
  60. package/dist/modules/invoice/interfaces/responses/index.js +25 -0
  61. package/dist/modules/invoice/interfaces/responses/invoice-status.response.d.ts +116 -0
  62. package/dist/modules/invoice/interfaces/responses/invoice-status.response.js +2 -0
  63. package/dist/modules/invoice/interfaces/responses/invoice.response.d.ts +13 -0
  64. package/dist/modules/invoice/interfaces/responses/invoice.response.js +2 -0
  65. package/dist/modules/invoice/interfaces/responses/receipt.response.d.ts +6 -0
  66. package/dist/modules/invoice/interfaces/responses/receipt.response.js +2 -0
  67. package/dist/modules/invoice/invoice.module.d.ts +2 -0
  68. package/dist/modules/invoice/invoice.module.js +20 -0
  69. package/dist/modules/invoice/invoice.service.d.ts +154 -0
  70. package/dist/modules/invoice/invoice.service.js +187 -0
  71. package/dist/modules/merchant/interfaces/index.d.ts +1 -0
  72. package/dist/modules/merchant/interfaces/index.js +17 -0
  73. package/dist/modules/merchant/interfaces/responses/index.d.ts +2 -0
  74. package/dist/modules/merchant/interfaces/responses/index.js +18 -0
  75. package/dist/modules/merchant/interfaces/responses/merchant.response.d.ts +17 -0
  76. package/dist/modules/merchant/interfaces/responses/merchant.response.js +2 -0
  77. package/dist/modules/merchant/interfaces/responses/pubkey.response.d.ts +10 -0
  78. package/dist/modules/merchant/interfaces/responses/pubkey.response.js +2 -0
  79. package/dist/modules/merchant/merchant.module.d.ts +2 -0
  80. package/dist/modules/merchant/merchant.module.js +20 -0
  81. package/dist/modules/merchant/merchant.service.d.ts +36 -0
  82. package/dist/modules/merchant/merchant.service.js +58 -0
  83. package/dist/modules/qr/enums/amount-type.enum.d.ts +11 -0
  84. package/dist/modules/qr/enums/amount-type.enum.js +15 -0
  85. package/dist/modules/qr/enums/index.d.ts +1 -0
  86. package/dist/modules/qr/enums/index.js +17 -0
  87. package/dist/modules/qr/interfaces/index.d.ts +0 -0
  88. package/dist/modules/qr/interfaces/index.js +0 -0
  89. package/dist/modules/qr/interfaces/responses/index.d.ts +2 -0
  90. package/dist/modules/qr/interfaces/responses/index.js +18 -0
  91. package/dist/modules/qr/interfaces/responses/list.response.d.ts +8 -0
  92. package/dist/modules/qr/interfaces/responses/list.response.js +2 -0
  93. package/dist/modules/qr/interfaces/responses/qr.response.d.ts +14 -0
  94. package/dist/modules/qr/interfaces/responses/qr.response.js +2 -0
  95. package/dist/modules/qr/qr.module.d.ts +2 -0
  96. package/dist/modules/qr/qr.module.js +20 -0
  97. package/dist/modules/qr/qr.service.d.ts +32 -0
  98. package/dist/modules/qr/qr.service.js +56 -0
  99. package/dist/modules/statement/interfaces/index.d.ts +1 -0
  100. package/dist/modules/statement/interfaces/index.js +17 -0
  101. package/dist/modules/statement/interfaces/responses/index.d.ts +1 -0
  102. package/dist/modules/statement/interfaces/responses/index.js +17 -0
  103. package/dist/modules/statement/interfaces/responses/statement.response.d.ts +99 -0
  104. package/dist/modules/statement/interfaces/responses/statement.response.js +2 -0
  105. package/dist/modules/statement/statement.module.d.ts +2 -0
  106. package/dist/modules/statement/statement.module.js +20 -0
  107. package/dist/modules/statement/statement.service.d.ts +17 -0
  108. package/dist/modules/statement/statement.service.js +38 -0
  109. package/dist/modules/subscription/enums/index.d.ts +2 -0
  110. package/dist/modules/subscription/enums/index.js +18 -0
  111. package/dist/modules/subscription/enums/subscription-status.enum.d.ts +13 -0
  112. package/dist/modules/subscription/enums/subscription-status.enum.js +17 -0
  113. package/dist/modules/subscription/enums/wallet-status.enum.d.ts +17 -0
  114. package/dist/modules/subscription/enums/wallet-status.enum.js +21 -0
  115. package/dist/modules/subscription/interfaces/index.d.ts +2 -0
  116. package/dist/modules/subscription/interfaces/index.js +18 -0
  117. package/dist/modules/subscription/interfaces/requests/client-subscriptions.request.d.ts +26 -0
  118. package/dist/modules/subscription/interfaces/requests/client-subscriptions.request.js +2 -0
  119. package/dist/modules/subscription/interfaces/requests/create-subscription.request.d.ts +32 -0
  120. package/dist/modules/subscription/interfaces/requests/create-subscription.request.js +2 -0
  121. package/dist/modules/subscription/interfaces/requests/edit-subscription.request.d.ts +18 -0
  122. package/dist/modules/subscription/interfaces/requests/edit-subscription.request.js +2 -0
  123. package/dist/modules/subscription/interfaces/requests/history.request.d.ts +15 -0
  124. package/dist/modules/subscription/interfaces/requests/history.request.js +2 -0
  125. package/dist/modules/subscription/interfaces/requests/index.d.ts +4 -0
  126. package/dist/modules/subscription/interfaces/requests/index.js +20 -0
  127. package/dist/modules/subscription/interfaces/responses/client-subscriptions.response.d.ts +27 -0
  128. package/dist/modules/subscription/interfaces/responses/client-subscriptions.response.js +2 -0
  129. package/dist/modules/subscription/interfaces/responses/create-subscription.response.d.ts +5 -0
  130. package/dist/modules/subscription/interfaces/responses/create-subscription.response.js +2 -0
  131. package/dist/modules/subscription/interfaces/responses/history.response.d.ts +9 -0
  132. package/dist/modules/subscription/interfaces/responses/history.response.js +2 -0
  133. package/dist/modules/subscription/interfaces/responses/index.d.ts +5 -0
  134. package/dist/modules/subscription/interfaces/responses/index.js +21 -0
  135. package/dist/modules/subscription/interfaces/responses/subscription-status.response.d.ts +29 -0
  136. package/dist/modules/subscription/interfaces/responses/subscription-status.response.js +2 -0
  137. package/dist/modules/subscription/interfaces/responses/subscription.response.d.ts +9 -0
  138. package/dist/modules/subscription/interfaces/responses/subscription.response.js +2 -0
  139. package/dist/modules/subscription/subscription.module.d.ts +2 -0
  140. package/dist/modules/subscription/subscription.module.js +20 -0
  141. package/dist/modules/subscription/subscription.service.d.ts +91 -0
  142. package/dist/modules/subscription/subscription.service.js +121 -0
  143. package/dist/modules/wallet/interfaces/index.d.ts +2 -0
  144. package/dist/modules/wallet/interfaces/index.js +18 -0
  145. package/dist/modules/wallet/interfaces/requests/create-card-token.request.d.ts +42 -0
  146. package/dist/modules/wallet/interfaces/requests/create-card-token.request.js +2 -0
  147. package/dist/modules/wallet/interfaces/requests/index.d.ts +1 -0
  148. package/dist/modules/wallet/interfaces/requests/index.js +17 -0
  149. package/dist/modules/wallet/interfaces/responses/card-token.response.d.ts +37 -0
  150. package/dist/modules/wallet/interfaces/responses/card-token.response.js +2 -0
  151. package/dist/modules/wallet/interfaces/responses/create-card-token.response.d.ts +7 -0
  152. package/dist/modules/wallet/interfaces/responses/create-card-token.response.js +2 -0
  153. package/dist/modules/wallet/interfaces/responses/index.d.ts +2 -0
  154. package/dist/modules/wallet/interfaces/responses/index.js +18 -0
  155. package/dist/modules/wallet/wallet.module.d.ts +2 -0
  156. package/dist/modules/wallet/wallet.module.js +20 -0
  157. package/dist/modules/wallet/wallet.service.d.ts +54 -0
  158. package/dist/modules/wallet/wallet.service.js +78 -0
  159. package/dist/modules/webhook/webhook.module.d.ts +2 -0
  160. package/dist/modules/webhook/webhook.module.js +24 -0
  161. package/dist/modules/webhook/webhook.service.d.ts +44 -0
  162. package/dist/modules/webhook/webhook.service.js +72 -0
  163. package/dist/monobank.module.d.ts +36 -0
  164. package/dist/monobank.module.js +117 -0
  165. package/dist/monobank.service.d.ts +17 -0
  166. package/dist/monobank.service.js +42 -0
  167. package/package.json +68 -0
  168. package/src/common/enums/discount.enum.ts +26 -0
  169. package/src/common/enums/index.ts +1 -0
  170. package/src/common/interfaces/common.interface.ts +206 -0
  171. package/src/common/interfaces/index.ts +2 -0
  172. package/src/common/interfaces/monobank-options.interface.ts +18 -0
  173. package/src/core/config/monobank.constants.ts +1 -0
  174. package/src/core/http/monobank.error.ts +10 -0
  175. package/src/core/http/monobank.http-client.ts +66 -0
  176. package/src/core/http/monobank.interceptor.ts +24 -0
  177. package/src/index.ts +3 -0
  178. package/src/modules/invoice/enums/cancel-status.enum.ts +20 -0
  179. package/src/modules/invoice/enums/charge-status.enum.ts +16 -0
  180. package/src/modules/invoice/enums/index.ts +3 -0
  181. package/src/modules/invoice/enums/invoice-status.enum.ts +40 -0
  182. package/src/modules/invoice/interfaces/index.ts +2 -0
  183. package/src/modules/invoice/interfaces/requests/create-cancel.request.ts +26 -0
  184. package/src/modules/invoice/interfaces/requests/create-charge.request.ts +52 -0
  185. package/src/modules/invoice/interfaces/requests/create-finalize.request.ts +22 -0
  186. package/src/modules/invoice/interfaces/requests/create-invoice.request.ts +103 -0
  187. package/src/modules/invoice/interfaces/requests/index.ts +4 -0
  188. package/src/modules/invoice/interfaces/responses/cancel.response.ts +21 -0
  189. package/src/modules/invoice/interfaces/responses/charge.response.ts +43 -0
  190. package/src/modules/invoice/interfaces/responses/create-cancel.response.ts +7 -0
  191. package/src/modules/invoice/interfaces/responses/create-charge.response.ts +7 -0
  192. package/src/modules/invoice/interfaces/responses/create-finalize.response.ts +7 -0
  193. package/src/modules/invoice/interfaces/responses/create-invoice.response.ts +7 -0
  194. package/src/modules/invoice/interfaces/responses/finalize.response.ts +9 -0
  195. package/src/modules/invoice/interfaces/responses/fiscal-checks.response.ts +49 -0
  196. package/src/modules/invoice/interfaces/responses/index.ts +10 -0
  197. package/src/modules/invoice/interfaces/responses/invoice-status.response.ts +142 -0
  198. package/src/modules/invoice/interfaces/responses/invoice.response.ts +14 -0
  199. package/src/modules/invoice/interfaces/responses/receipt.response.ts +6 -0
  200. package/src/modules/invoice/invoice.module.ts +8 -0
  201. package/src/modules/invoice/invoice.service.ts +191 -0
  202. package/src/modules/merchant/interfaces/index.ts +1 -0
  203. package/src/modules/merchant/interfaces/responses/index.ts +2 -0
  204. package/src/modules/merchant/interfaces/responses/merchant.response.ts +19 -0
  205. package/src/modules/merchant/interfaces/responses/pubkey.response.ts +10 -0
  206. package/src/modules/merchant/merchant.module.ts +8 -0
  207. package/src/modules/merchant/merchant.service.ts +46 -0
  208. package/src/modules/qr/enums/amount-type.enum.ts +13 -0
  209. package/src/modules/qr/enums/index.ts +1 -0
  210. package/src/modules/qr/interfaces/index.ts +0 -0
  211. package/src/modules/qr/interfaces/responses/index.ts +2 -0
  212. package/src/modules/qr/interfaces/responses/list.response.ts +11 -0
  213. package/src/modules/qr/interfaces/responses/qr.response.ts +18 -0
  214. package/src/modules/qr/qr.module.ts +8 -0
  215. package/src/modules/qr/qr.service.ts +43 -0
  216. package/src/modules/statement/interfaces/index.ts +1 -0
  217. package/src/modules/statement/interfaces/responses/index.ts +1 -0
  218. package/src/modules/statement/interfaces/responses/statement.response.ts +119 -0
  219. package/src/modules/statement/statement.module.ts +8 -0
  220. package/src/modules/statement/statement.service.ts +25 -0
  221. package/src/modules/subscription/enums/index.ts +2 -0
  222. package/src/modules/subscription/enums/subscription-status.enum.ts +14 -0
  223. package/src/modules/subscription/enums/wallet-status.enum.ts +19 -0
  224. package/src/modules/subscription/interfaces/index.ts +2 -0
  225. package/src/modules/subscription/interfaces/requests/client-subscriptions.request.ts +31 -0
  226. package/src/modules/subscription/interfaces/requests/create-subscription.request.ts +38 -0
  227. package/src/modules/subscription/interfaces/requests/edit-subscription.request.ts +20 -0
  228. package/src/modules/subscription/interfaces/requests/history.request.ts +20 -0
  229. package/src/modules/subscription/interfaces/requests/index.ts +4 -0
  230. package/src/modules/subscription/interfaces/responses/client-subscriptions.response.ts +36 -0
  231. package/src/modules/subscription/interfaces/responses/create-subscription.response.ts +6 -0
  232. package/src/modules/subscription/interfaces/responses/history.response.ts +12 -0
  233. package/src/modules/subscription/interfaces/responses/index.ts +5 -0
  234. package/src/modules/subscription/interfaces/responses/subscription-status.response.ts +40 -0
  235. package/src/modules/subscription/interfaces/responses/subscription.response.ts +11 -0
  236. package/src/modules/subscription/subscription.module.ts +8 -0
  237. package/src/modules/subscription/subscription.service.ts +121 -0
  238. package/src/modules/wallet/interfaces/index.ts +2 -0
  239. package/src/modules/wallet/interfaces/requests/create-card-token.request.ts +50 -0
  240. package/src/modules/wallet/interfaces/requests/index.ts +1 -0
  241. package/src/modules/wallet/interfaces/responses/card-token.response.ts +44 -0
  242. package/src/modules/wallet/interfaces/responses/create-card-token.response.ts +7 -0
  243. package/src/modules/wallet/interfaces/responses/index.ts +2 -0
  244. package/src/modules/wallet/wallet.module.ts +8 -0
  245. package/src/modules/wallet/wallet.service.ts +71 -0
  246. package/src/modules/webhook/webhook.module.ts +12 -0
  247. package/src/modules/webhook/webhook.service.ts +60 -0
  248. package/src/monobank.module.ts +115 -0
  249. package/src/monobank.service.ts +21 -0
  250. package/tsconfig.json +18 -0
@@ -0,0 +1,43 @@
1
+ import { Injectable } from "@nestjs/common";
2
+ import { MonobankHttpClient } from "../../core/http/monobank.http-client";
3
+ import type { ListResponse, QrResponse } from "./interfaces/responses";
4
+
5
+ @Injectable()
6
+ export class QrService {
7
+ public constructor(public readonly http: MonobankHttpClient) {}
8
+
9
+ /**
10
+ * Отримує список усіх QR-кас мерчанта.
11
+ * @returns {Promise<ListResponse>} Список QR-кас.
12
+ * @example
13
+ * const qrList = await this.monobankService.qr.getList();
14
+ * console.log(qrList.list);
15
+ */
16
+ public async getList(): Promise<ListResponse> {
17
+ return this.http.get("/merchant/qr/list");
18
+ }
19
+
20
+ /**
21
+ * Отримує деталі конкретної QR-каси.
22
+ * @param {string} qrId - Ідентифікатор QR-каси, яку потрібно отримати.
23
+ * @returns {Promise<QrResponse>} Деталі QR-каси.
24
+ * @example
25
+ * const qrDetails = await this.monobankService.qr.getDetails('123456');
26
+ * console.log(qrDetails.pageUrl);
27
+ */
28
+ public async getDetails(qrId: string): Promise<QrResponse> {
29
+ return this.http.get(`/merchant/qr/details?qrId=${qrId}`);
30
+ }
31
+
32
+ /**
33
+ * Видаляє суму оплати конкретної QR-каси.
34
+ * @param {string} qrId - Ідентифікатор QR-каси, для якої потрібно скинути суму.
35
+ * @returns {Promise<void>} Порожня відповідь при успішному видаленні суми.
36
+ * @example
37
+ * await this.monobankService.qr.resetAmount('XJ_DiM4rTd5V');
38
+ * console.log('Суму було видалено');
39
+ */
40
+ public async resetAmount(qrId: string): Promise<void> {
41
+ return this.http.post(`/merchant/qr/reset-amount`, { qrId });
42
+ }
43
+ }
@@ -0,0 +1 @@
1
+ export * from './responses'
@@ -0,0 +1 @@
1
+ export * from './statement.response'
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Інформація про скасований платіж у виписці.
3
+ */
4
+ export interface StatmentCancelItem {
5
+ /**
6
+ * Сума скасованої транзакції в мінімальних одиницях.
7
+ */
8
+ amount: number;
9
+
10
+ /**
11
+ * ISO 4217 код валюти.
12
+ */
13
+ ccy: number;
14
+
15
+ /**
16
+ * Дата скасування транзакції або null, якщо відсутня.
17
+ */
18
+ date: string | null;
19
+
20
+ /**
21
+ * Код авторизації транзакції.
22
+ */
23
+ approvalCode: string;
24
+
25
+ /**
26
+ * RRN (Retrieval Reference Number) транзакції.
27
+ */
28
+ rrn: string;
29
+
30
+ /**
31
+ * Маскований номер картки.
32
+ */
33
+ maskedPan: string;
34
+ }
35
+
36
+ /**
37
+ * Запис про транзакцію у виписці.
38
+ */
39
+ export interface StatementItem {
40
+ /**
41
+ * Ідентифікатор рахунку (invoice).
42
+ */
43
+ invoiceId: string;
44
+
45
+ /**
46
+ * Поточний статус транзакції.
47
+ */
48
+ status: string;
49
+
50
+ /**
51
+ * Маскований номер картки.
52
+ */
53
+ maskedPan: string;
54
+
55
+ /**
56
+ * Дата транзакції або null, якщо відсутня.
57
+ */
58
+ date: string | null;
59
+
60
+ /**
61
+ * Платіжна система (Visa, Mastercard тощо) або null.
62
+ */
63
+ paymentScheme: string | null;
64
+
65
+ /**
66
+ * Сума транзакції в мінімальних одиницях.
67
+ */
68
+ amount: number;
69
+
70
+ /**
71
+ * Сума доходу (прибутку) від транзакції.
72
+ */
73
+ profitAmount: number;
74
+
75
+ /**
76
+ * ISO 4217 код валюти.
77
+ */
78
+ ccy: number;
79
+
80
+ /**
81
+ * Код авторизації транзакції.
82
+ */
83
+ approvalCode: string;
84
+
85
+ /**
86
+ * RRN (Retrieval Reference Number) транзакції.
87
+ */
88
+ rrn: string;
89
+
90
+ /**
91
+ * Референс мерчанта або внутрішній ідентифікатор.
92
+ */
93
+ reference: string;
94
+
95
+ /**
96
+ * Короткий ідентифікатор QR-коду, пов’язаний з транзакцією.
97
+ */
98
+ shortQrId: string;
99
+
100
+ /**
101
+ * Призначення платежу або опис транзакції.
102
+ */
103
+ destination: string;
104
+
105
+ /**
106
+ * Список скасувань, пов’язаних з цією транзакцією.
107
+ */
108
+ cancelList: StatmentCancelItem[];
109
+ }
110
+
111
+ /**
112
+ * Виписка з рахунку, що містить список транзакцій.
113
+ */
114
+ export interface StatementResponse {
115
+ /**
116
+ * Список транзакцій у виписці.
117
+ */
118
+ list: StatementItem[];
119
+ }
@@ -0,0 +1,8 @@
1
+ import { Module } from "@nestjs/common";
2
+ import { StatementService } from "./statement.service";
3
+
4
+ @Module({
5
+ providers: [StatementService],
6
+ exports: [StatementService],
7
+ })
8
+ export class StatementModule {}
@@ -0,0 +1,25 @@
1
+ import { Injectable } from "@nestjs/common";
2
+ import { MonobankHttpClient } from "../../core/http/monobank.http-client";
3
+ import type { StatementResponse } from "./interfaces";
4
+
5
+ @Injectable()
6
+ export class StatementService {
7
+ public constructor(
8
+ private readonly http: MonobankHttpClient
9
+ ) {}
10
+
11
+ /**
12
+ * Отримує виписки по рахунках за заданий період.
13
+ * @param {string} account - Ідентифікатор рахунку (наприклад, номер картки). 0 — основний рахунок в UAH.
14
+ * @param {string} from - Початковий час періоду в форматі Unix time (секунди).
15
+ * @param {string} [to] - Кінцевий час періоду в форматі Unix time (секунди). Якщо не вказано, використовується поточний час.
16
+ * @returns {Promise<StatementResponse>} Список операцій за період.
17
+ * @example
18
+ * const statement = await this.monobankService.statement.getStatementByPeriod('0', '1680000000', '1681000000');
19
+ * console.log(statement.items);
20
+ */
21
+ public async getStatementByPeriod(account: string, from: string, to?: string): Promise<StatementResponse> {
22
+ const url = to ? `/merchant/statement/${account}/${from}/${to}` : `/merchant/statement/${account}/${from}`;
23
+ return this.http.get("get", url);
24
+ }
25
+ }
@@ -0,0 +1,2 @@
1
+ export * from './wallet-status.enum'
2
+ export * from './subscription-status.enum'
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Статуси підписки.
3
+ */
4
+ export enum SubscriptionStatusEnum {
5
+ /**
6
+ * Підписка активна.
7
+ */
8
+ ACTIVE = 'active',
9
+
10
+ /**
11
+ * Підписка скасована.
12
+ */
13
+ CANCELLED = 'cancelled',
14
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Статуси кошика.
3
+ */
4
+ export enum WalletStatusEnum {
5
+ /**
6
+ * Кошик новостворений.
7
+ */
8
+ NEW = 'new',
9
+
10
+ /**
11
+ * Кошик успішно створений.
12
+ */
13
+ SUCCESS = 'success',
14
+
15
+ /**
16
+ * Кошик не успішно створений.
17
+ */
18
+ FAILED = 'failed',
19
+ }
@@ -0,0 +1,2 @@
1
+ export * from './requests'
2
+ export * from './responses'
@@ -0,0 +1,31 @@
1
+ import type { SubscriptionStatusEnum } from "../../enums";
2
+
3
+ /**
4
+ * Запит на отримання списку підписок клієнта.
5
+ */
6
+ export interface ClientSubscriptionsRequest {
7
+ /**
8
+ * Статус підписки.
9
+ */
10
+ status?: SubscriptionStatusEnum;
11
+
12
+ /**
13
+ * Кількість підписок на сторінку.
14
+ */
15
+ limit?: number;
16
+
17
+ /**
18
+ * Номер сторінки.
19
+ */
20
+ page?: number;
21
+
22
+ /**
23
+ * Дата початку періоду.
24
+ */
25
+ dateFrom: string;
26
+
27
+ /**
28
+ * Дата кінця періоду.
29
+ */
30
+ dateTo?: string;
31
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Запит на створення підписки (регулярного платежу).
3
+ */
4
+ export interface CreateSubscriptionRequest {
5
+ /**
6
+ * Сума регулярного платежу у мінімальних одиницях валюти
7
+ */
8
+ amount: number;
9
+
10
+ /**
11
+ * ISO 4217 код валюти (за замовчуванням 980 — гривня)
12
+ */
13
+ ccy?: number;
14
+
15
+ /**
16
+ * Періодичність списання: 1d, 2w, 1m, 1y
17
+ */
18
+ interval: string;
19
+
20
+ /**
21
+ * Строк дії інвойса у секундах (макс. 30 днів)
22
+ */
23
+ validity?: number;
24
+
25
+ /**
26
+ * URL для повернення користувача після оплати
27
+ */
28
+ redirectUrl?: string;
29
+
30
+ /**
31
+ * Webhook-и для подій підписки
32
+ */
33
+ webhookUrls?: {
34
+ chargeUrl?: string;
35
+ statusUrl?: string;
36
+ };
37
+ }
38
+
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Запит на зміну (скасування) підписки
3
+ */
4
+ export interface EditSubscriptionRequest {
5
+ /**
6
+ * Ідентифікатор підписки
7
+ */
8
+ subscriptionId: string;
9
+
10
+ /**
11
+ * Дія над підпискою
12
+ */
13
+ action: 'cancel';
14
+
15
+ /**
16
+ * Сума для повернення у мінімальних одиницях валюти
17
+ * Якщо не передано, повернення коштів не виконується
18
+ */
19
+ refundAmount?: number;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Запит на отримання історії платежів за підпискою
3
+ */
4
+ export interface HistoryRequest {
5
+ /** Ідентифікатор підписки */
6
+ subscriptionId: string;
7
+
8
+ /** Кількість отриманих платежів (дефолт 20) */
9
+ limit?: number;
10
+
11
+ /** Номер сторінки / зміщення (дефолт 1) */
12
+ page?: number;
13
+
14
+ /** Дата від (RFC3339) */
15
+ dateFrom: string;
16
+
17
+ /** Дата до (RFC3339) */
18
+ dateTo?: string;
19
+ }
20
+
@@ -0,0 +1,4 @@
1
+ export * from './create-subscription.request'
2
+ export * from './edit-subscription.request'
3
+ export * from './history.request'
4
+ export * from './client-subscriptions.request'
@@ -0,0 +1,36 @@
1
+ import type { PaginatedResponse } from "../../../../common/interfaces";
2
+ import type { SubscriptionStatusEnum } from "../../enums";
3
+
4
+ /**
5
+ * Інформація про підписку клієнта
6
+ */
7
+ export interface ClientSubscription {
8
+ /** Ідентифікатор підписки */
9
+ subscriptionId: string;
10
+
11
+ /** Сума списання у мінімальних одиницях валюти */
12
+ amount: number;
13
+
14
+ /** Періодичність списання (наприклад, "1m", "2w") */
15
+ interval: string;
16
+
17
+ /** Дата початку підписки (RFC3339 / ISO8601) */
18
+ startDate: string;
19
+
20
+ /** Дата створення підписки */
21
+ created: string;
22
+
23
+ /** Дата наступного списання (якщо відома) */
24
+ nextChargeDate?: string;
25
+
26
+ /** Дата завершення підписки (якщо задана) */
27
+ endDate?: string;
28
+
29
+ /** Статус підписки */
30
+ status: SubscriptionStatusEnum;
31
+ }
32
+
33
+ /**
34
+ * Відповідь API з історією або списком підписок клієнта
35
+ */
36
+ export type ClientSubscriptionResponse = PaginatedResponse<ClientSubscription[]>
@@ -0,0 +1,6 @@
1
+ import { SubscriptionResponse } from "./subscription.response";
2
+
3
+ /**
4
+ * Відповідь на створення підписки
5
+ */
6
+ export type CreateSubscriptionResponse = SubscriptionResponse;
@@ -0,0 +1,12 @@
1
+ import type { PaginatedResponse } from "../../../../common/interfaces";
2
+ import type { WalletStatusEnum } from "../../enums";
3
+
4
+ export interface PaymentResponse {
5
+ amount: number
6
+ status: WalletStatusEnum
7
+ chargedAt: string
8
+ ccy: string
9
+ }
10
+
11
+ export type HistoryResponse = PaginatedResponse<PaymentResponse>;
12
+
@@ -0,0 +1,5 @@
1
+ export * from './subscription.response'
2
+ export * from './subscription-status.response'
3
+ export * from './client-subscriptions.response'
4
+ export * from './history.response'
5
+ export * from './create-subscription.response'
@@ -0,0 +1,40 @@
1
+ import type { SubscriptionSummary, WalletData } from "../../../../common/interfaces";
2
+ import type { SubscriptionStatusEnum } from "../../enums";
3
+
4
+ /**
5
+ * Статус підписки клієнта
6
+ */
7
+ export interface SubscriptionStatusResponse {
8
+ /** Ідентифікатор підписки */
9
+ subscriptionId: string;
10
+
11
+ /** Статус підписки */
12
+ status: SubscriptionStatusEnum;
13
+
14
+ /** Дата початку підписки (ISO 8601) */
15
+ startDate: string;
16
+
17
+ /** Дата завершення підписки (ISO 8601), якщо підписка закінчена або запланована */
18
+ endDate?: string;
19
+
20
+ /** Сума списання у мінімальних одиницях валюти */
21
+ amount: number;
22
+
23
+ /** Числовий код валюти ISO 4217 */
24
+ ccy: number;
25
+
26
+ /** Періодичність списання (наприклад, "1m", "2w") */
27
+ interval: string;
28
+
29
+ /** Дата наступного списання (ISO 8601), якщо відома */
30
+ nextChargeDate?: string;
31
+
32
+ /** Причина скасування, якщо підписка була скасована */
33
+ cancellationDesc?: string;
34
+
35
+ /** Статистика платежів по підписці */
36
+ summary: SubscriptionSummary;
37
+
38
+ /** Дані гаманця, через який проходять списання */
39
+ walletData: WalletData;
40
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Відповідь API при створенні або отриманні підписки
3
+ */
4
+ export interface SubscriptionResponse {
5
+ /** Ідентифікатор підписки */
6
+ subscriptionId: string;
7
+
8
+ /** URL сторінки підписки для користувача */
9
+ pageUrl: string;
10
+ }
11
+
@@ -0,0 +1,8 @@
1
+ import { Module } from "@nestjs/common";
2
+ import { SubscriptionService } from "./subscription.service";
3
+
4
+ @Module({
5
+ providers: [SubscriptionService],
6
+ exports: [SubscriptionService],
7
+ })
8
+ export class SubscriptionModule {}
@@ -0,0 +1,121 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import type {
3
+ ClientSubscriptionResponse,
4
+ ClientSubscriptionsRequest,
5
+ CreateSubscriptionRequest,
6
+ CreateSubscriptionResponse,
7
+ EditSubscriptionRequest,
8
+ HistoryRequest,
9
+ HistoryResponse,
10
+ SubscriptionStatusResponse
11
+ } from "./interfaces";
12
+ import { MonobankHttpClient } from "../../core/http/monobank.http-client";
13
+
14
+ @Injectable()
15
+ export class SubscriptionService {
16
+ public constructor(private readonly http: MonobankHttpClient) {}
17
+
18
+ /**
19
+ * Створює нову підписку (регулярний платіж).
20
+ * Після створення клієнта необхідно перенаправити на `pageUrl`
21
+ * для підтвердження підписки.
22
+ *
23
+ * @param {CreateSubscriptionRequest} data Дані для створення підписки
24
+ * @returns {Promise<CreateSubscriptionResponse>} Обʼєкт із посиланням на сторінку оплати
25
+ *
26
+ * @example
27
+ * const subscription = await this.monobankService.subscription.create({
28
+ * amount: 19900,
29
+ * redirectUrl: 'https://example.com/payment/success',
30
+ * webHookUrls: {
31
+ * chargeUrl: "https://example.com/api/v1/webhooks/monobank/charge"
32
+ * statusUrl: "https://example.com/api/v1/webhooks/monobank/status"
33
+ * }
34
+ * interval: '1m',
35
+ * validity: 2592000
36
+ * });
37
+ *
38
+ * console.log(subscription.pageUrl);
39
+ */
40
+ public async create(data: CreateSubscriptionRequest): Promise<CreateSubscriptionResponse> {
41
+ return this.http.post('/merchant/subscription/create', data)
42
+ }
43
+
44
+ /**
45
+ * Отримує поточний статус підписки.
46
+ *
47
+ * @param {string} subscriptionId Унікальний ідентифікатор підписки
48
+ * @returns {Promise<SubscriptionStatusResponse>} Інформація про статус підписки
49
+ *
50
+ * @example
51
+ * const status = await this.monobankService.subscription.getStatus('sub_123456');
52
+ * console.log(status.status);
53
+ */
54
+ public async getStatus(subscriptionId: string): Promise<SubscriptionStatusResponse> {
55
+ return this.http.get(`/merchant/subscription/status?subscriptionId=${subscriptionId}`);
56
+ }
57
+
58
+ /**
59
+ * Отримує історію платежів по підписці.
60
+ *
61
+ * @param {HistoryRequest} query Параметри фільтрації (subscriptionId, дати, ліміти)
62
+ * @returns {Promise<HistoryResponse>} Список платежів
63
+ *
64
+ * @example
65
+ * const history = await this.monobankService.subscription.getHistory({
66
+ * subscriptionId: 'sub_123456',
67
+ * dateFrom: '2025-01-01T00:00:00Z',
68
+ * limit: 20
69
+ * });
70
+ */
71
+ public async getHistory(query: HistoryRequest): Promise<HistoryResponse> {
72
+ return this.http.get('/merchant/subscription/payments', { params: query })
73
+ }
74
+
75
+
76
+ /**
77
+ * Отримує список підписок мерчанта або клієнта.
78
+ *
79
+ * @param {ClientSubscriptionsRequest} query Параметри пошуку (статус, дати, сторінка)
80
+ * @returns {Promise<ClientSubscriptionsResponse>} Масив підписок
81
+ *
82
+ * @example
83
+ * const subscriptions = await this.monobankService.subscription.getClientSubscriptions({
84
+ * status: 'active',
85
+ * limit: 10
86
+ * });
87
+ */
88
+ public async getClientSubscriptions(query: ClientSubscriptionsRequest): Promise<ClientSubscriptionResponse> {
89
+ return this.http.get(`/merchant/subscription/list`, { params: query });
90
+ }
91
+
92
+ /**
93
+ * Редагує або скасовує підписку.
94
+ * На даний момент підтримується дія `cancel`.
95
+ *
96
+ * @param {EditSubscriptionRequest} data Дані для редагування підписки
97
+ * @returns {Promise<void>}
98
+ *
99
+ * @example
100
+ * await this.monobankService.subscription.editSubscription({
101
+ * subscriptionId: 'sub_123456',
102
+ * action: 'cancel'
103
+ * });
104
+ */
105
+ public async editSubscription(data: EditSubscriptionRequest): Promise<void> {
106
+ return this.http.post(`/merchant/subscription/edit`, data);
107
+ }
108
+
109
+ /**
110
+ * Видаляє (деактивує) підписку.
111
+ *
112
+ * @param {string} subscriptionId Ідентифікатор підписки
113
+ * @returns {Promise<void>}
114
+ *
115
+ * @example
116
+ * await this.monobankService.subscription.removeSubscription('sub_123456');
117
+ */
118
+ public async removeSubscription(subscriptionId: string): Promise<void> {
119
+ return this.http.post(`/merchant/subscription/remove?subscriptionId=${subscriptionId}`);
120
+ }
121
+ }
@@ -0,0 +1,2 @@
1
+ export * from './requests'
2
+ export * from './responses'
@@ -0,0 +1,50 @@
1
+ import type { MerchantPaymInfoItem } from "../../../../common/interfaces";
2
+
3
+ /**
4
+ * Запит на створення платежу за токеном картки.
5
+ */
6
+ export interface CreateCardTokenRequest {
7
+ /**
8
+ * Токен картки, отриманий з особистого кабінету або тестовий токен
9
+ */
10
+ cardToken: string;
11
+
12
+ /**
13
+ * Сума платежу в мінімальних одиницях (наприклад, копійки для гривні)
14
+ */
15
+ amount: number;
16
+
17
+ /**
18
+ * ISO 4217 код валюти
19
+ */
20
+ ccy: number;
21
+
22
+ /**
23
+ * (Не обов'язковий) URL для переадресації користувача після 3DS підтвердження
24
+ */
25
+ redirectUrl?: string;
26
+
27
+ /**
28
+ * (Не обов'язковий) URL для вебхука, на який надсилаються оновлення статусу платежу
29
+ */
30
+ webHookUrl?: string;
31
+
32
+ /**
33
+ * Тип ініціації платежу:
34
+ * "merchant" - ініціатива мерчанту (наприклад, регулярний платіж)
35
+ * "client" - ініціатива клієнта (клієнт підтверджує платіж)
36
+ */
37
+ initiationKind: "merchant" | "client";
38
+
39
+ /**
40
+ * (Не обов'язковий) Тип платежу:
41
+ * "debit" - списання коштів
42
+ * "hold" - блокування коштів
43
+ */
44
+ paymentType?: "debit" | "hold";
45
+
46
+ /**
47
+ * (Не обов'язковий) Інформація про платіж, для зв'язку з ПРРО через веб-кабінет
48
+ */
49
+ merchantPaymInfo?: MerchantPaymInfoItem;
50
+ }