stripe / stripe-terminal-android

Stripe Terminal Android SDK
https://stripe.dev/stripe-terminal-android/
Other
93 stars 45 forks source link

Contactless transaction failed java.lang.IllegalStateException: App Error: SERVER_ERROR An unknown error has occurred: kotlin.NoWhenBranchMatchedException: null #411

Closed rscherf closed 10 months ago

rscherf commented 10 months ago

Summary

A subset of users across many devices have started receiving the following error. This happens after Tap to Pay has been enabled and the user attempts to create the PaymentIntent.

Contactless transaction failed java.lang.IllegalStateException: App Error: SERVER_ERROR 'An unknown error has occurred: kotlin.NoWhenBranchMatchedException: null'

Code to reproduce

            PaymentIntentParameters.Builder builder = new PaymentIntentParameters.Builder(paymentMethodList)
                    .setAmount(amount)
                    .setCurrency(currency);

            PaymentIntentParameters params = builder.build();

            Terminal.getInstance().createPaymentIntent(params, new PaymentIntentCallback() {
                @Override
                public void onSuccess(@NotNull PaymentIntent paymentIntent) {
                    future.complete(paymentIntent);
                }

                @Override
                public void onFailure(@NotNull TerminalException e) {
                    future.completeExceptionally(e);
                }
            }, new CreateConfiguration(OfflineBehavior.REQUIRE_ONLINE));

Android version

Android 13.0

SDK version

    implementation 'com.stripe:stripe-android:20.29.2'
    implementation "com.stripe:stripeterminal-core:3.2.0"
    implementation "com.stripe:stripeterminal-handoffclient:3.2.0"
    implementation "com.stripe:stripeterminal-localmobile:3.0.0"
    implementation 'com.stripe:stripecardscan:20.25.8'

Other information

I was able to find the root cause from USB debugging.

