Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When user closes customer sheet without choosing new card error occurs #1579

Closed
JSBmanD opened this issue Dec 29, 2023 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@JSBmanD
Copy link

JSBmanD commented Dec 29, 2023

Describe the bug
The error being thrown if the user closes customer sheet without choosing another card, not already selected.

To Reproduce
Steps to reproduce the behavior:

  1. Open customer sheet
  2. Add card
  3. Confirm and close
  4. Open sheet again
  5. Just close

Expected behavior
CustomerSheetResult or null is returned

Actual behavior

Stacktrace
type 'Null' is not a subtype of type 'String' in type cast
    type 'Null' is not a subtype of type 'String' in type cast
    #0      _$$StripeErrorGenericImplFromJson (package:stripe_platform_interface/src/models/errors.g.dart:12:32)
    #1      new _$StripeErrorGenericImpl.fromJson (package:stripe_platform_interface/src/models/errors.freezed.dart:123:7)
    #2      _$StripeErrorFromJson (package:stripe_platform_interface/src/models/errors.freezed.dart:18:10)
    #3      new StripeError.fromJson (package:stripe_platform_interface/src/models/errors.dart:26:7)
    #4      _$$CustomerSheetResultImplFromJson (package:stripe_platform_interface/src/models/customer_sheet.g.dart:115:13)
    #5      new _$CustomerSheetResultImpl.fromJson (package:stripe_platform_interface/src/models/customer_sheet.freezed.dart:973:7)
    #6      _$CustomerSheetResultFromJson (package:stripe_platform_interface/src/models/customer_sheet.freezed.dart:804:31)
    #7      new CustomerSheetResult.fromJson (package:stripe_platform_interface/src/models/customer_sheet.dart:96:7)
    #8      MethodChannelStripe._parseCustomerSheetResult (package:stripe_platform_interface/src/method_channel_stripe.dart:357:36)
    #9      MethodChannelStripe.presentCustomerSheet (package:stripe_platform_interface/src/method_channel_stripe.dart:277:12)
    <asynchronous suspension>
    #10     _SetupFuturePaymentScreenState._handleSavePress (package:client_app/src/feature/order/widget/test_stripe.dart:140:22)
    <asynchronous suspension>
    #11     _LoadingButtonState._loadFuture (package:client_app/src/feature/order/widget/widgets/loading_button.dart:50:7)
    <asynchronous suspension>

Sample

``` Future _handleSavePress() async { if (_card == null) { return; } try { // 1. Create setup intent on backend final stripeConfig = await _createSetupIntentOnBackend(_email);
  // 2. Gather customer billing information (ex. email)
  const billingDetails = BillingDetails(
    name: 'Test User',
    email: '[email protected]',
    phone: '+48888000888',
    address: Address(
      city: 'Houston',
      country: 'US',
      line1: '1459  Circle Drive',
      line2: '',
      state: 'Texas',
      postalCode: '77063',
    ),
  ); // mo/ mocked data for tests

  // 3. Confirm setup intent

  await Stripe.instance.initCustomerSheet(
    customerSheetInitParams: CustomerSheetInitParams(
      setupIntentClientSecret: stripeConfig.clientSecret,
      customerId: stripeConfig.customerId,
      customerEphemeralKeySecret: stripeConfig.ephemeralKeySecret,
    ),
  );

  final result = await Stripe.instance.presentCustomerSheet();

  print(result);
} catch (error) {
  ScaffoldMessenger.of(context)
      .showSnackBar(SnackBar(content: Text('Error code: $error')));
  rethrow;
}

}

</details>


**Smartphone / tablet**
 - Device: Iphone 15 simulator
 - OS: ios 17.2
 - Package version: 10.0.0
 - Flutter version 3.16.0

@JSBmanD JSBmanD added the needs triage Needs triage label Dec 29, 2023
remonh87 pushed a commit that referenced this issue Jan 1, 2024
@remonh87 remonh87 added bug Something isn't working and removed needs triage Needs triage labels Jan 1, 2024
@remonh87
Copy link
Member

remonh87 commented Jan 1, 2024

created a pull request for fixing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants