square / in-app-payments-flutter-plugin

Flutter Plugin for Square In-App Payments SDK
https://developer.squareup.com/docs
Apache License 2.0
340 stars 121 forks source link

Can't pay/save with SCA card (verifyBuyer) #191

Closed mdeandrea-mrmilu closed 1 year ago

mdeandrea-mrmilu commented 2 years ago

Describe the issue

When try verify a card with SCA (buyer verification) in release mode and minifyEnabled true, app crash

Error log

E/AndroidRuntime(20018): FATAL EXCEPTION: main E/AndroidRuntime(20018): Process: sqip.flutter.example, PID: 20018 E/AndroidRuntime(20018): java.lang.ExceptionInInitializerError E/AndroidRuntime(20018): at com.ndsthreeds.android.sdk.getTmNetworkCountryIso.values(Unknown Source:33) E/AndroidRuntime(20018): at com.ndsthreeds.android.sdk.getTmNetworkCountryIso.(Unknown Source:7) E/AndroidRuntime(20018): at com.ndsthreeds.android.sdk.getTmNetworkCountryIso.valueOf(Unknown Source:16) E/AndroidRuntime(20018): at com.ndsthreeds.android.sdk.getNoValueReason.(Unknown Source:9) E/AndroidRuntime(20018): at com.ndsthreeds.android.sdk.NdsThreeDS2ServiceImpl.initialize(Unknown Source:73) E/AndroidRuntime(20018): at com.ndsthreeds.android.sdk.NdsThreeDSSDK.initialize(Unknown Source:20) E/AndroidRuntime(20018): at b.d.d.a.r.a(Unknown Source:12) E/AndroidRuntime(20018): at b.d.d.b.f.f(Unknown Source:51) E/AndroidRuntime(20018): at b.d.d.b.f.g(Unknown Source:67) E/AndroidRuntime(20018): at sqip.internal.verification.service.nudata.NuDataVerificationService.startThreeDSWidget(Unknown Source:125) E/AndroidRuntime(20018): at sqip.internal.verification.service.nudata.NuDataVerificationService.verify(Unknown Source:39) E/AndroidRuntime(20018): at sqip.internal.verification.BuyerVerificationController.startVerificationService(Unknown Source:14) E/AndroidRuntime(20018): at sqip.internal.verification.BuyerVerificationController.handleResponse(Unknown Source:131) E/AndroidRuntime(20018): at sqip.internal.verification.BuyerVerificationController.onCreateVerificationSuccess(Unknown Source:4) E/AndroidRuntime(20018): at sqip.internal.verification.BuyerVerificationController.access$onCreateVerificationSuccess(Unknown Source:0) E/AndroidRuntime(20018): at sqip.internal.verification.BuyerVerificationController$startCreateVerification$1.invoke(Unknown Source:9) E/AndroidRuntime(20018): at sqip.internal.verification.BuyerVerificationController$startCreateVerification$1.invoke(Unknown Source:2) E/AndroidRuntime(20018): at sqip.internal.verification.BuyerVerificationRequestHandler$Real.sendSuccess(Unknown Source:6) E/AndroidRuntime(20018): at sqip.internal.verification.BuyerVerificationRequestHandler$Real.onResponse(Unknown Source:70) E/AndroidRuntime(20018): at sqip.internal.verification.BuyerVerificationRequestHandler$Real$createVerification$1.onResponse(Unknown Source:14) E/AndroidRuntime(20018): at k.i$b$a.c(Unknown Source:25) E/AndroidRuntime(20018): at k.i$b$a.d(Unknown Source:0) E/AndroidRuntime(20018): at k.b.run(Unknown Source:6) E/AndroidRuntime(20018): at android.os.Handler.handleCallback(Handler.java:938) E/AndroidRuntime(20018): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(20018): at android.os.Looper.loop(Looper.java:236) E/AndroidRuntime(20018): at android.app.ActivityThread.main(ActivityThread.java:8107) E/AndroidRuntime(20018): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(20018): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) E/AndroidRuntime(20018): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) E/AndroidRuntime(20018): Caused by: java.lang.RuntimeException: Field keySize_ for b.c.b.a.y.q not found. Known fields are [private int b.c.b.a.y.q.h, private static final b.c.b.a.y.q b.c.b.a.y.q.f, private static volatile b.c.b.a.z.a.a1 b.c.b.a.y.q.g] E/AndroidRuntime(20018): at b.c.b.a.z.a.v0.m0(Unknown Source:72) E/AndroidRuntime(20018): at b.c.b.a.z.a.v0.S(Unknown Source:697) E/AndroidRuntime(20018): at b.c.b.a.z.a.v0.Q(Unknown Source:12) E/AndroidRuntime(20018): at b.c.b.a.z.a.k0.e(Unknown Source:60) E/AndroidRuntime(20018): at b.c.b.a.z.a.k0.a(Unknown Source:49) E/AndroidRuntime(20018): at b.c.b.a.z.a.d1.d(Unknown Source:17) E/AndroidRuntime(20018): at b.c.b.a.z.a.d1.e(Unknown Source:4) E/AndroidRuntime(20018): at b.c.b.a.z.a.z.C(Unknown Source:4) E/AndroidRuntime(20018): at b.c.b.a.z.a.z$a.q(Unknown Source:9) E/AndroidRuntime(20018): at b.c.b.a.z.a.z$a.p(Unknown Source:0) E/AndroidRuntime(20018): at b.c.b.a.u.a.k(Unknown Source:8) E/AndroidRuntime(20018): at b.c.b.a.u.a.j(Unknown Source:4) E/AndroidRuntime(20018): at a.p.a.a$d.(Unknown Source:2) E/AndroidRuntime(20018): ... 30 more

