IPaymentInfo.fromJson constructor
IPaymentInfo.fromJson(
- Map<String, dynamic> json
)
Implementation
factory IPaymentInfo.fromJson(Map<String, dynamic> json) {
List<IPaymentMethod> formatedListOfPaymentMethods = [];
debugPrint("json : ${json.containsKey('listOfPaymentMethods')}");
if (json.containsKey('listOfPaymentMethods') &&
json['listOfPaymentMethods'] != null) {
for (var item in json['listOfPaymentMethods']) {
formatedListOfPaymentMethods.add(IPaymentMethod.fromJson(item));
}
}
List<IMobileMoneyPhoneCode> formatedListOfPhoneCodes = [];
debugPrint("json : ${json.containsKey('listOfMobileMoneyPhoneCodes')}");
if (json.containsKey('listOfMobileMoneyPhoneCodes') &&
json['listOfMobileMoneyPhoneCodes'] != null) {
for (var item in json['listOfMobileMoneyPhoneCodes']) {
formatedListOfPhoneCodes.add(IMobileMoneyPhoneCode.fromJson(item));
}
}
return IPaymentInfo(
listOfPaymentMethods: formatedListOfPaymentMethods,
selectedPaymentMethod: json.containsKey('selected_payment_method')
? IPaymentMethod.fromJson(json['selected_payment_method'])
: IPaymentMethod.empty(),
listOfMobileMoneyPhoneCodes: formatedListOfPhoneCodes,
amount: json.containsKey('amount')
? double.tryParse("${json['amount']}")!
: 0,
fee: json.containsKey('fee') ? double.tryParse("${json['fee']}")! : 0,
customerUrlToListenTo: json.containsKey('customer_url_to_listen_to')
? json['customer_url_to_listen_to']
: '-',
systemUrlToListenTo: json.containsKey('system_url_to_listen_to')
? json['system_url_to_listen_to']
: '-',
currency: json.containsKey('currency')
? ICurrency.fromJson(json['currency'])
: ICurrency.empty(),
eChannel:
json.containsKey('bin_channel') ? json['bin_channel'] : EChannel.none,
fillingInfo: json.containsKey('filling_info')
? json['filling_info']
: IFillingInfo.none,
id: json.containsKey('_id') ? json['_id'] : '-',
directPayRedirectUrl: json.containsKey('direct_pay_redirect_url')
? json['direct_pay_redirect_url']
: '-',
description: json.containsKey('description') ? json['description'] : '-',
);
}