flutter_stripe icon indicating copy to clipboard operation
flutter_stripe copied to clipboard

confirmSetupIntent throws error with google pay cardFromToken and valid client secret

Open klivin opened this issue 3 years ago • 5 comments

Hi, thanks for any help with this.

confirmSetupIntent fails only in android using google pay token. Google pay works all the way through with payment intents with same card, just not with setup intents.

To Reproduce

      // acquire valid payment result from google pay:
      var token = paymentResult['paymentMethodData']['tokenizationData']['token'];
        final tokenJson = Map.castFrom(json.decode(token));
        tokenId = tokenJson['id'];
      }
      final params = PaymentMethodParams.cardFromToken(
          token: tokenId,
          setupFutureUsage: PaymentIntentsFutureUsage.OnSession);

        // Free trial, capture intent for future billing
        final response = await createSetupIntent(customerId);
        final clientSecret = response['clientSecret'];
        // THIS FAILS WITH GOOGLE PAY TOKEN BUT WORKS WITH APPLE PAY TOKEN
        final setupIntentResult = await Stripe.instance.confirmSetupIntent(
          clientSecret,
          params,
      }

Expected behavior This should work just like with acquiring an Apple Pay token like we do via:

     token = await Stripe.instance.createApplePayToken(paymentResult);

The error thrown in Stripe.instance.confirmSetupIntent is "Card Details not complete"

The same card works fine in android with confirmPayment when there's an immediate charge, just not as a setup intent (for a free trial for a subscription for instance). I would use a payment intent, but it won't let me confirm a payment intent with zero charge.

There's no google pay setup intent in the example, and it will fail with same error if I were to change the setup future payment screen to use google pay.

klivin avatar Oct 08 '21 22:10 klivin

Thanks for submitting the issue, there is an error confirmed where the createdSetupIntent does not support tokenized cards right now

We will update it as soon as it is fixed on the official repo https://github.com/stripe/stripe-react-native/issues/643

jamesblasco avatar Oct 12 '21 12:10 jamesblasco

Hi is there any update on this @jamesblasco ?

guymclean avatar Jan 18 '22 10:01 guymclean

any update?

atearjen avatar Feb 20 '22 00:02 atearjen

This is now fixed by https://github.com/stripe/stripe-react-native/pull/931 in version 0.9.0 of the React Native Stripe implementation. All we need now is a new release of flutter_stripe synced to this new version to close out this issue.

@jamesblasco @remonh87 @jonasbark 🙏

daveols avatar May 11 '22 01:05 daveols

I've posted a PR just for this fix: https://github.com/flutter-stripe/flutter_stripe/pull/714

If you're impatient you can reference my fork, I'll leave it up for a few weeks:

dependency_overrides:
  stripe_android:
    git:
      url: https://github.com/daveols/flutter_stripe
      ref: android-confirm-setup-intent-hotfix
      path: packages/stripe_android

daveols avatar May 11 '22 05:05 daveols

This is available in the latest stripe sdk 5.0.0

remonh87 avatar Sep 12 '22 19:09 remonh87