info method

  1. @override
Future<GetnetInfoResponse> info()
override

Implementation

@override
Future<GetnetInfoResponse> info() async {
  try {
    final response = await methodChannel.invokeMethod<Map>('info');
    if (response is Map) {
      if ((response['code'] == GetnetStatusDeeplink.SUCCESS.name || response['code'] == GetnetStatusDeeplink.PENDING.name) && response['data'] is Map) {
        if (response['code'] == GetnetStatusDeeplink.SUCCESS.name) {
          final jsonData = response['data'];
          return GetnetInfoResponse.fromJson(json: jsonData);
        } else {
          return GetnetInfoResponse(
            result: response['result'] ?? '5',
            ec: '',
            numserie: '',
            numlogic: '',
            version: '',
            cnpjEC: '',
            razaoSocialEC: '',
            cidadeEC: '',
          );
        }
      } else {
        throw GetnetInfoException(message: response['message']);
      }
    } else {
      throw GetnetInfoException(message: 'invalid response');
    }
  } on GetnetInfoException catch (e) {
    throw GetnetInfoException(message: e.message);
  } on PlatformException catch (e) {
    throw GetnetInfoException(message: e.message ?? 'PlatformException');
  } catch (e) {
    throw GetnetInfoException(message: "info payment Error: $e");
  }
}