createCvvUpdateToken method

Future<CvvUpdateToken> createCvvUpdateToken()

Attempt to create a CVV update token based on the CVV details entered by the user

Returns a CvvUpdateToken if the CVV value is in a valid format.

If an error occurs a PlatformException will be thrown. The code property on the exception can be used to determine what went wrong and take appropriate action. The message property can be used to get more information about what went wrong

When a PlatformException is thrown, the code property will be one of the following:

Implementation

Future<CvvUpdateToken> createCvvUpdateToken() async {
  try {
    final Map<dynamic, dynamic>? result = await _channel.invokeOloMapMethod(
      DataKeys.createCvvUpdateToken,
    );

    if (result == null) {
      throw PlatformExceptionFactory.create(
        errorDetails: Strings.unexpectedNullValue,
      );
    }

    return CvvUpdateToken(
      id: result[DataKeys.cvvIdKey],
      productionEnvironment: result[DataKeys.productionEnvironmentKey],
    );
  } on PlatformException catch (e) {
    _errorHandler?.call(e.message!);
    rethrow;
  } catch (e, trace) {
    throw PlatformExceptionFactory.createFromError(error: e, trace: trace);
  }
}