Skip to content

tighten checkout confirmation - #9037

Merged
jigar-f merged 3 commits into
jigar/alipay-payment-checkfrom
atavism/alipay-payment-check
Sep 10, 2026
Merged

jigar-f merged 3 commits into
jigar/alipay-payment-checkfrom
atavism/alipay-payment-check

Conversation

@atavism

@atavism atavism commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Wait for account data before starting checkout so existing Pro access doesn’t falsely confirm a renewal.

Copilot AI lite review requested due to automatic review settings September 9, 2026 20:03
@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: e957f852-8b1e-4c9c-a809-8cf16f546f46

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@atavism
atavism requested a review from jigar-f September 9, 2026 20:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.future and capture expirationBefore (and Stripe subscriptionBefore) 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.reloadUserData and in checkUserAccountStatus, 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.

@jigar-f jigar-f left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jigar-f
jigar-f merged commit f4634d6 into jigar/alipay-payment-check Sep 10, 2026
2 checks passed
@jigar-f
jigar-f deleted the atavism/alipay-payment-check branch September 10, 2026 14:10
jigar-f added a commit that referenced this pull request Sep 10, 2026
* 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>
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

Successfully merging this pull request may close these issues.

3 participants