To Reproduce

Use modified example from plugin

Modified example

  1. Create proguard file int android/app/proguard-rules.pro with lines: To use square plugin in release: -keep class sqip.** { *; } To see class log error details: -keep class com.ndsthreeds.** { *; }

  2. Config release signin. Add to file android/app/build.gradle this lines:

    android {

    // Other configs buildTypes { release { signingConfig signingConfigs.debug minifyEnabled true } }

  3. Modify buy_sheet.dart to use verifyBuyer. Uncomment await _onStartCardEntryFlowWithBuyerVerification(); and comment await _onStartCardEntryFlow();

    // call _onStartCardEntryFlow to start Card Entry without buyer verification (SCA) // await _onStartCardEntryFlow(); // OR call _onStartCardEntryFlowWithBuyerVerification to start Card Entry with buyer verification (SCA) // NOTE this requires _squareLocationSet to be set await _onStartCardEntryFlowWithBuyerVerification();

Reproduce error

  1. Start example in release mode flutter run --release
  2. Press button Pay with card
  3. Add card with SCA to payment. Example: 4800 0000 0000 0004 01/23 111 00000. References
  4. Press pay
  5. Error: App crash

Expected behavior

Don't crash app when use minifyEnabled true in release mode

Environment (please complete the following information):

Flutter doctor

[✓] Flutter (Channel stable, 2.8.1, on macOS 12.4 21F79 darwin-x64, locale en-ES) • Flutter version 2.8.1 at /Users/matias/fvm/versions/2.8.1 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 77d935af4d (6 months ago), 2021-12-16 08:37:33 -0800 • Engine revision 890a5fca2e • Dart version 2.15.1 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/matias/Library/Android/sdk • Platform android-31, build-tools 31.0.0 • ANDROID_HOME = /Users/matias/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.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 11.0.11+0-b60-7590822) [!] Android Studio • Android Studio at /Applications/Android Studio 2.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 ✗ Android Studio not found at /Applications/Android Studio 2.app/Contents • Try updating or re-installing Android Studio. [✓] VS Code (version 1.67.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.42.0 [✓] Connected device (2 available) • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.61

Additional context

I try add more proguard rules but don't work

Other pro guard rules

-keep class io.flutter.app.** { *; } -keep class io.flutter.plugin.** { *; } -keep class io.flutter.util.** { *; } -keep class io.flutter.view.** { *; } -keep class io.flutter.** { *; } -keep class io.flutter.plugins.** { *; } -dontnote android.net.http.* -dontnote org.apache.commons.codec.** -dontnote org.apache.http.** -dontwarn okhttp3.** -dontwarn okio.** -dontwarn javax.annotation.** -dontwarn org.conscrypt.** -dontwarn retrofit2.Platform$Java8 -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase -keep class com.google.android.gms.** { *; } -dontwarn com.google.android.gms.** -keep class com.crashlytics.** { *; } -dontwarn com.crashlytics.** -keepclasseswithmembers class * { @com.squareup.moshi.* ; } -keep @com.squareup.moshi.JsonQualifier interface * -keepclassmembers class kotlin.Metadata { public ; } -keep class **JsonAdapter { (...); ; } -keepnames @com.squareup.moshi.JsonClass class * -keepnames @kotlin.Metadata class com.myapp.model.api.** -keep class com.myapp.model.api.** { *; } -keepclassmembers class com.myapp.model.api.** { *; } -keep class kotlin.reflect.** -keep class org.threeten.bp.** -keep class kotlin.Boolean -keep class java.math.BigDecimal

Workaround

Set minifyEnabled false and shrinkResources false

CharmisG commented 1 year ago

Closing this issue but if you still find this problem please reopen this issue. Thank you.

mdeandrea-mrmilu commented 1 year ago

Hi @CharmisG What is the criteria to close this issue?

Armaxis commented 1 year ago

Hello! Thank you for flagging this issue, I'm happy to help you with it.

First, some questions:

  1. What version of Android In-App Payments SDK are you using? Latest is 1.5.8; and Flutter plugin might be pulling in an older version (like 1.5.6)
  2. Can you share your build/outputs/mapping/release/mapping.txt file that way we can identify what b.d.d.a.r.a might be? If yes, please use this link to send it safely to me https://squareup.sendsafely.com/u/artem
  3. What does the final (merged) proguard-rules.pro look like? Can you share it as well, please?
mdeandrea-mrmilu commented 1 year ago
  1. In-App Payments Plugin version: 1.7.4
  2. and 3. Now I don't have time to do this, but when posible I might send the files
fka3 commented 1 year ago

Are you still facing this?