Skip to content

fix(billing): pin Checkout's locale so the cart shows the app's US$ price - #25494

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/currency-consistency
Nov 16, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/currency-consistency

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

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

Why

Google Play rejected Android 1.0.587 (code 1560) on 2026-11-06:

Subscriptions policy: Violation of Subscriptions policy — Currency differences with prominent display price. Ensure that currency displayed is consistent through multiple screens such as offers page and payment cart within the purchase flow and is appropriately localized for each country that your app is targeting.

The offer page is correct. Google's attached screenshot shows the native trial paywall rendering US$269.91/year and Try for US$0.00 — the explicit, locale-independent form the app's shared formatter produces.

The cart was not. create_subscription_checkout_session passed locale: 'auto', so Stripe Checkout formatted the same USD amount using the buyer's browser language.

Evidence

Rendered live Checkout sessions on 2026-11-16 with the production session parameters (currency pinned to the price, adaptive_pricing.enabled = false):

Session locale Cart renders App renders Match
en $269.91 US$269.91 ✗
en-GB US$269.91 US$269.91 ✓
de 269,91 $ US$269.91 ✗
auto + Adaptive Pricing on ₫7,231,887 US$269.91 ✗✗

The last row is the earlier build-1504 failure mode, still correctly prevented by the existing adaptive_pricing pin.

Change

CHECKOUT_LOCALE = 'en-GB', used instead of 'auto'. One constant, one call site.

  • Adaptive Pricing stays disabled; the currency is still the price's own, so the charged-vs-displayed fix is untouched.
  • The cart is now deterministic: it no longer depends on the buyer's browser language.
  • en-GB is the only supported Stripe locale that renders USD with the US prefix, which is what the app shows. en-CA is not a valid Stripe locale (the API rejects it).

Trade-off, stated plainly: non-English buyers get an English checkout. A per-locale pin would restore localized copy but reintroduce the mismatch, because de renders 269,91 $ and en renders $269.91. Consistency is the finding Google cited, so it wins for now; if localized checkout is wanted later, each locale has to be verified to render the same string before it is enabled.

Verification

Command Result
pytest tests/unit/test_payment_promo_adaptive_pricing.py 8 passed
pytest tests/unit/test_payment_currency_changes.py tests/unit/test_storefront.py tests/unit/test_storefront_presentation.py 465 passed

The new test pins CHECKOUT_LOCALE == 'en-GB' and fails if 'locale': 'auto' returns to the source.

Layer measured: unit tests plus live Stripe Checkout renders in a sandbox account. No production session was created, no charge was made, and no store state was touched.

What this does not fix

This closes the currency finding only. Selling digital subscriptions through Stripe inside the app is still a Play Payments policy exposure, and the same model is live on iOS under App Review 3.1.1. That decision (link-out, consumption-only, or store billing) is separate and in progress.

View guided diff Turn on auto-fix

…rice

Google Play rejected Android 1.0.587 (code 1560) for "Subscriptions policy:
Currency differences with prominent display price". The app renders every
purchase amount as an explicit, locale-independent "US$269.91"
(app/lib/utils/billing_price.dart), but Checkout ran with locale 'auto', so the
cart followed the buyer's browser language and rendered a different string.

Verified against live Checkout renders on 2026-11-16 with the production
session parameters (currency pinned, Adaptive Pricing disabled):

  locale 'en'    -> "$269.91"
  locale 'en-GB' -> "US$269.91"   <- matches the app
  locale 'de'    -> "269,91 $"

Pin the session locale to en-GB so the cart is deterministic and identical to
the offer page. Adaptive Pricing stays disabled and the currency is still the
price's own, so the earlier charged-vs-displayed fix is untouched. The
trade-off is an English checkout for non-English buyers, which is the cost of a
consistent currency string; a per-locale pin would reintroduce the mismatch
because only en-GB renders USD with the US prefix.

The test pins the constant and fails if 'auto' returns.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T14:09:05.504755Z 3ee92ac PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

The two red checks are infrastructure, not this diff.

  • Listen Pusher Stack Gauntlet fails with httpx.ReadTimeout / httpcore.ReadTimeout against the Firestore emulator stack, on both the original run and the re-run.
  • Backend Hermetic Merge Gate fails closed because that upstream job failed.

Main is failing the same job at the same time: run 43884677546 (main, 2026-11-16T14:20:23Z) fails Listen Pusher Stack Gauntlet with 503 failed to connect to all addresses ... Trying to connect an http1.x server, plus the same merge gate. The previous main runs at 13:20, 13:17, 12:49, 12:33 and 12:25 all passed, so this is a transient emulator/network fault that started around 14:20Z.

This diff is two files: a module-level CHECKOUT_LOCALE constant in backend/utils/stripe.py and its test. It does not touch the listen/pusher stack, the emulator, or any network path the gauntlet exercises.

Required checks are green (39 passing). Merging with admin so the backend deploy can be queued; the failing pair is tracked by the main run above.

@Git-on-my-level
Git-on-my-level merged commit 8b9fd35 into main Nov 16, 2026
70 of 74 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/currency-consistency branch November 16, 2026 14:29
Git-on-my-level added a commit that referenced this pull request Dec 1, 2026
…), default off (#26841)

> **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 (#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) |
![](https://raw.githubusercontent.com/BasedHardware/omi/efd9e05157e7e88bafe88d5e7656478befaecb46/.agent-artifacts/ui-evidence/play-local-currency-storefront/001-mobile-ios-trial-paywall-us-switch-on.png)
|
![](https://raw.githubusercontent.com/BasedHardware/omi/efd9e05157e7e88bafe88d5e7656478befaecb46/.agent-artifacts/ui-evidence/play-local-currency-storefront/002-mobile-ios-plans-us-switch-on.png)
|
| GB, switch off (today) |
![](https://raw.githubusercontent.com/BasedHardware/omi/efd9e05157e7e88bafe88d5e7656478befaecb46/.agent-artifacts/ui-evidence/play-local-currency-storefront/003-mobile-ios-trial-paywall-gb-switch-off.png)
|
![](https://raw.githubusercontent.com/BasedHardware/omi/efd9e05157e7e88bafe88d5e7656478befaecb46/.agent-artifacts/ui-evidence/play-local-currency-storefront/004-mobile-ios-plans-gb-switch-off.png)
|
| GB, switch on (£22.99 / £206.99 approved) |
![](https://raw.githubusercontent.com/BasedHardware/omi/efd9e05157e7e88bafe88d5e7656478befaecb46/.agent-artifacts/ui-evidence/play-local-currency-storefront/005-mobile-ios-trial-paywall-gb-switch-on.png)
|
![](https://raw.githubusercontent.com/BasedHardware/omi/efd9e05157e7e88bafe88d5e7656478befaecb46/.agent-artifacts/ui-evidence/play-local-currency-storefront/006-mobile-ios-plans-gb-switch-on.png)
|

## 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 (#25494, #26078). Google has not cited
it so far. Play Billing (#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](https://claude.com/claude-code)
nitsi pushed a commit to nitsi/omi that referenced this pull request Dec 1, 2026
…dHardware#26074), default off

Google Play keeps rejecting Android production updates under the Subscriptions
policy ("Currency differences with prominent display price ... appropriately
localized for each country"). BasedHardware#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 BasedHardware#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 BasedHardware#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]>
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