import { NextResponse } from 'next/server';
const Zibal = require('zibal');
Zibal.init({
merchant: 'zibal',
callbackUrl: 'https://some-callback-url.tld',
logLevel: 2
});
export async function POST(req) {
try{
const { amount, mobile, description } = req.json();
try {
const result = await Zibal.request(amount, { mobile, description });
if (result.result === 100) {
const paymentUrl = Zibal.startURL(result.trackId);
return NextResponse.json({ paymentUrl },{status:200});
} else {
return NextResponse.json({ error: result.statusMessage },{status:400});
}
} catch (error) {
console.log(error)
return NextResponse.json({ error: 'Error creating payment request' },{status:500});
}
} catch {
return NextResponse.json({ error: 'The method is illegal' },{status:405});
}
}
TypeError: Zibal.init is not a function
How can I solve it? It is also written like this in the documentation of their site
New contributor
Mohammad Halimi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.