Skip to content

Play Billing follow-ups: plans sheet Retry stays, token store error ends the purchase, runbook cancel step - #26189

Merged
kodjima33 merged 3 commits into
mainfrom
fix/play-billing-nits
Nov 24, 2026
Merged

kodjima33 merged 3 commits into
mainfrom
fix/play-billing-nits

Conversation

@kodjima33

@kodjima33 kodjima33 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Five small items the reviewers of #26165 and #26181 left open. None changes a price, a purchase path or an entitlement rule.

  1. Plans sheet keeps Retry after a failed plan read (play_plans_content.dart, PlayPlansLoading). The loading state decided "failed" from the provider's shared error. A successful usage read clears that error, so the sheet went back to a skeleton with no Retry while the plan read was still known to have failed. It now uses billingProviderFailed, the same flag the paywalls and the paid app button use since Play Billing: purge waits only on chargeable purchases, deletion runbook, failed-read state (follow-up to #26163) #26165.
  2. A token store error ends the purchase as failed (play_billing.dart, _deliver). If reading or writing the pending-token store threw, the purchase was never finished: the paywall waited forever and PlayBilling.busy stayed true, which since Refresh the plan when the app resumes and when Plans & Billing opens #26181 also switches the resume read off for the session. _deliver now catches, logs and returns a failed result. The cleanup write after the server has answered has its own catch, so a plan the server granted is still reported as bought; the token is then sent once more on the next launch.
  3. Trial paywall's "was something bought before the reader left" check reads fresh (trial_paywall_page.dart). It could join a resume read that started before the purchase and offer the monthly trial to someone who had just paid. The 4 s timeout still bounds it.
  4. Runbook (backend/docs/runbooks/play-billing-deletion.md): the step for a purchase stuck more than a day told the operator to find the order in Play Console by the user's order. By then the account's email is deleted and the purchase document holds no order id. It now points at the stored purchase_token and the cancel call the wipe makes.
  5. Test that Home mounts PlanRefreshOnResume, so removing the wrapper fails a test.

Product invariants affected

none

How it was verified

  • New tests, each checked to fail without its fix:
    • play_billing_plans_sheet_test.dart: the plans sheet loading state shows the error state, a usage read clears the shared error, and the error state with Retry is still there (shimmer before the fix).
    • play_billing_test.dart: a purchase with a token store that throws returns failed and busy is false (hung before the fix). A store that fails only on the cleanup write still returns purchased.
    • plan_refresh_on_resume_test.dart: Home's source mounts PlanRefreshOnResume.
  • flutter test test/unit/play_billing_test.dart test/widgets/play_billing_plans_sheet_test.dart test/widgets/plan_refresh_on_resume_test.dart: 70 passed. flutter analyze on the changed files: no new issues.

UI evidence

UI-Evidence: none -- no layout or copy change; the existing "Unable to load plans" state with Retry now stays on screen in a case where it used to fall back to the existing skeleton

Failure class

No fix: commits; no declaration required.

…read, a token store error ends the purchase, runbook cancel step

- Plans sheet loading state uses the dedicated failed-plan-read flag, so Retry stays after a usage read clears the shared error.
- A token store error during delivery ends the purchase as failed instead of leaving it open for the session.
- The trial paywall's bought-before-leaving check asks for a read issued after the question.
- Runbook: cancel a stuck purchase from its stored purchase token (the email and order id are gone by then).
- Test that Home mounts the resume observer.
@kodjima33
kodjima33 merged commit c84f309 into main Nov 24, 2026
66 checks passed
@kodjima33
kodjima33 deleted the fix/play-billing-nits branch November 24, 2026 03:29
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.

1 participant