Unexpected_retrofit_failure calling requestGooglePayNonce in Android Application

I’m experiencing a problem completing orders using Google Pay in an Android native app (Kotlin/JetPack Compose). We had been using Google Pay with Square in this app for many months and this seems to have cropped up as Android Studio and/or Square dependencies have been routinely updated (unsure at this time exactly which dependency/platform change triggered the issue).

The problem occurs when calling the Square function to convert the GPay paymentData into a Square nonce. This happens in both Test and Prod environments, however in Test it produces an error, while in Prod it throws an exception–both the error and exception appear to be the same root cause.

The error appears to be unexpected_retrofit_failure occurring within the sqip.GooglePay.requestGooglePayNonce call.

Below is the information I’ve captured about the issue. I hope I’ve just made some mistake in usage, or have missed a release note advisory. Could you look at the usage and error content and advise anything that is incorrectly implemented?

If there is any info I can add please let me know. The issue is urgent for us, as we’ll need to disable Google Pay while we work through it (which will likely reduce product sales).

Thanks!
Rob

======= Square Dependencies ======

def inAppPaymentsSdkVersion = '1.6.2'
implementation "com.squareup.sdk.in-app-payments:card-entry:$inAppPaymentsSdkVersion"
implementation "com.squareup.sdk.in-app-payments:google-pay:$inAppPaymentsSdkVersion"

======== Result of call to requestGooglePayNonce in ENVIRONMENT_TEST ======
App doesn’t crash, requestGooglePayNonce returns the following error payload:

Error(code=USAGE_ERROR, message=Something went wrong. Please contact the developer of this application and provide them with this error code: google_pay_unexpected_retrofit_failure, debugCode=google_pay_unexpected_retrofit_failure, debugMessage=The Square In-App Payments SDK encountered an unexpected error. Please contact Square developer support via http://squareup.com/help/contact and provide them with the debug code: unexpected_retrofit_failure.)

======== Result of call to requestGooglePayNonce in ENVIRONMENT_PRODUCTION ======
Call to requestGooglePayNonce produces an exception (full stack trace at end)
java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call

========== Handler for Google Pay Events. =======

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
	when (requestCode) {
		.
		.
		.
    GOOGLE_PAY_REQUEST_CODE -> {
        when (resultCode) {
            Activity.RESULT_OK -> {
                if (data != null) {
                    val paymentData = PaymentData.getFromIntent(data)
                    if (paymentData != null) {
                        try { 
                            val nonceResult = requestGooglePayNonce(paymentData).execute()
                            capturePayment(googlePayService.onNonceRequestResult(nonceResult))
                        } catch (e:Error) {
                            handleGooglePayError(e.message ?: "Unable to obtain Google Pay Nonce.")
                        }
                    } else {
                        handleGooglePayError("Invalid Google Pay Response.")
                    }
                } else {
                    handleGooglePayError("Invalid Google Payment Data.")
                }
            }
            Activity.RESULT_CANCELED -> {
                handleGooglePayError("Google Pay Canceled.")
            }
            
            AutoResolveHelper.RESULT_ERROR -> {
                AutoResolveHelper.getStatusFromIntent(data)?.let {
                    handleGooglePayError(it.statusMessage ?: "Google Pay Error")
                }
            }
        }
    }
    else -> {
        super.onActivityResult(requestCode, resultCode, data)
    }
  }
}

========== Exception thrown on call to sqip.GooglePay.requestGooglePayNonce(paymentData)

FATAL EXCEPTION: main
Process: com.*****.****, PID: 22213
  java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=5556, result=-1, data=Intent { (has extras) }} to activity {com.*****.****/com.*****.****.MainActivity}: java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call
      for method CreateGooglePayNonceService.createGooglePayNonce
  	at android.app.ActivityThread.deliverResults(ActivityThread.java:5994)
  	at android.app.ActivityThread.handleSendResult(ActivityThread.java:6033)
  	at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67)
  	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
  	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
  	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
  	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
  	at android.os.Handler.dispatchMessage(Handler.java:106)
  	at android.os.Looper.loopOnce(Looper.java:226)
  	at android.os.Looper.loop(Looper.java:313)
  	at android.app.ActivityThread.main(ActivityThread.java:8757)
  	at java.lang.reflect.Method.invoke(Native Method)
  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
  Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call
      for method CreateGooglePayNonceService.createGooglePayNonce
  	at retrofit2.Utils.methodError(Utils.java:54)
  	at retrofit2.HttpServiceMethod.createCallAdapter(HttpServiceMethod.java:116)
  	at retrofit2.HttpServiceMethod.parseAnnotations(HttpServiceMethod.java:67)
  	at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:39)
  	at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:202)
  	at retrofit2.Retrofit$1.invoke(Retrofit.java:160)
  	at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
  	at $Proxy7.createGooglePayNonce(Unknown Source)
  	at sqip.internal.nonce.CreateNonceCall.<init>(CreateNonceCall.kt:69)
  	at sqip.internal.nonce.CreateNonceCall$Factory.create(CreateNonceCall.kt:56)
  	at sqip.GooglePay.requestGooglePayNonce(GooglePay.kt:60)
  	at com.*****.****.MainActivity.onActivityResult(MainActivity.kt:151)
  	at android.app.Activity.dispatchActivityResult(Activity.java:8951)
  	at android.app.ActivityThread.deliverResults(ActivityThread.java:5987)
  	... 13 more
  Caused by: java.lang.IllegalArgumentException: Call return type must be parameterized as Call<Foo> or Call<? extends Foo>
  	at retrofit2.DefaultCallAdapterFactory.get(DefaultCallAdapterFactory.java:42)
  	at retrofit2.Retrofit.nextCallAdapter(Retrofit.java:253)
  	at retrofit2.Retrofit.callAdapter(Retrofit.java:237)
  	at retrofit2.HttpServiceMethod.createCallAdapter(HttpServiceMethod.java:114)
  	... 25 more

Was there anything that recently changed in the app that would have caused this? Were not finding anything definitive on our end. :slightly_smiling_face: