Repository navigation
feat(app): switch a declined yearly renewal to monthly from the Home row - #25294
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
…thly price GET /v1/users/me/subscription adds payment_issue.monthly_switch (the plan's catalog monthly price and the unpaid yearly amount) when a past_due renewal is on a consumer plan's configured yearly USD price with no discount, trial, schedule or pause. Omitted otherwise, so released clients see the same body. POST /v1/payments/payment-issue/monthly-switch (routers/monthly_switch.py) pauses automatic collection of the unpaid yearly invoice, charges the monthly price now (billing_cycle_anchor=now, proration none, error_if_incomplete), then voids the yearly invoice. Any failure that did not switch resumes collection, so a declined card changes nothing and dunning continues as before. One switch per user at a time (Redis lock), a repeat replays without charging, the amount must match what the reader saw and Stripe's preview, invoice.paid retries a void that failed, and a superseded yearly invoice found paid is reported for a refund. PAYMENT_ISSUE_MONTHLY_SWITCH_ENABLED (default on) turns it off.
When payment_issue carries monthly_switch, the declined-card row says "Update it, or get <plan> back for <price> a month" and adds Switch to Monthly next to Update. The confirm sheet (same layout as the yearly switch) shows the plan, what is charged today and that the unpaid yearly charge is replaced; Confirm sends only that amount. A declined card says nothing changed and keeps the row; a lost answer re-reads the plan before saying anything. Without monthly_switch (older servers) the row is unchanged. The shared fact row stacks at large text and the sheet scrolls, so the amount never breaks and Confirm stays reachable. Copy in all 49 locales; Monthly Shown/Tapped/Switched/Failed events (unsampled).
kodjima33
force-pushed
the
mux/2026-11-14-yearly-renewal-save
branch
from
November 14, 2026 12:43
0b1ec84 to
34b1546
Compare
kodjima33
marked this pull request as ready for review
November 14, 2026 12:45
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
First-year yearly plans renew at only 42% (22 of 52 anniversaries since Oct 1): 25% end on a failed card, 23% cancel, 10% pending. 58% of trial-end and renewal card failures are insufficient funds. 329 first-year yearly renewals come due in the next 75 days (about 147 between Dec 7 and 27), and half of those payers had no app session in 30 days. Source:
~/mobile-ux-agent/runs/2026-11-13/analysis/sessions.mdsection 5 (Stripe, ACTUAL).#23953's declined-card row on Home already recovers some failed renewals, but it only offers updating the card for the same yearly charge. Someone who cannot pay $199.99 today has no smaller option and is lost after Stripe's retries.
New fact from the same Stripe snapshot: all 320 first-year yearly renewals due in the next 75 days are on the Neo yearly price (
price_1RtJQ71F8wnoWYvwKMPaGlGY, $199.99), not Omi Pro's $269.91. So the switch targets the subscription's own plan's catalog monthly price (Neo monthly $19.99, live and active; Omi Pro monthly $29.99), whichretired_plan_change_erroralready allows ("may switch interval within it").Change
What the reader sees (only when the renewal that failed is yearly):
Backend:
utils/monthly_switch.py: offer rules and the switch.GET /v1/users/me/subscriptionaddspayment_issue.monthly_switch(price_id,amount,currency,yearly_amount), omitted when not offered.POST /v1/payments/payment-issue/monthly-switch(routers/monthly_switch.py, mounted next toyearly_switch).routers/payment.py:invoice.paidretries a void the switch could not finish (+5 lines).PAYMENT_ISSUE_MONTHLY_SWITCH_ENABLED(default on,ops_kill, registered inconfig/feature-flags.yaml).App:
payment_issue_row.dart, newmonthly_switch_sheet.dart, model + API call, 8 strings in all 49 locales. At large text the stacked actions put Update (the primary) first, so it stays clear of Home's pinned Ask bar.PlanSwitchFactRow(shared with the yearly sheet) stacks label over value at large text so amounts never break mid-number.Money safety
Invoice.modify(auto_advance=False)), so no Stripe retry can collect it while the switch runs or while a failed void is being retried.Subscription.modify(items=[monthly], billing_cycle_anchor=now, proration_behavior=none, payment_behavior=error_if_incomplete). The unpaid yearly period earns no credit.card_error, Stripe changed nothing) resumes collection.record_fallback); Update still pays the invoice.paid(amount_paid > 0),void_supersededlogs an error and recordsmonthly_switch_superseded_invoice → paid_twice(outcome exhausted) so someone refunds it. No automatic refund.livemode=false, test clock;runs/2026-11-14/y1/stripe-sandbox/proof2.log). Three payers whose 19999 renewal was declined:card_error, collection resumed with the same next retry as before the pause, still past_due on yearly. Once the card works, dunning collects it: 19999, 19999 and no monthly charge.proof.log: a declined switch leaves no stray invoice, the preview equals the price, and the void with the same idempotency key replays.expected_amountmust equal the live price and Stripe's preview for the same items, anchor and proration. No new prices, coupons or discounts. Only the plan's configured monthly price is accepted.subscription_cycleinvoice, wrong owner uid, kill switch off.invoice.paidfor the new monthly invoice retries the void and returns 503 so Stripe redelivers. With the pause, nothing can collect the yearly invoice in the meantime.contracts/client-compat,check_app_client_openapi_compatibility.pypasses): the new field is additive and omitted when absent.Impact estimate
Basis:
runs/2026-11-14/metrics.json,subscriber_churn).At ship
payment_issue.monthly_switcharrives, andPAYMENT_ISSUE_MONTHLY_SWITCH_ENABLED=falseturns the offer and the endpoint off.contracts/analytics/events.json, consumersubscription-payment-recovery:Subscription Payment Issue Monthly Shown/Tapped/Switched(after the server confirms) /Failed(reason: declined, refused, error)._schedule_payment_recovery_notificationinrouters/payment.py, "Payment declined / Update your payment method…",navigate_to: /conversations= Home, where this row is).billing_recovery.payment_issue_from_stripe+monthly_switch.offer()return an offer at the past_due transition, append "Or keep for a month." to the body. It needs copy approval and server-side l10n.invoice.paidevents do one extra invoice read.subscriptionfield for the webhook gate.invoice.paidevents do one extra invoice read.subscriptionfield for the webhook gate.Evidence
Simulator (MUX pipeline, lane sim, iPhone 17 Pro iOS 26.2, local backend + Stripe stub). Same seed on main (BEFORE) and this branch (AFTER): Omi Pro yearly, first renewal declined, past_due with an open $269.91 invoice.
payment_issue{past_due, unlimited_v2}monthly_switch {2999 usd, yearly 26991}The full flow passed on the final backend tree (
runs/2026-11-14/y1/raw/after-light-final/checks.txt): collection paused then resumed for the declined attempt, paused for the switch, yearly invoice void, 1 charge. Artifacts in~/mobile-ux-agent/runs/2026-11-14/y1/:before-after.png,demo.mp4(28 s),demo.gif,result.txt,stripe-sandbox/proof.logbefore/andafter/(light, dark, largest text light and dark, de/ja/ar)stripe-sandbox/proof2.log: the pause proofTests
tests/unit/test_monthly_switch.py(50): offer rules, pause, charge, void order; a decline resumes collection; an unclear failure resumes only if not switched; a failed pause never charges; a failed resume and a paid-twice invoice are reported; refusals before any write; replay; failed void; kill switch.tests/routers/test_payment_monthly_switch.py(12): status codes, lock, store.tests/unit/test_monthly_switch_webhook.py(3): void retry oninvoice.paid, 503 on failure.tests/routers/test_users_payment_issue.py(+2): offer on the subscription response.test/pages/home/payment_issue_row_test.dart(24): offer row, old-server row, sheet content, Cancel, single charge on double tap, declined, refused, lost answer, largest text (row with Update first, and the sheet), events.Not verified
voice_recorder_test) flaked once in a full run and passes alone on main and on this branch.Line-Count-Exception: backend/routers/payment.py | 2100 -> 2105 | the invoice.paid webhook is the durable retry point for voiding the superseded yearly invoice; the endpoint itself lives in routers/monthly_switch.py
UI-Evidence: see the images above (.agent-artifacts/ui-evidence/mux-2026-11-14-yearly-renewal-save)