Skip to content

Commit

Permalink
refactor: correct data type on confirmation and validation (#12)
Browse files Browse the repository at this point in the history
correct data type on confirmation and validation
  • Loading branch information
amosmachora committed Aug 30, 2024
1 parent bed0c67 commit d09e1cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions app/api/confirmation/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { NextRequest, NextResponse } from "next/server";

export const POST = async (req: NextRequest) => {
//When this API is hit it does nothing for now. The use case of this API is not currently yet defined but some facilities may register this URL.
return NextResponse.json({ message: "confirmed" }, { status: 200 });
// When this API is hit it does nothing for now.
// The use case of this API is not currently yet defined but some facilities may register this URL.
return NextResponse.json({
ResultCode: 0,
ResultDesc: "Success",
});
};
2 changes: 1 addition & 1 deletion app/api/register-url/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const POST = async (req: NextRequest) => {
const res: RegisterUrlResponse = await axios.post(
`${BASE_URL}/mpesa/c2b/v1/registerurl`,
{
ShortCode: facilityMpesaConfig.MPESA_BUSINESS_SHORT_CODE,
ShortCode: parseInt(facilityMpesaConfig.MPESA_BUSINESS_SHORT_CODE),
ResponseType: "Completed",
ConfirmationURL: `${BASE_URL}/api/confirmation`,
ValidationURL: `${BASE_URL}/api/validation`,
Expand Down
2 changes: 1 addition & 1 deletion app/api/validation/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export const POST = async (req: NextRequest) => {
//When this API is hit it automatically completes the transaction.
return NextResponse.json({
ResultCode: "0",
ResultDesc: "Validation request received successfully",
ResultDesc: "Accepted",
});
};

0 comments on commit d09e1cf

Please sign in to comment.