startPayment method
Future<bool>
startPayment({
- required FawryLaunchModel launchModel,
- required String baseURL,
- required String lang,
override
Initiates the Fawry payment process.
Implementation
@override
Future<bool> startPayment({
required FawryLaunchModel launchModel,
required String baseURL,
required String lang,
}) async {
try {
// Encode launchModel to JSON and invoke native method
return await _channel.invokeMethod(_METHOD_PAY, <String, String>{
'launchModelJson': json.encode(launchModel),
'baseURL': baseURL,
'lang': lang
});
} on PlatformException catch (e) {
// Handle specific platform exceptions
if (e.code == _ERROR_INIT) {
throw "Error Occurred: Code: $_ERROR_INIT. Message: ${e.message}. Details: SDK Init Error";
}
throw "Error Occurred: Code: ${e.code}. Message: ${e.message}. Details: ${e.details}";
} catch (e) {
// Catch any other exceptions
throw "Error Occurred: Message: $e";
}
}