Update deferred Stripe renewal and retry handling - #8952
Conversation
atavism
commented
Aug 5, 2026
- Handle both PaymentIntent and SetupIntent subscription flows
- Prevent PaymentSheet retries from creating duplicate subscriptions
- Adds Stripe tests covering both intent modes, retries, initialization, and error filtering
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates the app’s deferred Stripe PaymentSheet flow to support both PaymentIntent and SetupIntent subscription confirmations (notably for renewal/trial scenarios), while preventing retries from creating duplicate backend subscriptions. It also adds widget tests to validate intent-mode selection, retry behavior, and user-facing Stripe error filtering.
Changes:
- Add
StripeIntentMode+stripeIntentModeForRenewal(...)and use intent-mode–specific confirmation secrets in the deferred confirm handler. - Cache the in-flight subscription creation request during PaymentSheet retries to avoid duplicate subscriptions.
- Add Stripe service widget tests for publishable-key initialization ordering, retry semantics, setup-mode confirmation, and error-message filtering.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/core/services/stripe_service.dart |
Adds intent-mode selection and retry-safe subscription creation for deferred PaymentSheet confirmation; updates Stripe error filtering. |
lib/features/auth/choose_payment_method.dart |
Selects the correct Stripe intent mode for renewals (PaymentIntent vs SetupIntent) and passes it into StripeService. |
lib/lantern_app.dart |
Makes the builder safer when child is null by providing a fallback widget. |
test/core/services/stripe_service_test.dart |
Introduces widget tests validating deferred Stripe flow behavior across intent modes, retries, and error filtering. |
Suppressed comments (1)
lib/core/services/stripe_service.dart:196
- The empty-secret path throws a hard-coded English string that will be shown to users in the PaymentSheet retry UI. This bypasses the app’s i18n approach (used elsewhere in this file via
.i18n) and makes the message non-localizable.
if (secret.isEmpty) {
throw Exception(
'Please try again after some time. If the issue persists, contact support.',
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jigar-f
left a comment
There was a problem hiding this comment.
LGTM, Thanks for adding test
* Update the Stripe subscription flow for Android. * hide user-sensitive errors * code review updates * update UI * code review updates * code review updates * Update deferred Stripe renewal and retry handling (#8952) * Harden deferred Stripe subscription flow * code review updates * code review updates --------- Co-authored-by: atavism <atavism@users.noreply.github.com>