Adyen / adyen-react-native

Adyen React Native
https://docs.adyen.com/checkout
MIT License
45 stars 32 forks source link

Additional Payment handler `nativeComponent.handle(action)` not working on android #545

Closed iyanushow closed 1 day ago

iyanushow commented 1 day ago

Describe the bug On android, when using a payment method that requires a redirect e.g Paypal or klarna. The nativeComponent.handle(result.action) does not work to open the webview or browser to complete the payment. It only closes the app, but no error is shown

To Reproduce Steps to reproduce the behavior:

  1. Select Paypal as a payment method and start payment
  2. App closes but does not open Paypal screen

result.action object

{"method": "GET", "paymentMethodType": "paypal", "type": "redirect", "url": "https://test.adyen.com/hpp/checkout.shtml?u=redirectPayPal&p=eJztWEtv2zgQ-jX2JaAgknpYBx0SWd64TeI0dpJiLwElUTYbmVIpKlnvr9*hJCttHk26WBRbIBfCmvlmOPw4HHPIiqK8p9MlCbVq*JhVVSFSpkUp5zIvrUIkiqndGdvykGU7LpEsM45YJVCvesnkiqsaRCEOLMeyxyCTWQS2YcV2FSvG6UqxlFdMcalD20YkoTTgHk0SRnPfSzPqe5QmAU8YzxI-R17GJgGeJIQkOM0DB9l4nG54els22tL-obNDrfm20vMszGnm2gFNELNdipzAS9AkyANk29jOkxS7HsuwT*2JbbuYuv4kiEl05HmziPiRHbjkMI5nhy52qe27M2-qwteRhz2POgGd*rETBLEfxN40BvPocDobp2Ujtdq1RE3jcdooWFLafceXF*NCSD6H8Opw5B6N-KMRISKDYUQPYcyw404y5qDc4YGJ10GMTBxEvdzBEHQepIkBkwjGtCxKNZgGE-y9ZsrrVInKbOsAOioafjByATM7uN4IzQcTCQkywI5LCDc7WG2EvD1YMRiW95zpgw8sveX64ImXg8GNFrp4q5-BqFJl1qSwX4Ohk7uwIOKhnLkYOU7iogkLXBRg5js4JX5G7cfmH-lusJ-b1PGc4AZIufn8*TFyWTTrAbppY0TaxIg0xIhqEyNKYJHo3qwOUTp4YPesECwp*KeGSVhsP6XndOqv30lxJ6zT5klg2Btc1uLvB8ZOBrGQS12mt53GHO2e4FKz4lyJdG-TptC3aTb4g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viLdQ8kNhsCPHNh8mrfba*XmIHWJhP7AwIRahk0EDpRd2sK0kMViYpBmcthN1f5BDPMMfTRvX8Aezj2tQ9-F1Hfne4cr8DZBxDVnYvew1iXVHrOsZidwP3ufoeDr56E*ItXJql2bnK1xd3jUn1RX9vIu*-vXFY9nV8nhZVPE0rpYyPq50*Q9nxVWw"}

Expected behavior App should redirect to Paypal screen to complete payment

Smartphone (please complete the following information):

descorp commented 1 day ago

Hey @iyanushow

This looks like App crash. Could you check for app logs in Android studio Logcat?

iyanushow commented 1 day ago

@descorp I took a look at the logs and this is the closest thing that makes sense

