Retrieving the Account Balance
To retrieve the account balance using the Mpesa API, you can use the mpesa.getAccountBalance()
method. This allows you to check the available balance in your Mpesa account.
mpesa.getAccountBalance({
PartyA: process.env.PARTY_A,
Remarks: "test",
Initiator: "",
SecurityCredential: process.env.SECURITY_CREDENTIAL,
QueueTimeOutURL: process.env.CALLBACK_URL,
ResultURL: "",
})
.then((response) => {
// Account balance retrieved successfully
console.log(response);
})
.catch((error) => {
// Error occurred while retrieving the account balance
console.log(error);
});