12-16 01:25:11.433 18739 19635 D StripeTerminal: class=Terminal message=createPaymentIntent
12-16 01:25:11.434 18739 19517 D StripeTerminal: class=OnlineDirectResourceRepository message=createPaymentIntent
12-16 01:25:11.434 18739 19517 D StripeTerminal: class=ApiClient message=createPaymentIntent
12-16 01:25:11.439 18739 19517 I StripeTerminal: class=RestClient message="url=https://api.stripe.com/v1/payment_intents request={"amount":"100","applicationFeeAmount":"0","captureMethod":"manual","currency":"usd","customer":"cus_PC4CB5rQ8bBU3l","metadata":{"device_name":"Galaxy S23 FE","app_version":"9.3","from_app":"com.nudge.payment","device":"r11q (SM-S711U1) samsung"},"paymentMethodOptions":{"cardPresent":{}},"paymentMethodTypes":["card_present"]}"
12-16 01:25:11.843 18739 19517 I StripeTerminal: class=RestClient message="url=https://api.stripe.com/v1/payment_intents status=OK headers={access-control-allow-credentials=true, access-control-allow-methods=GET,HEAD,PUT,PATCH,POST,DELETE, access-control-allow-origin=*, access-control-expose-headers=Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required, access-control-max-age=300, cache-control=no-cache, no-store, content-length=1673, content-security-policy=report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_intents; block-all-mixed-content; default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self', content-type=application/json, date=Fri, 15 Dec 2023 18:25:11 GMT, idempotency-key=170266471144083b4f8bb-94e2-4c75-960e-b3910794780fGlhC5S3X, original-request=req_FZ2uSpF0l0FjKB, request-id=req_FZ2uSpF0l0FjKB, server=nginx, strict-transport-security=max-age=63072000; includeSubDomains; preload, stripe-account=acct_2TUfNOFfcKADmELVl8bN, stripe-should-retry=false, stripe-version=2019-02-19, vary=Origin, x-stripe-routing-context-priority-tier=livemode-critical} response={"amount":"100","amountCapturable":"0","amountDetails":{"tip":{}},"amountReceived":"0","applicationFeeAmount":"0","captureMethod":"manual","charges":{"hasMore":false,"totalCount":0},"created":"1702664711","currency":"usd","customer":"cus_PC4CB5rQ8bBU3l","id":"pi_2ONg4RNOFfcKADmE1TVTXBhN","livemode":true,"metadata":{"app_version":"9.3","device":"r11q (SM-S711U1) samsung","device_name":"Galaxy S23 FE","from_app":"com.nudge.payment"},"paymentMethodOptions":{"cardPresent":{}},"status":"requires_payment_method","__redacted_fields":["clientSecret"]}"
12-16 01:25:11.845 18739 19636 D StripeTerminal: class=Terminal message=collectPaymentMethod config="CollectConfiguration(skipTipping=false, moto=false, updatePaymentIntent=false, tippingConfiguration=null, enableCustomerCancellation=false)"
12-16 01:25:11.846 18739 19517 I StripeTerminal: class=TerminalStatusManager message=waitForInput.
12-16 01:25:11.846 18739 19517 D StripeTerminal: class=ProxyTerminalListener message=onPaymentStatusChange(WAITING_FOR_INPUT)
12-16 01:25:11.846 18739 19517 I System.out: 
12-16 01:25:11.846 18739 19517 I System.out: 
12-16 01:25:11.846 18739 19517 I System.out: 
12-16 01:25:11.846 18739 19517 I System.out: onPaymentStatusChange: WAITING_FOR_INPUT
12-16 01:25:11.846 18739 19517 I System.out: 
12-16 01:25:11.846 18739 19517 I System.out: 
12-16 01:25:11.853 18739 19517 I StripeTerminal: class=TerminalStatusManager message=endPaymentFlow.
12-16 01:25:11.853 18739 19517 D StripeTerminal: class=ProxyTerminalListener message=onPaymentStatusChange(READY)
12-16 01:25:11.853 18739 19517 I System.out: 
12-16 01:25:11.853 18739 19517 I System.out: 
12-16 01:25:11.853 18739 19517 I System.out: 
12-16 01:25:11.853 18739 19517 I System.out: onPaymentStatusChange: READY
12-16 01:25:11.853 18739 19517 I System.out: 
12-16 01:25:11.853 18739 19517 I System.out: 
12-16 01:25:11.854 18739 19517 E StripeTerminal: class=TerminalSession
12-16 01:25:11.854 18739 19517 E StripeTerminal: com.stripe.stripeterminal.external.models.TerminalException: Contactless transaction failed java.lang.IllegalStateException: App Error: SERVER_ERROR 'An unknown error has occurred: kotlin.NoWhenBranchMatchedException: null'.
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at com.stripe.stripeterminal.internal.common.adapter.CotsAdapter.callAidlWithExceptionConverted(CotsAdapter.kt:373)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at com.stripe.stripeterminal.internal.common.adapter.CotsAdapter.collectPaymentMethodHandler(CotsAdapter.kt:141)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at com.stripe.stripeterminal.internal.common.adapter.CotsAdapter.collectPaymentMethod(CotsAdapter.kt:134)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at com.stripe.stripeterminal.internal.common.adapter.ProxyAdapter.collectPaymentMethod(ProxyAdapter.kt:144)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession$CollectPaymentMethodOperation.executeIfNotCanceled(TerminalSession.kt:1296)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession$CancelableOperation.execute(TerminalSession.kt:1057)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession$ExternalOperation.run$terminalsession_release(TerminalSession.kt:1015)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession.enqueueOperation$lambda$6(TerminalSession.kt:874)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession.$r8$lambda$6lM7341_XI6PEqXfOM-yc2U5tkQ(Unknown Source:0)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession$$ExternalSyntheticLambda0.run(Unknown Source:4)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
12-16 01:25:11.854 18739 19517 E StripeTerminal:    at java.lang.Thread.run(Thread.java:1012)
chr-stripe commented 10 months ago

Hi @rscherf, it looks like you're using mismatched versions of the SDKs here:

implementation "com.stripe:stripeterminal-core:3.2.0"
implementation "com.stripe:stripeterminal-handoffclient:3.2.0"
implementation "com.stripe:stripeterminal-localmobile:3.0.0"

The stripeterminal-localmobile dependency needs to be updated to 3.2.0 as well.

rscherf commented 10 months ago

Hey @chr-stripe, so this is a known issue and expected error? Just want to make sure I understand correctly.

chr-stripe commented 10 months ago

This is a requirement laid out in our README:

The stripeterminal-localmobile SDK version must match the version you're using for other stripeterminal libraries.

The Terminal SDK libraries all need to use the same version so that they agree on which data models can be passed back and forth. It's likely that a new value was introduced in 3.2.0 that stripeterminal-core is aware of and stripeterminal-localmobile is not, which is causing the NoWhenBranchMatchedException to be raised.

rscherf commented 10 months ago

Thank you! I'll close but not delete in case someone else Googles this.