requestGooglePay method

  1. @override
Future<TapPayPrime?> requestGooglePay({
  1. required double price,
  2. required String currencyCode,
})
override

Request Google Pay

price is the price of the transaction currencyCode is the currency code of the transaction

return GooglePayResult with value success as true if success. return GooglePayResult with value success as false if fail. return GooglePayResult with value message as String if fail. return GooglePayResult with value prime as String if success. return null if the request is incomplete

Implementation

@override
Future<TapPayPrime?> requestGooglePay({
  required double price,
  required String currencyCode,
}) async {
  if (Platform.isAndroid == false) {
    return TapPayPrime(
        success: false,
        message: "Google Pay is only available on Android devices.");
  }

  final result = await methodChannel
      .invokeMethod<Map<Object?, Object?>>('requestGooglePay', {
    'price': price,
    'currencyCode': currencyCode,
  });

  if (result == null) {
    return TapPayPrime(
        success: false,
        message:
            "Encountered an unidentified error while requesting Google Pay.");
  } else {
    return TapPayPrime.fromMap(Map<String, dynamic>.from(result));
  }
}