Repository navigation
feat(billing): recognise JPY Plus and Unlimited prices - #20804
Merged
Merged
Conversation
Add the four JPY recurring prices for Plus and Unlimited (monthly and annual) to the recognised Stripe price ledger so a JPY purchase resolves to its plan and interval and unlocks the subscriber. Bumps catalog_revision to 5 and regenerates the projection.
Covers each JPY price resolving to its plan and interval, and both the checkout.session.completed and customer.subscription.created webhook paths unlocking a subscriber on it.
This was referenced Oct 25, 2026
aryanorastar
added a commit
that referenced
this pull request
Oct 25, 2026
## What changed An existing JPY subscriber selecting Unlimited in the mobile sheet received a USD price that Stripe rejected. #20804 recognized JPY prices for entitlements but explicitly excluded in-app plan changes. The sheet now shows the approved JPY offer, preserves its formatted total through the generated DTO, and confirms the exact displayed price instead of looking it up in a separate USD catalog. The canonical catalog explicitly admits the four existing JPY Plus/Unlimited IDs for managing an existing JPY subscription. Resolution checks currency, active state, interval, mode and entitlement version. Stale USD, retired/unbound and nonrecurring targets are rejected before releasing schedules or changing entitlements. Retained prices cannot open new Checkout; the exact current JPY price can reactivate its own pending cancellation, after promotion-code validation. Existing cancellation indicators and desktop/legacy/ladder boundaries remain guarded. No amounts are imported and no production Stripe prices are created or changed. Old sheets must update before receiving non-USD offers because their annual summary hardcodes USD. The currency capability header and additive response fields are reflected in the generated Dart, Swift and TypeScript clients. Closes #23584. Related recognition-only work: #20804. Parallel submissions #23592 (@PINYOPATTANAWASANPORN) and #23597 (@khoap1220-hue) were reviewed for consolidation; their useful boundary behaviors are already covered here. No commits were imported from either submission. [Coordination and attribution record](#23584 (comment)). ## Product invariants affected none ## How it was verified - **524 backend tests passed in 12 isolated files**, using `BACKEND_UNIT_TEST_FILE_LIST` with `backend/test.sh`: currency management, JPY recognition, catalog/compiler and immutable entitlements, pricing resilience, proration/decline/cancellation/promotion guards, subscription ingestion, BYOK payment access and v1 storefront-flag independence. - **Six real Stripe sandbox flows passed**: catalog → paid immediate JPY upgrade; JPY annual schedule plus stale-USD rejection preserving it; declined payment preserves the paid plan; reactivation leaves exactly one subscription; a real one-time JPY price is excluded/rejected; an invalid promotion leaves cancellation unchanged. Only synthetic identity bindings and DB/cache seams are substituted, not Stripe requests. Opt-in command from `backend/`: `python -m pytest --confcutdir=tests/integration/billing tests/integration/billing/test_jpy_plan_changes_stripe.py -v` with an explicitly supplied standard test key. - **36 focused Flutter tests**, **23 mobile-verify checks**, targeted analysis and the three-run mobile performance gate passed. - **CI follow-up:** refreshed 52 backend/mobile storefront goldens and the mobile revision assertion for catalog revision 11. Reviewed every fixture diff: the revision is the only changed field. The formerly failing storefront file now passes **343 backend tests** with the normal timing guard; **70 mobile fixture-consumer tests** also pass. Existing simulator and Stripe evidence remains applicable because this follow-up changes only test metadata. - **Fresh iPhone 16 Pro / iOS 26.5 simulator**, Flutter 3.44.5, Japanese Flutter locale: selected Unlimited and Monthly, verified the exact JPY confirmation, then cancelled back to the sheet through agent-flutter. This tests the production PlansSheet and generated DTO with synthetic offers; payment mutations are exercised separately by the real sandbox route tests. Replay fixture and commands accompany the screenshots. - Repository preflight and the final bounded push gate passed, including full backend type checking, OpenAPI compatibility, all generated clients, desktop Swift compilation and formatting. Current-head CI is green at `a37882a71bc9e40e4e7c025bf6f8744a5211b25e` (41 passed, 23 skipped, no pending or failed checks). Aryan supplied a final review finding no merge-blocking code issues at this head and reported another 371 backend tests and 29 Flutter tests passing; those reruns were reported by the reviewer rather than repeated by this implementation session. ## UI evidence    ## Release and remaining verification Current-head CI and the supplied final code review have passed. Before production release, an Omi Stripe owner must verify the production JPY prices are active with the expected currency, recurrence, mode and entitlement bindings; personal-sandbox results do not establish the production catalog or this customer's account state. Merge and deploy the backend before releasing the currency-aware mobile app. No production subscriptions/customer data, deployment or app release were changed by this work. Keep the support case open until the customer verifies the displayed JPY price and successful plan change on the released build. Failure-Class: none Line-Count-Exception: backend/routers/payment.py | 1846 -> 1934 | Keep currency admission beside existing authenticated subscription and schedule mutations; reusable currency resolution is extracted to utils/billing_currency.py. A broader payment-router split is outside this safety fix and the exception needs maintainer review.
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.
Summary
The backend did not recognise four new JPY recurring prices for Plus and Unlimited (monthly and annual). A JPY purchase would charge the customer but resolve to no plan, so the webhook skipped the subscription write and the user stayed locked.
This adds the four prices to the recognised Stripe price ledger in
backend/config/plan_catalog.json, bumpscatalog_revisionto 5, and regeneratesplan_catalog_generated.py. Each JPY price now resolves to its plan and interval throughresolve_stripe_price_planandRECOGNIZED_STRIPE_PRICE_INTERVALS, the same as its USD counterpart.price_1ULq501F8wnoWYvwwN56CHzOunlimited_v2price_1ULq5e1F8wnoWYvwQT8XQ4Uwunlimited_v2price_1ULq6b1F8wnoWYvwtchjjNqqplusprice_1ULq7H1F8wnoWYvwC1poOtd5plusAll four are active live prices on the already-recognised Plus and Unlimited v2 products, so product recognition needs no change.
Zero-decimal / USD audit
JPY amounts are whole yen, not cents. I checked every place a price ID, amount, or currency matters:
checkout.session.completed,customer.subscription.created/updated): resolves the plan from the price ID only. It never reads an amount or currency, so it is correct once the price is recognised.subscription_events.py): emits plan and interval only, with no amount. Correct.No correctness fixes were needed beyond the catalog. Out of scope and left unchanged, none of which affects unlocking:
$…/100price text inrouters/payment.pyandrouters/users.pywould mis-render JPY. The JP storefront sells JPY outside the app, and the app does not display JPY prices.scripts/finops/pull_stripe.pydividesunit_amountby 100, which undercounts JPY revenue in that offline report.Tests
backend/tests/unit/test_jpy_price_recognition.pyruns the real webhook handler against the real catalog resolver:checkout.session.completedunlocks a subscriber on each JPY pricecustomer.subscription.createdunlocks a subscriber on each JPY priceAll 12 cases fail against the previous catalog and pass with this change. The related catalog, webhook, payment, and subscription suites pass locally (160 tests), and
generate_plan_catalog.py --check --base-ref origin/mainpasses, including the append-only ledger guard.Product invariants affected
none
🤖 Generated with Claude Code