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

[Mobile] Parsing error when calling createPaymentMethod for US bank account #1802

Closed
SincerelyFaust opened this issue Jun 13, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@SincerelyFaust
Copy link

SincerelyFaust commented Jun 13, 2024

Describe the bug
I get a parsing error when calling the createPaymentMethod function and it says this:

type 'String' is not a subtype of type 'List<dynamic>?' in type cast

To Reproduce
Steps to reproduce the behavior:

  1. Create token for US bank account
  2. Call createPaymentMethod
  3. Get error

Expected behavior
When creating a payment method with EU bank account using PaymentMethodParams.sepaDebit it works flawlessly, however, when creating an US one with PaymentMethodParams.usBankAccount I get the error.

Smartphone / tablet

  • Device: [iPhone 12 Pro Max]
  • OS: [iOS 17.5.1]
  • Package version: [^10.1.1]
  • Flutter version [3.16.8]

Additional context
Here's my code:

  Future<stripe.TokenData?> createBankAccountToken({
    required String accountNumber,
    required String accountHolderName,
    String? routingNumber,
    required String country,
    required String currency,
    required String email,
  }) async {
    try {
      final tokenData = await stripe.Stripe.instance.createToken(
        stripe.CreateTokenParams.bankAccount(
          params: stripe.BankAccountTokenParams(
            accountNumber: accountNumber,
            accountHolderName: accountHolderName,
            routingNumber: routingNumber,
            country: country,
            currency: currency,
            accountHolderType: stripe.BankAccountHolderType.Individual,
          ),
        ),
      );

      if (country == "US") {
        await createPaymentMethod(
          method: stripe.PaymentMethodParams.usBankAccount(
            paymentMethodData: stripe.PaymentMethodDataUsBank(
                accountNumber: accountNumber,
                routingNumber: routingNumber,
                accountHolderType: stripe.BankAccountHolderType.Individual,
                billingDetails: stripe.BillingDetails(
                  name: accountHolderName,
                )),
          ),
        );
      } else {
        await createPaymentMethod(
          method: stripe.PaymentMethodParams.sepaDebit(
            paymentMethodData: stripe.PaymentMethodDataSepa(
                iban: accountNumber,
                billingDetails: stripe.BillingDetails(
                  name: accountHolderName,
                  email: email,
                )),
          ),
        );
      }

      return tokenData;
    } catch (e) {
      if (e is stripe.StripeException) {
        showErrorToastMessage(
          context: RoutingManager.instance.context!,
          title: "Stripe Error",
          textMessage: e.error.message,
        );
        throw e.error;
      } else {
        showErrorToastMessage(
          context: RoutingManager.instance.context!,
          title: "App Error",
          textMessage: e.toString(),
        );
        throw e.toString();
      }
    }
  }
  }
@SincerelyFaust SincerelyFaust added the needs triage Needs triage label Jun 13, 2024
@remonh87 remonh87 added bug Something isn't working and removed needs triage Needs triage labels Jun 17, 2024
@remonh87
Copy link
Member

Good catch the return type was incorrect this will be fixed in the next version

remonh87 pushed a commit that referenced this issue Jun 17, 2024
@remonh87 remonh87 self-assigned this Jun 17, 2024
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