Skip to content

Offer new buyers the plan price in their local currency (revives #26074), default off - #26841

Merged
Git-on-my-level merged 6 commits into
mainfrom
fix/play-local-currency-storefront-v2
Dec 1, 2026
Merged

Git-on-my-level merged 6 commits into
mainfrom
fix/play-local-currency-storefront-v2

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Revives #26074 (kodjima33, closed 2026-11-23 in favour of Play Billing) on current main, as written, at David's request (2026-12-01): try currency localization through Stripe before turning on Play Billing (#26826, left as a draft). Original author credited on the commit.

On top of #26074 @ aec826ee9c0: resolved conflicts with main (Play Billing's is_play_customer checkout check and http_request parameter in payment.py, the prepaid_code_redeem import in retention_offer.py, playMinorUnits in billing_price.dart, the trialDays local in trial_paywall_page.dart); stubbed is_play_customer in the new checkout test helper; registered STOREFRONT_LOCAL_CURRENCY and STOREFRONT_LOCAL_CURRENCY_TABLE in config/feature-flags.yaml with the ramp plan below. No behaviour change against the original PR.

Review round 1 (omi-panel review-20261201t012244-67c6): F1 accepted. Android now sends only the Play billing country: no locale fallback, and a failed read is retried (luna's fix check). F4 accepted: a malformed table falls back to USD. F2 accepted: test that the region header is sent. F5 deferred to ramp step 5. F3 and F6 deferred (minor).

Merging changes nothing for buyers. The switch is on, but both live Omi Pro Prices are USD-only (read 2026-12-01T00:4xZ with the read-only key: price_1TuIa8… 2999 usd/month and price_1TuIap… 26991 usd/year, currency_options = usd only), so every path falls back to today's USD.

On by default (David, 2026-12-01)

Prod serves STOREFRONT_LOCAL_CURRENCY=android and the full price table (backend/deploy/runtime_env/prod.overlay.yaml). Kill switch: set STOREFRONT_LOCAL_CURRENCY=off. David chose on by default so a later release, config cleanup or rollback cannot drop local prices silently and reopen the Play Subscriptions finding.

What a buyer sees after this merges, step by step:

Step Who Effect
1. Merge; backend serves the switch and the table David (billing class) None. Both Omi Pro Stripe Prices are USD-only, so every buyer falls back to USD (logged as local currency <cur> unavailable)
2. Stripe write: scripts/local_currency_options.py --table <prod table> --apply --confirm David approves the dry-run output first New Android buyers on a build with the region header, whose Play billing country is in the table, see and pay the local price
3. New Android build replaces the held 1605 at 1% in Play production (agent through the Play API); David clicks Send for review agent, David Play reviewer sees local prices
4. all (iOS, desktop, web) billing owner Only after web and desktop send X-Omi-Storefront-Region (panel F5)

Clean metric: local currency <cur> unavailable lines fall to zero after step 2. Checkout sessions charge the displayed amount, and there are no currency refunds or tickets. Rollback: off. New buyers go back to USD, and subscribers already billed in a local currency keep it (Stripe fixes a customer's currency).

Price table: 63 countries, 43 currencies

This is #26074's 53-country, 33-currency first rollout (below), plus the ten it dropped. They're priced from open.er-api.com USD rates of 2026-12-01 00:02Z, using the existing table's rounding: x.99 under 1,000, nearest 50 up to 9,999, nearest 5×10ⁿ above. All pass _valid_amount, and a test loads the rendered prod value whole. #26074 did not record why these ten were removed (volatility, card acceptance or something else). David approves the full table with this PR.

Currency Country Monthly Annual Stripe minor units (monthly / annual) USD rate
INR IN ₹2,750.00 ₹25,000.00 275000 / 2500000 92.3848
PKR PK PKR 8,300.00 PKR 74,500.00 830000 / 7450000 276.7613
EGP EG EGP 1,650.00 EGP 14,500.00 165000 / 1450000 54.4072
NGN NG NGN 41,000.00 NGN 370,000.00 4100000 / 37000000 1370.8915
ARS AR ARS 48,000.00 ARS 435,000.00 4800000 / 43500000 1608.4695
TRY TR TRY 1,500.00 TRY 13,500.00 150000 / 1350000 50.8373
UAH UA UAH 1,350.00 UAH 12,000.00 135000 / 1200000 45.0979
BDT BD BDT 3,750.00 BDT 34,000.00 375000 / 3400000 125.5905
KES KE KES 3,900.00 KES 35,000.00 390000 / 3500000 130.1779
ISK IS ISK 3,800 ISK 34,000 380000 / 3400000 125.9020

ARS and TRY lose value fast against USD. Their amounts need a periodic review, and a change is a new currency_options amount plus a table edit.


What changed and why

Google Play rejected Android (com.friend.ios) again on Nov 21 for version code 1605: "Currency differences with prominent display price ... appropriately localized for each country". Its evidence is the trial paywall priced in US$ for a reviewer outside the US. The three earlier fixes (#23852 adaptive pricing off, #25494 pinned CHECKOUT_LOCALE) made the Stripe cart match the app's USD price; the offer page itself still showed US$ to a non-US buyer, which Google's Subscriptions policy lists as a violation ("language and currency are not localized to the user's country").

This adds a local-currency offer for buyers with no paid subscription. It is off by default and changes nothing until both a switch and a price table are set.

  • A buyer whose country has an approved local price sees that currency and amount on every price surface (trial paywall, Plans sheet, /v1/users/me/subscription price strings, the Stripe cart and its trial line), and Checkout charges the same Stripe currency_options entry on the same Price ID.
  • A US buyer, a buyer in a country outside the table, and every released build (they send no region) get today's responses byte for byte: US$, as Google Play itself prices where it has no local currency. Nothing hides the purchase UI.
  • A table currency the live Price does not carry in currency_options, or whose amount differs from the table, is logged (local currency <cur> unavailable on <price> ...) and that buyer gets USD, so a config mistake cannot open a Checkout in a currency the Price lacks.
  • A subscriber's billed currency is decided from Stripe alone (the subscription's currency and the Price's currency_options[that currency], utils/local_currency.py billed_option_amount), never from the switch or the table, so a rollback or table edit cannot tell a GBP subscriber "US$269.91 a year" while Stripe bills £. That subscriber keeps the currency in available plans, interval change (schedule phases pinned to it), the Plans current card, the trial-ending push, promo redemption, the retention offer and billing analytics. If the Price cannot be read the surface shows no amount (no push, no current price, a 503 on plan management), never a guessed one. The yearly and monthly switch offers refuse non-USD subscriptions, as before.
  • An existing Stripe customer's currency is fixed, so it wins over the region on every new-buyer surface and at Checkout (buyer_currency, new_buyer_offer): a lapsed USD customer in a table country stays in US$; a lapsed GBP customer who moved to the US sees and pays £ when the Prices carry GBP, independent of the switch; a customer currency the Prices lack keeps today's US$ path. First-time buyers with the switch off read nothing new; the customer read happens only once an offered Price carries a non-USD option.
  • Promo codes on a subscription billed through a currency option (utils/promotion_redemption.py _check_local_currency_eligible): a minimum stated in the subscription currency (directly or in restrictions.currency_options) is compared with the option amount; a minimum stated only in the Price's own currency (the USD-only bundle and prepaid codes) is compared with the same Price's USD amount, because it is the same plan, so those buyers can redeem and are not charged at trial end because the code was refused; a minimum in any other currency is refused; a fixed amount_off coupon needs an amount in the subscription currency (Stripe cannot apply a USD amount there); percent-off codes, including 100%, always apply.

Turning it on (operator steps, not part of this PR)

  1. Nik approves amounts (proposal below).
  2. backend/scripts/local_currency_options.py --table table.json prints the exact stripe.Price.modify(... currency_options=...) calls for the two Omi Pro prices. It is a dry run; only --apply writes, and that was not run.
  3. Set on the backend service:
    • STOREFRONT_LOCAL_CURRENCY=android (first rollout; all adds iOS/desktop/web, off or unset is today).
    • STOREFRONT_LOCAL_CURRENCY_TABLE = one JSON object: {"countries": {"<ISO 3166-1 alpha-2, upper>": "<ISO 4217, lower>", ...}, "currencies": {"<iso 4217>": {"monthly": <int>, "annual": <int>}, ...}}, e.g. {"countries": {"JP": "jpy", "GB": "gbp", "DE": "eur", "FR": "eur"}, "currencies": {"jpy": {"monthly": 4800, "annual": 43200}, "gbp": {"monthly": 2299, "annual": 20699}, "eur": {"monthly": 2699, "annual": 24299}}}. Amounts are Stripe minor units: zero-decimal currencies in whole units (JPY 4800 = ¥4,800, KRW, VND, CLP and the rest of Stripe's list), three-decimal in thousandths, HUF/TWD/ISK/UGX in hundredths and whole hundreds. Many countries may share a currency; a country mapped to usd is the US price. Entries Stripe or the cart cannot represent (not a Stripe currency, not whole hundreds for HUF/TWD/ISK/UGX, a fraction ISK/UGX cannot display) are dropped with a warning at read time.
  4. Ship the Android build from this branch. The server shows a local price only when Stripe's currency_options amount equals the table amount for both intervals; otherwise USD (logged), never mixed.

Investigation

Every price string that reaches a client

Surface Where Before Now (switch on, local buyer)
Trial paywall, paywall variants, Plans sheet (old catalog) GET /v1/payments/available-plans, backend/routers/payment.py:497 USD unit_amount, price_string, billing_total from format_money same Price IDs in the local currency (_localized_pricing_options, payment.py:684)
Plans sheet v2 (new buyer Omi Pro sheet, Free card) GET /v2/payments/plans, routers/storefront.py:119, utils/storefront.py build_single_plan_storefront US$ headline/subline; Free card headline_free = "US$0" (config/storefront_copy_v1.json) local headline/subline and Free card in the local currency
Plans current card for a subscriber utils/storefront.py build_storefront, current_line (utils/storefront_copy.py) price row's base currency subscription currency option
/v1/users/me/subscription available_plans[].prices[].price_string routers/users.py:1296 US$ (not rendered by the Flutter app) local
Stripe cart, trial terms line, "All amounts are in" utils/stripe.py:213, utils/trial_reminder.py checkout_trial_terms price currency; CHECKOUT_LOCALE='en-GB' currency = local, locale en (renders the same glyph as the app), local trial line
Trial-ending push utils/trial_reminder.py trial_ending_reminder_body item price unit_amount (base USD on a multi-currency Price) subscription currency option
Retention (cancel) offer utils/retention_offer.py evaluate item price subscription currency option
Yearly switch / monthly switch utils/yearly_switch.py:30, utils/monthly_switch.py:40 SWITCH_CURRENCIES={'usd'} unchanged: a non-USD subscription is refused (reason='currency')
Hardcoded "US$" in the app app/lib/utils/billing_price.dart (only formatter; every surface calls it with the server's currency), app_en.arb descriptions only (examples, not values) US$, ¥, else CODE 1.00 generated table, the exact Checkout render for all 138 Stripe currencies; USD and JPY strings unchanged

app/lib/models/subscription.dart, yearly_switch.dart, trial_paywall_page.dart, storefront_plans_content.dart, paywall_checkout.dart, monthly_switch_sheet.dart, payment_issue_row.dart and cancel_subscription_sheet.dart already format through formatBillingPrice(amount, currency) with a usd fallback only when the server sends no currency, so no other app surface hardcodes US$. Server-side copy (format_money) is unchanged for every existing response; the local path uses local_currency.display_money, the same string the app renders.

Existing subscribers' strings with the switch off (review item 7). formatBillingPrice now renders every currency as Checkout does, which changes the string for currencies other than USD and JPY (for example CAD 29.99 becomes CA$29.99). That is intended, because it is the cart's own text, and it cannot reach anyone today: the plan catalog and the management bindings contain only USD and JPY Prices (test_released_currencies_reach_the_app_unchanged_with_the_switch_off), and USD and JPY render byte for byte as before (US$29.99, ¥4,800; app test "USD and JPY render exactly as before"). Keeping two formatters for a switch the app cannot see would be the larger change.

Display string = the Checkout render. Stripe Checkout formats amounts with the browser's Intl.NumberFormat in the session locale, which the server pins: en-GB for USD (US$, #25494), en for every other currency (local_currency.checkout_locale). backend/scripts/generate_checkout_currency_format.py renders all 138 Stripe presentment currencies through Node's ICU (77.1, CLDR 47) at that locale and writes the symbol prefix, display decimals, Stripe exponent and a sample to backend/config/checkout_currency_format.json and app/lib/utils/checkout_currency_format.dart. The server display_money and the app formatBillingPrice are both tested against every sample character for character, NBSP included (AED\u00a0109.99, ¥4,800, ₩39,000, CLP\u00a027,990, HUF\u00a010,990.00, NT$990.00, ISK\u00a03,999, UGX\u00a0110,000, KWD\u00a01.234). --check fails when either output is stale. The generator refuses to run on anything but Node v22.22.0 with ICU 77.1 (ICU 78 renders HUF, COP, IDR, PKR and RSD differently) and is registered in .github/checks-manifest.yaml (checkout-currency-format, local and ci lanes); the CI hygiene job installs exactly Node 22.22.0.

Country signal. Read, not guessed: the backend never reads a client IP or geo header (routers/public_shared_conversation_chat.py:165, pusher/main.py:130), backend/charts and backend/deploy declare no load-balancer request headers, and the live prod backend services behind api.omi.me (custom-domains-api-omi-me-backend-*, prod-omi-backend-api) have no customRequestHeaders (gcloud compute backend-services list, read-only). So there is no trustworthy server-side country today. The primary signal is the device region the new app sends as X-Omi-Storefront-Region (system locale country, app/lib/utils/storefront_region.dart, added in app/lib/backend/http/shared.dart). It needs no permission or native code and every build after this one sends it. An old app sends nothing and gets today's behaviour. It is user-settable, so it can only choose among prices Nik approved; the follow-up that would make it match where the reviewer physically is would be a GCP LB X-Client-Region: {client_region} header, a prod infra change outside this PR.

Stripe price shape. The live Omi Pro prices (STRIPE_UNLIMITED_V2_MONTHLY_PRICE_ID 2999 USD/month, ..._ANNUAL_PRICE_ID 26991 USD/year) carry currency_options={'usd'} only (pipeline snapshot fetched with expand[]=currency_options). currency_options is returned only when expanded, so every local read uses expand=['currency_options'] (local_currency.retrieve_with_options). Checkout already pins currency to the session and disables adaptive pricing (utils/stripe.py); with a multi-currency Price, currency=<local> selects that option, so the cart charges exactly the option amount.

What else assumes USD

  • A subscription on a multi-currency Price carries the base Price (USD) on items[0].price; the subscription's own currency is the billed one. Every reader of items[0].price.unit_amount therefore needs the option amount: trial reminder, retention offer, promo redemption, analytics MRR, Plans current card. All handled behind local_currency.billed_in_option, which is false unless the subscription currency is in the approved table, so older Adaptive Pricing conversions keep today's handling.
  • Promo codes (Unlimited membership promo codes carry a USD $269 minimum, rejected for customers paying in other currencies #23299): utils/promotion_redemption.py compared minimum_amount against the base USD amount. For an option-billed subscription it now requires the minimum in that currency (minimum_amount_currency or restrictions.currency_options) against the option amount, and refuses a fixed amount_off coupon without an amount in that currency. At Checkout, Stripe evaluates the code in the session currency.
  • Upgrade/interval change: routers/payment.py refused any target whose currency differs from the subscription. It now accepts the same multi-currency Price when it has the subscription's option and pins both schedule phases to that currency. price_for_currency(..., allow_options=...) only offers options when the current item itself is option-billed, so legacy JPY subscribers (JPY-native prices) are unaffected.
  • Analytics: utils/observability/subscription_events.py emits mrr_cents only for USD; an option-billed subscription now reports its own currency and no USD MRR. backend/scripts/finops/pull_stripe.py still books by price.currency and would count an option subscription at its base USD list price; not changed here (offline finops, follow-up).
  • Receipts/emails: Stripe sends them in the subscription currency. routers/users.py legacy price_string is not rendered by the Flutter app.

Not handled (revenue reporting books local subscribers as USD)

These read the subscription item's Price (currency, unit_amount), which is the base USD Price for a subscription billed through a currency option, so a £/¥ subscriber is counted as US$29.99 / US$269.91 and never in a non-USD bucket. Left for a follow-up; they should read subscription.currency and, when it differs, the Price's currency_options[subscription.currency]:

  • backend/scripts/finops/pull_stripe.py:123-126 (monthly_amount) and :313-333 (currency = p.get("currency"), mrr_usd), feeding contracts/product-telemetry/bigquery/plan-revenue-mrr.sql.
  • web/admin/lib/stripe-subscriptions.ts:105-132 (monthlyAmount, isNonUsd on the item price) and :318-349 (wall metrics, FX by item currency).
  • web/admin/app/api/omi/subscriptions/route.ts:93-96 (item price amount and currency).

Handled here: backend/utils/observability/subscription_events.py emits no USD mrr_cents and the subscription's own currency whenever the subscription currency differs from its item Price.

Money-safety review (changed lines near price selection, checkout and entitlement)

  • backend/utils/local_currency.py (new): offer_for, approved_amount (Stripe option must equal the table), billed_in_option, option_amount_for, checkout_locale, display_money.
  • backend/utils/stripe.py create_subscription_checkout_session: new local_currency_code; retrieves with options, raises ValueError('local_currency_unavailable') when the Price lacks that option (the router decided approval or customer currency), sets currency, locale, trial terms amount, "All amounts are in". USD path unchanged.
  • Review round 1: billed_option_amount / OptionLookupFailed / UNKNOWN_CURRENCY (Stripe-only subscriber currency), buyer_currency / new_buyer_offer / customer_currency (customer currency first), cached_price_with_options (5-minute cache for the new-buyer and subscriber gates; Checkout re-reads live).
  • backend/routers/payment.py: CreateCheckoutRequest.currency; _new_buyer_checkout_currency (same rule as the offer pages, read live) and the displayed-currency check before session creation (400 when the currency the app showed differs from the one the server would charge; 503 on Stripe read failure); checkout_options['local_currency_code'] only when local. Available plans: billed_in_option, allow_options, new-buyer localize (USD otherwise). Upgrade: option-currency gate and schedule currency. Trial-will-end webhook: Stripe read moved to stripe_executor for option-billed trials only.
  • backend/utils/billing_currency.py price_for_currency(allow_options=...).
  • backend/routers/storefront.py: new-buyer sheet via new_buyer_offer (USD otherwise); _subscription_billing_currency reads the subscription currency (cached 30 days, it never changes) only once the current Price carries a non-USD option, and returns UNKNOWN_CURRENCY on a read failure so the current card shows no price.
  • backend/utils/storefront.py: offer_currency/money threading; build_single_plan_storefront(local_currency_code=...) returns None when any price lacks its option.
  • backend/utils/promotion_redemption.py, utils/retention_offer.py, utils/trial_reminder.py, utils/observability/subscription_events.py: option-billed branches.
  • No entitlement code changed: plan identity, price-ID → plan mapping and config/plan_catalog.json are untouched; the same Price IDs are sold.
  • App: createCheckoutSession(currency:) sends the currency the reader saw from every paywall and the Plans sheet.

First-rollout price table (#26074's 53 countries, now committed as part of the prod table)

Loaded through utils.local_currency.load_table() from ~/mobile-ux-agent/runs/2026-11-22/play/storefront_local_currency_table.first_rollout.json: 53 countries, 33 currencies (INR, ARS, TRY, NGN, EGP, PKR, UAH, BDT, KES and Iceland removed), 0 entries dropped (scripts/local_currency_options.py dropped_entries). Display strings are display_money, identical to the app and the Checkout render (NBSP after letter codes):

Currency Countries Monthly Annual Stripe minor units (monthly / annual)
AED AE AED 109.99 AED 990.99 10999 / 99099
AUD AU A$44.99 A$406.99 4499 / 40699
BRL BR R$177.99 R$1,600.00 17799 / 160000
CAD CA CA$42.99 CA$386.99 4299 / 38699
CHF CH CHF 24.99 CHF 226.99 2499 / 22699
CLP CL CLP 30,500 CLP 275,000 30500 / 275000
COP CO COP 105,000.00 COP 930,000.00 10500000 / 93000000
CZK CZ CZK 667.99 CZK 6,000.00 66799 / 600000
DKK DK DKK 203.99 DKK 1,850.00 20399 / 185000
EUR AT BE BG CY DE EE ES FI FR GR HR IE IT LT LU LV MT NL PT SI SK €26.99 €245.99 2699 / 24599
GBP GB £22.99 £205.99 2299 / 20599
HKD HK HK$234.99 HK$2,100.00 23499 / 210000
HUF HU HUF 10,000.00 HUF 92,000.00 1000000 / 9200000
IDR ID IDR 550,000.00 IDR 4,950,000.00 55000000 / 495000000
ILS IL ₪100.99 ₪904.99 10099 / 90499
JPY JP ¥4,750 ¥43,000 4750 / 43000
KRW KR ₩40,500 ₩365,000 40500 / 365000
MXN MX MX$572.99 MX$5,150.00 57299 / 515000
MYR MY MYR 122.99 MYR 1,100.00 12299 / 110000
NOK NO NOK 291.99 NOK 2,650.00 29199 / 265000
NZD NZ NZ$54.99 NZ$492.99 5499 / 49299
PEN PE PEN 102.99 PEN 928.99 10299 / 92899
PHP PH ₱1,900.00 ₱17,000.00 190000 / 1700000
PLN PL PLN 121.99 PLN 1,100.00 12199 / 110000
QAR QA QAR 108.99 QAR 981.99 10899 / 98199
RON RO RON 145.99 RON 1,300.00 14599 / 130000
SAR SA SAR 111.99 SAR 1,000.00 11199 / 100000
SEK SE SEK 306.99 SEK 2,750.00 30699 / 275000
SGD SG SGD 38.99 SGD 347.99 3899 / 34799
THB TH THB 1,000.00 THB 9,150.00 100000 / 915000
TWD TW NT$990.00 NT$8,900.00 99000 / 890000
VND VN ₫775,000 ₫6,950,000 775000 / 6950000
ZAR ZA ZAR 524.99 ZAR 4,750.00 52499 / 475000

Dry run of the Stripe write (no --apply; nothing sent)

cd backend && STRIPE_UNLIMITED_V2_MONTHLY_PRICE_ID=price_1TuIa81F8wnoWYvw0iX0j5M8 STRIPE_UNLIMITED_V2_ANNUAL_PRICE_ID=price_1TuIap1F8wnoWYvwHWq0EvNU \
  python scripts/local_currency_options.py --table storefront_local_currency_table.first_rollout.json

Offline, no key, prints dropped entries: none. It would make exactly these two calls, adding 33 currencies to each Price:

stripe.Price.modify('price_1TuIa81F8wnoWYvw0iX0j5M8', currency_options={"aed":{"unit_amount":10999},"aud":{"unit_amount":4499},"brl":{"unit_amount":17799},"cad":{"unit_amount":4299},"chf":{"unit_amount":2499},"clp":{"unit_amount":30500},"cop":{"unit_amount":10500000},"czk":{"unit_amount":66799},"dkk":{"unit_amount":20399},"eur":{"unit_amount":2699},"gbp":{"unit_amount":2299},"hkd":{"unit_amount":23499},"huf":{"unit_amount":1000000},"idr":{"unit_amount":55000000},"ils":{"unit_amount":10099},"jpy":{"unit_amount":4750},"krw":{"unit_amount":40500},"mxn":{"unit_amount":57299},"myr":{"unit_amount":12299},"nok":{"unit_amount":29199},"nzd":{"unit_amount":5499},"pen":{"unit_amount":10299},"php":{"unit_amount":190000},"pln":{"unit_amount":12199},"qar":{"unit_amount":10899},"ron":{"unit_amount":14599},"sar":{"unit_amount":11199},"sek":{"unit_amount":30699},"sgd":{"unit_amount":3899},"thb":{"unit_amount":100000},"twd":{"unit_amount":99000},"vnd":{"unit_amount":775000},"zar":{"unit_amount":52499}})
stripe.Price.modify('price_1TuIap1F8wnoWYvwHWq0EvNU', currency_options={"aed":{"unit_amount":99099},"aud":{"unit_amount":40699},"brl":{"unit_amount":160000},"cad":{"unit_amount":38699},"chf":{"unit_amount":22699},"clp":{"unit_amount":275000},"cop":{"unit_amount":93000000},"czk":{"unit_amount":600000},"dkk":{"unit_amount":185000},"eur":{"unit_amount":24599},"gbp":{"unit_amount":20599},"hkd":{"unit_amount":210000},"huf":{"unit_amount":9200000},"idr":{"unit_amount":495000000},"ils":{"unit_amount":90499},"jpy":{"unit_amount":43000},"krw":{"unit_amount":365000},"mxn":{"unit_amount":515000},"myr":{"unit_amount":110000},"nok":{"unit_amount":265000},"nzd":{"unit_amount":49299},"pen":{"unit_amount":92899},"php":{"unit_amount":1700000},"pln":{"unit_amount":110000},"qar":{"unit_amount":98199},"ron":{"unit_amount":130000},"sar":{"unit_amount":100000},"sek":{"unit_amount":275000},"sgd":{"unit_amount":34799},"thb":{"unit_amount":915000},"twd":{"unit_amount":890000},"vnd":{"unit_amount":6950000},"zar":{"unit_amount":475000}})

Operator sequence (parent runs it; read-only first):

  1. STRIPE_READ_API_KEY=<read key> python scripts/local_currency_options.py --count-non-usd-subscriptions counts live (active, trialing, past_due, unpaid, paused) subscriptions on the two Prices whose currency is not USD, by currency (older Adaptive Pricing conversions; a manual option overrides Adaptive Pricing for that currency).
  2. STRIPE_API_KEY=<write key> python scripts/local_currency_options.py --table <file> --apply --confirm reads both Prices with expand=currency_options, prints the existing options, and exits 2 before any write if the table dropped an entry or a table currency already exists on a Price with a different amount; otherwise it adds only the missing currencies.

Earlier proposed price table (superseded by the table above)

Omi Pro is US$29.99/month and US$269.91/year (9 × monthly). Rates: open.er-api.com, 2026-11-23 00:02 UTC. Converted, then rounded to Play's local price patterns (x.99; JPY to ¥100; MXN to whole pesos ending in 9), with annual = 9 × local monthly re-rounded so the yearly saving stays "3 months free". The JPY row equals the existing JPY Omi Pro management prices (¥4,800 / ¥43,200). Play's own template prices include VAT/GST where prices are tax-inclusive (EU, GB, AU, JP); Stripe Checkout here collects no tax, so these are tax-exclusive like the US price. Nothing below is in the default config.

Countries (top non-US Android upgraders, 30 d) Currency Rate per US$ Monthly Annual Table entry (minor units)
JP (34) JPY 158.70 ¥4,800 ¥43,200 "jpy": {"monthly": 4800, "annual": 43200}
GB (29) GBP 0.7636 £22.99 £206.99 "gbp": {"monthly": 2299, "annual": 20699}
AU (21) AUD 1.5070 A$44.99 A$404.99 "aud": {"monthly": 4499, "annual": 40499}
CA (20) CAD 1.4332 CA$42.99 CA$386.99 "cad": {"monthly": 4299, "annual": 38699}
MX (15) MXN 19.113 MX$569.00 MX$5,119.00 "mxn": {"monthly": 56900, "annual": 511900}
AE (12) AED 3.6725 AED 109.99 AED 989.99 "aed": {"monthly": 10999, "annual": 98999}
ES (10), NL (9), DE (8), other euro countries EUR 0.9111 €26.99 €242.99 "eur": {"monthly": 2699, "annual": 24299}
BR (7) BRL 5.9453 R$177.99 R$1,601.99 "brl": {"monthly": 17799, "annual": 160199}

Verification (this revival, on main @ 0736f7075d0)

  • Backend: bash test.sh on the 73 billing-related unit files (payment, checkout, storefront, Stripe, promotion, retention, trial reminder, Play Billing, currency, subscription events and more) under omi-heavy: all pass except, at first, test_local_currency_offer.py::test_checkout_currency_equals_the_displayed_currency. Main's checkout now calls play_subscriptions_db.is_play_customer, which the PR's helper did not stub. After the stub, the file passes 48 of 48.

  • App: flutter analyze on every changed Dart file: no issues. flutter test on the billing, paywall, Plans sheet, storefront and Play Billing tests: all pass after one fix. Main's play_billing_plans_sheet_test.dart fake createUserCheckoutSession lacked the new currency parameter and did not compile; that test now passes 92 of 92.

  • Local manifest checks (run_checks.py --lane local --base origin/main): all pass except two.

    • checkout-currency-format needs Node 22.22.0 with ICU 77.1. This host has 22.23.2 with ICU 78.2. Rerun with the checksum-verified pinned Node: --check passes.
    • feature-flag-registry blamed this PR for LADDER_V1_PRO_GATES_ENABLED's overdue deadline because of a checker bug. Adding REGION_HEADER to routers/storefront.py made the checker count that file's unchanged LADDER read as new. This branch carries the fix commit (fix(flags): count a Python flag read as added only when the base file did not read it), which is also its own PR, fix/flag-registry-base-scan-gate. Whichever merges second picks it up from main. With the fix: feature-flag registry: OK.
  • The original PR's verification and its iOS simulator evidence follow.

  • Backend: bash test.sh on the 22 touched/related suites (payment, checkout trial, promo/adaptive pricing, currency changes, JPY recognition, storefront x3, trial reminder, retention, promo redemption, yearly switch, billing events, available plans, users subscription boundary, referral checkout) plus the new tests/unit/test_local_currency_offer.py (48 tests): all pass. New tests cover: switch off / empty / malformed table byte-identical (available plans, v2 sheet, users subscription); JP, GB, DE paths; country outside the table keeps USD on Android and iOS; table currency missing from the Price falls back to USD and logs; old app (no region); US and USD-country buyers; Stripe option missing or not equal to the table; checkout currency equals displayed currency and refuses a mismatch; table validation for zero-decimal and whole-hundreds currencies; every Stripe currency's display string; a local trial keeps its currency through Checkout, an in-trial interval change and the reminder; cart currency, locale, adaptive pricing off and trial line; promo minimum and amount-off in GBP; yearly switch refusal in GBP; retention offer in GBP; local subscriber available plans + interval change with schedule currency; local subscriber Plans card; legacy JPY subscriber sheet unchanged; dry-run script prints and never writes; review round 1: rollback with switch off and empty table keeps a GBP subscriber in GBP on available plans, the Plans card, the retention offer, the trial push and promo redemption (and shows no price when Stripe is unreadable); a lapsed USD customer in GB stays USD on the page and at Checkout; a lapsed GBP customer in the US gets GBP with the switch on and off; a customer currency the Prices lack keeps USD; USD-only promo minimum compared with the USD Price; --apply needs --confirm, prints existing options, refuses a different amount or dropped entries before writing and adds only missing currencies; read-only non-USD subscription count; released currencies unchanged with the switch off.

  • Pyright on the touched backend modules: 0 errors (it caught a variable collision in build_storefront during development).

  • App: flutter test full suite (10,045 passed; the two visual-audit files failed to compile on a missed fake and pass after the fix; capture_cold_mute_test failed once under load and passes alone), new test/unit/local_currency_price_test.dart, flutter analyze on changed files (one pre-existing info).

  • Simulator (iOS, pipeline lane sim, local backend + Stripe stub with a GBP option, switch all because the simulator is iOS):

Trial paywall Plans
US, switch on (unchanged)
GB, switch off (today)
GB, switch on (£22.99 / £206.99 approved)

UNVERIFIED

  • The display strings are ICU's render at the pinned locale, the engine Checkout's browser formatter uses, not a live Checkout page: creating a session writes to Stripe. A browser on an older ICU could differ in rare symbols. Check one test-mode session per table currency before turning the switch on.

  • Whether Google's reviewer device locale names their country. If their device reports en-US, they still see USD (as Play would for a US account). An LB X-Client-Region header would remove that dependency.

  • Android build not run on a device or emulator here; the iOS simulator exercises the same Dart paths.

  • Trial conversion and renewal in the local currency rest on Stripe's rule that a subscription's currency is fixed at creation and every invoice bills that currency's option of the item Price. The tests prove Checkout creates the trial in the local currency and that no later path (interval change during the trial, schedule, upgrade) changes it; they cannot run Stripe's invoicing.

  • Stripe accepting currency on SubscriptionSchedule phases for an option-billed subscription is from the API reference, exercised only against fakes.

  • That Stripe refuses a Checkout whose currency differs from the customer's currency, and that Customer.currency is set after a trial-only subscription, are from the API reference; the customer-currency rule avoids both cases but was not run against Stripe.

  • A new buyer entering a USD-minimum or USD amount_off code in a local-currency Checkout: Stripe evaluates it in the session currency and may refuse it there. The in-app path for bundle and prepaid codes is redemption after the trial starts (promotion_redemption.py, handled above); list the live codes' restrictions read-only before turning on.

  • Whether existing currency_options can be edited or removed after --apply (the docs disagree); the script never edits one, and the 5-minute cache assumes they do not change.

  • Reviewer region (the risk that matters most for Play). Since panel F1, the Android app sends Google Play's billing country for the account (InAppPurchasePlatform.countryCode), read before a price screen loads. If Play doesn't answer within 3 s, the app sends no region, so the buyer gets today's USD; it never guesses from the locale. The next price screen retries. This matches the market Play itself prices the reviewer in, even when the phone's locale names another country. The table leaves out INR, PKR, EGP, NGN, ARS, TRY, UAH, BDT, KES and ISK. A reviewer whose Play country is one of those still sees US$. This PR is as written at David's request; widening the table is a follow-up decision.

  • Play Payments policy. Selling a digital subscription through Stripe in the Android app, without an alternative-billing program, is a separate Play Payments exposure (fix(billing): pin Checkout's locale so the cart shows the app's US$ price #25494, Google Play Billing for new Android subscriptions, behind ANDROID_BILLING (default off) #26078). Google has not cited it so far. Play Billing (deploy(billing): turn on Google Play Billing for Android builds 1617+ (unblocks Play review) #26826) remains the fallback.

Line-count exceptions

Line-Count-Exception: backend/routers/payment.py | 2546 -> 2648 | the checkout currency check and available-plans localization sit on the routes that create Checkout; the decision logic itself lives in utils/local_currency.py
Line-Count-Exception: backend/routers/users.py | 2923 -> 2945 | /v1/users/me/subscription must localize its own price strings for the same buyer

Product invariants affected

  • INV-MEM-4: cited because backend/deploy/runtime_env.yaml is a locked path for it. This PR adds only two billing settings to the prod backend service (STOREFRONT_LOCAL_CURRENCY, STOREFRONT_LOCAL_CURRENCY_TABLE) and changes no memory intake, consolidation or promotion setting.

Failure class (fixes)

Failure-Class: FC-subscription-price-presentment-drift

🤖 Generated with Claude Code

Git-on-my-level and others added 2 commits November 30, 2026 19:53
…), default off

Google Play keeps rejecting Android production updates under the Subscriptions
policy ("Currency differences with prominent display price ... appropriately
localized for each country"). #25494 made the Stripe cart match the app's US$
price; the offer page itself still shows US$ to a non-US reviewer.

This brings back kodjima33's #26074 (closed 2026-11-23 in favour of Play
Billing) onto current main as written: buyers with no paid subscription whose
device region has an approved price see and pay that currency through Stripe
currency_options on the same Price IDs. Off until STOREFRONT_LOCAL_CURRENCY
and STOREFRONT_LOCAL_CURRENCY_TABLE are set and the Prices carry the options.

Changes on top of #26074 @ aec826e:
- resolve conflicts with main (Play Billing checkout check, prepaid-code
  import, playMinorUnits, trial paywall trialDays);
- stub play_subscriptions_db.is_play_customer in the checkout test helper,
  which main's checkout now calls;
- register both switches in config/feature-flags.yaml with a ramp plan.

Failure-Class: FC-subscription-price-presentment-drift

Co-authored-by: kodjima33 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… did not read it

python_reads skips any file whose text has none of getenv, environ, _FLAG_KEY,
_ENV, _COHORT, _HEADER, enabled_env_var or kill_switch. added_read_keys used
the same gated scan on the base version, so when an edit added one of those
tokens to a file that already read a flag (for example
`local_currency.REGION_HEADER` in backend/routers/storefront.py beside its
existing `policy.enabled('LADDER_V1_PRO_GATES_ENABLED')`), the base scan found
nothing and the unchanged read counted as added. The PR then "touched" that
flag and inherited its overdue error, which it cannot remediate.

The base side of the comparison now scans without the token gate. The current
side is unchanged, so no new reads are reported and none are hidden.

Failure-Class: FC-check-scope-exceeds-remediation-scope

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Dec 1, 2026, 1:22 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

16 issues found across 58 files

Confidence score: 2/5

  • offer_for in backend/utils/local_currency.py trusts the client-supplied region for price eligibility, so buyers can spoof a country to get its configured local price. Base eligibility on trusted payment or account geography.
  • In backend/utils/storefront.py, an unreadable existing subscription currency can leave the offer currency as USD, so the sheet may show foreign USD prices. Preserve the unreadable state and avoid rendering prices until the billed currency is known.
  • The new manifest check can fail in the release-eligibility caller because it does not install the Node/ICU version required by generate_checkout_currency_format.py. Add the pinned Node setup to that caller.
  • buildHeaders in app/lib/backend/http/shared.dart sends the device region to arbitrary download and custom-backend URLs. Restrict the header to Omi authorities or add it only to storefront requests.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/test/widgets/billing_currency_surfaces_test.dart">

<violation number="1" location="app/test/widgets/billing_currency_surfaces_test.dart:67">
P2: This fixture accepts the new `currency` argument but discards it, so the checkout handoff tests cannot verify the new currency contract. Capture currency and assert it with a localized offer test.</violation>
</file>

<file name="app/lib/backend/http/shared.dart">

<violation number="1" location="app/lib/backend/http/shared.dart:235">
P2: `buildHeaders` also serves arbitrary download and custom-backend URLs, so this unconditionally discloses the device’s region to third parties. Restrict the header to Omi authorities (or add it only at storefront callers) so firmware and override requests do not receive location metadata.</violation>
</file>

<file name="backend/scripts/generate_checkout_currency_format.py">

<violation number="1" location="backend/scripts/generate_checkout_currency_format.py:43">
P2: Pinning the table to ICU 77 does not keep it aligned with Checkout’s browser `Intl.NumberFormat`; newer runtimes render five supported currencies differently. Use a formatting source or contract that matches Checkout’s runtime, or avoid promising exact parity for ICU-sensitive currencies.</violation>

<violation number="2" location="backend/scripts/generate_checkout_currency_format.py:126">
P2: The generator relies on the platform default encoding for Unicode artifacts, so Windows users can get `UnicodeEncodeError` or false stale results. Read and write both generated files with `encoding='utf-8'`.</violation>
</file>

<file name="backend/utils/storefront.py">

<violation number="1" location="backend/utils/storefront.py:214">
P2: The local-currency yearly switch still formats its headline, savings CTA, and confirmation amount with `format_money`, so these strings do not match the Checkout-compatible `display_money` output. Pass the selected formatter through all switch-specific formatting paths.</violation>

<violation number="2" location="backend/utils/storefront.py:313">
P2: When Stripe cannot reveal an existing subscriber's billed currency, this branch clears only `current_row` and leaves `offer_currency` as USD, so the sheet can still render foreign USD prices. Carry the unreadable state through tier filtering and show no prices until the billed currency is known.</violation>
</file>

<file name="backend/scripts/local_currency_options.py">

<violation number="1" location="backend/scripts/local_currency_options.py:62">
P2: The apply path does not verify that override IDs are the intended monthly and annual Prices. A swapped or unrelated valid Price can receive the wrong interval's amounts; preflight each retrieved Price's product and recurring interval before any write.</violation>

<violation number="2" location="backend/scripts/local_currency_options.py:119">
P2: `price_ids` silently drops a missing monthly or annual ID, so `--count-non-usd-subscriptions` can return exit 0 with a census for only one Price; the same unvalidated list also permits both plan flags to point at one Price during `--apply`. Require both IDs and reject duplicates before either Stripe mode runs.</violation>

<violation number="3" location="backend/scripts/local_currency_options.py:158">
P3: `_stripe` imports the Stripe SDK inside a function, but backend scripts require imports at module scope. Move `import stripe` into the top-level import block so this script follows the backend import policy.

(Based on your team's feedback about module-scope backend imports.)</violation>
</file>

<file name="app/test/widgets/storefront_checkout_handoff_test.dart">

<violation number="1" location="app/test/widgets/storefront_checkout_handoff_test.dart:38">
P2: This test double discards the new currency argument, so these checkout-handoff tests cannot catch the plans sheet sending the wrong currency or omitting it. Capture `currency` in `_Usage` and assert it in the successful checkout cases.</violation>
</file>

<file name="backend/utils/promotion_redemption.py">

<violation number="1" location="backend/utils/promotion_redemption.py:120">
P2: After this branch accepts a multi-currency fixed coupon, `redeem_promotion_code` still returns the coupon’s base `amount_off` and `currency`, so the redemption response reports the wrong discount for local subscriptions. Return the selected `currency_options[currency]` amount and the subscription currency instead.</violation>
</file>

<file name=".github/checks-manifest.yaml">

<violation number="1" location=".github/checks-manifest.yaml:1428">
P2: This new manifest check will fail in the release-eligibility caller because that caller does not install the exact Node/ICU version required by `generate_checkout_currency_format.py`; add the pinned Node setup to every CI route that can execute this check.</violation>
</file>

<file name="backend/routers/users.py">

<violation number="1" location="backend/routers/users.py:1346">
P2: This passes every available plan into the all-or-nothing currency check, so one legacy/ladder price without a local option suppresses localization for Omi Pro as well. Restrict the offer lookup and rewrite loop to the localized `unlimited_v2` prices, leaving unrelated plans on their existing USD strings.</violation>
</file>

<file name="backend/utils/local_currency.py">

<violation number="1" location="backend/utils/local_currency.py:97">
P2: `load_table` crashes on valid JSON whose `currencies` or `countries` value is not an object, despite promising to drop malformed input. Guard both sections with `isinstance(..., dict)` before calling `.items()` so a bad operator value fails closed to USD.</violation>

<violation number="2" location="backend/utils/local_currency.py:140">
P1: `offer_for` treats the client-supplied region as price authorization, so buyers can spoof a country such as `JP` and obtain its configured local price. Derive eligibility from trusted payment/account geography, or prevent a client region from authorizing a cheaper charge before enabling this flag.</violation>

<violation number="3" location="backend/utils/local_currency.py:267">
P3: This new backend module places `stripe` and `redis_db` imports inside functions. Move them to the module import block to follow the backend module-scope import rule and keep dependency structure consistent.

(Based on your team's feedback about module-scope backend imports.)</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread backend/utils/local_currency.py Resolved
@override
Future<Map<String, dynamic>?> createUserCheckoutSession(
{required String priceId, String? promotionCode, int? trialDays}) async {
{required String priceId, String? promotionCode, int? trialDays, String? currency}) async {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This fixture accepts the new currency argument but discards it, so the checkout handoff tests cannot verify the new currency contract. Capture currency and assert it with a localized offer test.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/test/widgets/billing_currency_surfaces_test.dart, line 67:

<comment>This fixture accepts the new `currency` argument but discards it, so the checkout handoff tests cannot verify the new currency contract. Capture currency and assert it with a localized offer test.</comment>

<file context>
@@ -64,7 +64,7 @@ class _Usage extends UsageProvider {
   @override
   Future<Map<String, dynamic>?> createUserCheckoutSession(
-      {required String priceId, String? promotionCode, int? trialDays}) async {
+      {required String priceId, String? promotionCode, int? trialDays, String? currency}) async {
     sessions.add((priceId, trialDays, promotionCode));
     return {'error': true, 'status_code': 400, 'detail': 'Fixture: checkout handoff captured'};
</file context>

Comment thread app/lib/backend/http/shared.dart Outdated
'X-Omi-Plan-Identity': '1',
'X-App-Build': PlatformManager.instance.appBuild,
appChannelHeader: currentAppChannel().wire,
if (deviceStorefrontRegion() case final region?) storefrontRegionHeader: region,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: buildHeaders also serves arbitrary download and custom-backend URLs, so this unconditionally discloses the device’s region to third parties. Restrict the header to Omi authorities (or add it only at storefront callers) so firmware and override requests do not receive location metadata.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/backend/http/shared.dart, line 235:

<comment>`buildHeaders` also serves arbitrary download and custom-backend URLs, so this unconditionally discloses the device’s region to third parties. Restrict the header to Omi authorities (or add it only at storefront callers) so firmware and override requests do not receive location metadata.</comment>

<file context>
@@ -231,6 +232,7 @@ Future<Map<String, String>> buildHeaders({
     'X-Omi-Plan-Identity': '1',
     'X-App-Build': PlatformManager.instance.appBuild,
     appChannelHeader: currentAppChannel().wire,
+    if (deviceStorefrontRegion() case final region?) storefrontRegionHeader: region,
     ...fromHeaders,
   };
</file context>
Suggested change
if (deviceStorefrontRegion() case final region?) storefrontRegionHeader: region,
if (url == null || shouldAttachOmiCredentials(url))
if (deviceStorefrontRegion() case final region?) storefrontRegionHeader: region,

return 1
return 0
for path, text in outputs.items():
path.write_text(text)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The generator relies on the platform default encoding for Unicode artifacts, so Windows users can get UnicodeEncodeError or false stale results. Read and write both generated files with encoding='utf-8'.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/scripts/generate_checkout_currency_format.py, line 126:

<comment>The generator relies on the platform default encoding for Unicode artifacts, so Windows users can get `UnicodeEncodeError` or false stale results. Read and write both generated files with `encoding='utf-8'`.</comment>

<file context>
@@ -0,0 +1,131 @@
+            return 1
+        return 0
+    for path, text in outputs.items():
+        path.write_text(text)
+    return 0
+
</file context>

SAMPLE_MINOR = 1234500
# Bump together with .github/workflows/repo-checks.yml's setup-node, then regenerate.
NODE_VERSION = 'v22.22.0'
ICU_VERSION = '77.1'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Pinning the table to ICU 77 does not keep it aligned with Checkout’s browser Intl.NumberFormat; newer runtimes render five supported currencies differently. Use a formatting source or contract that matches Checkout’s runtime, or avoid promising exact parity for ICU-sensitive currencies.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/scripts/generate_checkout_currency_format.py, line 43:

<comment>Pinning the table to ICU 77 does not keep it aligned with Checkout’s browser `Intl.NumberFormat`; newer runtimes render five supported currencies differently. Use a formatting source or contract that matches Checkout’s runtime, or avoid promising exact parity for ICU-sensitive currencies.</comment>

<file context>
@@ -0,0 +1,131 @@
+SAMPLE_MINOR = 1234500
+# Bump together with .github/workflows/repo-checks.yml's setup-node, then regenerate.
+NODE_VERSION = 'v22.22.0'
+ICU_VERSION = '77.1'
+
+NODE = r"""
</file context>

lanes: ["local", "ci"]
reason: "#9843 Ticket 02: macOS-only manifest checks must have an executable CI route"
- id: checkout-currency-format
command: ["python3", "backend/scripts/generate_checkout_currency_format.py", "--check"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This new manifest check will fail in the release-eligibility caller because that caller does not install the exact Node/ICU version required by generate_checkout_currency_format.py; add the pinned Node setup to every CI route that can execute this check.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/checks-manifest.yaml, line 1428:

<comment>This new manifest check will fail in the release-eligibility caller because that caller does not install the exact Node/ICU version required by `generate_checkout_currency_format.py`; add the pinned Node setup to every CI route that can execute this check.</comment>

<file context>
@@ -1424,6 +1424,12 @@ checks:
     lanes: ["local", "ci"]
     reason: "#9843 Ticket 02: macOS-only manifest checks must have an executable CI route"
+  - id: checkout-currency-format
+    command: ["python3", "backend/scripts/generate_checkout_currency_format.py", "--check"]
+    triggers: ["backend/scripts/generate_checkout_currency_format.py", "backend/config/checkout_currency_format.json", "app/lib/utils/checkout_currency_format.dart", ".github/workflows/repo-checks.yml", ".github/checks-manifest.yaml"]
+    lanes: ["local", "ci"]
</file context>

Comment thread backend/routers/users.py
return
prices = [price for plan in response.available_plans for price in plan.prices]
try:
offer = local_currency.new_buyer_offer(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This passes every available plan into the all-or-nothing currency check, so one legacy/ladder price without a local option suppresses localization for Omi Pro as well. Restrict the offer lookup and rewrite loop to the localized unlimited_v2 prices, leaving unrelated plans on their existing USD strings.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/routers/users.py, line 1346:

<comment>This passes every available plan into the all-or-nothing currency check, so one legacy/ladder price without a local option suppresses localization for Omi Pro as well. Restrict the offer lookup and rewrite loop to the localized `unlimited_v2` prices, leaving unrelated plans on their existing USD strings.</comment>

<file context>
@@ -1335,6 +1335,27 @@ def _byok_unlimited_subscription(
+        return
+    prices = [price for plan in response.available_plans for price in plan.prices]
+    try:
+        offer = local_currency.new_buyer_offer(
+            platform, region, lambda: users_db.get_stripe_customer_id(uid), [price.id for price in prices]
+        )
</file context>

Comment thread backend/utils/local_currency.py Resolved


def _stripe(key_env: str):
import stripe

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: _stripe imports the Stripe SDK inside a function, but backend scripts require imports at module scope. Move import stripe into the top-level import block so this script follows the backend import policy.

(Based on your team's feedback about module-scope backend imports.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/scripts/local_currency_options.py, line 158:

<comment>`_stripe` imports the Stripe SDK inside a function, but backend scripts require imports at module scope. Move `import stripe` into the top-level import block so this script follows the backend import policy.

(Based on your team's feedback about module-scope backend imports.) </comment>

<file context>
@@ -0,0 +1,165 @@
+
+
+def _stripe(key_env: str):
+    import stripe
+
+    stripe.api_key = os.environ[key_env]
</file context>

@@ -0,0 +1,376 @@
"""Local-currency offers for new buyers (Google Play Subscriptions policy). Default off.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This new backend module places stripe and redis_db imports inside functions. Move them to the module import block to follow the backend module-scope import rule and keep dependency structure consistent.

(Based on your team's feedback about module-scope backend imports.)

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/local_currency.py, line 267:

<comment>This new backend module places `stripe` and `redis_db` imports inside functions. Move them to the module import block to follow the backend module-scope import rule and keep dependency structure consistent.

(Based on your team's feedback about module-scope backend imports.) </comment>

<file context>
@@ -0,0 +1,376 @@
+
+def retrieve_with_options(price_id: str) -> Any:
+    """A Stripe Price with its ``currency_options`` (not returned unless expanded)."""
+    import stripe
+
+    return stripe.Price.retrieve(price_id, expand=['currency_options'])
</file context>

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui 1ff32a389aed661267549508a7d27930ded235b8. A later head keeps the approval while the PR's own UI changes stay the same, including after a rebase or a merge from main; a new or edited UI change needs a fresh one. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

Git-on-my-level and others added 3 commits November 30, 2026 20:39
…one locale

Panel F1 (review-20261201t012244-67c6): the region came only from the device
locale, so a buyer, or a Play reviewer, in a table country whose phone says
en-US or names no country still saw US$. On Android the app now reads Play's
billing country for the account (InAppPurchasePlatform.countryCode, the market
Play itself prices in) once, before the first price screen loads (available
plans and the v2 plans sheet), and sends it in X-Omi-Storefront-Region. It is
read lazily, as PlayBilling already does, so app start never connects to Play;
any failure or 3 s timeout keeps the locale region.

Also from the same review:
- F4: a table whose currencies or countries field is not an object now falls
  back to USD instead of raising at checkout.
- F2: shared_test asserts buildHeaders sends the region header, prefers Play's
  country, falls back to the locale and reads Play once.

Failure-Class: FC-subscription-price-presentment-drift

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…retries a failed read

Panel F1 fix check (review-20261201t012244-67c6, luna): falling back to the
device locale when Play's country was unavailable reintroduced the mismatch F1
named, and a failed read was cached so it never retried. On Android the
storefront region is now Play's billing country or nothing (today's USD); a
failed, timed-out or empty read is retried by the next price screen; a success
is kept. iOS, desktop and web still send the locale region.

Failure-Class: FC-subscription-price-presentment-drift

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member Author

REVIEW: SHIP (fixed) ce5824e (omi-panel review-20261201t012244-67c6, review cap 1/2 money). F1 accepted and fix-checked PASS by luna: Android sends only Play's billing country, with no locale fallback and a retry after a failed read. F4 and F2 fixed in the same commit set. F5 is a precondition for ramp step 5 (all), and F3 and F6 are deferred as minor. Billing change: David merges.

…es (kill switch: off)

David 2026-12-01: ship local-currency pricing on by default rather than as an
operator setting, so a later release, config cleanup or rollback cannot drop
it silently and reopen the Play Subscriptions finding. Prod now serves
STOREFRONT_LOCAL_CURRENCY=android and the price table; `off` is the kill
switch. Nothing changes for buyers until the two Omi Pro Stripe Prices carry
the matching currency_options (a separate, David-approved write): until then
every buyer falls back to USD, logged. Builds without the region header keep
USD.

The table is #26074's 53-country, 33-currency first rollout plus the ten it
dropped (IN INR, PK PKR, EG EGP, NG NGN, AR ARS, TR TRY, UA UAH, BD BDT,
KE KES, IS ISK), priced from open.er-api.com USD rates of 2026-12-01 00:02Z
with the existing table's rounding (x.99 under 1,000; nearest 50 to 9,999;
nearest 5x10^n above). A test loads the rendered prod value and proves all 63
countries and 43 currencies survive validation.

Failure-Class: FC-subscription-price-presentment-drift

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui ce5824e8cae5fa61436784ccca909d4093704498. A later head keeps the approval while the PR's own UI changes stay the same, including after a rebase or a merge from main; a new or edited UI change needs a fresh one. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

/approve-ui ce5824e

@Git-on-my-level

Copy link
Copy Markdown
Member Author

/approve-ui 184a9a6

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Scoped review of the on-by-default delta ce5824e8cae..184a9a6c161 (review pool, luna, read-only; agentctl exec-defense-charge-crystal-receive-click-wait). The rest of the PR has panel SHIP; omi-panel's pass on this head was a fix-check of F1 only.

No blocking findings. Verified: with the switch on and USD-only Stripe Prices, no path displays or charges a non-USD amount (plans and subscription routes fall back to USD; checkout uses the base USD Price unless it verified a local option). The overlay and rendered YAML table match exactly (63 countries, 43 currencies), all 86 amounts pass _valid_amount, annual/monthly is 8.79-9.20x, and at the 2026-12-01 rates the amounts sit at about $29-32/month and $262-288/year. The registry row raises no check error.

Deferred minors:

  1. local currency <cur> unavailable warns on every eligible offer check until the Stripe write. It's temporary, and it's the clean metric.
  2. A StripeError on the expanded Price read at checkout returns 503 rather than a USD checkout. Checkout already depends on Stripe to create the session.
  3. STOREFRONT_LOCAL_CURRENCY (the mode) isn't in config/deployment-setting-classification.json. The boundary check passes today; this is a one-line follow-up.

@Git-on-my-level
Git-on-my-level merged commit 3371daf into main Dec 1, 2026
83 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/play-local-currency-storefront-v2 branch December 1, 2026 05:05
Git-on-my-level added a commit that referenced this pull request Dec 1, 2026
…igh-volatility currencies (#26877)

David 2026-12-01: support local prices only in the major countries where we have
buyers and where Google Play is likely to review, and drop the high-volatility,
high-risk currencies. Done before the Stripe currency_options write, because
those entries are effectively permanent once added.

Prod table: euro (21 countries), GBP, JPY, CAD, AUD, NZD, CHF, SGD, MXN, BRL,
AED, INR. Amounts unchanged from #26841. Dropped: ARS, TRY, NGN, EGP, PKR, UAH,
BDT, KES, ISK, COP, CLP, PEN, ZAR, IDR, PHP, THB, MYR, VND, KRW, TWD, HKD, ILS,
QAR, SAR, PLN, CZK, HUF, RON, SEK, NOK, DKK. Buyers there keep USD, as today.

Failure-Class: FC-subscription-price-presentment-drift

Co-authored-by: Claude Opus 5.5 <[email protected]>
kodjima33 added a commit that referenced this pull request Dec 1, 2026
…en at the largest text size (#26791)

## Problem

At the largest iOS text size the free trial paywall breaks. The brand
cuts to "O...", "Today" in the timeline stacks one letter per line next
to its date, and on a 375x667 phone the footer overflows (Privacy Policy
is cut, the page body gets no room). Gotcha 12 in the MUX pipeline
README logged this on 2026-10-28. The round 2 build of this PR also
showed plan cards breaking mid-word at AX5 ("Mont/hly", "US$/29./99").

## Decision

Nik chose option A on 2026-11-30, which overrides the round 1 review's
no-clamp finding. At the largest text sizes, the price and the buy
button stay on the first screen, even if they draw slightly smaller than
the system text size.

## Change

`app/lib/pages/paywall/trial_paywall_page.dart`. Everything below
applies at accessibility text sizes only (scale >= 1.6, iOS AX1 and up),
except the busy-button fix, which applies at every size. The default
text size otherwise keeps main's widgets.

- The offer is pinned at the bottom at every text size, as on main.
Inside it, the price line, Start Free Trial and Terms/Privacy stop
growing at a 1.7x cap (before fitting). At AX5, body text there draws at
up to 29 pt instead of 53 pt. Before main's per-month copy, 1.7x was the
most at which the German renewal line and the button fit in half of a
320x568 screen. Terms/Privacy scroll inside the footer under the button
when they do not fit. The price line and button never scroll. If a
translation is still too tall, they shrink together as one block, so the
button is never tappable with the price line cut off. With main's longer
per-month yearly line, this fit shrink triggers in the 320x568 AX5
widget tests for German (0.78 of the cap) and Arabic (0.68), still above
the default text size; it did not visibly trigger in the native
simulator captures (17 Pro and SE).
- Above the footer, the headline and body text keep the full system text
size. The "Omi Pro" brand, the Restore label, and plan names and prices
may scale down to fit their slot (see below). The cancel note and code
hint scroll with the page, as on main.
- Plan cards stack at accessibility sizes. Plan names and prices stay on
one line and scale down to the card if needed, so no word or price
breaks.
- The timeline date goes on its own line under the row body. The "Omi
Pro" brand scales to its slot instead of cutting off.
- The button keeps its size while checkout is pending, failed or
retrying, at every text size including default (round 3).
- Removed: round 2's offer at the end of the scroll and its first tap
that scrolled instead of buying.

Money: the CTA still binds to the shown offer. The double-tap lock and
the provider's in-flight guard are unchanged, and so are prices and the
Play paths.

## Impact estimate

Owners who pay: 29.77% -> 29.78-29.83% (MODELED).

- A = 29.77%: ACTUAL, `runs/2026-11-30/metrics.json` (3467 paid of 11646
observed owners, Oct 31 to Nov 30).
- Reach is MODELED: PostHog has no text-size property, so the share of
trial paywall viewers at accessibility sizes is unknown. Trial-start and
trial-to-paid lift are MODELED from the brief's range.

## Evidence

iOS simulator (iOS 26.4), iPhone 17 Pro and iPhone SE (3rd gen), offline
backend with live Stripe prices, built at e61a5b5 (merge with main;
same tree as the current head minus the evidence commit). Every frame
opened. Raw frames: `~/mobile-ux-agent/runs/2026-11-30/p1/r6/` and round
5 `~/mobile-ux-agent/runs/2026-11-30/p1/sim/r5/`.

Largest text (AX5), first screen with no scroll. Left: main a4c0f74
(round 5, before main's per-month copy) for comparison. Then this change
on iPhone 17 Pro and iPhone SE: the whole price line sits right above a
whole "Try for US$0.00", Terms and Privacy below.

![largest
text](https://raw.githubusercontent.com/BasedHardware/omi/a6dd19dc2148d91799b17820565921c754d95e3b/.agent-artifacts/ui-evidence/mux-2026-11-30-trial-paywall-ax/001-mobile-ios-trial-paywall-largest-text.png)

Default text, iPhone 17 Pro: main a4c0f74 (round 5) | this change.
Default keeps main's layout, now with main's per-month yearly price
line.

![default
text](https://raw.githubusercontent.com/BasedHardware/omi/a6dd19dc2148d91799b17820565921c754d95e3b/.agent-artifacts/ui-evidence/mux-2026-11-30-trial-paywall-ax/002-mobile-ios-trial-paywall-default-text.png)

Largest text in German, Arabic and Japanese (17 Pro, SE each), system
glyphs:


![locales](https://raw.githubusercontent.com/BasedHardware/omi/a6dd19dc2148d91799b17820565921c754d95e3b/.agent-artifacts/ui-evidence/mux-2026-11-30-trial-paywall-ax/003-mobile-ios-trial-paywall-largest-text-locales.png)

Plan switch at the largest text: scrolled to the cards and picked
Monthly then Yearly (German SE), Monthly (Arabic 17 Pro, Japanese SE).
The pinned price line follows the selected plan; card prices stay on one
line.

![plan
switch](https://raw.githubusercontent.com/BasedHardware/omi/a6dd19dc2148d91799b17820565921c754d95e3b/.agent-artifacts/ui-evidence/mux-2026-11-30-trial-paywall-ax/004-mobile-ios-trial-paywall-plan-switch.png)

Round 5 on the pre-merge head 2d9a45e also covered close, reopen,
relaunch, Close/Restore pinned and the Terms/Privacy round trip on both
phones (`~/mobile-ux-agent/runs/2026-11-30/p1/result.txt`, "Simulator
r5").

## Merge with main (round 6)

Main's per-month pricing copy (#26841) conflicted in
`trial_paywall_page.dart`. The merge keeps this PR's stacked plan cards
and pinned footer with main's per-month price, percent saving and yearly
terms line. That line is longer, so on small phones at AX5 it can take
the footer's safety shrink (German 320x568: 0.78, Arabic: 0.68 of the
1.7x cap), still above the default text size, per option A. The
real-font test now allows that shrink with a floor at the default size,
and counts Arabic vowel marks as part of their word in the plan-card
check.

## At ship

- No flags, no new events, no copy changes.

## Tests

- `app/test/widgets/trial_paywall_real_font_test.dart` uses SF Pro and
covers en/de/ar/ja on 402x874 and 375x667 with Face ID insets, and
375x667 and 320x568 with home-button insets, at 200% and AX5. On the
first frame with no scroll: the price line is whole, on screen and right
above the button; the footer is at most half the screen; the price line
and button are laid out at the 1.7x cap before fitting, and after the
fit shrink their drawn scale stays at or above 1.0x (the default size);
the headline keeps the system scale; one tap starts checkout.
- The same file also covers: Terms and Privacy open from the footer
without moving the button; no plan-card word or price breaks across
lines; through a pending, then failed, then retried checkout the CTA
rect and scroll offset stay put (the price line rect is checked after
the failure), and a second tap while pending starts nothing (AX5 at
320x568 and 375x667, plus default size); at default size the brand
ellipsizes, the footer is unclamped, the cards sit side by side and the
notes are pinned.
- Mutation checks: with stacking and fit off, the plan-card cases fail;
without the scale cap, the first-screen cases fail.
- After the merge: the four trial paywall test files, 144/144 pass on
Flutter 3.44.5 (before the merge, 37 paywall, billing, plan and trial
files: 588/588). `check_mobile_ux_contract`, `check_mobile_ui_isolate`
and `check_brand_ui` are clean.

## Not verified

- Dark appearance: with iOS set to dark, this paywall renders light, on
main and here alike (not changed by this PR).
- Arabic and Japanese in widget tests use square fallback glyphs. These
are wider than SF Arabic, so the footer and card measurements for them
are pessimistic. For Arabic plan-card footnote words wider than a line
in squares, the test skips the word check.
- Android at its largest font size: not verified. The layout tests force
the iOS platform and inject linear text scalers, and no Android device
or emulator was shot.
- Outside this PR: at AX5 the German headline still breaks mid-word ("So
funk/tioniert") at full system scale, as it does on main.

## Product invariants affected

none

## Failure class (fixes)

Failure-Class: none

UI-Evidence: see the images above
(.agent-artifacts/ui-evidence/mux-2026-11-30-trial-paywall-ax)
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