@mnpay/bonum 1.5.0
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/@types/api.d.ts +225 -0
- package/@types/constants/apiUrls.d.ts +26 -0
- package/@types/constants/index.d.ts +1 -0
- package/@types/definitions/index.d.ts +1 -0
- package/@types/definitions/store.d.ts +11 -0
- package/@types/index.d.ts +6 -0
- package/@types/lib/api.d.ts +4 -0
- package/@types/lib/index.d.ts +1 -0
- package/@types/requests/auth.d.ts +11 -0
- package/@types/requests/card.d.ts +49 -0
- package/@types/requests/index.d.ts +6 -0
- package/@types/requests/invoice.d.ts +33 -0
- package/@types/requests/neo.d.ts +10 -0
- package/@types/requests/qr.d.ts +28 -0
- package/@types/requests/subscription.d.ts +96 -0
- package/@types/schemas/auth.d.ts +12 -0
- package/@types/schemas/card.d.ts +64 -0
- package/@types/schemas/common.d.ts +11 -0
- package/@types/schemas/config.d.ts +17 -0
- package/@types/schemas/index.d.ts +9 -0
- package/@types/schemas/invoice.d.ts +79 -0
- package/@types/schemas/neo.d.ts +5 -0
- package/@types/schemas/qr.d.ts +46 -0
- package/@types/schemas/subscription.d.ts +92 -0
- package/@types/schemas/webhook.d.ts +140 -0
- package/@types/test/_lib/liveTokenCache.d.ts +19 -0
- package/@types/test/_mocks/api.d.ts +241 -0
- package/@types/test/api.live.test.d.ts +1 -0
- package/@types/test/api.test.d.ts +1 -0
- package/@types/test/headers.test.d.ts +1 -0
- package/@types/test/setup.d.ts +1 -0
- package/@types/test/webhook.test.d.ts +1 -0
- package/@types/types/auth.d.ts +4 -0
- package/@types/types/card.d.ts +9 -0
- package/@types/types/common.d.ts +5 -0
- package/@types/types/config.d.ts +3 -0
- package/@types/types/index.d.ts +9 -0
- package/@types/types/invoice.d.ts +9 -0
- package/@types/types/neo.d.ts +3 -0
- package/@types/types/qr.d.ts +6 -0
- package/@types/types/subscription.d.ts +8 -0
- package/@types/types/webhook.d.ts +13 -0
- package/@types/utils/headers.d.ts +9 -0
- package/@types/utils/index.d.ts +2 -0
- package/@types/utils/webhook.d.ts +11 -0
- package/@types/vite.config.d.ts +2 -0
- package/@types/vitest.config.d.ts +2 -0
- package/CHANGELOG.md +57 -0
- package/README.md +486 -0
- package/dist/index.js +314 -0
- package/dist/index.umd.cjs +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const PaymentProviderSchema: z.ZodEnum<{
|
|
3
|
+
QPAY: "QPAY";
|
|
4
|
+
E_COMMERCE: "E_COMMERCE";
|
|
5
|
+
WE_CHAT: "WE_CHAT";
|
|
6
|
+
SONO_SHOP: "SONO_SHOP";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const PaymentProviderItemSchema: z.ZodObject<{
|
|
9
|
+
provider: z.ZodEnum<{
|
|
10
|
+
QPAY: "QPAY";
|
|
11
|
+
E_COMMERCE: "E_COMMERCE";
|
|
12
|
+
WE_CHAT: "WE_CHAT";
|
|
13
|
+
SONO_SHOP: "SONO_SHOP";
|
|
14
|
+
}>;
|
|
15
|
+
enabled: z.ZodBoolean;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export declare const InvoiceItemSchema: z.ZodObject<{
|
|
18
|
+
image: z.ZodOptional<z.ZodString>;
|
|
19
|
+
title: z.ZodString;
|
|
20
|
+
remark: z.ZodOptional<z.ZodString>;
|
|
21
|
+
amount: z.ZodNumber;
|
|
22
|
+
count: z.ZodNumber;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const ExtraInputTypeSchema: z.ZodEnum<{
|
|
25
|
+
NUMBER: "NUMBER";
|
|
26
|
+
PHONE: "PHONE";
|
|
27
|
+
EMAIL: "EMAIL";
|
|
28
|
+
TEXT: "TEXT";
|
|
29
|
+
ALL: "ALL";
|
|
30
|
+
}>;
|
|
31
|
+
export declare const InvoiceExtraSchema: z.ZodObject<{
|
|
32
|
+
placeholder: z.ZodString;
|
|
33
|
+
type: z.ZodEnum<{
|
|
34
|
+
NUMBER: "NUMBER";
|
|
35
|
+
PHONE: "PHONE";
|
|
36
|
+
EMAIL: "EMAIL";
|
|
37
|
+
TEXT: "TEXT";
|
|
38
|
+
ALL: "ALL";
|
|
39
|
+
}>;
|
|
40
|
+
required: z.ZodBoolean;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export declare const CreateInvoiceRequestSchema: z.ZodObject<{
|
|
43
|
+
amount: z.ZodNumber;
|
|
44
|
+
callback: z.ZodString;
|
|
45
|
+
transactionId: z.ZodString;
|
|
46
|
+
expiresIn: z.ZodNumber;
|
|
47
|
+
providers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
48
|
+
QPAY: "QPAY";
|
|
49
|
+
E_COMMERCE: "E_COMMERCE";
|
|
50
|
+
WE_CHAT: "WE_CHAT";
|
|
51
|
+
SONO_SHOP: "SONO_SHOP";
|
|
52
|
+
}>>>;
|
|
53
|
+
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
54
|
+
image: z.ZodOptional<z.ZodString>;
|
|
55
|
+
title: z.ZodString;
|
|
56
|
+
remark: z.ZodOptional<z.ZodString>;
|
|
57
|
+
amount: z.ZodNumber;
|
|
58
|
+
count: z.ZodNumber;
|
|
59
|
+
}, z.core.$strip>>>;
|
|
60
|
+
extras: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
61
|
+
placeholder: z.ZodString;
|
|
62
|
+
type: z.ZodEnum<{
|
|
63
|
+
NUMBER: "NUMBER";
|
|
64
|
+
PHONE: "PHONE";
|
|
65
|
+
EMAIL: "EMAIL";
|
|
66
|
+
TEXT: "TEXT";
|
|
67
|
+
ALL: "ALL";
|
|
68
|
+
}>;
|
|
69
|
+
required: z.ZodBoolean;
|
|
70
|
+
}, z.core.$strip>>>;
|
|
71
|
+
language: z.ZodOptional<z.ZodEnum<{
|
|
72
|
+
mn: "mn";
|
|
73
|
+
en: "en";
|
|
74
|
+
}>>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export declare const CreateInvoiceResponseSchema: z.ZodObject<{
|
|
77
|
+
invoiceId: z.ZodString;
|
|
78
|
+
followUpLink: z.ZodString;
|
|
79
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CreateQrCodeRequestSchema: z.ZodObject<{
|
|
3
|
+
amount: z.ZodNumber;
|
|
4
|
+
transactionId: z.ZodString;
|
|
5
|
+
expiresIn: z.ZodNumber;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const QrDeepLinkSchema: z.ZodObject<{
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
description: z.ZodString;
|
|
10
|
+
logo: z.ZodString;
|
|
11
|
+
link: z.ZodString;
|
|
12
|
+
appStoreId: z.ZodString;
|
|
13
|
+
androidPackageName: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const CreateQrCodeResponseDataSchema: z.ZodObject<{
|
|
16
|
+
invoiceId: z.ZodString;
|
|
17
|
+
qrCode: z.ZodString;
|
|
18
|
+
qrImage: z.ZodString;
|
|
19
|
+
links: z.ZodArray<z.ZodObject<{
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
description: z.ZodString;
|
|
22
|
+
logo: z.ZodString;
|
|
23
|
+
link: z.ZodString;
|
|
24
|
+
appStoreId: z.ZodString;
|
|
25
|
+
androidPackageName: z.ZodString;
|
|
26
|
+
}, z.core.$strip>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export declare const CreateQrCodeResponseSchema: z.ZodObject<{
|
|
29
|
+
data: z.ZodObject<{
|
|
30
|
+
invoiceId: z.ZodString;
|
|
31
|
+
qrCode: z.ZodString;
|
|
32
|
+
qrImage: z.ZodString;
|
|
33
|
+
links: z.ZodArray<z.ZodObject<{
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
description: z.ZodString;
|
|
36
|
+
logo: z.ZodString;
|
|
37
|
+
link: z.ZodString;
|
|
38
|
+
appStoreId: z.ZodString;
|
|
39
|
+
androidPackageName: z.ZodString;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export declare const PayByCardTokenQrRequestSchema: z.ZodObject<{
|
|
44
|
+
qrCode: z.ZodString;
|
|
45
|
+
transactionId: z.ZodString;
|
|
46
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const RecurringTypeSchema: z.ZodEnum<{
|
|
3
|
+
WEEKLY: "WEEKLY";
|
|
4
|
+
MONTHLY: "MONTHLY";
|
|
5
|
+
YEARLY: "YEARLY";
|
|
6
|
+
}>;
|
|
7
|
+
export declare const PaymentPlanSchema: z.ZodObject<{
|
|
8
|
+
planId: z.ZodNumber;
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
remark: z.ZodString;
|
|
11
|
+
createdAt: z.ZodString;
|
|
12
|
+
recurringType: z.ZodEnum<{
|
|
13
|
+
WEEKLY: "WEEKLY";
|
|
14
|
+
MONTHLY: "MONTHLY";
|
|
15
|
+
YEARLY: "YEARLY";
|
|
16
|
+
}>;
|
|
17
|
+
amount: z.ZodNumber;
|
|
18
|
+
status: z.ZodEnum<{
|
|
19
|
+
ACTIVE: "ACTIVE";
|
|
20
|
+
INACTIVE: "INACTIVE";
|
|
21
|
+
}>;
|
|
22
|
+
cardCount: z.ZodNumber;
|
|
23
|
+
retryCount: z.ZodNumber;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare const SubscribeRequestSchema: z.ZodObject<{
|
|
26
|
+
planId: z.ZodNumber;
|
|
27
|
+
cycleValue: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
28
|
+
cycles: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
29
|
+
payNow: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
custEmail: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export declare const SubscriptionDataSchema: z.ZodObject<{
|
|
33
|
+
subscriptionId: z.ZodNumber;
|
|
34
|
+
subscribedAt: z.ZodString;
|
|
35
|
+
cardMask: z.ZodString;
|
|
36
|
+
plan: z.ZodObject<{
|
|
37
|
+
planId: z.ZodNumber;
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
remark: z.ZodString;
|
|
40
|
+
createdAt: z.ZodString;
|
|
41
|
+
recurringType: z.ZodEnum<{
|
|
42
|
+
WEEKLY: "WEEKLY";
|
|
43
|
+
MONTHLY: "MONTHLY";
|
|
44
|
+
YEARLY: "YEARLY";
|
|
45
|
+
}>;
|
|
46
|
+
amount: z.ZodNumber;
|
|
47
|
+
status: z.ZodEnum<{
|
|
48
|
+
ACTIVE: "ACTIVE";
|
|
49
|
+
INACTIVE: "INACTIVE";
|
|
50
|
+
}>;
|
|
51
|
+
cardCount: z.ZodNumber;
|
|
52
|
+
retryCount: z.ZodNumber;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
nextBillAt: z.ZodString;
|
|
55
|
+
lastBilledAt: z.ZodString;
|
|
56
|
+
status: z.ZodEnum<{
|
|
57
|
+
ACTIVE: "ACTIVE";
|
|
58
|
+
INACTIVE: "INACTIVE";
|
|
59
|
+
CANCELLED: "CANCELLED";
|
|
60
|
+
}>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export declare const ChangeSubscriptionTokenRequestSchema: z.ZodObject<{
|
|
63
|
+
callback: z.ZodString;
|
|
64
|
+
transactionId: z.ZodString;
|
|
65
|
+
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
66
|
+
image: z.ZodOptional<z.ZodString>;
|
|
67
|
+
title: z.ZodString;
|
|
68
|
+
remark: z.ZodOptional<z.ZodString>;
|
|
69
|
+
amount: z.ZodNumber;
|
|
70
|
+
count: z.ZodNumber;
|
|
71
|
+
}, z.core.$strip>>>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export declare const ListPaymentPlansResponseSchema: z.ZodObject<{
|
|
74
|
+
data: z.ZodArray<z.ZodObject<{
|
|
75
|
+
planId: z.ZodNumber;
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
remark: z.ZodString;
|
|
78
|
+
createdAt: z.ZodString;
|
|
79
|
+
recurringType: z.ZodEnum<{
|
|
80
|
+
WEEKLY: "WEEKLY";
|
|
81
|
+
MONTHLY: "MONTHLY";
|
|
82
|
+
YEARLY: "YEARLY";
|
|
83
|
+
}>;
|
|
84
|
+
amount: z.ZodNumber;
|
|
85
|
+
status: z.ZodEnum<{
|
|
86
|
+
ACTIVE: "ACTIVE";
|
|
87
|
+
INACTIVE: "INACTIVE";
|
|
88
|
+
}>;
|
|
89
|
+
cardCount: z.ZodNumber;
|
|
90
|
+
retryCount: z.ZodNumber;
|
|
91
|
+
}, z.core.$strip>>;
|
|
92
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const WebhookTypeSchema: z.ZodEnum<{
|
|
3
|
+
PAYMENT: "PAYMENT";
|
|
4
|
+
"CARD-TOKEN": "CARD-TOKEN";
|
|
5
|
+
"SUBSCRIPTION-PAYMENT": "SUBSCRIPTION-PAYMENT";
|
|
6
|
+
UNSUBSCRIBED: "UNSUBSCRIBED";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const WebhookStatusSchema: z.ZodEnum<{
|
|
9
|
+
SUCCESS: "SUCCESS";
|
|
10
|
+
FAILED: "FAILED";
|
|
11
|
+
}>;
|
|
12
|
+
export declare const WebhookMessageSchema: z.ZodObject<{
|
|
13
|
+
type: z.ZodEnum<{
|
|
14
|
+
PAYMENT: "PAYMENT";
|
|
15
|
+
"CARD-TOKEN": "CARD-TOKEN";
|
|
16
|
+
"SUBSCRIPTION-PAYMENT": "SUBSCRIPTION-PAYMENT";
|
|
17
|
+
UNSUBSCRIBED: "UNSUBSCRIBED";
|
|
18
|
+
}>;
|
|
19
|
+
status: z.ZodEnum<{
|
|
20
|
+
SUCCESS: "SUCCESS";
|
|
21
|
+
FAILED: "FAILED";
|
|
22
|
+
}>;
|
|
23
|
+
message: z.ZodOptional<z.ZodString>;
|
|
24
|
+
body: z.ZodUnknown;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
/**
|
|
27
|
+
* PDF §3.3 — `PAYMENT` webhook body.
|
|
28
|
+
*
|
|
29
|
+
* The SUCCESS body carries the full transaction detail; the FAILED / expired body is a
|
|
30
|
+
* smaller shape (`transactionId`, `amount`, `currency`, `terminalId`, `invoiceStatus`).
|
|
31
|
+
* SUCCESS-only fields are therefore optional so a single schema parses both variants.
|
|
32
|
+
*/
|
|
33
|
+
export declare const PaymentWebhookBodySchema: z.ZodObject<{
|
|
34
|
+
amount: z.ZodNumber;
|
|
35
|
+
currency: z.ZodString;
|
|
36
|
+
transactionId: z.ZodString;
|
|
37
|
+
terminalId: z.ZodString;
|
|
38
|
+
completedAt: z.ZodOptional<z.ZodString>;
|
|
39
|
+
invoiceId: z.ZodOptional<z.ZodString>;
|
|
40
|
+
paymentVendor: z.ZodOptional<z.ZodString>;
|
|
41
|
+
initType: z.ZodOptional<z.ZodString>;
|
|
42
|
+
status: z.ZodOptional<z.ZodString>;
|
|
43
|
+
'extras-inputs': z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
44
|
+
extras: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
45
|
+
invoiceStatus: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
/** PDF §5.3 — `SUBSCRIPTION-PAYMENT` webhook body (automatic recurring charge). */
|
|
48
|
+
export declare const SubscriptionPaymentWebhookBodySchema: z.ZodObject<{
|
|
49
|
+
subscriptionId: z.ZodNumber;
|
|
50
|
+
invoiceId: z.ZodNumber;
|
|
51
|
+
planId: z.ZodNumber;
|
|
52
|
+
transactionId: z.ZodString;
|
|
53
|
+
completedAt: z.ZodString;
|
|
54
|
+
amount: z.ZodNumber;
|
|
55
|
+
currency: z.ZodString;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
/** Bank descriptor as carried inside the `CARD-TOKEN` webhook body (PDF §4.1). */
|
|
58
|
+
export declare const WebhookBankInfoSchema: z.ZodObject<{
|
|
59
|
+
id: z.ZodNumber;
|
|
60
|
+
code: z.ZodString;
|
|
61
|
+
name: z.ZodString;
|
|
62
|
+
icon: z.ZodString;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
/** PDF §4.1 — `CARD-TOKEN` webhook body (fired after a token is successfully created). */
|
|
65
|
+
export declare const CardTokenWebhookBodySchema: z.ZodObject<{
|
|
66
|
+
token: z.ZodString;
|
|
67
|
+
mask: z.ZodString;
|
|
68
|
+
expiry: z.ZodString;
|
|
69
|
+
bank: z.ZodObject<{
|
|
70
|
+
id: z.ZodNumber;
|
|
71
|
+
code: z.ZodString;
|
|
72
|
+
name: z.ZodString;
|
|
73
|
+
icon: z.ZodString;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
transactionId: z.ZodString;
|
|
76
|
+
completedAt: z.ZodString;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
/**
|
|
79
|
+
* Discriminated union over the three documented Bonum webhook `type`s
|
|
80
|
+
* (PDF §3.3 `PAYMENT`, §4.1 `CARD-TOKEN`, §5.3 `SUBSCRIPTION-PAYMENT`), each
|
|
81
|
+
* `SUCCESS` / `FAILED` (§7.2). Field names match the PDF exactly.
|
|
82
|
+
*/
|
|
83
|
+
export declare const bonumWebhookSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
84
|
+
type: z.ZodLiteral<"PAYMENT">;
|
|
85
|
+
status: z.ZodEnum<{
|
|
86
|
+
SUCCESS: "SUCCESS";
|
|
87
|
+
FAILED: "FAILED";
|
|
88
|
+
}>;
|
|
89
|
+
message: z.ZodOptional<z.ZodString>;
|
|
90
|
+
body: z.ZodObject<{
|
|
91
|
+
amount: z.ZodNumber;
|
|
92
|
+
currency: z.ZodString;
|
|
93
|
+
transactionId: z.ZodString;
|
|
94
|
+
terminalId: z.ZodString;
|
|
95
|
+
completedAt: z.ZodOptional<z.ZodString>;
|
|
96
|
+
invoiceId: z.ZodOptional<z.ZodString>;
|
|
97
|
+
paymentVendor: z.ZodOptional<z.ZodString>;
|
|
98
|
+
initType: z.ZodOptional<z.ZodString>;
|
|
99
|
+
status: z.ZodOptional<z.ZodString>;
|
|
100
|
+
'extras-inputs': z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
101
|
+
extras: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
102
|
+
invoiceStatus: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
105
|
+
type: z.ZodLiteral<"CARD-TOKEN">;
|
|
106
|
+
status: z.ZodEnum<{
|
|
107
|
+
SUCCESS: "SUCCESS";
|
|
108
|
+
FAILED: "FAILED";
|
|
109
|
+
}>;
|
|
110
|
+
message: z.ZodOptional<z.ZodString>;
|
|
111
|
+
body: z.ZodObject<{
|
|
112
|
+
token: z.ZodString;
|
|
113
|
+
mask: z.ZodString;
|
|
114
|
+
expiry: z.ZodString;
|
|
115
|
+
bank: z.ZodObject<{
|
|
116
|
+
id: z.ZodNumber;
|
|
117
|
+
code: z.ZodString;
|
|
118
|
+
name: z.ZodString;
|
|
119
|
+
icon: z.ZodString;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
transactionId: z.ZodString;
|
|
122
|
+
completedAt: z.ZodString;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
125
|
+
type: z.ZodLiteral<"SUBSCRIPTION-PAYMENT">;
|
|
126
|
+
status: z.ZodEnum<{
|
|
127
|
+
SUCCESS: "SUCCESS";
|
|
128
|
+
FAILED: "FAILED";
|
|
129
|
+
}>;
|
|
130
|
+
message: z.ZodOptional<z.ZodString>;
|
|
131
|
+
body: z.ZodObject<{
|
|
132
|
+
subscriptionId: z.ZodNumber;
|
|
133
|
+
invoiceId: z.ZodNumber;
|
|
134
|
+
planId: z.ZodNumber;
|
|
135
|
+
transactionId: z.ZodString;
|
|
136
|
+
completedAt: z.ZodString;
|
|
137
|
+
amount: z.ZodNumber;
|
|
138
|
+
currency: z.ZodString;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
}, z.core.$strip>], "type">;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BonumConfig } from '../../types/config.js';
|
|
2
|
+
import type { GetTokenResponse } from '../../types/auth.js';
|
|
3
|
+
/** Default path next to this file; override with `BONUM_TOKEN_CACHE_PATH`. */
|
|
4
|
+
export declare const defaultLiveTokenCachePath: string;
|
|
5
|
+
export declare const getLiveTokenCachePath: () => string;
|
|
6
|
+
export declare const isLiveTokenCacheEnabled: () => boolean;
|
|
7
|
+
export type LiveTokenCacheFile = {
|
|
8
|
+
fetchedAt: string;
|
|
9
|
+
response: GetTokenResponse;
|
|
10
|
+
};
|
|
11
|
+
/** Map a fresh authenticate response to `initialTokens` (TTL seconds are valid from now). */
|
|
12
|
+
export declare const initialTokensFromGetTokenResponse: (data: GetTokenResponse) => NonNullable<BonumConfig["initialTokens"]>;
|
|
13
|
+
/**
|
|
14
|
+
* Reconstruct `initialTokens` from a cached response + issue time.
|
|
15
|
+
* Returns `undefined` if the refresh window has ended (cache unusable).
|
|
16
|
+
*/
|
|
17
|
+
export declare const initialTokensFromCacheFile: (file: LiveTokenCacheFile) => NonNullable<BonumConfig["initialTokens"]> | undefined;
|
|
18
|
+
export declare const readLiveTokenCache: (cachePath: string) => Promise<LiveTokenCacheFile | null>;
|
|
19
|
+
export declare const writeLiveTokenCache: (cachePath: string, response: GetTokenResponse) => Promise<void>;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
2
|
+
export declare const bonum: {
|
|
3
|
+
api: import("axios").AxiosInstance;
|
|
4
|
+
getToken: (options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
5
|
+
tokenType: "Bearer";
|
|
6
|
+
accessToken: string;
|
|
7
|
+
expiresIn: number;
|
|
8
|
+
refreshToken: string;
|
|
9
|
+
refreshExpiresIn: number;
|
|
10
|
+
unit: "SECONDS";
|
|
11
|
+
}, any, {}>>;
|
|
12
|
+
refreshToken: (options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
13
|
+
accessToken: string;
|
|
14
|
+
}, any, {}>>;
|
|
15
|
+
getPaymentProviders: (options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
16
|
+
provider: "QPAY" | "E_COMMERCE" | "WE_CHAT" | "SONO_SHOP";
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
}[], any, {}>>;
|
|
19
|
+
createInvoice: (data: {
|
|
20
|
+
amount: number;
|
|
21
|
+
callback: string;
|
|
22
|
+
transactionId: string;
|
|
23
|
+
expiresIn: number;
|
|
24
|
+
providers?: ("QPAY" | "E_COMMERCE" | "WE_CHAT" | "SONO_SHOP")[] | undefined;
|
|
25
|
+
items?: {
|
|
26
|
+
title: string;
|
|
27
|
+
amount: number;
|
|
28
|
+
count: number;
|
|
29
|
+
image?: string | undefined;
|
|
30
|
+
remark?: string | undefined;
|
|
31
|
+
}[] | undefined;
|
|
32
|
+
extras?: {
|
|
33
|
+
placeholder: string;
|
|
34
|
+
type: "NUMBER" | "PHONE" | "EMAIL" | "TEXT" | "ALL";
|
|
35
|
+
required: boolean;
|
|
36
|
+
}[] | undefined;
|
|
37
|
+
language?: "mn" | "en" | undefined;
|
|
38
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
39
|
+
invoiceId: string;
|
|
40
|
+
followUpLink: string;
|
|
41
|
+
}, any, {}>>;
|
|
42
|
+
getInvoiceStatus: (data: {
|
|
43
|
+
invoiceId: string;
|
|
44
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
45
|
+
setInvoicePaid: (data: {
|
|
46
|
+
invoiceId: string;
|
|
47
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
48
|
+
createQrCode: (data: {
|
|
49
|
+
amount: number;
|
|
50
|
+
transactionId: string;
|
|
51
|
+
expiresIn: number;
|
|
52
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
53
|
+
data: {
|
|
54
|
+
invoiceId: string;
|
|
55
|
+
qrCode: string;
|
|
56
|
+
qrImage: string;
|
|
57
|
+
links: {
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
logo: string;
|
|
61
|
+
link: string;
|
|
62
|
+
appStoreId: string;
|
|
63
|
+
androidPackageName: string;
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
}, any, {}>>;
|
|
67
|
+
invoiceByQrCode: (data: {
|
|
68
|
+
qrCode: string;
|
|
69
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
70
|
+
payByCardTokenQr: (data: {
|
|
71
|
+
qrCode: string;
|
|
72
|
+
transactionId: string;
|
|
73
|
+
} & {
|
|
74
|
+
cardToken: string;
|
|
75
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
76
|
+
createCardToken: (data: {
|
|
77
|
+
callback: string;
|
|
78
|
+
transactionId: string;
|
|
79
|
+
payment?: {
|
|
80
|
+
amount: number;
|
|
81
|
+
} | undefined;
|
|
82
|
+
subscription?: {
|
|
83
|
+
planId: number;
|
|
84
|
+
cycleValue: string;
|
|
85
|
+
cycles?: number | null | undefined;
|
|
86
|
+
payNow?: boolean | undefined;
|
|
87
|
+
custEmail?: string | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
items?: {
|
|
90
|
+
title: string;
|
|
91
|
+
amount: number;
|
|
92
|
+
count: number;
|
|
93
|
+
image?: string | undefined;
|
|
94
|
+
remark?: string | undefined;
|
|
95
|
+
}[] | undefined;
|
|
96
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
97
|
+
followUpLink: string;
|
|
98
|
+
id: string;
|
|
99
|
+
}, any, {}>>;
|
|
100
|
+
purchaseWithCardToken: (data: {
|
|
101
|
+
amount: number;
|
|
102
|
+
currency: string;
|
|
103
|
+
transactionId: string;
|
|
104
|
+
} & {
|
|
105
|
+
cardToken: string;
|
|
106
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
107
|
+
id: number;
|
|
108
|
+
status: "SUCCESS" | "FAILED" | "QUEUED";
|
|
109
|
+
completedAt?: string | undefined;
|
|
110
|
+
description?: string | undefined;
|
|
111
|
+
cardStatus?: "ACTIVE" | "INACTIVE" | null | undefined;
|
|
112
|
+
respCode?: string | null | undefined;
|
|
113
|
+
}, any, {}>>;
|
|
114
|
+
rollbackPurchase: (data: {
|
|
115
|
+
id: string;
|
|
116
|
+
cardToken: string;
|
|
117
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
118
|
+
listPaymentPlans: (options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
119
|
+
data: {
|
|
120
|
+
planId: number;
|
|
121
|
+
name: string;
|
|
122
|
+
remark: string;
|
|
123
|
+
createdAt: string;
|
|
124
|
+
recurringType: "WEEKLY" | "MONTHLY" | "YEARLY";
|
|
125
|
+
amount: number;
|
|
126
|
+
status: "ACTIVE" | "INACTIVE";
|
|
127
|
+
cardCount: number;
|
|
128
|
+
retryCount: number;
|
|
129
|
+
}[];
|
|
130
|
+
}, any, {}>>;
|
|
131
|
+
subscribe: (data: {
|
|
132
|
+
planId: number;
|
|
133
|
+
cycleValue: string | number;
|
|
134
|
+
cycles?: number | null | undefined;
|
|
135
|
+
payNow?: boolean | undefined;
|
|
136
|
+
custEmail?: string | undefined;
|
|
137
|
+
} & {
|
|
138
|
+
cardToken: string;
|
|
139
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
140
|
+
subscriptionId: number;
|
|
141
|
+
subscribedAt: string;
|
|
142
|
+
cardMask: string;
|
|
143
|
+
plan: {
|
|
144
|
+
planId: number;
|
|
145
|
+
name: string;
|
|
146
|
+
remark: string;
|
|
147
|
+
createdAt: string;
|
|
148
|
+
recurringType: "WEEKLY" | "MONTHLY" | "YEARLY";
|
|
149
|
+
amount: number;
|
|
150
|
+
status: "ACTIVE" | "INACTIVE";
|
|
151
|
+
cardCount: number;
|
|
152
|
+
retryCount: number;
|
|
153
|
+
};
|
|
154
|
+
nextBillAt: string;
|
|
155
|
+
lastBilledAt: string;
|
|
156
|
+
status: "ACTIVE" | "INACTIVE" | "CANCELLED";
|
|
157
|
+
}, any, {}>>;
|
|
158
|
+
getSubscriptions: (data: {
|
|
159
|
+
cardToken: string;
|
|
160
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
161
|
+
subscriptionId: number;
|
|
162
|
+
subscribedAt: string;
|
|
163
|
+
cardMask: string;
|
|
164
|
+
plan: {
|
|
165
|
+
planId: number;
|
|
166
|
+
name: string;
|
|
167
|
+
remark: string;
|
|
168
|
+
createdAt: string;
|
|
169
|
+
recurringType: "WEEKLY" | "MONTHLY" | "YEARLY";
|
|
170
|
+
amount: number;
|
|
171
|
+
status: "ACTIVE" | "INACTIVE";
|
|
172
|
+
cardCount: number;
|
|
173
|
+
retryCount: number;
|
|
174
|
+
};
|
|
175
|
+
nextBillAt: string;
|
|
176
|
+
lastBilledAt: string;
|
|
177
|
+
status: "ACTIVE" | "INACTIVE" | "CANCELLED";
|
|
178
|
+
}[], any, {}>>;
|
|
179
|
+
unsubscribe: (data: {
|
|
180
|
+
subscriptionId: string;
|
|
181
|
+
planId?: string;
|
|
182
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
183
|
+
deleteSubscription: (data: {
|
|
184
|
+
subscriptionId: string;
|
|
185
|
+
planId?: string;
|
|
186
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
187
|
+
changeSubscriptionTokenNewCard: (data: {
|
|
188
|
+
callback: string;
|
|
189
|
+
transactionId: string;
|
|
190
|
+
items?: {
|
|
191
|
+
title: string;
|
|
192
|
+
amount: number;
|
|
193
|
+
count: number;
|
|
194
|
+
image?: string | undefined;
|
|
195
|
+
remark?: string | undefined;
|
|
196
|
+
}[] | undefined;
|
|
197
|
+
} & {
|
|
198
|
+
subscriptionId: string;
|
|
199
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<{
|
|
200
|
+
followUpLink: string;
|
|
201
|
+
}, any, {}>>;
|
|
202
|
+
changeSubscriptionTokenExisting: (data: {
|
|
203
|
+
subscriptionId: string;
|
|
204
|
+
newCardToken: string;
|
|
205
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
206
|
+
executeSubscriptionPayment: (data: {
|
|
207
|
+
subscriptionId: string;
|
|
208
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
209
|
+
getNeoUserData: (data: {
|
|
210
|
+
requestId: string;
|
|
211
|
+
mChatBaseUrl: string;
|
|
212
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
213
|
+
sendNeoMessage: (data: {
|
|
214
|
+
phoneNumber: string;
|
|
215
|
+
message: string;
|
|
216
|
+
} & {
|
|
217
|
+
neoBaseUrl: string;
|
|
218
|
+
}, options?: import("axios").AxiosRequestConfig) => Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
219
|
+
verifyWebhookChecksum: (rawBody: string, headerChecksum: string) => boolean;
|
|
220
|
+
};
|
|
221
|
+
export declare const mockApi: MockAdapter;
|
|
222
|
+
export declare const mockGetToken: () => void;
|
|
223
|
+
export declare const mockRefreshToken: () => void;
|
|
224
|
+
export declare const mockGetPaymentProviders: () => void;
|
|
225
|
+
export declare const mockCreateInvoice: () => void;
|
|
226
|
+
export declare const mockGetInvoiceStatus: (invoiceId: string) => void;
|
|
227
|
+
export declare const mockSetInvoicePaid: (invoiceId: string) => void;
|
|
228
|
+
export declare const mockCreateQrCode: () => void;
|
|
229
|
+
export declare const mockInvoiceByQrCode: () => void;
|
|
230
|
+
export declare const mockPayByCardTokenQr: () => void;
|
|
231
|
+
export declare const mockCreateCardToken: () => void;
|
|
232
|
+
export declare const mockPurchaseWithCardToken: () => void;
|
|
233
|
+
export declare const mockRollbackPurchase: (id: string) => void;
|
|
234
|
+
export declare const mockListPaymentPlans: () => void;
|
|
235
|
+
export declare const mockSubscribe: () => void;
|
|
236
|
+
export declare const mockGetSubscriptions: () => void;
|
|
237
|
+
export declare const mockUnsubscribe: (subscriptionId: string) => void;
|
|
238
|
+
export declare const mockDeleteSubscription: (subscriptionId: string) => void;
|
|
239
|
+
export declare const mockChangeSubscriptionTokenNewCard: (subscriptionId: string) => void;
|
|
240
|
+
export declare const mockChangeSubscriptionTokenExisting: (subscriptionId: string) => void;
|
|
241
|
+
export declare const mockExecuteSubscriptionPayment: (subscriptionId: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CardTokenPaymentSchema, CardTokenSubscriptionSchema, CreateCardTokenRequestSchema, CreateCardTokenResponseSchema, BankInfoSchema, PurchaseRequestSchema, PurchaseTransactionDataSchema } from '../schemas/card.js';
|
|
3
|
+
export type CardTokenPayment = z.infer<typeof CardTokenPaymentSchema>;
|
|
4
|
+
export type CardTokenSubscription = z.infer<typeof CardTokenSubscriptionSchema>;
|
|
5
|
+
export type CreateCardTokenRequest = z.infer<typeof CreateCardTokenRequestSchema>;
|
|
6
|
+
export type CreateCardTokenResponse = z.infer<typeof CreateCardTokenResponseSchema>;
|
|
7
|
+
export type BankInfo = z.infer<typeof BankInfoSchema>;
|
|
8
|
+
export type PurchaseRequest = z.infer<typeof PurchaseRequestSchema>;
|
|
9
|
+
export type PurchaseTransactionData = z.infer<typeof PurchaseTransactionDataSchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './config.js';
|
|
2
|
+
export * from './auth.js';
|
|
3
|
+
export * from './invoice.js';
|
|
4
|
+
export * from './qr.js';
|
|
5
|
+
export * from './card.js';
|
|
6
|
+
export * from './subscription.js';
|
|
7
|
+
export * from './neo.js';
|
|
8
|
+
export * from './common.js';
|
|
9
|
+
export * from './webhook.js';
|