AmwalSdkSettings.fromJson constructor
Creates an AmwalSdkSettings instance from a JSON map.
This factory constructor allows easy deserialization from JSON data, making it convenient for loading settings from configuration files or API responses.
Parameters
json
: A map containing the configuration data
Example
final jsonData = {
'merchantId': 'merchant_123',
'terminalId': 'terminal_1',
'transactionId': 'txn_456',
'currency': 'SAR',
'amount': '100.00',
};
final settings = AmwalSdkSettings.fromJson(jsonData);
Implementation
factory AmwalSdkSettings.fromJson(Map<String, dynamic> json) {
return AmwalSdkSettings(
token: json['token'] ?? '',
secureHashValue: json['secureHashValue'],
merchantId: json['merchantId'],
transactionId: json['transactionId'],
currency: json['currency'],
amount: json['amount'],
terminalId: json['terminalId'],
merchantName: json['merchantName'],
getTransactionFunction: null,
onCountComplete: null,
locale: json['locale'],
isMocked: json['isMocked'],
transactionType: json['isNfc'] == true
? TransactionType.nfc
: TransactionType.cardWallet,
onError: null,
log: null,
onTokenExpired: null,
countDownInSeconds: json['countDownInSeconds'] ?? 90,
flavor: json['flavor'],
additionValues: json['additionValues'] != null
? Map<String, String>.from(json['additionValues'])
: null,
);
}