tighten checkout confirmation - #9037
Conversation
|
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: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
🟢 Approval recommended
The updated purchase-confirmation logic is consistently applied across checkout flows and is backed by focused tests covering baseline-waiting, disposal safety, and polling stop conditions.
Pull request overview
This PR tightens post-checkout confirmation by ensuring checkout flows capture a reliable “pre-purchase” account baseline and by making polling for refreshed account status stop safely when the UI closes. This prevents a false-positive renewal confirmation when the user already has Pro access but the renewal hasn’t actually been credited yet.
Changes:
- Require checkout flows to await
homeProvider.futureand captureexpirationBefore(and StripesubscriptionBefore) prior to opening checkout/confirming purchase. - Enhance purchase confirmation logic to treat Stripe “new subscription created” as a valid completion signal even if expiration hasn’t advanced yet, while still requiring renewals to extend expiration.
- Add mounted/disposal guards in
HomeNotifier.reloadUserDataand incheckUserAccountStatus, plus new targeted widget/unit tests for these behaviors.
File summaries
| File | Description |
|---|---|
| test/features/home/provider/home_notifier_test.dart | Adds coverage for reloadUserData() waiting for initial build and safely ignoring results after disposal. |
| test/features/auth/checkout_account_readiness_test.dart | New widget test ensuring checkout waits for account baseline and stops cleanly if the screen closes or account load fails. |
| test/core/common/user_data_reflects_purchase_test.dart | Expands tests for renewal vs. Stripe subscription signals when expiration doesn’t change. |
| test/core/common/check_user_account_status_test.dart | New widget tests ensuring polling stops/ignores results when the screen closes and retries transient failures. |
| lib/features/home/provider/home_notifier.dart | Adds ref.mounted guards to prevent async continuations from writing state after disposal; trims overly verbose user-data logging. |
| lib/features/auth/choose_payment_method.dart | Captures account baseline before checkout; wires expirationBefore/subscriptionBefore into purchase confirmation to avoid false renewal confirmation. |
| lib/core/common/common.dart | Refines userDataReflectsPurchase and extends checkUserAccountStatus with subscriptionBefore and context.mounted early-exit guards. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
* Check Alipay payment status on webview close * Refresh user data on startup and purchase Retry the startup user-data fetch with backoff and notify Flutter when it succeeds so the cached account state is reloaded. Also use a longer post-checkout poll schedule to wait for delayed entitlement crediting. * code review updates * tighten checkout confirmation (#9037) * code review updates * code review updates --------- Co-authored-by: atavism <paul@getlantern.org> Co-authored-by: atavism <atavism@users.noreply.github.com>
Wait for account data before starting checkout so existing Pro access doesn’t falsely confirm a renewal.