@singularity-payments/fastify 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 +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
|
@@ -47,6 +47,27 @@ function createMpesaHandlers(client) {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
+
simulateC2B: async (req, reply) => {
|
|
51
|
+
try {
|
|
52
|
+
const { amount, phoneNumber, billRefNumber, commandID } = req.body;
|
|
53
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
54
|
+
reply.status(400).send({
|
|
55
|
+
error: "Amount, phone number, and bill reference number are required"
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const response = await client.simulateC2B({
|
|
60
|
+
amount: Number(amount),
|
|
61
|
+
phoneNumber: String(phoneNumber),
|
|
62
|
+
billRefNumber: String(billRefNumber),
|
|
63
|
+
commandID
|
|
64
|
+
});
|
|
65
|
+
reply.send(response);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error("C2B Simulate error:", error);
|
|
68
|
+
reply.status(500).send({ error: error.message || "Request failed" });
|
|
69
|
+
}
|
|
70
|
+
},
|
|
50
71
|
c2bValidation: async (req, reply) => {
|
|
51
72
|
try {
|
|
52
73
|
const body = req.body;
|
|
@@ -458,6 +479,7 @@ function createMpesa(config, options) {
|
|
|
458
479
|
fastify.post("/reversal-timeout", handlers.reversalTimeout);
|
|
459
480
|
fastify.post("/status-result", handlers.statusResult);
|
|
460
481
|
fastify.post("/status-timeout", handlers.statusTimeout);
|
|
482
|
+
fastify.post("/simulate-c2b", handlers.simulateC2B);
|
|
461
483
|
return fastify;
|
|
462
484
|
};
|
|
463
485
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -21,6 +21,27 @@ function createMpesaHandlers(client) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
+
simulateC2B: async (req, reply) => {
|
|
25
|
+
try {
|
|
26
|
+
const { amount, phoneNumber, billRefNumber, commandID } = req.body;
|
|
27
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
28
|
+
reply.status(400).send({
|
|
29
|
+
error: "Amount, phone number, and bill reference number are required"
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const response = await client.simulateC2B({
|
|
34
|
+
amount: Number(amount),
|
|
35
|
+
phoneNumber: String(phoneNumber),
|
|
36
|
+
billRefNumber: String(billRefNumber),
|
|
37
|
+
commandID
|
|
38
|
+
});
|
|
39
|
+
reply.send(response);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error("C2B Simulate error:", error);
|
|
42
|
+
reply.status(500).send({ error: error.message || "Request failed" });
|
|
43
|
+
}
|
|
44
|
+
},
|
|
24
45
|
c2bValidation: async (req, reply) => {
|
|
25
46
|
try {
|
|
26
47
|
const body = req.body;
|
|
@@ -434,6 +455,7 @@ function createMpesa(config, options) {
|
|
|
434
455
|
fastify.post("/reversal-timeout", handlers.reversalTimeout);
|
|
435
456
|
fastify.post("/status-result", handlers.statusResult);
|
|
436
457
|
fastify.post("/status-timeout", handlers.statusTimeout);
|
|
458
|
+
fastify.post("/simulate-c2b", handlers.simulateC2B);
|
|
437
459
|
return fastify;
|
|
438
460
|
};
|
|
439
461
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularity-payments/fastify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"fastify": ">=4.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@singularity-payments/core": "1.
|
|
39
|
+
"@singularity-payments/core": "1.2.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^25.0.3",
|