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.
- package/LICENSE +661 -0
- package/README.md +18 -0
- package/dist/common/enums/discount.enum.d.ts +24 -0
- package/dist/common/enums/discount.enum.js +2 -0
- package/dist/common/enums/index.d.ts +1 -0
- package/dist/common/enums/index.js +17 -0
- package/dist/common/interfaces/common.interface.d.ts +177 -0
- package/dist/common/interfaces/common.interface.js +2 -0
- package/dist/common/interfaces/index.d.ts +2 -0
- package/dist/common/interfaces/index.js +18 -0
- package/dist/common/interfaces/monobank-options.interface.d.ts +15 -0
- package/dist/common/interfaces/monobank-options.interface.js +4 -0
- package/dist/core/config/monobank.constants.d.ts +1 -0
- package/dist/core/config/monobank.constants.js +4 -0
- package/dist/core/http/monobank.error.d.ts +6 -0
- package/dist/core/http/monobank.error.js +13 -0
- package/dist/core/http/monobank.http-client.d.ts +16 -0
- package/dist/core/http/monobank.http-client.js +66 -0
- package/dist/core/http/monobank.interceptor.d.ts +2 -0
- package/dist/core/http/monobank.interceptor.js +19 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/modules/invoice/enums/cancel-status.enum.d.ts +18 -0
- package/dist/modules/invoice/enums/cancel-status.enum.js +22 -0
- package/dist/modules/invoice/enums/charge-status.enum.d.ts +14 -0
- package/dist/modules/invoice/enums/charge-status.enum.js +18 -0
- package/dist/modules/invoice/enums/index.d.ts +3 -0
- package/dist/modules/invoice/enums/index.js +19 -0
- package/dist/modules/invoice/enums/invoice-status.enum.d.ts +34 -0
- package/dist/modules/invoice/enums/invoice-status.enum.js +38 -0
- package/dist/modules/invoice/interfaces/index.d.ts +2 -0
- package/dist/modules/invoice/interfaces/index.js +18 -0
- package/dist/modules/invoice/interfaces/requests/create-cancel.request.d.ts +22 -0
- package/dist/modules/invoice/interfaces/requests/create-cancel.request.js +2 -0
- package/dist/modules/invoice/interfaces/requests/create-charge.request.d.ts +42 -0
- package/dist/modules/invoice/interfaces/requests/create-charge.request.js +2 -0
- package/dist/modules/invoice/interfaces/requests/create-finalize.request.d.ts +19 -0
- package/dist/modules/invoice/interfaces/requests/create-finalize.request.js +2 -0
- package/dist/modules/invoice/interfaces/requests/create-invoice.request.d.ts +88 -0
- package/dist/modules/invoice/interfaces/requests/create-invoice.request.js +2 -0
- package/dist/modules/invoice/interfaces/requests/index.d.ts +4 -0
- package/dist/modules/invoice/interfaces/requests/index.js +20 -0
- package/dist/modules/invoice/interfaces/responses/cancel.response.d.ts +18 -0
- package/dist/modules/invoice/interfaces/responses/cancel.response.js +2 -0
- package/dist/modules/invoice/interfaces/responses/charge.response.d.ts +35 -0
- package/dist/modules/invoice/interfaces/responses/charge.response.js +2 -0
- package/dist/modules/invoice/interfaces/responses/create-cancel.response.d.ts +7 -0
- package/dist/modules/invoice/interfaces/responses/create-cancel.response.js +2 -0
- package/dist/modules/invoice/interfaces/responses/create-charge.response.d.ts +7 -0
- package/dist/modules/invoice/interfaces/responses/create-charge.response.js +2 -0
- package/dist/modules/invoice/interfaces/responses/create-finalize.response.d.ts +7 -0
- package/dist/modules/invoice/interfaces/responses/create-finalize.response.js +2 -0
- package/dist/modules/invoice/interfaces/responses/create-invoice.response.d.ts +7 -0
- package/dist/modules/invoice/interfaces/responses/create-invoice.response.js +2 -0
- package/dist/modules/invoice/interfaces/responses/finalize.response.d.ts +9 -0
- package/dist/modules/invoice/interfaces/responses/finalize.response.js +2 -0
- package/dist/modules/invoice/interfaces/responses/fiscal-checks.response.d.ts +42 -0
- package/dist/modules/invoice/interfaces/responses/fiscal-checks.response.js +2 -0
- package/dist/modules/invoice/interfaces/responses/index.d.ts +9 -0
- package/dist/modules/invoice/interfaces/responses/index.js +25 -0
- package/dist/modules/invoice/interfaces/responses/invoice-status.response.d.ts +116 -0
- package/dist/modules/invoice/interfaces/responses/invoice-status.response.js +2 -0
- package/dist/modules/invoice/interfaces/responses/invoice.response.d.ts +13 -0
- package/dist/modules/invoice/interfaces/responses/invoice.response.js +2 -0
- package/dist/modules/invoice/interfaces/responses/receipt.response.d.ts +6 -0
- package/dist/modules/invoice/interfaces/responses/receipt.response.js +2 -0
- package/dist/modules/invoice/invoice.module.d.ts +2 -0
- package/dist/modules/invoice/invoice.module.js +20 -0
- package/dist/modules/invoice/invoice.service.d.ts +154 -0
- package/dist/modules/invoice/invoice.service.js +187 -0
- package/dist/modules/merchant/interfaces/index.d.ts +1 -0
- package/dist/modules/merchant/interfaces/index.js +17 -0
- package/dist/modules/merchant/interfaces/responses/index.d.ts +2 -0
- package/dist/modules/merchant/interfaces/responses/index.js +18 -0
- package/dist/modules/merchant/interfaces/responses/merchant.response.d.ts +17 -0
- package/dist/modules/merchant/interfaces/responses/merchant.response.js +2 -0
- package/dist/modules/merchant/interfaces/responses/pubkey.response.d.ts +10 -0
- package/dist/modules/merchant/interfaces/responses/pubkey.response.js +2 -0
- package/dist/modules/merchant/merchant.module.d.ts +2 -0
- package/dist/modules/merchant/merchant.module.js +20 -0
- package/dist/modules/merchant/merchant.service.d.ts +36 -0
- package/dist/modules/merchant/merchant.service.js +58 -0
- package/dist/modules/qr/enums/amount-type.enum.d.ts +11 -0
- package/dist/modules/qr/enums/amount-type.enum.js +15 -0
- package/dist/modules/qr/enums/index.d.ts +1 -0
- package/dist/modules/qr/enums/index.js +17 -0
- package/dist/modules/qr/interfaces/index.d.ts +0 -0
- package/dist/modules/qr/interfaces/index.js +0 -0
- package/dist/modules/qr/interfaces/responses/index.d.ts +2 -0
- package/dist/modules/qr/interfaces/responses/index.js +18 -0
- package/dist/modules/qr/interfaces/responses/list.response.d.ts +8 -0
- package/dist/modules/qr/interfaces/responses/list.response.js +2 -0
- package/dist/modules/qr/interfaces/responses/qr.response.d.ts +14 -0
- package/dist/modules/qr/interfaces/responses/qr.response.js +2 -0
- package/dist/modules/qr/qr.module.d.ts +2 -0
- package/dist/modules/qr/qr.module.js +20 -0
- package/dist/modules/qr/qr.service.d.ts +32 -0
- package/dist/modules/qr/qr.service.js +56 -0
- package/dist/modules/statement/interfaces/index.d.ts +1 -0
- package/dist/modules/statement/interfaces/index.js +17 -0
- package/dist/modules/statement/interfaces/responses/index.d.ts +1 -0
- package/dist/modules/statement/interfaces/responses/index.js +17 -0
- package/dist/modules/statement/interfaces/responses/statement.response.d.ts +99 -0
- package/dist/modules/statement/interfaces/responses/statement.response.js +2 -0
- package/dist/modules/statement/statement.module.d.ts +2 -0
- package/dist/modules/statement/statement.module.js +20 -0
- package/dist/modules/statement/statement.service.d.ts +17 -0
- package/dist/modules/statement/statement.service.js +38 -0
- package/dist/modules/subscription/enums/index.d.ts +2 -0
- package/dist/modules/subscription/enums/index.js +18 -0
- package/dist/modules/subscription/enums/subscription-status.enum.d.ts +13 -0
- package/dist/modules/subscription/enums/subscription-status.enum.js +17 -0
- package/dist/modules/subscription/enums/wallet-status.enum.d.ts +17 -0
- package/dist/modules/subscription/enums/wallet-status.enum.js +21 -0
- package/dist/modules/subscription/interfaces/index.d.ts +2 -0
- package/dist/modules/subscription/interfaces/index.js +18 -0
- package/dist/modules/subscription/interfaces/requests/client-subscriptions.request.d.ts +26 -0
- package/dist/modules/subscription/interfaces/requests/client-subscriptions.request.js +2 -0
- package/dist/modules/subscription/interfaces/requests/create-subscription.request.d.ts +32 -0
- package/dist/modules/subscription/interfaces/requests/create-subscription.request.js +2 -0
- package/dist/modules/subscription/interfaces/requests/edit-subscription.request.d.ts +18 -0
- package/dist/modules/subscription/interfaces/requests/edit-subscription.request.js +2 -0
- package/dist/modules/subscription/interfaces/requests/history.request.d.ts +15 -0
- package/dist/modules/subscription/interfaces/requests/history.request.js +2 -0
- package/dist/modules/subscription/interfaces/requests/index.d.ts +4 -0
- package/dist/modules/subscription/interfaces/requests/index.js +20 -0
- package/dist/modules/subscription/interfaces/responses/client-subscriptions.response.d.ts +27 -0
- package/dist/modules/subscription/interfaces/responses/client-subscriptions.response.js +2 -0
- package/dist/modules/subscription/interfaces/responses/create-subscription.response.d.ts +5 -0
- package/dist/modules/subscription/interfaces/responses/create-subscription.response.js +2 -0
- package/dist/modules/subscription/interfaces/responses/history.response.d.ts +9 -0
- package/dist/modules/subscription/interfaces/responses/history.response.js +2 -0
- package/dist/modules/subscription/interfaces/responses/index.d.ts +5 -0
- package/dist/modules/subscription/interfaces/responses/index.js +21 -0
- package/dist/modules/subscription/interfaces/responses/subscription-status.response.d.ts +29 -0
- package/dist/modules/subscription/interfaces/responses/subscription-status.response.js +2 -0
- package/dist/modules/subscription/interfaces/responses/subscription.response.d.ts +9 -0
- package/dist/modules/subscription/interfaces/responses/subscription.response.js +2 -0
- package/dist/modules/subscription/subscription.module.d.ts +2 -0
- package/dist/modules/subscription/subscription.module.js +20 -0
- package/dist/modules/subscription/subscription.service.d.ts +91 -0
- package/dist/modules/subscription/subscription.service.js +121 -0
- package/dist/modules/wallet/interfaces/index.d.ts +2 -0
- package/dist/modules/wallet/interfaces/index.js +18 -0
- package/dist/modules/wallet/interfaces/requests/create-card-token.request.d.ts +42 -0
- package/dist/modules/wallet/interfaces/requests/create-card-token.request.js +2 -0
- package/dist/modules/wallet/interfaces/requests/index.d.ts +1 -0
- package/dist/modules/wallet/interfaces/requests/index.js +17 -0
- package/dist/modules/wallet/interfaces/responses/card-token.response.d.ts +37 -0
- package/dist/modules/wallet/interfaces/responses/card-token.response.js +2 -0
- package/dist/modules/wallet/interfaces/responses/create-card-token.response.d.ts +7 -0
- package/dist/modules/wallet/interfaces/responses/create-card-token.response.js +2 -0
- package/dist/modules/wallet/interfaces/responses/index.d.ts +2 -0
- package/dist/modules/wallet/interfaces/responses/index.js +18 -0
- package/dist/modules/wallet/wallet.module.d.ts +2 -0
- package/dist/modules/wallet/wallet.module.js +20 -0
- package/dist/modules/wallet/wallet.service.d.ts +54 -0
- package/dist/modules/wallet/wallet.service.js +78 -0
- package/dist/modules/webhook/webhook.module.d.ts +2 -0
- package/dist/modules/webhook/webhook.module.js +24 -0
- package/dist/modules/webhook/webhook.service.d.ts +44 -0
- package/dist/modules/webhook/webhook.service.js +72 -0
- package/dist/monobank.module.d.ts +36 -0
- package/dist/monobank.module.js +117 -0
- package/dist/monobank.service.d.ts +17 -0
- package/dist/monobank.service.js +42 -0
- package/package.json +68 -0
- package/src/common/enums/discount.enum.ts +26 -0
- package/src/common/enums/index.ts +1 -0
- package/src/common/interfaces/common.interface.ts +206 -0
- package/src/common/interfaces/index.ts +2 -0
- package/src/common/interfaces/monobank-options.interface.ts +18 -0
- package/src/core/config/monobank.constants.ts +1 -0
- package/src/core/http/monobank.error.ts +10 -0
- package/src/core/http/monobank.http-client.ts +66 -0
- package/src/core/http/monobank.interceptor.ts +24 -0
- package/src/index.ts +3 -0
- package/src/modules/invoice/enums/cancel-status.enum.ts +20 -0
- package/src/modules/invoice/enums/charge-status.enum.ts +16 -0
- package/src/modules/invoice/enums/index.ts +3 -0
- package/src/modules/invoice/enums/invoice-status.enum.ts +40 -0
- package/src/modules/invoice/interfaces/index.ts +2 -0
- package/src/modules/invoice/interfaces/requests/create-cancel.request.ts +26 -0
- package/src/modules/invoice/interfaces/requests/create-charge.request.ts +52 -0
- package/src/modules/invoice/interfaces/requests/create-finalize.request.ts +22 -0
- package/src/modules/invoice/interfaces/requests/create-invoice.request.ts +103 -0
- package/src/modules/invoice/interfaces/requests/index.ts +4 -0
- package/src/modules/invoice/interfaces/responses/cancel.response.ts +21 -0
- package/src/modules/invoice/interfaces/responses/charge.response.ts +43 -0
- package/src/modules/invoice/interfaces/responses/create-cancel.response.ts +7 -0
- package/src/modules/invoice/interfaces/responses/create-charge.response.ts +7 -0
- package/src/modules/invoice/interfaces/responses/create-finalize.response.ts +7 -0
- package/src/modules/invoice/interfaces/responses/create-invoice.response.ts +7 -0
- package/src/modules/invoice/interfaces/responses/finalize.response.ts +9 -0
- package/src/modules/invoice/interfaces/responses/fiscal-checks.response.ts +49 -0
- package/src/modules/invoice/interfaces/responses/index.ts +10 -0
- package/src/modules/invoice/interfaces/responses/invoice-status.response.ts +142 -0
- package/src/modules/invoice/interfaces/responses/invoice.response.ts +14 -0
- package/src/modules/invoice/interfaces/responses/receipt.response.ts +6 -0
- package/src/modules/invoice/invoice.module.ts +8 -0
- package/src/modules/invoice/invoice.service.ts +191 -0
- package/src/modules/merchant/interfaces/index.ts +1 -0
- package/src/modules/merchant/interfaces/responses/index.ts +2 -0
- package/src/modules/merchant/interfaces/responses/merchant.response.ts +19 -0
- package/src/modules/merchant/interfaces/responses/pubkey.response.ts +10 -0
- package/src/modules/merchant/merchant.module.ts +8 -0
- package/src/modules/merchant/merchant.service.ts +46 -0
- package/src/modules/qr/enums/amount-type.enum.ts +13 -0
- package/src/modules/qr/enums/index.ts +1 -0
- package/src/modules/qr/interfaces/index.ts +0 -0
- package/src/modules/qr/interfaces/responses/index.ts +2 -0
- package/src/modules/qr/interfaces/responses/list.response.ts +11 -0
- package/src/modules/qr/interfaces/responses/qr.response.ts +18 -0
- package/src/modules/qr/qr.module.ts +8 -0
- package/src/modules/qr/qr.service.ts +43 -0
- package/src/modules/statement/interfaces/index.ts +1 -0
- package/src/modules/statement/interfaces/responses/index.ts +1 -0
- package/src/modules/statement/interfaces/responses/statement.response.ts +119 -0
- package/src/modules/statement/statement.module.ts +8 -0
- package/src/modules/statement/statement.service.ts +25 -0
- package/src/modules/subscription/enums/index.ts +2 -0
- package/src/modules/subscription/enums/subscription-status.enum.ts +14 -0
- package/src/modules/subscription/enums/wallet-status.enum.ts +19 -0
- package/src/modules/subscription/interfaces/index.ts +2 -0
- package/src/modules/subscription/interfaces/requests/client-subscriptions.request.ts +31 -0
- package/src/modules/subscription/interfaces/requests/create-subscription.request.ts +38 -0
- package/src/modules/subscription/interfaces/requests/edit-subscription.request.ts +20 -0
- package/src/modules/subscription/interfaces/requests/history.request.ts +20 -0
- package/src/modules/subscription/interfaces/requests/index.ts +4 -0
- package/src/modules/subscription/interfaces/responses/client-subscriptions.response.ts +36 -0
- package/src/modules/subscription/interfaces/responses/create-subscription.response.ts +6 -0
- package/src/modules/subscription/interfaces/responses/history.response.ts +12 -0
- package/src/modules/subscription/interfaces/responses/index.ts +5 -0
- package/src/modules/subscription/interfaces/responses/subscription-status.response.ts +40 -0
- package/src/modules/subscription/interfaces/responses/subscription.response.ts +11 -0
- package/src/modules/subscription/subscription.module.ts +8 -0
- package/src/modules/subscription/subscription.service.ts +121 -0
- package/src/modules/wallet/interfaces/index.ts +2 -0
- package/src/modules/wallet/interfaces/requests/create-card-token.request.ts +50 -0
- package/src/modules/wallet/interfaces/requests/index.ts +1 -0
- package/src/modules/wallet/interfaces/responses/card-token.response.ts +44 -0
- package/src/modules/wallet/interfaces/responses/create-card-token.response.ts +7 -0
- package/src/modules/wallet/interfaces/responses/index.ts +2 -0
- package/src/modules/wallet/wallet.module.ts +8 -0
- package/src/modules/wallet/wallet.service.ts +71 -0
- package/src/modules/webhook/webhook.module.ts +12 -0
- package/src/modules/webhook/webhook.service.ts +60 -0
- package/src/monobank.module.ts +115 -0
- package/src/monobank.service.ts +21 -0
- 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,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,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,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,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,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,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,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,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
|
+
}
|