The doGPayPayment API opens the Google Pay application directly for the customer to make the payment. On payment completion, the SDK verifies the payment and the response is delivered through onActivityResult().

Add the google maven repository to your project in the top level build.gradle. Add the following google maven repository to your project in the top level (project) build.gradle only if you are using doGPayPayment() function.

allprojects{
  repositories {
    google()
    ...
  }
}

Add the following dependencies to your module

dependencies {
    ...
    //Dependencies used by all payment functions
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    //doGPayPayment  - Also add the google maven repository as shown in the consecutive step
    implementation files ("libs/google-pay-client-api-1.0.0.aar")
    implementation 'com.google.android.gms:play-services-tasks:15.0.1'

}

You need to first check if the Google Pay app is available for payments.

Call the function isGPayReadyForPayment before showing the GPay payment option to the user. It checks if the GPay app is installed in the device and if it is ready for making payments.

public  void  isGPayReadyForPayment(Context context, final  GooglePayStatusListener listener)

Parameters: context: Context of the calling activity. listener: GooglePayStatusListener to receive the result.

public  interface  GooglePayStatusListener {
    void  isReady();
    void  isNotReady();
}
public  void  gPayPayment(Context context, Map<String, String> params, String token, String stage)

Parameters

  • context: Context of the calling activity.
  • params: A map of all the relevant parameters described here.
  • token: The token generated here.
  • stage: Value should be either "TEST" for testing server, or "PROD" for production server respectively.

© 2019 Cashfree Payments India Pvt Ltd