From d09e1cf33a649981430e860b9ad85bf6733391bd Mon Sep 17 00:00:00 2001 From: Amos Machora Date: Fri, 30 Aug 2024 17:24:35 +0300 Subject: [PATCH] refactor: correct data type on confirmation and validation (#12) correct data type on confirmation and validation --- app/api/confirmation/route.ts | 8 ++++++-- app/api/register-url/route.ts | 2 +- app/api/validation/route.ts | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/api/confirmation/route.ts b/app/api/confirmation/route.ts index 9e9a4df..e6c7718 100644 --- a/app/api/confirmation/route.ts +++ b/app/api/confirmation/route.ts @@ -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", + }); }; diff --git a/app/api/register-url/route.ts b/app/api/register-url/route.ts index 27c0747..7f04540 100644 --- a/app/api/register-url/route.ts +++ b/app/api/register-url/route.ts @@ -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`, diff --git a/app/api/validation/route.ts b/app/api/validation/route.ts index 38dad22..475eab8 100644 --- a/app/api/validation/route.ts +++ b/app/api/validation/route.ts @@ -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", }); };