purchaseItem method

  1. @override
Future<GalaxyPurchase?> purchaseItem(
  1. String productId,
  2. String passThroughParam, {
  3. OperationMode operationMode = OperationMode.test,
})
override

Implementation

@override
Future<GalaxyPurchase?> purchaseItem(
    String productId, String passThroughParam,
    {OperationMode operationMode = OperationMode.test}) async {
  try {
    final purchaseResponse =
        await methodChannel.invokeMethod('purchaseItem', {
      'productId': productId,
      'passThroughParam': passThroughParam,
      'operationMode': operationMode.getName()
    });
    return GalaxyPurchase.fromJson(
        jsonDecode(purchaseResponse) as Map<String, dynamic>);
  } on PlatformException catch (e) {
    throw PlatformException(
      code: e.code,
      message: 'Error while purchasing item: ${e.message}',
      details: e.details,
    );
  }
}