payWithCard method
Implementation
void payWithCard(BuildContext context)async {
try {
isLoading(true);
var visitorId = await FingerPrintJs().getVisitorId();
var meta = {
'ip': '',
'fingerprint': visitorId,
'device': 'Mobile App',
'browser': 'Mobile App',
'country': '',
'city': '',
'isp': '',
};
var request = {
'token': Storage.getValue(Constants.token),
'api_key': Constants.apiKey,
'sub_client_api_key': Storage.getValue(Constants.subClientApiKey),
'amount' : Storage.getValue(Constants.amountToProcess),
'card_id' : Storage.getValue(Constants.cardId),
'meta' : meta
};
var response = await DioClient().request(context: context,api:'/charge-funding-source',method:Method.POST ,params: request);
ChargeFundResponse chargeFundResponse = ChargeFundResponse.fromJson(response) ;
if (chargeFundResponse.status == Strings.success) {
Utils.navigationReplace(
context,
Successful(
successTitle: Strings.paymentSuccessful,
successMessage: Strings.paymentSuccessmgs,
));
Utils.showSnackbar(context, Strings.success,
chargeFundResponse.message!, AppColors.green);
} else {
return Utils.showSnackbar(context, Strings.error,response['message'].toString().toTitleCase(), AppColors.red);
}
} finally {
isLoading(false);
}
update();
}