toPesalinkPhoneNo method Null safety
Implements Send to Pesalink PhoneNo end point, which enables transactions from the configured account baseAccountNo to user whom has connected their phoneNumber
to bank account using pesalink
It has a return type of BankReponse & the raw response can be gotten by calling BankReponse.rawResponceBody
Sample success response;
{
'MessageReference': '40ca18c6765086089a1',
'MessageDateTime': '2017-12-04T09:27:00',
'MessageCode': '0',
'MessageDescription': 'REQUEST ACCEPTED SUCCESSFULLY'
}
Implementation
Future<BankReponse> toPesalinkPhoneNo({
required String referenceNumber,
required String phoneNumber,
required String bankCode,
required double amount,
required String callBackUrl,
String transactionCurrency = 'KES',
required String transactionDescription,
required String accessToken,
})async{
Map<String, String> _header ={
'content-type': 'application/json',
'Authorization': 'Bearer $accessToken'
};
Map<String, dynamic> _payload = {
'MessageReference': referenceNumber,
'CallBackUrl': callBackUrl,
'Source': transactionSource(amount, transactionDescription),
'Destinations': [
{
'ReferenceNumber': '${referenceNumber}_1',
'PhoneNumber': phoneNumber,
'Amount': amount,
'TransactionCurrency': transactionCurrency,
'Narration': transactionDescription
}
]
};
try {
return await pesalinkProcessTransaction(toPesaLinkPhoneUrl, _header, _payload, applicationMode);
} catch (e) {
rethrow;
}
}