pesaLink method Null safety
Implements Pesalink end point, which enables transactions from the configured account baseAccountNo to any bank account participating in IPSL 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> pesaLink({
required String referenceNumber,
required String accountNumber,
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',
'AccountNumber': accountNumber,
'BankCode': bankCode,
'Amount': amount,
'TransactionCurrency': transactionCurrency,
'Narration': transactionDescription
}
]
};
try {
return await pesalinkProcessTransaction(pesaLinkUrl, _header, _payload, applicationMode);
} catch (e) {
rethrow;
}
}