Google Pay Integration in Mobile App

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Google Pay Integration in Mobile App
Complex
~2-3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1054
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Integration of Google Pay Payment System into Mobile Application

Google Pay on Android works via Google Pay API — not separate SDK, but part of Google Play Services. Integration technically simpler than Apple Pay: no certificates and separate developer portal, only PaymentDataRequest configuration and token handling. But points where can make mistakes sufficient.

PaymentsClient and ENVIRONMENT_TEST / ENVIRONMENT_PRODUCTION

Google Pay works in two environments. In ENVIRONMENT_TEST can get fake tokens without real card — convenient for development. In ENVIRONMENT_PRODUCTION need pre-pass Google verification (fill form in Google Pay Business Console and get approval).

private fun createPaymentsClient(activity: Activity): PaymentsClient {
    val walletOptions = Wallet.WalletOptions.Builder()
        .setEnvironment(WalletConstants.ENVIRONMENT_PRODUCTION)
        .build()
    return Wallet.getPaymentsClient(activity, walletOptions)
}

PaymentDataRequest configuration

private fun createPaymentDataRequest(price: String): PaymentDataRequest {
    val tokenizationSpec = JSONObject().apply {
        put("type", "PAYMENT_GATEWAY")
        put("parameters", JSONObject().apply {
            put("gateway", "stripe")  // or "cloudpayments", "yookassa" etc
            put("stripe:version", "2023-10-16")
            put("stripe:publishableKey", "pk_live_...")
        })
    }

    val cardPaymentMethod = JSONObject().apply {
        put("type", "CARD")
        put("parameters", JSONObject().apply {
            put("allowedAuthMethods", JSONArray(listOf("PAN_ONLY", "CRYPTOGRAM_3DS")))
            put("allowedCardNetworks", JSONArray(listOf("MASTERCARD", "VISA", "MIR")))
        })
        put("tokenizationSpecification", tokenizationSpec)
    }

    val request = JSONObject().apply {
        put("apiVersion", 2)
        put("apiVersionMinor", 0)
        put("allowedPaymentMethods", JSONArray(listOf(cardPaymentMethod)))
        put("transactionInfo", JSONObject().apply {
            put("totalPrice", price)
            put("totalPriceStatus", "FINAL")
            put("currencyCode", "RUB")
            put("countryCode", "RU")
        })
        put("merchantInfo", JSONObject().apply {
            put("merchantName", "Your Company Name")
            put("merchantId", "YOUR_MERCHANT_ID") // from Business Console
        })
    }

    return PaymentDataRequest.fromJson(request.toString())
}

PAN_ONLY vs CRYPTOGRAM_3DS

Often causes questions. PAN_ONLY — card added to Google Pay via browser or manually, without 3DS token. CRYPTOGRAM_3DS — device with hardware protection (SE or StrongBox), card tokenized in Trusted Execution Environment. For Russian acquirers both methods supported, but clarify with provider — some accept only CRYPTOGRAM_3DS to reduce fraud.

Launch payment interface

private val paymentLauncher = registerForActivityResult(
    ActivityResultContracts.StartIntentSenderForResult()
) { result ->
    when (result.resultCode) {
        Activity.RESULT_OK -> {
            val data = result.data ?: return@registerForActivityResult
            val paymentData = PaymentData.getFromIntent(data)
            val token = paymentData
                ?.paymentMethodToken
                ?.token  // JSON-string with provider token

            // Send token to backend
        }
        Activity.RESULT_CANCELED -> { /* user closed */ }
        AutoResolveHelper.RESULT_ERROR -> {
            val status = AutoResolveHelper.getStatusFromIntent(result.data)
            Log.e("GPay", "Error: ${status?.statusMessage}")
        }
    }
}

// Launch
val task = paymentsClient.loadPaymentData(createPaymentDataRequest("1500.00"))
task.addOnCompleteListener { completedTask ->
    if (completedTask.isSuccessful) {
        paymentLauncher.launch(
            IntentSenderRequest.Builder(
                completedTask.result.resolutionPendingIntent!!.intentSender
            ).build()
        )
    }
}

Google Pay button: design requirements

Google strictly regulates button appearance. Can't change color, font, aspect ratio of Google Pay button. Google checks this during review before ENVIRONMENT_PRODUCTION release.

Correctly use ready widget:

val button = PayButton(context).apply {
    initialize(
        ButtonOptions.newBuilder()
            .setButtonType(ButtonType.BUY)
            .setCornerRadius(8)
            .build()
    )
}

isReadyToPay before showing button

Don't show Google Pay button without check:

val isReadyToPayRequest = IsReadyToPayRequest.fromJson(
    JSONObject().apply {
        put("apiVersion", 2)
        put("apiVersionMinor", 0)
        put("allowedPaymentMethods", JSONArray(listOf(cardPaymentMethod)))
    }.toString()
)

paymentsClient.isReadyToPay(isReadyToPayRequest)
    .addOnSuccessListener { result ->
        googlePayButton.isVisible = result
    }

If card not added to Google Pay or device incompatible — don't show button.

What's included

  • PaymentsClient setup with correct environment
  • tokenizationSpecification configuration for payment provider
  • isReadyToPay implementation and correct button hiding
  • PaymentData handling and token passing to backend
  • Passing Google Pay Business Console review

Timeline

2–3 days. Cost calculated individually.