intive / adyen_flutter

A Flutter plugin for the Adyen Payment Provider DropIn UI
MIT License
11 stars 26 forks source link

Android - submitting card details form crashes the app #3

Closed alexghiu closed 3 years ago

alexghiu commented 3 years ago

Really appreciate the time you've put into developing this plugin!

Description

On Android, submitting the card details form, causes the following exception to be shown in the flutter run output:

E/AndroidRuntime( 7715): FATAL EXCEPTION: AsyncTask #5
E/AndroidRuntime( 7715): Process: com.frontend, PID: 7715
E/AndroidRuntime( 7715): java.lang.RuntimeException: An error occurred while executing doInBackground()
E/AndroidRuntime( 7715):    at android.os.AsyncTask$3.done(AsyncTask.java:353)
E/AndroidRuntime( 7715):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
E/AndroidRuntime( 7715):    at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
E/AndroidRuntime( 7715):    at java.util.concurrent.FutureTask.run(FutureTask.java:271)
E/AndroidRuntime( 7715):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/AndroidRuntime( 7715):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/AndroidRuntime( 7715):    at java.lang.Thread.run(Thread.java:764)
E/AndroidRuntime( 7715): Caused by: java.lang.IllegalArgumentException: baseUrl must end in /: http://192.168.1.136:3000/my
E/AndroidRuntime( 7715):    at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:515)
E/AndroidRuntime( 7715):    at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:458)
E/AndroidRuntime( 7715):    at app.adyen.flutter_adyen.CheckoutApiServiceKt.getService(CheckoutApiService.kt:67)
E/AndroidRuntime( 7715):    at app.adyen.flutter_adyen.AdyenDropinService.makePaymentsCall(FlutterAdyenPlugin.kt:182)
E/AndroidRuntime( 7715):    at com.adyen.checkout.dropin.service.DropInService.askPaymentsCall(DropInService.kt:131)
E/AndroidRuntime( 7715):    at com.adyen.checkout.dropin.service.DropInService.onHandleWork(DropInService.kt:103)
E/AndroidRuntime( 7715):    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:392)
E/AndroidRuntime( 7715):    at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:383)
E/AndroidRuntime( 7715):    at android.os.AsyncTask$2.call(AsyncTask.java:333)
E/AndroidRuntime( 7715):    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime( 7715):    ... 3 more

The application completely crashes with these last few lines:

D/        ( 7715): HostConnection::get() New Host Connection established 0x6f050540, tid 7796
I/zygote  ( 7715): Do full code cache collection, code=995KB, data=662KB
I/zygote  ( 7715): After code cache collection, code=856KB, data=496KB
D/EGL_emulation( 7715): eglMakeCurrent: 0x9c407340: ver 1 0 (tinfo 0x859e8a90)
D/EGL_emulation( 7715): eglMakeCurrent: 0x9c405540: ver 2 0 (tinfo 0x87c1b8e0)
D/EGL_emulation( 7715): eglMakeCurrent: 0x9c405540: ver 2 0 (tinfo 0x87c1b8e0)
E/BufferQueueProducer( 7715): [SurfaceTexture-0-7715-0] setAsyncMode: BufferQueue has been abandoned
E/BufferQueueProducer( 7715): [SurfaceTexture-0-7715-0] cancelBuffer: BufferQueue has been abandoned
E/libEGL  ( 7715): call to OpenGL ES API with no current context (logged once per thread)
D/FlutterLocationService( 7715): Unbinding from location service.
D/FlutterLocationService( 7715): Destroying service.
Lost connection to device.

Screenshots

Description Picture
Fill card details one
After pressing submit two

Environment details

Here is also a dump of flutter doctor -v:

[✓] Flutter (Channel stable, 2.0.6, on Mac OS X 10.15.7 19H1030 darwin-x64, locale en-US)
    • Flutter version 2.0.6 at /Users/alex/Applications/flutter
    • Framework revision 1d9032c7e1 (3 weeks ago), 2021-04-29 17:37:58 -0700
    • Engine revision 05e680e202
    • Dart version 2.12.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/alex/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212

• No issues found!

Questions

Any idea on whats is going wrong and how to fix it?

bennibau commented 3 years ago

@alexghiu I can see this error message in your logs: E/AndroidRuntime( 7715): Caused by: java.lang.IllegalArgumentException: baseUrl must end in /: http://192.168.1.136:3000/my

Please try to insert a correct baseUrl first and see if the crash still exists

alexghiu commented 3 years ago

@bennibau thanks for reaching out. Indeed that did the trick! Much appreciated!

I guess I must of misinterpreted the following bits in the README:

The app uses these endpoints for payment submit and payment details calls:

<your base url>/payment
<your base url>/payment/details
alexghiu commented 3 years ago

After following your suggestion and added the / at the end of the base path:

I had a look at the iOS code. It adds the / after the baseUrl: https://github.com/intive-opensource/adyen_flutter/blob/master/ios/Classes/SwiftFlutterAdyenPlugin.swift#L95 https://github.com/intive-opensource/adyen_flutter/blob/master/ios/Classes/SwiftFlutterAdyenPlugin.swift#L156

On Android, it seems that the app crashes without that / there. Is it possible to align the two?

What I'm looking to end up with on both platforms is a request that gets sent to:

https://foo.bar/my/payment
https://foo.bar/my/payment/details

So baseUrl would need to be https://foo.bar/my or https://foo.bar/my/

alexghiu commented 3 years ago

I'm happy to submit a PR for an iOS code change.

I'm afraid that I'm a bit intimidated by the body of getService so I'm inclined to leave the Android code alone.

bennibau commented 3 years ago

you are correct this is indeed a bug. we are using two different base urls in our build environment. one with slash and one without. you can create a PR and I will review it

alexghiu commented 3 years ago

Let me know what you think about PR https://github.com/intive-opensource/adyen_flutter/pull/4.

bennibau commented 3 years ago

fixed with #4