Loading bound service for intent: Intent { act=com.google.android.gms.measurement.START pkg=com.google.android.gms }
E  FATAL EXCEPTION: main
                      Process: com.carhartt_wip_staging, PID: 23960
                      android.view.InflateException: Binary XML file line #53 in com.carhartt_wip_staging:layout/view_payment_in_progress: Binary XML file line #53 in com.carhartt_wip_staging:layout/view_payment_in_progress: Error inflating class com.google.android.material.button.MaterialButton
                        Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@e63290b, Dispatchers.Main.immediate]
                      Caused by: android.view.InflateException: Binary XML file line #53 in com.carhartt_wip_staging:layout/view_payment_in_progress: Error inflating class com.google.android.material.button.MaterialButton
                      Caused by: java.lang.reflect.InvocationTargetException
                        at java.lang.reflect.Constructor.newInstance0(Native Method)
                        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
                        at android.view.LayoutInflater.createView(LayoutInflater.java:866)
                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1018)
                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:973)
                        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1135)
                        at android.view.LayoutInflater.inflate(LayoutInflater.java:664)
                        at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
                        at android.view.LayoutInflater.inflate(LayoutInflater.java:485)
                        at com.adyen.checkout.ui.core.databinding.ViewPaymentInProgressBinding.inflate(ViewPaymentInProgressBinding.java:58)
                        at com.adyen.checkout.ui.core.internal.ui.view.PaymentInProgressView.<init>(PaymentInProgressView.kt:41)
                        at com.adyen.checkout.ui.core.internal.ui.view.PaymentInProgressView.<init>(PaymentInProgressView.kt:29)
                        at com.adyen.checkout.redirect.internal.ui.RedirectViewProvider.getView(RedirectViewProvider.kt:23)
                        at com.adyen.checkout.ui.core.internal.ui.ViewProvider$DefaultImpls.getView(ViewProvider.kt:25)
                        at com.adyen.checkout.redirect.internal.ui.RedirectViewProvider.getView(RedirectViewProvider.kt:17)
                        at com.adyen.checkout.ui.core.AdyenComponentView.loadView(AdyenComponentView.kt:128)
                        at com.adyen.checkout.ui.core.AdyenComponentView.access$loadView(AdyenComponentView.kt:51)
                        at com.adyen.checkout.ui.core.AdyenComponentView$attach$1.invokeSuspend(AdyenComponentView.kt:109)
                        at com.adyen.checkout.ui.core.AdyenComponentView$attach$1.invoke(Unknown Source:8)
                        at com.adyen.checkout.ui.core.AdyenComponentView$attach$1.invoke(Unknown Source:4)
                        at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit(Emitters.kt:219)
                        at kotlinx.coroutines.flow.StateFlowImpl.collect(StateFlow.kt:396)
                        at kotlinx.coroutines.flow.StateFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
                        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
                        at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:65)
                        at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:371)
                        at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26)
                        at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:21)
                        at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:88)
                        at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:123)
                        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:52)
                        at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
                        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:43)
                        at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
                        at kotlinx.coroutines.flow.FlowKt__CollectKt.launchIn(Collect.kt:45)
                        at kotlinx.coroutines.flow.FlowKt.launchIn(Unknown Source:1)
                        at com.adyen.checkout.action.core.internal.ui.DefaultGenericActionDelegate.observeViewFlow(DefaultGenericActionDelegate.kt:191)

at com.adyen.checkout.action.core.internal.ui.DefaultGenericActionDelegate.observeDelegate(DefaultGenericActionDelegate.kt:156)
                      at com.adyen.checkout.action.core.internal.ui.DefaultGenericActionDelegate.createDelegateAndObserve(DefaultGenericActionDelegate.kt:149)
                      at com.adyen.checkout.action.core.internal.ui.DefaultGenericActionDelegate.handleAction(DefaultGenericActionDelegate.kt:127)
                      at com.adyen.checkout.action.core.internal.DefaultActionHandlingComponent.handleAction(DefaultActionHandlingComponent.kt:41)
                      at com.adyen.checkout.instant.InstantPaymentComponent.handleAction(Unknown Source:12)
                      at com.adyenreactnativesdk.component.base.BaseComponentFragment.onEvent(BaseComponentFragment.kt:72)
                      at com.adyenreactnativesdk.component.base.BaseComponentFragment.access$onEvent(BaseComponentFragment.kt:28)
                      at com.adyenreactnativesdk.component.base.BaseComponentFragment$onViewCreated$1$1$2.invokeSuspend$onEvent(BaseComponentFragment.kt:58)
                      at com.adyenreactnativesdk.component.base.BaseComponentFragment$onViewCreated$1$1$2.access$invokeSuspend$onEvent(Unknown Source:0)
                      at com.adyenreactnativesdk.component.base.BaseComponentFragment$onViewCreated$1$1$2$1.emit(BaseComponentFragment.kt:58)
                      at com.adyenreactnativesdk.component.base.BaseComponentFragment$onViewCreated$1$1$2$1.emit(BaseComponentFragment.kt:58)
                      at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:392)
                      at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
                      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                      at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
                      at android.os.Handler.handleCallback(Handler.java:958)
                      at android.os.Handler.dispatchMessage(Handler.java:99)
                      at android.os.Looper.loopOnce(Looper.java:205)
                      at android.os.Looper.loop(Looper.java:294)
                      at android.app.ActivityThread.main(ActivityThread.java:8177)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
                    Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
                      at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:247)
                      at com.google.android.material.internal.ThemeEnforcement.checkMaterialTheme(ThemeEnforcement.java:216)
                      at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:144)
                      at com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(ThemeEnforcement.java:76)
                      at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:239)
                      at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:230)
iyanushow commented 1 day ago

Looks like its something similar to #107. With the MaterialTheme in styles.xml

descorp commented 1 day ago

That is the one, indeed. Please use MaterialComponents

descorp commented 1 day ago

I am going to close this one as duplicate. Please feel free to continue here or on original ticket