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 type { ChargeStatusEnum } from "../../enums";
2
+
3
+ export interface ChargeResponse {
4
+ /**
5
+ * Ідентифікатор інвойсу, за яким здійснювалась оплата
6
+ */
7
+ invoiceId: string;
8
+
9
+ /**
10
+ * Посилання на проходження 3DS підтвердження платежу (якщо потрібне)
11
+ */
12
+ tdsUrl?: string;
13
+
14
+ /**
15
+ * Статус оплати
16
+ */
17
+ status: ChargeStatusEnum;
18
+
19
+ /**
20
+ * Причина відмови в оплаті
21
+ */
22
+ failureReason?: string;
23
+
24
+ /**
25
+ * Сума у мінімальних одиницях валюти (наприклад, копійки)
26
+ */
27
+ amount: number;
28
+
29
+ /**
30
+ * ISO 4217 код валюти
31
+ */
32
+ ccy: number;
33
+
34
+ /**
35
+ * Дата і час створення заяви на оплату
36
+ */
37
+ createdDate: string;
38
+
39
+ /**
40
+ * Дата і час останньої модифікації операції оплати
41
+ */
42
+ modifiedDate: string;
43
+ }
@@ -0,0 +1,7 @@
1
+ import type { Cancel } from "./cancel.response";
2
+
3
+ /**
4
+ * Відповідь API при створенні запиту на скасування інвойсу.
5
+ * Наслідує базову структуру Cancel.
6
+ */
7
+ export interface CreateCancelResponse extends Cancel {}
@@ -0,0 +1,7 @@
1
+ import type { ChargeResponse } from "./charge.response";
2
+
3
+ /**
4
+ * Відповідь API при створенні заяви на оплату.
5
+ * Наслідує базову структуру Charge.
6
+ */
7
+ export interface CreateChargeResponse extends ChargeResponse {}
@@ -0,0 +1,7 @@
1
+ import type { FinalizeResponse } from "./finalize.response";
2
+
3
+ /**
4
+ * Відповідь API при підтвердженні холду.
5
+ * Наслідує базову структуру CaptureHold.
6
+ */
7
+ export interface CreateFinalizeResponse extends FinalizeResponse {}
@@ -0,0 +1,7 @@
1
+ import type { Invoice } from "./invoice.response";
2
+
3
+ /**
4
+ * Відповідь API при створенні рахунку (invoice).
5
+ * Наслідує базову структуру Invoice.
6
+ */
7
+ export interface CreateInvoiceResponse extends Invoice {}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Результат підтвердження холду.
3
+ */
4
+ export interface FinalizeResponse {
5
+ /**
6
+ * Статус операції: наприклад, "success", "failure" або null, якщо статус невідомий.
7
+ */
8
+ status: string | null;
9
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Інформація про чек.
3
+ */
4
+ export interface FiscalCheckItem {
5
+ /**
6
+ * Унікальний ідентифікатор чеку.
7
+ */
8
+ id: string;
9
+
10
+ /**
11
+ * Тип транзакції (наприклад, sale — продаж).
12
+ */
13
+ type: string;
14
+
15
+ /**
16
+ * Поточний статус чеку.
17
+ */
18
+ status: string;
19
+
20
+ /**
21
+ * Опис статусу чеку, якщо є.
22
+ */
23
+ statusDescription: string;
24
+
25
+ /**
26
+ * URL для перегляду або перевірки чеку.
27
+ */
28
+ taxUrl: string;
29
+
30
+ /**
31
+ * Посилання на файл, пов'язаний з чеком.
32
+ */
33
+ file: string;
34
+
35
+ /**
36
+ * Джерело фіскалізації (наприклад, monopay).
37
+ */
38
+ fiscalizationSource: string;
39
+ }
40
+
41
+ /**
42
+ * Список чеків.
43
+ */
44
+ export interface FiscalChecksResponse {
45
+ /**
46
+ * Масив об'єктів типу `CheckItem`.
47
+ */
48
+ checks: FiscalCheckItem[];
49
+ }
@@ -0,0 +1,10 @@
1
+ export * from './create-invoice.response'
2
+ export * from './create-finalize.response'
3
+ export * from './create-cancel.response'
4
+
5
+ export * from './cancel.response'
6
+ export * from './finalize.response'
7
+ export * from './invoice-status.response'
8
+ export * from './invoice.response'
9
+ export * from './fiscal-checks.response'
10
+ export * from './receipt.response'
@@ -0,0 +1,142 @@
1
+ import type { InvoiceCancelItem, TipsInfo, WalletData } from "../../../../common/interfaces";
2
+ import type { InvoiceStatusEnum } from "../../enums";
3
+
4
+ /**
5
+ * Інформація про здійснений платіж за рахунком.
6
+ */
7
+ export interface InvoiceStatusPaymentInfo {
8
+ /**
9
+ * Маскований номер картки, з якої здійснено платіж.
10
+ */
11
+ maskedPan: string;
12
+
13
+ /**
14
+ * Код авторизації транзакції.
15
+ */
16
+ approvalCode: string;
17
+
18
+ /**
19
+ * RRN (Retrieval Reference Number) — унікальний ідентифікатор транзакції.
20
+ */
21
+ rrn: string;
22
+
23
+ /**
24
+ * Унікальний ідентифікатор транзакції в системі банку.
25
+ */
26
+ tranId: string;
27
+
28
+ /**
29
+ * Ідентифікатор терміналу, через який проведено оплату.
30
+ */
31
+ terminal: string;
32
+
33
+ /**
34
+ * Назва банку, що обробив платіж.
35
+ */
36
+ bank: string;
37
+
38
+ /**
39
+ * Платіжна система (наприклад, Visa, Mastercard).
40
+ */
41
+ paymentSystem: string;
42
+
43
+ /**
44
+ * Метод оплати (наприклад, картка, Google Pay, Apple Pay).
45
+ */
46
+ paymentMethod: string;
47
+
48
+ /**
49
+ * Комісія, стягнена банком, у мінімальних одиницях валюти.
50
+ */
51
+ fee: number;
52
+
53
+ /**
54
+ * Код країни у форматі ISO 3166-1 numeric (наприклад, 804 — Україна).
55
+ */
56
+ country: 804;
57
+
58
+ /**
59
+ * Комісія агента, якщо застосовується (у мінімальних одиницях).
60
+ */
61
+ agentFee: number;
62
+ }
63
+
64
+ /**
65
+ * Інформація про статус рахунку.
66
+ */
67
+ export interface InvoiceStatus {
68
+ /**
69
+ * Ідентифікатор інвойсу.
70
+ */
71
+ invoiceId: string;
72
+
73
+ /**
74
+ * Поточний статус інвойсу.
75
+ */
76
+ status: InvoiceStatusEnum;
77
+
78
+ /**
79
+ * Причина відмови, якщо оплата неуспішна.
80
+ */
81
+ failureReason?: string;
82
+
83
+ /**
84
+ * Код помилки, яка виникла під час обробки платежу.
85
+ */
86
+ errCode?: string;
87
+
88
+ /**
89
+ * Сума у мінімальних одиницях валюти.
90
+ */
91
+ amount: number;
92
+
93
+ /**
94
+ * Валюта операції.
95
+ */
96
+ ccy: number;
97
+
98
+ /**
99
+ * Підсумкова сума після оплати та повернень.
100
+ */
101
+ finalAmount: number;
102
+
103
+ /**
104
+ * Дата і час фінансової операції.
105
+ */
106
+ createdDate: string;
107
+
108
+ /**
109
+ * Дата і час останньої модифікації операції.
110
+ */
111
+ modifiedDate: string;
112
+
113
+ /**
114
+ * Референс платежу, який визначається продавцем.
115
+ */
116
+ reference: string;
117
+
118
+ /**
119
+ * Призначення платежу, визначається продавцем.
120
+ */
121
+ destination: string;
122
+
123
+ /**
124
+ * Список прийнятих заявок на скасування.
125
+ */
126
+ cancelList: InvoiceCancelItem[];
127
+
128
+ /**
129
+ * Інформація про платіж, що включає деталі транзакції.
130
+ */
131
+ paymentInfo: InvoiceStatusPaymentInfo;
132
+
133
+ /**
134
+ * Дані про гаманця користувача, що зберігає токенізовану картку.
135
+ */
136
+ walletData: WalletData;
137
+
138
+ /**
139
+ * Інформація про чайові, якщо вони були сплачені.
140
+ */
141
+ tipsInfo: TipsInfo;
142
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Відповідь після створення інвойсу.
3
+ */
4
+ export interface Invoice {
5
+ /**
6
+ * Ідентифікатор інвойсу.
7
+ */
8
+ invoiceId: string;
9
+
10
+ /**
11
+ * Посилання на сторінку оплати.
12
+ */
13
+ pageUrl: string;
14
+ }
@@ -0,0 +1,6 @@
1
+ export interface ReceiptResponse {
2
+ /**
3
+ * Base64-закодований PDF-файл квитанції
4
+ */
5
+ file: string;
6
+ }
@@ -0,0 +1,8 @@
1
+ import { Module } from "@nestjs/common";
2
+ import { InvoiceService } from "./invoice.service";
3
+
4
+ @Module({
5
+ providers: [InvoiceService],
6
+ exports: [InvoiceService]
7
+ })
8
+ export class InvoiceModule {}
@@ -0,0 +1,191 @@
1
+ import { Injectable } from "@nestjs/common";
2
+ import type {
3
+ CreateChargeRequest,
4
+ CreateCancelRequest,
5
+ CreateFinalizeRequest,
6
+ CreateFinalizeResponse,
7
+ CreateInvoiceRequest,
8
+ CreateInvoiceResponse,
9
+ CreateCancelResponse,
10
+ FiscalChecksResponse,
11
+ InvoiceStatus,
12
+ ReceiptResponse
13
+ } from './interfaces'
14
+ import { MonobankHttpClient } from "../../core/http/monobank.http-client";
15
+ import { CreateChargeResponse } from "./interfaces/responses/create-charge.response";
16
+
17
+ @Injectable()
18
+ export class InvoiceService {
19
+ public constructor(private readonly http: MonobankHttpClient) {}
20
+
21
+ /**
22
+ * Створює рахунок для оплати через Monobank.
23
+ * @param {CreateInvoiceRequest} data - Дані для створення рахунку.
24
+ * @returns {Promise<CreateInvoiceResponse>} Відповідь від API з деталями рахунку.
25
+ *
26
+ * @example
27
+ * const invoiceData: CreateInvoiceRequest = {
28
+ * amount: 1000,
29
+ * ccy: 980, // UAH
30
+ * merchantPaymInfo: {
31
+ * reference: "my_shop_order_28142",
32
+ * destination: "Оплата за замовлення #28142",
33
+ * basketOrder: [
34
+ * {
35
+ * name: "Товар1",
36
+ * qty: 2,
37
+ * sum: 500,
38
+ * icon: "https://example.com/images/product1.jpg",
39
+ * unit: "уп."
40
+ * }
41
+ * ]
42
+ * },
43
+ * redirectUrl: "https://example.com/order-result",
44
+ * webHookUrl: "https://example.com/mono-webhook",
45
+ * validity: 3600 * 24 * 7,
46
+ * paymentType: "debit"
47
+ * };
48
+ *
49
+ * const invoice = await this.monobankService.invoice.create(data);
50
+ * console.log(invoice.pageUrl);
51
+ */
52
+ public async create(data: CreateInvoiceRequest): Promise<CreateInvoiceResponse> {
53
+ return this.http.post('/merchant/invoice/create', data)
54
+ }
55
+
56
+ /**
57
+ * Проводить прямий платеж через Monobank.
58
+ * @param {CreateChargeRequest} data - Дані для проведення прямого платежу.
59
+ * @returns {Promise<CreateChargeResponse>} Відповідь від API з деталями платежу.
60
+ * @example
61
+ * const data: CreateChargeRequest = {
62
+ * amount: 1000,
63
+ * ccy: 980,
64
+ * cardData: {
65
+ * pan: "1234567890123456",
66
+ * exp: "1226",
67
+ * cvv: 123
68
+ * },
69
+ * merchantPaymInfo: {
70
+ * reference: "my_shop_order_28142",
71
+ * destination: "Оплата за замовлення #28142",
72
+ * basketOrder: [
73
+ * {
74
+ * name: "Товар1",
75
+ * qty: 2,
76
+ * sum: 500,
77
+ * icon: "https://example.com/images/product1.jpg",
78
+ * unit: "уп."
79
+ * }
80
+ * ]
81
+ * },
82
+ * webhookUrl: "https://example.com/mono-webhook",
83
+ * redirectUrl: "https://example.com/order-result",
84
+ * paymentType: "debit",
85
+ * initiationKind: "merchant"
86
+ * };
87
+ * const charge = await this.monobankService.invoice.charge(data);
88
+ * console.log(charge.invoiceId);
89
+ */
90
+ public async charge(data: CreateChargeRequest): Promise<CreateChargeResponse> {
91
+ return this.http.post('/merchant/invoice/payment-direct', data)
92
+ }
93
+
94
+ /**
95
+ * Отримує статус рахунку за його ID.
96
+ * @param {string} invoiceId - Унікальний ідентифікатор рахунку.
97
+ * @returns {Promise<InvoiceStatus>} Поточний статус рахунку.
98
+ * @example
99
+ * const invoiceId = "khsf8723hsdf8923hf";
100
+ * const status = await this.monobankService.invoice.getStatus(invoiceId);
101
+ * console.log(status);
102
+ */
103
+ public async getStatus(invoiceId: string): Promise<InvoiceStatus> {
104
+ return this.http.get(`/merchant/invoice/status?invoiceId=${invoiceId}`)
105
+ }
106
+
107
+ /**
108
+ * Отримує фіскальні чеки по рахунку.
109
+ * @param {string} invoiceId - Унікальний ідентифікатор рахунку.
110
+ * @returns {Promise<FiscalChecksResponse>} Список фіскальних чеків.
111
+ * @example
112
+ * const checks = await this.monobankService.invoice.getFiscalReceipts(invoiceId);
113
+ * console.log(checks);
114
+ */
115
+ public async getFiscalReceipts(invoiceId: string): Promise<FiscalChecksResponse> {
116
+ return this.http.get(`/merchant/invoice/fiscal-checks?invoiceId=${invoiceId}`)
117
+ }
118
+
119
+ /**
120
+ * Отримує квитанцію по рахунку.
121
+ * @param {string} invoiceId - Унікальний ідентифікатор рахунку.
122
+ * @returns {Promise<ReceiptResponse>} Квитанція по рахунку.
123
+ * @example
124
+ * const receipt = await this.monobankService.invoice.getReceipt(invoiceId);
125
+ * console.log(receipt);
126
+ */
127
+ public async getReceipt(invoiceId: string): Promise<ReceiptResponse> {
128
+ return this.http.get(`/merchant/invoice/receipt?invoiceId=${invoiceId}`)
129
+ }
130
+
131
+ /**
132
+ * Завершує утримання коштів за рахунком.
133
+ * @param {CreateFinalizeRequest} data - Дані для завершення утримання коштів.
134
+ * @returns {Promise<CreateFinalizeResponse>} Статус завершення утримання.
135
+ * @example
136
+ * const data: CreateFinalizeRequest = {
137
+ * invoiceId: "2210012MPLYwJjVUzchj",
138
+ * amount: 4200
139
+ * };
140
+ * const finalize = await this.monobankService.invoice.finalize(data);
141
+ * console.log(finalize.status);
142
+ */
143
+ public async finalize(data: CreateFinalizeRequest): Promise<CreateFinalizeResponse> {
144
+ return this.http.post('/merchant/invoice/finalize', data)
145
+ }
146
+
147
+ /**
148
+ * Скасовує (повертає) платіж за рахунком Monobank.
149
+ *
150
+ * Метод створює заявку на скасування оплати (cancel).
151
+ * Статус скасування може бути:
152
+ * - `processing` — заявка в обробці
153
+ * - `success` — скасування виконано успішно
154
+ * - `failure` — помилка під час скасування
155
+ *
156
+ * @param {CreateCancelRequest} data - Дані для створення запиту на скасування.
157
+ * @returns {Promise<CreateCancelResponse>} Результат операції скасування.
158
+ *
159
+ * @example
160
+ * const data: CreateCancelRequest = {
161
+ * invoiceId: "2210012MPLYwJjVUzchj",
162
+ * amount: 1500
163
+ * };
164
+ *
165
+ * const cancel = await this.monobankService.invoice.cancel(data);
166
+ * console.log(cancel.status);
167
+ */
168
+ public async cancel(data: CreateCancelRequest): Promise<CreateCancelResponse> {
169
+ return this.http.post("/merchant/invoice/cancel", data)
170
+ }
171
+
172
+ /**
173
+ * Видаляє (анулює) інвойсу Monobank за його ідентифікатором.
174
+ *
175
+ * Метод використовується для:
176
+ * - повного видалення інвойсу
177
+ * - припинення можливості оплати за інвойсом
178
+ *
179
+ * ⚠️ Зазвичай застосовується лише для інвойсів,
180
+ * які ще не були успішно оплачені.
181
+ *
182
+ * @param {string} invoiceId - Унікальний ідентифікатор інвойсу.
183
+ * @returns {Promise<void>} Результат операції (без тіла відповіді).
184
+ *
185
+ * @example
186
+ * await this.monobankService.invoice.remove("2210012MPLYwJjVUzchj");
187
+ */
188
+ public async remove(invoiceId: string): Promise<void> {
189
+ return this.http.post("/merchant/invoice/remove", invoiceId)
190
+ }
191
+ }
@@ -0,0 +1 @@
1
+ export * from './responses'
@@ -0,0 +1,2 @@
1
+ export * from './merchant.response'
2
+ export * from './pubkey.response'
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Інформація про мерчанта, зареєстрованого в Monobank.
3
+ */
4
+ export interface MerchantResponse {
5
+ /**
6
+ * Унікальний ідентифікатор мерчанта.
7
+ */
8
+ merchantId: string;
9
+
10
+ /**
11
+ * Назва компанії або організації.
12
+ */
13
+ merchantName: string;
14
+
15
+ /**
16
+ * ЄДРПОУ (ідентифікаційний код юридичної особи в Україні).
17
+ */
18
+ edrpou: string;
19
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Відповідь API з відкритим RSA-ключем мерчанта.
3
+ */
4
+ export interface PubkeyResponse {
5
+ /**
6
+ * Відкритий RSA-ключ у PEM-форматі.
7
+ * Використовується для верифікації підписів Monobank.
8
+ */
9
+ key: string;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { Module } from "@nestjs/common";
2
+ import { MerchantService } from "./merchant.service";
3
+
4
+ @Module({
5
+ providers: [MerchantService],
6
+ exports: [MerchantService]
7
+ })
8
+ export class MerchantModule {}
@@ -0,0 +1,46 @@
1
+ import { Injectable } from "@nestjs/common";
2
+ import type { MerchantResponse, PubkeyResponse } from './interfaces'
3
+ import { MonobankHttpClient } from "../../core/http/monobank.http-client";
4
+
5
+ @Injectable()
6
+ export class MerchantService {
7
+ public constructor(
8
+ private readonly http: MonobankHttpClient
9
+ ) {}
10
+
11
+ /**
12
+ * Отримує публічний ключ мерчанта Monobank.
13
+ *
14
+ * Публічний ключ використовується для:
15
+ * - верифікації підписів webhook-повідомлень
16
+ * - перевірки автентичності даних від Monobank
17
+ *
18
+ * @returns {Promise<PubkeyResponse>} Публічний RSA-ключ мерчанта.
19
+ *
20
+ * @example
21
+ * const pubkey = await this.monobankService.merchant.getMerchantPubkey();
22
+ * console.log(pubkey.key);
23
+ */
24
+ public async getMerchantPubkey(): Promise<PubkeyResponse> {
25
+ return this.http.get("/merchant/pubkey")
26
+ }
27
+
28
+ /**
29
+ * Отримує детальну інформацію про мерчанта Monobank.
30
+ *
31
+ * Метод повертає основні дані облікового запису мерчанта:
32
+ * - ідентифікатор мерчанта
33
+ * - назву
34
+ * - доступні налаштування
35
+ * - інформацію для інтеграції
36
+ *
37
+ * @returns {Promise<MerchantResponse>} Дані мерчанта.
38
+ *
39
+ * @example
40
+ * const merchant = await this.monobankService.merchant.getMerchant();
41
+ * console.log(merchant.name);
42
+ */
43
+ public async getMerchant(): Promise<MerchantResponse> {
44
+ return this.http.get('/merchant/details')
45
+ }
46
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Тип суми одноразової QR-каси
3
+ */
4
+ export enum AmountTypeEnum {
5
+ /** Суму встановлює мерчант */
6
+ MERCHANT = 'merchant',
7
+
8
+ /** Суму встановлює клієнт */
9
+ CLIENT = 'client',
10
+
11
+ /** Сума фіксована */
12
+ FIX = 'fix',
13
+ }
@@ -0,0 +1 @@
1
+ export * from './amount-type.enum'
File without changes
@@ -0,0 +1,2 @@
1
+ export * from './list.response'
2
+ export * from './qr.response'
@@ -0,0 +1,11 @@
1
+ import type { AmountTypeEnum } from "../../enums";
2
+ import type { QrResponse } from "./qr.response";
3
+
4
+ /**
5
+ * Відповідь API при отриманні списку QR-кас
6
+ */
7
+ export interface ListResponse {
8
+ /** Список QR-кас */
9
+ list: QrResponse[];
10
+ }
11
+
@@ -0,0 +1,18 @@
1
+ import { AmountTypeEnum } from "../../enums";
2
+
3
+ /**
4
+ * Дані однієї QR-каси
5
+ */
6
+ export interface QrResponse {
7
+ /** Короткий ідентифікатор QR-каси */
8
+ shortQrId: string;
9
+
10
+ /** Ідентифікатор QR-каси для встановлення суми оплати на існуючих QR-касах */
11
+ qrId: string;
12
+
13
+ /** Тип суми одноразової каси */
14
+ amountType: AmountTypeEnum
15
+
16
+ /** Посилання на оплату QR-каси */
17
+ pageUrl: string;
18
+ }
@@ -0,0 +1,8 @@
1
+ import { Module } from "@nestjs/common";
2
+ import { QrService } from "./qr.service";
3
+
4
+ @Module({
5
+ providers: [QrService],
6
+ exports: [QrService],
7
+ })
8
+ export class QrModule {}