@singularity-payments/nextjs 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 +52 -0
- package/dist/index.mjs +52 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -54,6 +54,39 @@ function createMpesaHandlers(client) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
+
/**
|
|
58
|
+
* C2B simulation handler (for testing)
|
|
59
|
+
* Simulates a C2B payment transaction
|
|
60
|
+
*/
|
|
61
|
+
simulateC2B: {
|
|
62
|
+
POST: async (request) => {
|
|
63
|
+
try {
|
|
64
|
+
const body = await request.json();
|
|
65
|
+
const { amount, phoneNumber, billRefNumber, commandID } = body;
|
|
66
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
67
|
+
return import_server.NextResponse.json(
|
|
68
|
+
{
|
|
69
|
+
error: "Amount, phone number, and bill reference number are required"
|
|
70
|
+
},
|
|
71
|
+
{ status: 400 }
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const response = await client.simulateC2B({
|
|
75
|
+
amount: Number(amount),
|
|
76
|
+
phoneNumber: String(phoneNumber),
|
|
77
|
+
billRefNumber: String(billRefNumber),
|
|
78
|
+
commandID
|
|
79
|
+
});
|
|
80
|
+
return import_server.NextResponse.json(response);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error("C2B Simulate error:", error);
|
|
83
|
+
return import_server.NextResponse.json(
|
|
84
|
+
{ error: error.message || "Request failed" },
|
|
85
|
+
{ status: 500 }
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
57
90
|
/**
|
|
58
91
|
* C2B validation handler
|
|
59
92
|
* Validates C2B transactions before they are processed
|
|
@@ -459,6 +492,25 @@ function createMpesaHandlers(client) {
|
|
|
459
492
|
});
|
|
460
493
|
return import_server.NextResponse.json(response);
|
|
461
494
|
}
|
|
495
|
+
if (lastSegment === "simulate-c2b") {
|
|
496
|
+
const body = await request.json();
|
|
497
|
+
const { amount, phoneNumber, billRefNumber, commandID } = body;
|
|
498
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
499
|
+
return import_server.NextResponse.json(
|
|
500
|
+
{
|
|
501
|
+
error: "Amount, phone number, and bill reference number are required"
|
|
502
|
+
},
|
|
503
|
+
{ status: 400 }
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
const response = await client.simulateC2B({
|
|
507
|
+
amount: Number(amount),
|
|
508
|
+
phoneNumber: String(phoneNumber),
|
|
509
|
+
billRefNumber,
|
|
510
|
+
commandID
|
|
511
|
+
});
|
|
512
|
+
return import_server.NextResponse.json(response);
|
|
513
|
+
}
|
|
462
514
|
if (lastSegment === "stk-query") {
|
|
463
515
|
const body = await request.json();
|
|
464
516
|
const { CheckoutRequestID } = body;
|
package/dist/index.mjs
CHANGED
|
@@ -28,6 +28,39 @@ function createMpesaHandlers(client) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
+
/**
|
|
32
|
+
* C2B simulation handler (for testing)
|
|
33
|
+
* Simulates a C2B payment transaction
|
|
34
|
+
*/
|
|
35
|
+
simulateC2B: {
|
|
36
|
+
POST: async (request) => {
|
|
37
|
+
try {
|
|
38
|
+
const body = await request.json();
|
|
39
|
+
const { amount, phoneNumber, billRefNumber, commandID } = body;
|
|
40
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
41
|
+
return NextResponse.json(
|
|
42
|
+
{
|
|
43
|
+
error: "Amount, phone number, and bill reference number are required"
|
|
44
|
+
},
|
|
45
|
+
{ status: 400 }
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const response = await client.simulateC2B({
|
|
49
|
+
amount: Number(amount),
|
|
50
|
+
phoneNumber: String(phoneNumber),
|
|
51
|
+
billRefNumber: String(billRefNumber),
|
|
52
|
+
commandID
|
|
53
|
+
});
|
|
54
|
+
return NextResponse.json(response);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error("C2B Simulate error:", error);
|
|
57
|
+
return NextResponse.json(
|
|
58
|
+
{ error: error.message || "Request failed" },
|
|
59
|
+
{ status: 500 }
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
31
64
|
/**
|
|
32
65
|
* C2B validation handler
|
|
33
66
|
* Validates C2B transactions before they are processed
|
|
@@ -433,6 +466,25 @@ function createMpesaHandlers(client) {
|
|
|
433
466
|
});
|
|
434
467
|
return NextResponse.json(response);
|
|
435
468
|
}
|
|
469
|
+
if (lastSegment === "simulate-c2b") {
|
|
470
|
+
const body = await request.json();
|
|
471
|
+
const { amount, phoneNumber, billRefNumber, commandID } = body;
|
|
472
|
+
if (!amount || !phoneNumber || !billRefNumber) {
|
|
473
|
+
return NextResponse.json(
|
|
474
|
+
{
|
|
475
|
+
error: "Amount, phone number, and bill reference number are required"
|
|
476
|
+
},
|
|
477
|
+
{ status: 400 }
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
const response = await client.simulateC2B({
|
|
481
|
+
amount: Number(amount),
|
|
482
|
+
phoneNumber: String(phoneNumber),
|
|
483
|
+
billRefNumber,
|
|
484
|
+
commandID
|
|
485
|
+
});
|
|
486
|
+
return NextResponse.json(response);
|
|
487
|
+
}
|
|
436
488
|
if (lastSegment === "stk-query") {
|
|
437
489
|
const body = await request.json();
|
|
438
490
|
const { CheckoutRequestID } = body;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularity-payments/nextjs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"directory": "packages/nextjs"
|
|
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/node": "^25.0.3",
|