consumePurchasedItem method

  1. @override
Future<List<GalaxyConsume>> consumePurchasedItem(
  1. String purchaseId, {
  2. OperationMode operationMode = OperationMode.test,
})
override

Implementation

@override
Future<List<GalaxyConsume>> consumePurchasedItem(String purchaseId,
    {OperationMode operationMode = OperationMode.test}) async {
  try {
    final consumeList =
        await methodChannel.invokeMethod('consumePurchasedItem', {
      'purchaseId': purchaseId,
      'operationMode': operationMode.getName(),
    });
    List<dynamic> jsonList = jsonDecode(consumeList);
    return jsonList
        .map((product) =>
            GalaxyConsume.fromJson(product as Map<String, dynamic>))
        .toList();
  } on PlatformException catch (e) {
    throw PlatformException(
      code: e.code,
      message: 'Error while consuming purchased item: ${e.message}',
      details: e.details,
    );
  }
}