{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Accept Google Pay on Android (Early Preview)","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"accept-google-pay-on-android-early-preview","__idx":0},"children":["Accept Google Pay on Android (Early Preview)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you have a native Android App you can use Tyro Android SDK to easily accept Google Pay payments."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":1},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Please familiarise yourself with the guide to  ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/online-payments/pay-online/integration-guide/tyro-js"},"children":["Accept an Online Payment"]},", as the steps outlined in this document builds upon the existing knowledge."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"integration-steps","__idx":2},"children":["Integration Steps"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"1-configure-your-android-app","__idx":3},"children":["1. Configure Your Android App"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Make sure your app's build file uses the following values:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["minSdkVersion"]}," of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["21"]}," or higher"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["compileSdkVersion"]}," of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["31"]}," or higher"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add the following element to the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["<application>"]}," element in your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AndroidManifest.xml"]}," file to enable Google Pay."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"xml","header":{"controls":{"copy":{}}},"source":"<meta-data\n  android:name=\"com.google.android.gms.wallet.api.enabled\"\n  android:value=\"true\" />\n","lang":"xml"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"2-add-tyro-android-sdk","__idx":4},"children":["2. Add Tyro Android SDK"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Currently the SDK is published to GitHub Packages, to use a published package from GitHub Packages, you need to authenticate to GitHub Package and also add the repository to your project."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"21-authentication-to-github","__idx":5},"children":["2.1 Authentication to GitHub"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Make sure you have your GitHub username accessible by the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["build.gradle"]},", you can store it as an environment variable:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"export GITHUB_PACKAGES_USER={YOUR_GITHUB_USERNAME}\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Follow this ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic"},"children":["GitHub guide"]}," to generate a GitHub Personal Access Token with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["read:packages"]}," permission, and store it as an environment variable:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"export GITHUB_PACKAGES_TOKEN={YOUR_GITHUB_TOKEN}\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"22-add-package-dependency","__idx":6},"children":["2.2 Add Package Dependency"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add the Tyro Android SDK dependency to your module's Gradle build file, which is commonly ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["app/build.gradle"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"groovy","header":{"controls":{"copy":{}}},"source":"dependencies {\n  implementation 'com.tyro:tyro-pay-api-sdk-android:+'\n}\n","lang":"groovy"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"23-add-repository-to-project","__idx":7},"children":["2.3 Add Repository to Project"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add the repository to your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["gradle.build"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"groovy","header":{"controls":{"copy":{}}},"source":"repositories {\n    maven {\n            url = uri(\"https://maven.pkg.github.com/tyro/tyro-pay-api-sdk-android\")\n            credentials {\n                username = System.getenv(\"GITHUB_PACKAGES_USER\")\n                password = System.getenv(\"GITHUB_PACKAGES_TOKEN\")\n            }\n        }\n}\n","lang":"groovy"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Check more detail on the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry"},"children":["GitHub Packages - working with the gradle registry"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"3-add-the-google-pay-button","__idx":8},"children":["3. Add The Google Pay Button"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Follow ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.google.com/pay/api/android/guides/brand-guidelines"},"children":["Google's guidelines"]}," to add the Google Pay button to your App's UI."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"4-create-a-tyrogooglepayclient","__idx":9},"children":["4. Create a TyroGooglePayClient"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Create an instance of the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TyroGooglePayClient"]}," inside ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onCreate()"]}," of your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Activity"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Fragment"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Provide the configuration and listeners."]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"// Kotlin Sample Code\nclass YourCheckoutActivity : AppCompatActivity() {\n  ...\n  override fun onCreate(savedInstanceState: Bundle?) {\n    super.onCreate(savedInstanceState)\n    setContentView(R.layout.your_checkout_activity)\n\n    val tyroGooglePayClient = TyroGooglePayClient(\n      activity = this,\n      config = TyroGooglePayClient.Config(\n        liveMode = false,\n        merchantName = \"Example Merchant\",\n        allowedCardNetworks = listOf(\n          GooglePayCardNetwork.AMEX,\n          GooglePayCardNetwork.JCB,\n          GooglePayCardNetwork.MASTERCARD,\n          GooglePayCardNetwork.VISA),\n          googlePayReadyListener = :: onGooglePayReady,\n          paymentResultListener = :: onPaymentResult,\n      )\n    )\n  }\n\n  private fun onGooglePayReady(available: Boolean) {...}\n  private fun onPaymentResult(result: TyroGooglePayClient.Result){...}\n  ...\n}\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"5-handle-the-google-pay-ready-event","__idx":10},"children":["5. Handle the Google Pay Ready Event"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Before you display the Google Pay button, use the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GooglePayReadyListener"]}," to determine if Google Pay is available for the user."," ","Show the button if ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["available"]}," is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]},", otherwise Google Pay is not available and the button cannot be shown."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"// Kotlin Sample Code\n...\nprivate fun onGooglePayReady(available: Boolean) {\n  if (available) {\n      googlePayButton.visibility = View.VISIBLE\n  }\n}\n...\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"6-add-the-google-pay-button-click-listener","__idx":11},"children":["6. Add the Google Pay Button Click Listener"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Obtain the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["paySecret"]}," by creating a PayRequest from your server."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Invoke ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tyroGooglePayClient.launchGooglePay(paySecret)"]}," to start Google Pay."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use listeners to obtain the payment result."]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"// Kotlin Sample Code\n  ...\n  override fun onCreate(savedInstanceState: Bundle?) {\n    ...\n    googlePayButton.setOnClickListener {\n        tyroGooglePayClient.launchGooglePay(paySecret)\n    }\n  }\n  ...\n","lang":"kotlin"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"7-implement-the-paymentresultlistener","__idx":12},"children":["7. Implement the PaymentResultListener"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This listener is called when payment completes successfully or unsuccessfully. This includes the user cancelling the payment."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["If the payment succeeds, the result will be ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TyroGooglePayClient.Result.Success"]},". Optionally call ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tyroGooglePayClient.fetchPayRequest(\"paySecret\")"]}," to get more info on the Pay Request."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["If the payment is cancelled, the result will be ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TyroGooglePayClient.Result.Cancelled"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["If the payment failed, the result will be ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[" TyroGooglePayClient.Result.Failed"]},". Inspect the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result.error.errorType"]}," and other fields from the following example to get more details."]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"// Kotlin Sample Code\n  ...\n  private fun onPaymentResult(result: TyroGooglePayClient.Result) {\n    when(result){\n      TyroGooglePayClient.Result.Cancelled -> {\n        // User cancelled operation\n        showCancelled()\n      }\n      TyroGooglePayClient.Result.Success -> {\n        // Google Pay Success, show success view\n        // Optionally call tyroGooglePayClient.fetchPayRequest(\"paySecret\")\n        // to get more info on the Pay Request\n        showSuccess()\n      }\n      is TyroGooglePayClient.Result.Failed -> {\n        // Transaction failed for some reason\n        // inspect the following fields to get more info\n        val (errorType, errorMessage, errorCode, gatewayCode) = result.error\n        when(errorType) {\n          TyroPayRequestErrorType.CLIENT_VALIDATION_ERROR -> showClientValidationError(errorMessage)\n          TyroPayRequestErrorType.SERVER_VALIDATION_ERROR -> showServerValidationError(errorMessage, errorCode, gatewayCode)\n          TyroPayRequestErrorType.CARD_ERROR -> showCardError(errorMessage, errorCode, gatewayCode)\n          TyroPayRequestErrorType.SERVER_ERROR -> showGenericError(errorMessage, errorCode, gatewayCode)\n          TyroPayRequestErrorType.THREED_SECURE_ERROR -> show3DSError(errorMessage, errorCode)\n          else -> showGenericError(errorMessage)\n        }\n      }\n    }\n  }\n  ...\n","lang":"kotlin"},"children":[]}]},"headings":[{"value":"Accept Google Pay on Android (Early Preview)","id":"accept-google-pay-on-android-early-preview","depth":1},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Integration Steps","id":"integration-steps","depth":2},{"value":"1. Configure Your Android App","id":"1-configure-your-android-app","depth":3},{"value":"2. Add Tyro Android SDK","id":"2-add-tyro-android-sdk","depth":3},{"value":"2.1 Authentication to GitHub","id":"21-authentication-to-github","depth":4},{"value":"2.2 Add Package Dependency","id":"22-add-package-dependency","depth":4},{"value":"2.3 Add Repository to Project","id":"23-add-repository-to-project","depth":4},{"value":"3. Add The Google Pay Button","id":"3-add-the-google-pay-button","depth":3},{"value":"4. Create a TyroGooglePayClient","id":"4-create-a-tyrogooglepayclient","depth":3},{"value":"5. Handle the Google Pay Ready Event","id":"5-handle-the-google-pay-ready-event","depth":3},{"value":"6. Add the Google Pay Button Click Listener","id":"6-add-the-google-pay-button-click-listener","depth":3},{"value":"7. Implement the PaymentResultListener","id":"7-implement-the-paymentresultlistener","depth":3}],"frontmatter":{"title":"Accept Google Pay on Android","seo":{"title":"Accept Google Pay on Android (Early Preview)"}},"lastModified":"2026-09-01T06:34:43.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/online-payments/pay-online/integration-guide/google-pay","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}