startCheckout method

Future startCheckout (
  1. {@required String publicKey,
  2. @required Map<String, dynamic> preference,
  3. @required String accessToken}
)

Implementation

static Future<dynamic> startCheckout({
  @required String publicKey,
  @required Map<String, dynamic> preference,
  @required String accessToken,
}) async {
  try {
    Map<String, dynamic> response =
        await _createNewPreference(preference, accessToken);
    if (response != null) {
      final String checkoutPreferenceId =
          response['response']['id'].toString();
      final String mpResult = await _channel.invokeMethod('startCheckout', {
        'publicKey': publicKey,
        'checkoutPreferenceId': checkoutPreferenceId,
      });
      debugPrint('RESULTADO $mpResult');
    } else {
      // ignore: todo
      //TODO (todo): handle error
    }
  } catch (e) {
    // ignore: todo
    //TODO (todo): handle error
  }
}