monime-package 1.0.5 → 1.0.7
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/README.md +664 -142
- package/dist/index.d.mts +194 -1
- package/dist/index.d.ts +194 -1
- package/dist/index.js +192 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +192 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,164 @@
|
|
|
1
|
+
// src/modules/checkout session/checkoutSession.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
var URL = "https://api.monime.io/v1/checkout-sessions";
|
|
4
|
+
async function createCheckout(client, name, amount, quantity, successUrl, cancelUrl, description, financialAccountId, primaryColor, images) {
|
|
5
|
+
const { monimeSpaceId, accessToken } = client._getConfig();
|
|
6
|
+
const body = {
|
|
7
|
+
name,
|
|
8
|
+
description,
|
|
9
|
+
cancelUrl,
|
|
10
|
+
successUrl,
|
|
11
|
+
callbackState: null,
|
|
12
|
+
reference: null,
|
|
13
|
+
financialAccountId,
|
|
14
|
+
lineItems: [
|
|
15
|
+
{
|
|
16
|
+
type: "custom",
|
|
17
|
+
name,
|
|
18
|
+
price: {
|
|
19
|
+
currency: "SLE",
|
|
20
|
+
value: amount
|
|
21
|
+
},
|
|
22
|
+
quantity,
|
|
23
|
+
reference: null,
|
|
24
|
+
description,
|
|
25
|
+
images
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
paymentOptions: {
|
|
29
|
+
card: {
|
|
30
|
+
disable: false
|
|
31
|
+
},
|
|
32
|
+
bank: {
|
|
33
|
+
disable: false,
|
|
34
|
+
enabledProviders: ["slb001", "slb004", "slb007"]
|
|
35
|
+
// disabledProviders: ["slb001"],
|
|
36
|
+
},
|
|
37
|
+
momo: {
|
|
38
|
+
disable: false,
|
|
39
|
+
enabledProviders: ["m17", "m18"]
|
|
40
|
+
// disabledProviders: ["m17"],
|
|
41
|
+
},
|
|
42
|
+
wallet: {
|
|
43
|
+
disable: false,
|
|
44
|
+
enabledProviders: ["dw001"]
|
|
45
|
+
// disabledProviders: ["dw001"],
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
brandingOptions: {
|
|
49
|
+
primaryColor
|
|
50
|
+
},
|
|
51
|
+
metadata: {}
|
|
52
|
+
};
|
|
53
|
+
try {
|
|
54
|
+
const res = await axios.post(URL, body, {
|
|
55
|
+
headers: {
|
|
56
|
+
"Monime-Space-Id": monimeSpaceId,
|
|
57
|
+
Authorization: `Bearer ${accessToken}`
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const data = res.data;
|
|
61
|
+
return { success: true, data };
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (axios.isAxiosError(error)) {
|
|
64
|
+
return { error, success: false };
|
|
65
|
+
}
|
|
66
|
+
return { error: new Error("unknown error"), success: false };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function getAllCheckout(client) {
|
|
70
|
+
const { accessToken, monimeSpaceId } = client._getConfig();
|
|
71
|
+
try {
|
|
72
|
+
const res = await axios.get(URL, {
|
|
73
|
+
headers: {
|
|
74
|
+
"Monime-Space-Id": monimeSpaceId,
|
|
75
|
+
Authorization: `Bearer ${accessToken}`
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const data = res.data;
|
|
79
|
+
return { success: true, data };
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (axios.isAxiosError(error)) {
|
|
82
|
+
return { error, success: false };
|
|
83
|
+
}
|
|
84
|
+
return { error: new Error("unknown error"), success: false };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function getOnecheckout(client, checkoutId) {
|
|
88
|
+
const { accessToken, monimeSpaceId } = client._getConfig();
|
|
89
|
+
try {
|
|
90
|
+
const res = await axios.get(`${URL}/${checkoutId}`, {
|
|
91
|
+
headers: {
|
|
92
|
+
"Monime-Space-Id": monimeSpaceId,
|
|
93
|
+
Authorization: `Bearer ${accessToken}`
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
const data = res.data;
|
|
97
|
+
return { success: true, data };
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (axios.isAxiosError(error)) {
|
|
100
|
+
return { error, success: false };
|
|
101
|
+
}
|
|
102
|
+
return { error: new Error("unknown error"), success: false };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function deleteCheckout(client, checkoutId) {
|
|
106
|
+
const { accessToken, monimeSpaceId } = client._getConfig();
|
|
107
|
+
try {
|
|
108
|
+
await axios.delete(`${URL}/${checkoutId}`, {
|
|
109
|
+
headers: {
|
|
110
|
+
"Monime-Space-Id": monimeSpaceId,
|
|
111
|
+
Authorization: `Bearer ${accessToken}`
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return { success: true };
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if (axios.isAxiosError(error)) {
|
|
117
|
+
return { error, success: false };
|
|
118
|
+
}
|
|
119
|
+
return { error: new Error("unknown error"), success: false };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/modules/checkout session/index.ts
|
|
124
|
+
function CheckoutSessionAPI(client) {
|
|
125
|
+
return {
|
|
126
|
+
create: (name, amount, quantity, successUrl, cancelUrl, description, financialAccountId, primaryColor, images) => createCheckout(
|
|
127
|
+
client,
|
|
128
|
+
name,
|
|
129
|
+
amount,
|
|
130
|
+
quantity,
|
|
131
|
+
successUrl,
|
|
132
|
+
cancelUrl,
|
|
133
|
+
description,
|
|
134
|
+
financialAccountId,
|
|
135
|
+
primaryColor,
|
|
136
|
+
images
|
|
137
|
+
),
|
|
138
|
+
get: () => getAllCheckout(client),
|
|
139
|
+
getOne: (checkoutId) => getOnecheckout(client, checkoutId),
|
|
140
|
+
delete: (checkoutId) => deleteCheckout(client, checkoutId)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
1
144
|
// src/modules/financialAccount/financialAccount.ts
|
|
2
145
|
import { randomBytes } from "crypto";
|
|
3
|
-
import
|
|
4
|
-
var
|
|
146
|
+
import axios2 from "axios";
|
|
147
|
+
var URL2 = "https://api.monime.io/v1/financial-accounts";
|
|
5
148
|
var value = randomBytes(20).toString("hex");
|
|
6
|
-
async function createFinancialAccount(accountName, client) {
|
|
149
|
+
async function createFinancialAccount(accountName, currency, client) {
|
|
7
150
|
if (accountName.trim() === "") {
|
|
8
151
|
return { success: false, error: new Error("accountName is required") };
|
|
9
152
|
}
|
|
10
153
|
const body = {
|
|
11
154
|
name: accountName,
|
|
12
|
-
currency
|
|
155
|
+
currency,
|
|
13
156
|
description: "",
|
|
14
157
|
metadata: {}
|
|
15
158
|
};
|
|
16
159
|
const { accessToken, monimeSpaceId } = client._getConfig();
|
|
17
160
|
try {
|
|
18
|
-
const res = await
|
|
161
|
+
const res = await axios2.post(URL2, body, {
|
|
19
162
|
headers: {
|
|
20
163
|
"Idempotency-Key": `${value}`,
|
|
21
164
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
@@ -26,7 +169,7 @@ async function createFinancialAccount(accountName, client) {
|
|
|
26
169
|
const data = res.data;
|
|
27
170
|
return { success: true, data };
|
|
28
171
|
} catch (error) {
|
|
29
|
-
if (
|
|
172
|
+
if (axios2.isAxiosError(error)) {
|
|
30
173
|
return { error, success: false };
|
|
31
174
|
}
|
|
32
175
|
return { error: new Error("unknown error"), success: false };
|
|
@@ -41,7 +184,7 @@ async function getFinancialAccount(financialAccountId, client) {
|
|
|
41
184
|
}
|
|
42
185
|
const { monimeSpaceId, accessToken } = client._getConfig();
|
|
43
186
|
try {
|
|
44
|
-
const res = await
|
|
187
|
+
const res = await axios2.get(`${URL2}/${financialAccountId}`, {
|
|
45
188
|
headers: {
|
|
46
189
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
47
190
|
Authorization: `Bearer ${accessToken}`
|
|
@@ -50,7 +193,7 @@ async function getFinancialAccount(financialAccountId, client) {
|
|
|
50
193
|
const data = res.data;
|
|
51
194
|
return { success: true, data };
|
|
52
195
|
} catch (error) {
|
|
53
|
-
if (
|
|
196
|
+
if (axios2.isAxiosError(error)) {
|
|
54
197
|
return { error, success: false };
|
|
55
198
|
}
|
|
56
199
|
return { error: new Error("unknown error"), success: false };
|
|
@@ -59,7 +202,7 @@ async function getFinancialAccount(financialAccountId, client) {
|
|
|
59
202
|
async function getAllFinancialAccount(client) {
|
|
60
203
|
const { monimeSpaceId, accessToken } = client._getConfig();
|
|
61
204
|
try {
|
|
62
|
-
const res = await
|
|
205
|
+
const res = await axios2.get(URL2, {
|
|
63
206
|
headers: {
|
|
64
207
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
65
208
|
Authorization: `Bearer ${accessToken}`
|
|
@@ -68,7 +211,7 @@ async function getAllFinancialAccount(client) {
|
|
|
68
211
|
const data = res.data;
|
|
69
212
|
return { success: true, data };
|
|
70
213
|
} catch (error) {
|
|
71
|
-
if (
|
|
214
|
+
if (axios2.isAxiosError(error)) {
|
|
72
215
|
return { error, success: false };
|
|
73
216
|
}
|
|
74
217
|
return { error: new Error("unknown error"), success: false };
|
|
@@ -78,19 +221,19 @@ async function getAllFinancialAccount(client) {
|
|
|
78
221
|
// src/modules/financialAccount/index.ts
|
|
79
222
|
function FinancialAccountAPI(client) {
|
|
80
223
|
return {
|
|
81
|
-
create: (name) => createFinancialAccount(name, client),
|
|
224
|
+
create: (name, currency) => createFinancialAccount(name, currency, client),
|
|
82
225
|
get: (financialAccountId) => getFinancialAccount(financialAccountId, client),
|
|
83
226
|
getAll: () => getAllFinancialAccount(client)
|
|
84
227
|
};
|
|
85
228
|
}
|
|
86
229
|
|
|
87
230
|
// src/modules/financialTransaction/financialTransaction.ts
|
|
88
|
-
import
|
|
89
|
-
var
|
|
231
|
+
import axios3 from "axios";
|
|
232
|
+
var URL3 = "https://api.monime.io/v1/financial-transactions";
|
|
90
233
|
async function getAllTransaction(client) {
|
|
91
234
|
const { monimeSpaceId, accessToken } = client._getConfig();
|
|
92
235
|
try {
|
|
93
|
-
const res = await
|
|
236
|
+
const res = await axios3.get(URL3, {
|
|
94
237
|
headers: {
|
|
95
238
|
Authorization: `Bearer ${accessToken}`,
|
|
96
239
|
"Monime-Space-Id": `${monimeSpaceId}`
|
|
@@ -99,7 +242,7 @@ async function getAllTransaction(client) {
|
|
|
99
242
|
const data = res.data;
|
|
100
243
|
return { success: true, data };
|
|
101
244
|
} catch (error) {
|
|
102
|
-
if (
|
|
245
|
+
if (axios3.isAxiosError(error)) {
|
|
103
246
|
return { error, success: false };
|
|
104
247
|
}
|
|
105
248
|
return { error: new Error("unknown error"), success: false };
|
|
@@ -114,7 +257,7 @@ async function getTransaction(client, transactionId) {
|
|
|
114
257
|
};
|
|
115
258
|
}
|
|
116
259
|
try {
|
|
117
|
-
const res = await
|
|
260
|
+
const res = await axios3.get(`${URL3}/${transactionId}`, {
|
|
118
261
|
headers: {
|
|
119
262
|
Authorization: `Bearer ${accessToken}`,
|
|
120
263
|
"Monime-Space-Id": `${monimeSpaceId}`
|
|
@@ -123,7 +266,7 @@ async function getTransaction(client, transactionId) {
|
|
|
123
266
|
const data = res.data;
|
|
124
267
|
return { success: true, data };
|
|
125
268
|
} catch (error) {
|
|
126
|
-
if (
|
|
269
|
+
if (axios3.isAxiosError(error)) {
|
|
127
270
|
return { error, success: false };
|
|
128
271
|
}
|
|
129
272
|
return { error: new Error("unknown error"), success: false };
|
|
@@ -140,8 +283,8 @@ function FinancialTransactionAPI(client) {
|
|
|
140
283
|
|
|
141
284
|
// src/modules/internalTransfer/internalTransfer.ts
|
|
142
285
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
143
|
-
import
|
|
144
|
-
var
|
|
286
|
+
import axios4 from "axios";
|
|
287
|
+
var URL4 = "https://api.monime.io/v1/internal-transfers";
|
|
145
288
|
var value2 = randomBytes2(20).toString("hex");
|
|
146
289
|
async function createInternalTransfer(sourceAccount, destinationAccount, client, amount) {
|
|
147
290
|
if (amount <= 0) {
|
|
@@ -171,7 +314,7 @@ async function createInternalTransfer(sourceAccount, destinationAccount, client,
|
|
|
171
314
|
};
|
|
172
315
|
const { accessToken, monimeSpaceId } = client._getConfig();
|
|
173
316
|
try {
|
|
174
|
-
const res = await
|
|
317
|
+
const res = await axios4.post(URL4, body, {
|
|
175
318
|
headers: {
|
|
176
319
|
"Idempotency-Key": `${value2}`,
|
|
177
320
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
@@ -182,7 +325,7 @@ async function createInternalTransfer(sourceAccount, destinationAccount, client,
|
|
|
182
325
|
const data = res.data;
|
|
183
326
|
return { success: true, data };
|
|
184
327
|
} catch (error) {
|
|
185
|
-
if (
|
|
328
|
+
if (axios4.isAxiosError(error)) {
|
|
186
329
|
return { error, success: false };
|
|
187
330
|
}
|
|
188
331
|
return { error: new Error("unkknown error"), success: false };
|
|
@@ -191,7 +334,7 @@ async function createInternalTransfer(sourceAccount, destinationAccount, client,
|
|
|
191
334
|
async function getAllInternalTransfers(client) {
|
|
192
335
|
const { monimeSpaceId, accessToken } = client._getConfig();
|
|
193
336
|
try {
|
|
194
|
-
const res = await
|
|
337
|
+
const res = await axios4.get(URL4, {
|
|
195
338
|
headers: {
|
|
196
339
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
197
340
|
Authorization: `Bearer ${accessToken}`
|
|
@@ -200,7 +343,7 @@ async function getAllInternalTransfers(client) {
|
|
|
200
343
|
const data = res.data;
|
|
201
344
|
return { success: true, data };
|
|
202
345
|
} catch (error) {
|
|
203
|
-
if (
|
|
346
|
+
if (axios4.isAxiosError(error)) {
|
|
204
347
|
return { success: false, error };
|
|
205
348
|
}
|
|
206
349
|
return { error: new Error("unkknown error"), success: false };
|
|
@@ -209,7 +352,7 @@ async function getAllInternalTransfers(client) {
|
|
|
209
352
|
async function getInternalTransfer(client, internalTransferId) {
|
|
210
353
|
const { accessToken, monimeSpaceId } = client._getConfig();
|
|
211
354
|
try {
|
|
212
|
-
const res = await
|
|
355
|
+
const res = await axios4.get(`${URL4}/${internalTransferId}`, {
|
|
213
356
|
headers: {
|
|
214
357
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
215
358
|
Authorization: `Bearer ${accessToken}`
|
|
@@ -218,7 +361,7 @@ async function getInternalTransfer(client, internalTransferId) {
|
|
|
218
361
|
const data = res.data;
|
|
219
362
|
return { success: true, data };
|
|
220
363
|
} catch (error) {
|
|
221
|
-
if (
|
|
364
|
+
if (axios4.isAxiosError(error)) {
|
|
222
365
|
return { success: false, error };
|
|
223
366
|
}
|
|
224
367
|
return { error: new Error("unkknown error"), success: false };
|
|
@@ -227,7 +370,7 @@ async function getInternalTransfer(client, internalTransferId) {
|
|
|
227
370
|
async function deleteInternalTransfer(client, internalTransferId) {
|
|
228
371
|
const { monimeSpaceId, accessToken } = client._getConfig();
|
|
229
372
|
try {
|
|
230
|
-
await
|
|
373
|
+
await axios4.delete(`${URL4}/${internalTransferId}`, {
|
|
231
374
|
headers: {
|
|
232
375
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
233
376
|
Authorization: `Bearer ${accessToken}`
|
|
@@ -235,7 +378,7 @@ async function deleteInternalTransfer(client, internalTransferId) {
|
|
|
235
378
|
});
|
|
236
379
|
return { success: true };
|
|
237
380
|
} catch (error) {
|
|
238
|
-
if (
|
|
381
|
+
if (axios4.isAxiosError(error)) {
|
|
239
382
|
return { success: false, error };
|
|
240
383
|
}
|
|
241
384
|
return { success: false, error: new Error("unknown error") };
|
|
@@ -259,9 +402,9 @@ function InternalTransferAPI(client) {
|
|
|
259
402
|
|
|
260
403
|
// src/modules/paymentCode/paymentCode.ts
|
|
261
404
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
262
|
-
import
|
|
405
|
+
import axios5 from "axios";
|
|
263
406
|
var value3 = randomBytes3(20).toString("hex");
|
|
264
|
-
var
|
|
407
|
+
var URL5 = "https://api.monime.io/v1/payment-codes";
|
|
265
408
|
async function createPaymentCode(paymentName, amount, financialAccountId, name, phoneNumber, client) {
|
|
266
409
|
let financialAccount = null;
|
|
267
410
|
if (financialAccountId !== "") {
|
|
@@ -306,7 +449,7 @@ async function createPaymentCode(paymentName, amount, financialAccountId, name,
|
|
|
306
449
|
metadata: {}
|
|
307
450
|
};
|
|
308
451
|
try {
|
|
309
|
-
const res = await
|
|
452
|
+
const res = await axios5.post(URL5, bodyData, {
|
|
310
453
|
headers: {
|
|
311
454
|
"Idempotency-Key": `${value3}`,
|
|
312
455
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
@@ -317,7 +460,7 @@ async function createPaymentCode(paymentName, amount, financialAccountId, name,
|
|
|
317
460
|
const data = res.data;
|
|
318
461
|
return { data, success: true };
|
|
319
462
|
} catch (error) {
|
|
320
|
-
if (
|
|
463
|
+
if (axios5.isAxiosError(error)) {
|
|
321
464
|
return { error: error.response?.data, success: false };
|
|
322
465
|
}
|
|
323
466
|
return { error: new Error("unknown error"), success: false };
|
|
@@ -329,7 +472,7 @@ async function deletePaymentCode(paymentCodeId, client) {
|
|
|
329
472
|
return { success: false, error: new Error("paymentCodeId is required") };
|
|
330
473
|
}
|
|
331
474
|
try {
|
|
332
|
-
await
|
|
475
|
+
await axios5.delete(`${URL5}/${paymentCodeId}`, {
|
|
333
476
|
headers: {
|
|
334
477
|
"Idempotency-Key": `${value3}`,
|
|
335
478
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
@@ -339,7 +482,7 @@ async function deletePaymentCode(paymentCodeId, client) {
|
|
|
339
482
|
});
|
|
340
483
|
return { success: true };
|
|
341
484
|
} catch (error) {
|
|
342
|
-
if (
|
|
485
|
+
if (axios5.isAxiosError(error)) {
|
|
343
486
|
return { error, success: false };
|
|
344
487
|
}
|
|
345
488
|
return { error: new Error("unknown error"), success: false };
|
|
@@ -348,7 +491,7 @@ async function deletePaymentCode(paymentCodeId, client) {
|
|
|
348
491
|
async function getAllPaymentCode(client) {
|
|
349
492
|
const { monimeSpaceId, accessToken } = client._getConfig();
|
|
350
493
|
try {
|
|
351
|
-
const res = await
|
|
494
|
+
const res = await axios5.get(URL5, {
|
|
352
495
|
headers: {
|
|
353
496
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
354
497
|
Authorization: `Bearer ${accessToken}`
|
|
@@ -357,7 +500,7 @@ async function getAllPaymentCode(client) {
|
|
|
357
500
|
const data = res.data;
|
|
358
501
|
return { success: true, data };
|
|
359
502
|
} catch (error) {
|
|
360
|
-
if (
|
|
503
|
+
if (axios5.isAxiosError(error)) {
|
|
361
504
|
return { error, success: false };
|
|
362
505
|
}
|
|
363
506
|
return { error: new Error("unknown error"), success: false };
|
|
@@ -366,7 +509,7 @@ async function getAllPaymentCode(client) {
|
|
|
366
509
|
async function getPaymentCode(paymentCodeId, client) {
|
|
367
510
|
const { monimeSpaceId, accessToken } = client._getConfig();
|
|
368
511
|
try {
|
|
369
|
-
const res = await
|
|
512
|
+
const res = await axios5.get(`${URL5}/${paymentCodeId}`, {
|
|
370
513
|
headers: {
|
|
371
514
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
372
515
|
Authorization: `Bearer ${accessToken}`
|
|
@@ -375,7 +518,7 @@ async function getPaymentCode(paymentCodeId, client) {
|
|
|
375
518
|
const data = res.data;
|
|
376
519
|
return { success: true, data };
|
|
377
520
|
} catch (error) {
|
|
378
|
-
if (
|
|
521
|
+
if (axios5.isAxiosError(error)) {
|
|
379
522
|
return { error, success: false };
|
|
380
523
|
}
|
|
381
524
|
return { error: new Error("unknown error"), success: false };
|
|
@@ -401,8 +544,8 @@ function PaymentCodeAPI(client) {
|
|
|
401
544
|
|
|
402
545
|
// src/modules/payout/payout.ts
|
|
403
546
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
404
|
-
import
|
|
405
|
-
var
|
|
547
|
+
import axios6 from "axios";
|
|
548
|
+
var URL6 = "https://api.monime.io/v1/payouts";
|
|
406
549
|
var value4 = randomBytes4(20).toString("hex");
|
|
407
550
|
async function createPayout(amount, sourceAccount, destination, client) {
|
|
408
551
|
if (sourceAccount.trim() === "") {
|
|
@@ -430,7 +573,7 @@ async function createPayout(amount, sourceAccount, destination, client) {
|
|
|
430
573
|
metadata: {}
|
|
431
574
|
};
|
|
432
575
|
try {
|
|
433
|
-
const res = await
|
|
576
|
+
const res = await axios6.post(URL6, body, {
|
|
434
577
|
headers: {
|
|
435
578
|
"Idempotency-Key": `${value4}`,
|
|
436
579
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
@@ -441,7 +584,7 @@ async function createPayout(amount, sourceAccount, destination, client) {
|
|
|
441
584
|
const data = res.data;
|
|
442
585
|
return { success: true, data };
|
|
443
586
|
} catch (error) {
|
|
444
|
-
if (
|
|
587
|
+
if (axios6.isAxiosError(error)) {
|
|
445
588
|
return { success: false, error };
|
|
446
589
|
}
|
|
447
590
|
return { success: false, error: new Error("unknown error") };
|
|
@@ -450,7 +593,7 @@ async function createPayout(amount, sourceAccount, destination, client) {
|
|
|
450
593
|
async function getAllPayout(client) {
|
|
451
594
|
const { accessToken, monimeSpaceId } = client._getConfig();
|
|
452
595
|
try {
|
|
453
|
-
const res = await
|
|
596
|
+
const res = await axios6.get(URL6, {
|
|
454
597
|
headers: {
|
|
455
598
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
456
599
|
Authorization: `Bearer ${accessToken}`
|
|
@@ -459,7 +602,7 @@ async function getAllPayout(client) {
|
|
|
459
602
|
const data = res.data;
|
|
460
603
|
return { success: true, data };
|
|
461
604
|
} catch (error) {
|
|
462
|
-
if (
|
|
605
|
+
if (axios6.isAxiosError(error)) {
|
|
463
606
|
return { success: false, error };
|
|
464
607
|
}
|
|
465
608
|
return { success: false, error: new Error("unknown error") };
|
|
@@ -468,7 +611,7 @@ async function getAllPayout(client) {
|
|
|
468
611
|
async function getPayout(payoutId, client) {
|
|
469
612
|
const { accessToken, monimeSpaceId } = client._getConfig();
|
|
470
613
|
try {
|
|
471
|
-
const res = await
|
|
614
|
+
const res = await axios6.get(`${URL6}/${payoutId}`, {
|
|
472
615
|
headers: {
|
|
473
616
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
474
617
|
Authorization: `Bearer ${accessToken}`
|
|
@@ -477,7 +620,7 @@ async function getPayout(payoutId, client) {
|
|
|
477
620
|
const data = res.data;
|
|
478
621
|
return { success: true, data };
|
|
479
622
|
} catch (error) {
|
|
480
|
-
if (
|
|
623
|
+
if (axios6.isAxiosError(error)) {
|
|
481
624
|
return { success: false, error };
|
|
482
625
|
}
|
|
483
626
|
return { success: false, error: new Error("unknown error") };
|
|
@@ -486,7 +629,7 @@ async function getPayout(payoutId, client) {
|
|
|
486
629
|
async function deletePayout(payoutId, client) {
|
|
487
630
|
const { accessToken, monimeSpaceId } = client._getConfig();
|
|
488
631
|
try {
|
|
489
|
-
await
|
|
632
|
+
await axios6.delete(`${URL6}/${payoutId}`, {
|
|
490
633
|
headers: {
|
|
491
634
|
"Monime-Space-Id": `${monimeSpaceId}`,
|
|
492
635
|
Authorization: `Bearer ${accessToken}`
|
|
@@ -494,7 +637,7 @@ async function deletePayout(payoutId, client) {
|
|
|
494
637
|
});
|
|
495
638
|
return { success: true };
|
|
496
639
|
} catch (error) {
|
|
497
|
-
if (
|
|
640
|
+
if (axios6.isAxiosError(error)) {
|
|
498
641
|
return { success: false, error };
|
|
499
642
|
}
|
|
500
643
|
return { success: false, error: new Error("unknown error") };
|
|
@@ -520,6 +663,7 @@ var MonimeClient = class {
|
|
|
520
663
|
paymentCode;
|
|
521
664
|
payout;
|
|
522
665
|
financialTransaction;
|
|
666
|
+
checkoutSession;
|
|
523
667
|
constructor(options) {
|
|
524
668
|
this.accessToken = options.accessToken;
|
|
525
669
|
this.monimeSpaceId = options.monimeSpaceId;
|
|
@@ -528,6 +672,7 @@ var MonimeClient = class {
|
|
|
528
672
|
this.paymentCode = PaymentCodeAPI(this);
|
|
529
673
|
this.payout = PayoutAPI(this);
|
|
530
674
|
this.financialTransaction = FinancialTransactionAPI(this);
|
|
675
|
+
this.checkoutSession = CheckoutSessionAPI(this);
|
|
531
676
|
}
|
|
532
677
|
/** @internal */
|
|
533
678
|
_getConfig() {
|