@singularity-payments/express 1.1.1 → 1.2.1
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -0
- package/dist/index.mjs +22 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -60,6 +60,27 @@ function createMpesaHandlers(client) {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
+
simulateC2B: async (req, res) => {
|
|
64
|
+
try {
|
|
65
|
+
const { amount, phoneNumber, billRefNumber, commandID } = req.body;
|
|
66
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
67
|
+
res.status(400).json({
|
|
68
|
+
error: "Amount, phone number, and bill reference number are required"
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const response = await client.simulateC2B({
|
|
73
|
+
amount: Number(amount),
|
|
74
|
+
phoneNumber: String(phoneNumber),
|
|
75
|
+
billRefNumber: String(billRefNumber),
|
|
76
|
+
commandID
|
|
77
|
+
});
|
|
78
|
+
res.json(response);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error("C2B Simulate error:", error);
|
|
81
|
+
res.status(500).json({ error: error.message || "Request failed" });
|
|
82
|
+
}
|
|
83
|
+
},
|
|
63
84
|
c2bConfirmation: async (req, res) => {
|
|
64
85
|
try {
|
|
65
86
|
const body = req.body;
|
|
@@ -472,6 +493,7 @@ function createMpesa(config, options) {
|
|
|
472
493
|
expressRouter.post("/reversal-timeout", handlers.reversalTimeout);
|
|
473
494
|
expressRouter.post("/status-result", handlers.statusResult);
|
|
474
495
|
expressRouter.post("/status-timeout", handlers.statusTimeout);
|
|
496
|
+
expressRouter.post("/simulate-c2b", handlers.simulateC2B);
|
|
475
497
|
return expressRouter;
|
|
476
498
|
};
|
|
477
499
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -34,6 +34,27 @@ function createMpesaHandlers(client) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
+
simulateC2B: async (req, res) => {
|
|
38
|
+
try {
|
|
39
|
+
const { amount, phoneNumber, billRefNumber, commandID } = req.body;
|
|
40
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
41
|
+
res.status(400).json({
|
|
42
|
+
error: "Amount, phone number, and bill reference number are required"
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const response = await client.simulateC2B({
|
|
47
|
+
amount: Number(amount),
|
|
48
|
+
phoneNumber: String(phoneNumber),
|
|
49
|
+
billRefNumber: String(billRefNumber),
|
|
50
|
+
commandID
|
|
51
|
+
});
|
|
52
|
+
res.json(response);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error("C2B Simulate error:", error);
|
|
55
|
+
res.status(500).json({ error: error.message || "Request failed" });
|
|
56
|
+
}
|
|
57
|
+
},
|
|
37
58
|
c2bConfirmation: async (req, res) => {
|
|
38
59
|
try {
|
|
39
60
|
const body = req.body;
|
|
@@ -448,6 +469,7 @@ function createMpesa(config, options) {
|
|
|
448
469
|
expressRouter.post("/reversal-timeout", handlers.reversalTimeout);
|
|
449
470
|
expressRouter.post("/status-result", handlers.statusResult);
|
|
450
471
|
expressRouter.post("/status-timeout", handlers.statusTimeout);
|
|
472
|
+
expressRouter.post("/simulate-c2b", handlers.simulateC2B);
|
|
451
473
|
return expressRouter;
|
|
452
474
|
};
|
|
453
475
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularity-payments/express",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"express": ">=4.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@singularity-payments/core": "1.
|
|
39
|
+
"@singularity-payments/core": "1.3.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/express": "^4.17.21",
|