processQrAndTransact method
Processes the QR data and performs an EMV transaction in a single operation.
This function decodes the QR code, extracts EMV transaction data, and initiates a transaction with the provided parameters.
amount The transaction amount in minor currency units (e.g., cents).
accountType The account type code (e.g., "10" for savings, "20" for checking).
rrn The Retrieval Reference Number associated with the transaction.
qrData The raw QR code string containing base64-encoded TLV EMV data.
Returns a map containing parsed EMV transaction fields if successful, or null on failure.
Throws IllegalArgumentException if any parameter is invalid or the QR data is malformed. Throws Exception for unexpected errors during processing or transaction execution.
Implementation
Future<EmvQrData?> processQrAndTransact({
required String qrData,
required String amount,
required String accountType,
required String rrn,
}) async {
try {
final Map<dynamic, dynamic> result = await _channel.invokeMethod(
'processQrAndTransact',
{
'qrData': qrData,
'amount': amount,
'accountType': accountType,
'rrn': rrn,
},
);
return result.isNotEmpty ? EmvQrData.fromMap(result) : null;
} on PlatformException catch (e) {
debugPrint('Error processing QR and transacting: ${e.message}');
return null;
}
}