Registering URLs for Mpesa API Callbacks
To register URLs for Mpesa API callbacks, you can use the mpesa.registerUrls()
method. This allows you to specify the required URLs for handling different callback events.
mpesa.registerUrls({
ShortCode: process.env.SHORT_CODE,
ResponseType: "Completed",
ConfirmationURL: process.env.CONFIRMATION_URL,
ValidationURL: process.env.VALIDATION_URL,
})
.then((response) => {
// URLs registered successfully
console.log(response);
})
.catch((error) => {
// Error occurred while registering the URLs
console.log(error);
});