-2

I faced an issue with google pay with stripe. The problem is that I fully followed the documentation and get an obscure error. I have this onGooglePayResult and i always have Result.Failed with error - " java.lang.RuntimeException: Google Pay failed with error 10 " And error code 2.Feel free to ask i can answer on all your questions.

Main error is java.lang.RuntimeException: Google Pay failed with error 10:. This is coming in GooglePayPaymentMethodLauncher.Result.Failed. I really can't understand why this is producing, I've checked stripe documentation twice, google pay set up and everything, but can't find out. I mean how to find out what is real error message is, I try to find anything related to this but unfortunatelythere is simply nothing of the kind.

Logcat - error = java.lang.RuntimeException: Google Pay failed with error 10: + error code = 2

private fun onGooglePayResult(
    result: GooglePayPaymentMethodLauncher.Result
) {
    when (result) {
        is GooglePayPaymentMethodLauncher.Result.Completed -> {
            // Payment details successfully captured.
            // Send the paymentMethodId to your server to finalize payment.
            val paymentMethodId = result.paymentMethod.id
            presenter.payPlanWithGooglePay(deviceIdentifier, paymentMethodId)
        }
        GooglePayPaymentMethodLauncher.Result.Canceled -> {
            // User cancelled the operation
            Timber.d("Cancel")
        }
        is GooglePayPaymentMethodLauncher.Result.Failed -> {
            // Operation failed; inspect `result.error` for the exception
            Timber.d("error = ${result.error} + error code = ${result.errorCode}")
        }
    }
}
Bogdan
  • 17
  • 1
  • 4

1 Answers1

0

I've resolved this issue, was my fault. I forget to add the PUBLISHABLE key from the stripe developer portal.

I use this function to set up Google pay. Just substitute TEST_PUBLISHABLE_KEY with your key in stripe account(Website).

private fun setUpGooglePay(): GooglePayPaymentMethodLauncher {
        PaymentConfiguration.init(this, TEST_PUBLISHABLE_KEY)
        return GooglePayPaymentMethodLauncher(
            activity = this,
            config = GooglePayPaymentMethodLauncher.Config(
                environment = GooglePayEnvironment.Test,
                merchantCountryCode = Constants.GooglePay.Manx.COUNTRY_CODE,
                merchantName = UIUtils.getString(R.string.app_name)
            ),
            readyCallback = ::onGooglePayReady,
            resultCallback = ::onGooglePayResult
        )
    }
Bogdan
  • 17
  • 1
  • 4