cancel method

  1. @override
Future<StoneCancelResponse> cancel({
  1. required StoneCancelPayload cancelPayload,
})
override

Implementation

@override
Future<StoneCancelResponse> cancel({required StoneCancelPayload cancelPayload}) async {
  try {
    final response = await methodChannel.invokeMethod<Map>('cancel', cancelPayload.toJson());

    if (response is Map) {
      if (response['code'] == StoneStatusDeeplink.SUCCESS.name && response['data'] is Map) {
        final jsonData = response['data'];
        return StoneCancelResponse.fromJson(jsonData);
      } else {
        throw StoneCancelException(message: response['message']);
      }
    } else {
      throw StoneCancelException(message: 'invalid response');
    }
  } on StoneCancelException catch (e) {
    throw StoneCancelException(message: e.message);
  } on PlatformException catch (e) {
    throw StoneCancelException(message: e.message ?? 'PlatformException');
  } catch (e) {
    throw StoneCancelException(message: "Cancel Error: $e");
  }
}