TapGooglePayKit-Flutter

A standalone Flutter kit for handling Google Pay™ (Only for Android)

Getting Started

Table of Contents


  1. Requirements
  2. Installation
    1. Installation with pubspec.yaml
  3. Additional Android Configuration
  4. Usage
    1. Configure Your App
    2. SDK Enums
    3. SDK Modes
    4. Allowed Methods
    5. Allowed Card Networks
    6. Google Pay Button Type
    7. Google Pay Button
    8. SDK Methods

Requirements


To use the SDK the following requirements must be met:

  1. Visual Studio - InteliJ Idea
  2. Dart 2.7.1 or newer
  3. Flutter: >=2.5.0 or newer

Installation


Include TapGooglePayKit plugin as a dependency in your pubspec.yaml

 dependencies:
     tap_google_pay_kit_flutter: ^0.0.4

Additional Android Configuration

To use GooglePay in your app , you will be required to do additional configuration as follows:

  1. In build.gradle file add
implementation "com.google.android.gms:play-services-wallet:18.1.3"
  1. Ensure your min sdk is 21
minSdk 21
targetSdk 32
  1. In Manifest file , Inside the <application tag do the below:
<meta-data
    android:name="com.google.android.gsm.wallet.api.enabled"
    android:value="true"
    />

Configure your app

TapGooglePayKit should be set up. To set it up, add the following lines of code somewhere in your project and make sure they will be called before any usage of TapGooglePayKit.

/**
 * Configure SDK.
 */
 TapGooglePayKitFlutter.configureSDK(
      secretKey: "sk_test_xxxxxxxxxxxxxxxxxx",
      bundleId: "com.xxx.xxxxxxx",
      countryCode: "US",
      transactionCurrency: "USD",
      sdkMode: SDKMode.Sandbox,
      allowedMethods: AllowedMethods.ALL,
      allowedCardNetworks: [AllowedCardNetworks.VISA.name],
      gatewayID: "xxxxx",
      gatewayMerchantID: "122xxxxx",
      amount: "23",
      sdkCallbackMode: SDKCallbackMode.GetGooglePayToken,
    );

SDK Enums

SDK Modes

sdkMode: SDKMode.Sandbox

You can set the sdk mode into one of the following modes:

  • Sandbox
    • dart SDKMode.Sandbox

    Testing mode

  • Production
    • dart SDKMode.Production

    Production mode

AllowedMethods

allowedMethods: AllowedMethods.ALL

You can set the allowed methods into one of the following modes:

  • PAN_ONLY
    • dart AllowedMethods.PAN_ONLY
  • CRYPTOGRAM
    • dart AllowedMethods.CRYPTOGRAM
  • ALL
    • dart AllowedMethods.ALL

AllowedCardNetworks

allowedCardNetworks: [AllowedCardNetworks.VISA.name]

You can set the allowed card networks mode into one of the following modes:

  • AMEX
    • dart AllowedCardNetworks.AMEX.name
  • MASTERCARD
    • dart AllowedCardNetworks.MASTERCARD.name
  • VISA
    • dart AllowedCardNetworks.VISA.name

GooglePayButtonType

googlePayButtonType: GooglePayButtonType.NORMAL_GOOGLE_PAY

You can set the google pay button type into one of the following types:

  • BUY_WITH_GOOGLE_PAY
    • dart GooglePayButtonType.BUY_WITH_GOOGLE_PAY
  • DONATE_WITH_GOOGLE_PAY
    • dart GooglePayButtonType.DONATE_WITH_GOOGLE_PAY
  • NORMAL_GOOGLE_PAY
    • dart GooglePayButtonType.NORMAL_GOOGLE_PAY
  • PAY_WITH_GOOGLE_PAY
    • dart GooglePayButtonType.PAY_WITH_GOOGLE_PAY
  • SUBSCRIBE_WITH_GOOGLE_PAY
    • dart GooglePayButtonType.SUBSCRIBE_WITH_GOOGLE_PAY
  • CHECKOUT_WITH_GOOGLE_PAY
    • dart GooglePayButtonType.CHECKOUT_WITH_GOOGLE_PAY
  • ORDER_WITH_GOOGLE_PAY
    • dart GooglePayButtonType.ORDER_WITH_GOOGLE_PAY
  • BOOK_WITH_GOOGLE_PAY
    • dart GooglePayButtonType.BOOK_WITH_GOOGLE_PAY

GooglePayButton

Google Pay Button Widget

TapGooglePayKitFlutter.googlePayButton(
    googlePayButtonType: GooglePayButtonType.NORMAL_GOOGLE_PAY,
     onTap: () {
     // Call available SDK Methods
   },
),

SDK Methods

Get Google Pay Token

   var tapGooglePaySDKResult = await TapGooglePayKitFlutter.getGooglePayToken;

Get Tap Token

   var tapTokenSDKResult = await TapGooglePayKitFlutter.getTapToken;