@singularity-payments/elysia 1.1.1 → 1.2.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/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +23 -1
- package/dist/index.mjs +23 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,7 @@ interface MpesaRouteHandlers {
|
|
|
28
28
|
reversal: MpesaRouteHandler;
|
|
29
29
|
registerC2B: MpesaRouteHandler;
|
|
30
30
|
generateQR: MpesaRouteHandler;
|
|
31
|
+
simulateC2B: MpesaRouteHandler;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
declare function createMpesaHandlers(client: MpesaClient): MpesaRouteHandlers;
|
|
@@ -415,6 +416,18 @@ declare function createMpesa(config: MpesaConfig, options?: MpesaClientOptions):
|
|
|
415
416
|
};
|
|
416
417
|
};
|
|
417
418
|
};
|
|
419
|
+
} & {
|
|
420
|
+
mpesa: {
|
|
421
|
+
"simulate-c2b": {
|
|
422
|
+
post: {
|
|
423
|
+
body: unknown;
|
|
424
|
+
params: {};
|
|
425
|
+
query: unknown;
|
|
426
|
+
headers: unknown;
|
|
427
|
+
response: {};
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
};
|
|
418
431
|
}, {
|
|
419
432
|
derive: {};
|
|
420
433
|
resolve: {};
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ interface MpesaRouteHandlers {
|
|
|
28
28
|
reversal: MpesaRouteHandler;
|
|
29
29
|
registerC2B: MpesaRouteHandler;
|
|
30
30
|
generateQR: MpesaRouteHandler;
|
|
31
|
+
simulateC2B: MpesaRouteHandler;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
declare function createMpesaHandlers(client: MpesaClient): MpesaRouteHandlers;
|
|
@@ -415,6 +416,18 @@ declare function createMpesa(config: MpesaConfig, options?: MpesaClientOptions):
|
|
|
415
416
|
};
|
|
416
417
|
};
|
|
417
418
|
};
|
|
419
|
+
} & {
|
|
420
|
+
mpesa: {
|
|
421
|
+
"simulate-c2b": {
|
|
422
|
+
post: {
|
|
423
|
+
body: unknown;
|
|
424
|
+
params: {};
|
|
425
|
+
query: unknown;
|
|
426
|
+
headers: unknown;
|
|
427
|
+
response: {};
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
};
|
|
418
431
|
}, {
|
|
419
432
|
derive: {};
|
|
420
433
|
resolve: {};
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,28 @@ function createMpesaHandlers(client) {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
|
+
simulateC2B: async (ctx) => {
|
|
81
|
+
try {
|
|
82
|
+
const { amount, phoneNumber, billRefNumber, commandID } = ctx.body;
|
|
83
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
84
|
+
ctx.set.status = 400;
|
|
85
|
+
return {
|
|
86
|
+
error: "Amount, phone number, and bill reference number are required"
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const response = await client.simulateC2B({
|
|
90
|
+
amount: Number(amount),
|
|
91
|
+
phoneNumber: String(phoneNumber),
|
|
92
|
+
billRefNumber: String(billRefNumber),
|
|
93
|
+
commandID
|
|
94
|
+
});
|
|
95
|
+
return response;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error("C2B Simulate error:", error);
|
|
98
|
+
ctx.set.status = 500;
|
|
99
|
+
return { error: error.message || "Request failed" };
|
|
100
|
+
}
|
|
101
|
+
},
|
|
80
102
|
b2cResult: async (ctx) => {
|
|
81
103
|
try {
|
|
82
104
|
const body = ctx.body;
|
|
@@ -479,7 +501,7 @@ var import_core2 = require("@singularity-payments/core");
|
|
|
479
501
|
function createMpesa(config, options) {
|
|
480
502
|
const client = new import_core.MpesaClient(config, options);
|
|
481
503
|
const handlers = createMpesaHandlers(client);
|
|
482
|
-
const app = new import_elysia.Elysia({ prefix: "/mpesa" }).post("/stk-push", handlers.stkPush).post("/stk-query", handlers.stkQuery).post("/b2c", handlers.b2c).post("/b2b", handlers.b2b).post("/balance", handlers.balance).post("/transaction-status", handlers.transactionStatus).post("/reversal", handlers.reversal).post("/register-c2b", handlers.registerC2B).post("/generate-qr", handlers.generateQR).post("/callback", handlers.stkCallback).post("/stk-callback", handlers.stkCallback).post("/c2b-validation", handlers.c2bValidation).post("/validation", handlers.c2bValidation).post("/c2b-confirmation", handlers.c2bConfirmation).post("/confirmation", handlers.c2bConfirmation).post("/b2c-result", handlers.b2cResult).post("/b2c-timeout", handlers.b2cTimeout).post("/b2b-result", handlers.b2bResult).post("/b2b-timeout", handlers.b2bTimeout).post("/balance-result", handlers.balanceResult).post("/balance-timeout", handlers.balanceTimeout).post("/reversal-result", handlers.reversalResult).post("/reversal-timeout", handlers.reversalTimeout).post("/status-result", handlers.statusResult).post("/status-timeout", handlers.statusTimeout);
|
|
504
|
+
const app = new import_elysia.Elysia({ prefix: "/mpesa" }).post("/stk-push", handlers.stkPush).post("/stk-query", handlers.stkQuery).post("/b2c", handlers.b2c).post("/b2b", handlers.b2b).post("/balance", handlers.balance).post("/transaction-status", handlers.transactionStatus).post("/reversal", handlers.reversal).post("/register-c2b", handlers.registerC2B).post("/generate-qr", handlers.generateQR).post("/callback", handlers.stkCallback).post("/stk-callback", handlers.stkCallback).post("/c2b-validation", handlers.c2bValidation).post("/validation", handlers.c2bValidation).post("/c2b-confirmation", handlers.c2bConfirmation).post("/confirmation", handlers.c2bConfirmation).post("/b2c-result", handlers.b2cResult).post("/b2c-timeout", handlers.b2cTimeout).post("/b2b-result", handlers.b2bResult).post("/b2b-timeout", handlers.b2bTimeout).post("/balance-result", handlers.balanceResult).post("/balance-timeout", handlers.balanceTimeout).post("/reversal-result", handlers.reversalResult).post("/reversal-timeout", handlers.reversalTimeout).post("/status-result", handlers.statusResult).post("/status-timeout", handlers.statusTimeout).post("/simulate-c2b", handlers.simulateC2B);
|
|
483
505
|
return {
|
|
484
506
|
/**
|
|
485
507
|
* M-Pesa client instance for making API calls
|
package/dist/index.mjs
CHANGED
|
@@ -51,6 +51,28 @@ function createMpesaHandlers(client) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
|
+
simulateC2B: async (ctx) => {
|
|
55
|
+
try {
|
|
56
|
+
const { amount, phoneNumber, billRefNumber, commandID } = ctx.body;
|
|
57
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
58
|
+
ctx.set.status = 400;
|
|
59
|
+
return {
|
|
60
|
+
error: "Amount, phone number, and bill reference number are required"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const response = await client.simulateC2B({
|
|
64
|
+
amount: Number(amount),
|
|
65
|
+
phoneNumber: String(phoneNumber),
|
|
66
|
+
billRefNumber: String(billRefNumber),
|
|
67
|
+
commandID
|
|
68
|
+
});
|
|
69
|
+
return response;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error("C2B Simulate error:", error);
|
|
72
|
+
ctx.set.status = 500;
|
|
73
|
+
return { error: error.message || "Request failed" };
|
|
74
|
+
}
|
|
75
|
+
},
|
|
54
76
|
b2cResult: async (ctx) => {
|
|
55
77
|
try {
|
|
56
78
|
const body = ctx.body;
|
|
@@ -455,7 +477,7 @@ import {
|
|
|
455
477
|
function createMpesa(config, options) {
|
|
456
478
|
const client = new MpesaClient(config, options);
|
|
457
479
|
const handlers = createMpesaHandlers(client);
|
|
458
|
-
const app = new Elysia({ prefix: "/mpesa" }).post("/stk-push", handlers.stkPush).post("/stk-query", handlers.stkQuery).post("/b2c", handlers.b2c).post("/b2b", handlers.b2b).post("/balance", handlers.balance).post("/transaction-status", handlers.transactionStatus).post("/reversal", handlers.reversal).post("/register-c2b", handlers.registerC2B).post("/generate-qr", handlers.generateQR).post("/callback", handlers.stkCallback).post("/stk-callback", handlers.stkCallback).post("/c2b-validation", handlers.c2bValidation).post("/validation", handlers.c2bValidation).post("/c2b-confirmation", handlers.c2bConfirmation).post("/confirmation", handlers.c2bConfirmation).post("/b2c-result", handlers.b2cResult).post("/b2c-timeout", handlers.b2cTimeout).post("/b2b-result", handlers.b2bResult).post("/b2b-timeout", handlers.b2bTimeout).post("/balance-result", handlers.balanceResult).post("/balance-timeout", handlers.balanceTimeout).post("/reversal-result", handlers.reversalResult).post("/reversal-timeout", handlers.reversalTimeout).post("/status-result", handlers.statusResult).post("/status-timeout", handlers.statusTimeout);
|
|
480
|
+
const app = new Elysia({ prefix: "/mpesa" }).post("/stk-push", handlers.stkPush).post("/stk-query", handlers.stkQuery).post("/b2c", handlers.b2c).post("/b2b", handlers.b2b).post("/balance", handlers.balance).post("/transaction-status", handlers.transactionStatus).post("/reversal", handlers.reversal).post("/register-c2b", handlers.registerC2B).post("/generate-qr", handlers.generateQR).post("/callback", handlers.stkCallback).post("/stk-callback", handlers.stkCallback).post("/c2b-validation", handlers.c2bValidation).post("/validation", handlers.c2bValidation).post("/c2b-confirmation", handlers.c2bConfirmation).post("/confirmation", handlers.c2bConfirmation).post("/b2c-result", handlers.b2cResult).post("/b2c-timeout", handlers.b2cTimeout).post("/b2b-result", handlers.b2bResult).post("/b2b-timeout", handlers.b2bTimeout).post("/balance-result", handlers.balanceResult).post("/balance-timeout", handlers.balanceTimeout).post("/reversal-result", handlers.reversalResult).post("/reversal-timeout", handlers.reversalTimeout).post("/status-result", handlers.statusResult).post("/status-timeout", handlers.statusTimeout).post("/simulate-c2b", handlers.simulateC2B);
|
|
459
481
|
return {
|
|
460
482
|
/**
|
|
461
483
|
* M-Pesa client instance for making API calls
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularity-payments/elysia",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"elysia": ">=1.0.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@singularity-payments/core": "1.
|
|
40
|
+
"@singularity-payments/core": "1.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^25.0.3",
|