getTransactions method

  1. @override
Future<TransactionResult> getTransactions({
  1. required String customerId,
  2. String? cursor,
})
override

Set the reload configuration for a customer.

Implementation

@override
Future<TransactionResult> getTransactions({
  required String customerId,
  String? cursor,
}) async {
  try {
    final result = await methodChannel.invokeMethod(
      'getTransactions',
      {
        'customerId': customerId,
        'cursor': cursor,
      },
    );
    if (result != null) {
      if (result is Map && result.containsKey('transactions')) {
        // Handle the case where the result is a nested map (iOS)
        final transactionResultMap = Map<String, dynamic>.from(result);
        final transactionResult =
            TransactionResult.fromMap(transactionResultMap);
        return transactionResult;
      } else if (result is List) {
        // Handle the case where the result is a direct list (Android)
        final transactionResult = TransactionResult.fromList(result);
        return transactionResult;
      } else {
        throw PlatformException(
          code: 'INVALID_RESULT',
          message: 'getTransactions returned an invalid result',
        );
      }
    } else {
      throw PlatformException(
        code: 'NULL_RESULT',
        message: 'getTransactions returned null',
      );
    }
  } on PlatformException {
    rethrow;
  }
}