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

How to use Confirm setup intent on Flutter Web #2074

Open
Prayer-RecycleSmart opened this issue Feb 13, 2025 · 0 comments
Open

How to use Confirm setup intent on Flutter Web #2074

Prayer-RecycleSmart opened this issue Feb 13, 2025 · 0 comments

Comments

@Prayer-RecycleSmart
Copy link

In the info page we have new methods for Flutter Web, one of each is Confirm setup intent

I have tried to get it working with PaymentElement as well as CardField

CardField throws: UnimplementedError

        PaymentMethodParams.card(
          paymentMethodData: PaymentMethodData(
            billingDetails: BillingDetails(),
          ),
        ),
        PaymentMethodOptions(
          setupFutureUsage: PaymentIntentsFutureUsage.OffSession,
        ),
      );

      debugPrint(paymentMethod.id);

      // Then confirm the setup intent
      final setupIntent = await WebStripe.instance.confirmSetupIntent(
        paymentIntentClientSecret ?? '',
        PaymentMethodParams.cardFromMethodId(
          paymentMethodData: PaymentMethodDataCardFromMethod(
            paymentMethodId: paymentMethod.id,
          ),
        ),
        PaymentMethodOptions(
          setupFutureUsage: PaymentIntentsFutureUsage.OffSession,
        ),
      );

I manage to get the payment method but then when Its trying to run setupIntent it stopes here:

  Future<SetupIntent> confirmSetupIntent(
    String setupIntentClientSecret,
    PaymentMethodParams data,
    PaymentMethodOptions? options,
  ) async {
    final response = await data
        .maybeWhen<Future<stripe_js.SetupIntentResponse>>(card: (params) {
      final data = stripe_js.ConfirmCardSetupData(
        paymentMethod: stripe_js.CardPaymentMethodDetails(
          card: element!,
          billingDetails: params.billingDetails?.toJs(),
        ),
      );
      return js.confirmCardSetup(
        setupIntentClientSecret,
        data: data,
      );
    }, orElse: () {
      throw UnimplementedError();
    });
    if (response.error != null) {
      throw response.error!;
    }

    return response.setupIntent!.parse();
  }

With PaymentElement I get: Invalid value for confirmCardSetup: payment_method.card was payment Element, which cannot be used to create card PaymentMethods.

There's no way to specify that the mode is setup .

What I am I missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant