Skip to content

feat(billing): recognise JPY Plus and Unlimited prices - #20804

Merged
mdmohsin7 merged 2 commits into
mainfrom
rex/jpy-price-recognition
Oct 6, 2026
Merged

mdmohsin7 merged 2 commits into
mainfrom
rex/jpy-price-recognition

Conversation

@mdmohsin7

@mdmohsin7 mdmohsin7 commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

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, bumps catalog_revision to 5, and regenerates plan_catalog_generated.py. Each JPY price now resolves to its plan and interval through resolve_stripe_price_plan and RECOGNIZED_STRIPE_PRICE_INTERVALS, the same as its USD counterpart.

Price Plan Interval
price_1ULq501F8wnoWYvwwN56CHzO unlimited_v2 month
price_1ULq5e1F8wnoWYvwQT8XQ4Uw unlimited_v2 year
price_1ULq6b1F8wnoWYvwtchjjNqq plus month
price_1ULq7H1F8wnoWYvwC1poOtd5 plus year

All 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:

  • Unlock path (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.
  • Plan/interval matching, reactivation, cancel: also keyed on price ID and the generated interval table. Correct once recognised.
  • Billing telemetry (subscription_events.py): emits plan and interval only, with no amount. Correct.
  • PostHog / product telemetry: no price amounts emitted.
  • Admin subscriptions dashboard: already excludes non-USD prices from MRR totals.

No correctness fixes were needed beyond the catalog. Out of scope and left unchanged, none of which affects unlocking:

  • $…/100 price text in routers/payment.py and routers/users.py would mis-render JPY. The JP storefront sells JPY outside the app, and the app does not display JPY prices.
  • scripts/finops/pull_stripe.py divides unit_amount by 100, which undercounts JPY revenue in that offline report.
  • In-app plan changes for a JPY subscriber would target a USD price, which Stripe rejects because a subscription's currency cannot change. JPY subscribers manage plan changes on the JP site.

Tests

backend/tests/unit/test_jpy_price_recognition.py runs the real webhook handler against the real catalog resolver:

  • each JPY price resolves to the right plan and interval
  • checkout.session.completed unlocks a subscriber on each JPY price
  • customer.subscription.created unlocks a subscriber on each JPY price

All 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/main passes, including the append-only ledger guard.

Product invariants affected

none

🤖 Generated with Claude Code

Review in cubic

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.
@mdmohsin7
mdmohsin7 merged commit ed4430a into main Oct 6, 2026
59 checks passed
@mdmohsin7
mdmohsin7 deleted the rex/jpy-price-recognition branch October 6, 2026 18:35
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

![Japanese annual JPY
offers](https://raw.githubusercontent.com/BasedHardware/omi/36e6d50bc6b9bf48680f1a9d78ce26db13f07840/.agent-artifacts/ui-evidence/fix-jpy-plan-change-currency/001-mobile-ios-jpy-annual-offers.png)

![Monthly Unlimited
selection](https://raw.githubusercontent.com/BasedHardware/omi/36e6d50bc6b9bf48680f1a9d78ce26db13f07840/.agent-artifacts/ui-evidence/fix-jpy-plan-change-currency/002-mobile-ios-jpy-monthly-selection.png)

![Exact JPY confirmation before
payment](https://raw.githubusercontent.com/BasedHardware/omi/36e6d50bc6b9bf48680f1a9d78ce26db13f07840/.agent-artifacts/ui-evidence/fix-jpy-plan-change-currency/003-mobile-ios-jpy-plan-confirmation.png)

## 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.
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