open method
Opens the payment gateway with the given URL and parameters
Returns a map containing:
- status: 'success', 'error', or 'cancelled'
- code: Error code or success code
- message: Human-readable message about the result
- response: The raw response from the payment gateway (if available)
Implementation
@override
Future<Map<String, dynamic>?> open(String url, Map<String, dynamic> params) async {
try {
final result = await methodChannel.invokeMethod<Map<dynamic, dynamic>>(
'open',
{'url': url, 'params': params}
);
// Convert the dynamic map to a String, dynamic map
return result?.map((key, value) => MapEntry(key.toString(), value));
} on PlatformException catch (e) {
return {
'status': 'error',
'code': e.code,
'message': e.message ?? 'An unknown error occurred',
'response': e.details
};
} catch (e) {
return {
'status': 'error',
'code': 'UNEXPECTED_ERROR',
'message': e.toString(),
'response': null
};
}
}