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

InAppPayments.showCardNonceProcessingError() throws Exception on iOS and crashes the APP #225

Closed sidatgoodvet closed 1 year ago

sidatgoodvet commented 1 year ago

Describe the issue

The app crashes with an uncaught exception after calling InAppPayments.showCardNonceProcessingError() on iOS. The log shows a SIGABRT signal and "objc_exception_throw", indicating an Objective-C exception was thrown and not caught, causing the crash.

Here are the key parts of the crash report:

Incident Identifier: 5CF54276-3A19-45F3-924E-3C456127C6C7

Hardware Model: iPhone12,1

Process: Runner [11779]

Path: /private/var/containers/Bundle/Application/2583D982-56DF-4596-A734-C6F193C6B2E2/Runner.app/Runner

Version: 1.0.5 (38)

Exception Type: EXC_CRASH (SIGABRT)

Exception Codes: 0x0000000000000000, 0x0000000000000000

Triggered by Thread: 0

Last Exception Backtrace:

  1. CoreFoundation 0x19081ccb4 __exceptionPreprocess + 164 (NSException.m:202)
  2. libobjc.A.dylib 0x1898c43d0 objc_exception_throw + 60 (objc-exception.mm:356)
  3. CoreFoundation 0x190989c6c -[NSException raise] + 16 (NSException.m:113)
  4. SquareInAppPaymentsSDK 0x1010b96d0 0x1010a0000 + 104144
  5. square_in_app_payments 0x1012a461c -[FSQIPCardEntry completeCardEntry:] + 92 (FSQIPCardEntry.m:189)
  6. square_in_app_payments 0x1012a6cc4 -[SquareInAppPaymentsFlutterPlugin handleMethodCall:result:] + 924 (SquareInAppPaymentsFlutterPlugin.m:84)
  7. Flutter 0x10186e2c4 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 112 (FlutterChannels.mm:291)

The key parts are:

To Reproduce

Initialize the In-App Payments SDK Call InAppPayments.showCardNonceProcessingError() The app crashes Here is the code: InAppPayments.showCardNonceProcessingError(error); // Crashes on iOS

Expected behavior

The method should display an error message to the user without crashing the app.

Environment:

Platform: iOS OS: iOS 16.4 Development environment: macOS Ventura 13.4 (22F66) In-App Payments plugin version: 1.7.6

### Flutter Doctor flutterdoctor.txt

Screenshots

N/A

Additional context

The crash only happens on iOS, not Android. Im using the latest version of the In-App Payments SDK for flutter (square_in_app_payments: ^1.7.6)

sidatgoodvet commented 1 year ago

I now know the problem, for anyone else facing this issue. Please make sure you do not let call

InAppPayments.completeCardEntry(
          onCardEntryComplete: _onCardEntryComplete);

after calling InAppPayments.showCardNonceProcessingError(error) or else the app will crash at least on iOS