@singularity-payments/nuxt 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 +49 -0
- package/dist/index.mjs +49 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -49,6 +49,38 @@ function createMpesaHandlers(client) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
}),
|
|
52
|
+
/**
|
|
53
|
+
* C2B simulation handler (for testing)
|
|
54
|
+
* Simulates a C2B payment transaction
|
|
55
|
+
*/
|
|
56
|
+
simulateC2B: (0, import_h3.defineEventHandler)(async (event) => {
|
|
57
|
+
try {
|
|
58
|
+
const body = await (0, import_h3.readBody)(event);
|
|
59
|
+
const { amount, phoneNumber, billRefNumber, commandID } = body;
|
|
60
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
61
|
+
throw (0, import_h3.createError)({
|
|
62
|
+
statusCode: 400,
|
|
63
|
+
message: "Amount, phone number, and bill reference number are required"
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const response = await client.simulateC2B({
|
|
67
|
+
amount: Number(amount),
|
|
68
|
+
phoneNumber: String(phoneNumber),
|
|
69
|
+
billRefNumber: String(billRefNumber),
|
|
70
|
+
commandID
|
|
71
|
+
});
|
|
72
|
+
return response;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error("C2B Simulate error:", error);
|
|
75
|
+
if (error.statusCode) {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
throw (0, import_h3.createError)({
|
|
79
|
+
statusCode: 500,
|
|
80
|
+
message: error.message || "Request failed"
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
52
84
|
/**
|
|
53
85
|
* C2B validation handler
|
|
54
86
|
* Validates C2B transactions before they are processed
|
|
@@ -251,6 +283,23 @@ function createMpesaHandlers(client) {
|
|
|
251
283
|
});
|
|
252
284
|
return response;
|
|
253
285
|
}
|
|
286
|
+
if (lastSegment === "simulate-c2b") {
|
|
287
|
+
const body = await (0, import_h3.readBody)(event);
|
|
288
|
+
const { amount, phoneNumber, billRefNumber, commandID } = body;
|
|
289
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
290
|
+
throw (0, import_h3.createError)({
|
|
291
|
+
statusCode: 400,
|
|
292
|
+
message: "Amount, phone number, and bill reference number are required"
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
const response = await client.simulateC2B({
|
|
296
|
+
amount: Number(amount),
|
|
297
|
+
phoneNumber: String(phoneNumber),
|
|
298
|
+
billRefNumber,
|
|
299
|
+
commandID
|
|
300
|
+
});
|
|
301
|
+
return response;
|
|
302
|
+
}
|
|
254
303
|
if (lastSegment === "stk-query") {
|
|
255
304
|
const body = await (0, import_h3.readBody)(event);
|
|
256
305
|
const { CheckoutRequestID } = body;
|
package/dist/index.mjs
CHANGED
|
@@ -29,6 +29,38 @@ function createMpesaHandlers(client) {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
}),
|
|
32
|
+
/**
|
|
33
|
+
* C2B simulation handler (for testing)
|
|
34
|
+
* Simulates a C2B payment transaction
|
|
35
|
+
*/
|
|
36
|
+
simulateC2B: defineEventHandler(async (event) => {
|
|
37
|
+
try {
|
|
38
|
+
const body = await readBody(event);
|
|
39
|
+
const { amount, phoneNumber, billRefNumber, commandID } = body;
|
|
40
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
41
|
+
throw createError({
|
|
42
|
+
statusCode: 400,
|
|
43
|
+
message: "Amount, phone number, and bill reference number are required"
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const response = await client.simulateC2B({
|
|
47
|
+
amount: Number(amount),
|
|
48
|
+
phoneNumber: String(phoneNumber),
|
|
49
|
+
billRefNumber: String(billRefNumber),
|
|
50
|
+
commandID
|
|
51
|
+
});
|
|
52
|
+
return response;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error("C2B Simulate error:", error);
|
|
55
|
+
if (error.statusCode) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
throw createError({
|
|
59
|
+
statusCode: 500,
|
|
60
|
+
message: error.message || "Request failed"
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
32
64
|
/**
|
|
33
65
|
* C2B validation handler
|
|
34
66
|
* Validates C2B transactions before they are processed
|
|
@@ -231,6 +263,23 @@ function createMpesaHandlers(client) {
|
|
|
231
263
|
});
|
|
232
264
|
return response;
|
|
233
265
|
}
|
|
266
|
+
if (lastSegment === "simulate-c2b") {
|
|
267
|
+
const body = await readBody(event);
|
|
268
|
+
const { amount, phoneNumber, billRefNumber, commandID } = body;
|
|
269
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
270
|
+
throw createError({
|
|
271
|
+
statusCode: 400,
|
|
272
|
+
message: "Amount, phone number, and bill reference number are required"
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const response = await client.simulateC2B({
|
|
276
|
+
amount: Number(amount),
|
|
277
|
+
phoneNumber: String(phoneNumber),
|
|
278
|
+
billRefNumber,
|
|
279
|
+
commandID
|
|
280
|
+
});
|
|
281
|
+
return response;
|
|
282
|
+
}
|
|
234
283
|
if (lastSegment === "stk-query") {
|
|
235
284
|
const body = await readBody(event);
|
|
236
285
|
const { CheckoutRequestID } = body;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularity-payments/nuxt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"directory": "packages/nuxt"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@singularity-payments/core": "1.
|
|
40
|
+
"@singularity-payments/core": "1.3.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^25.0.3",
|