Skip to content

fix(web): show Epay subscription payment amount in CNY (HQ-Task T261105-12) - #7

Merged
AdoreJc merged 1 commit into
fork-mainfrom
hq/T261105-12-epay-amount-cny-symbol
Nov 6, 2026
Merged

AdoreJc merged 1 commit into
fork-mainfrom
hq/T261105-12-epay-amount-cny-symbol

Conversation

@AdoreJc

@AdoreJc AdoreJc commented Nov 6, 2026

Copy link
Copy Markdown
Owner

HQ-Task: T261105-12

Agent

  • Tool: Claude Code (session started by the HQ supervisor session)
  • Tool version: not exposed to the session
  • Model (full id): claude-opus-5-5
  • Host (CLI / IDE / GitHub coding agent / other): other (Claude desktop app, Windows 10)
  • Date (UTC): 2026-11-05

Links

User request

  • Verbatim: (HQ brief, abridged) 生产上订阅购买对话框的 Epay 区块显示「在线支付金额 $203.93」,应为 ¥203.93。新增专用于支付网关(Epay)人民币实付金额的格式化函数,符号固定 ¥,不看额度显示类型;订阅购买对话框 Epay 金额和支付按钮改用它。
  • Later constraints or corrections from the user (quote, or none): none

Out of scope — refuse

  • Matched: no
  • If yes, what was told to the user: n/a

Open gate — do not open unless all are satisfied

  • Out of scope: no / Usage-config-integration: no / Issue facts present: yes / Real verification: yes / Short and factual: yes
  • Open: yes

Kind

  • Bug fix

Issue facts

  • Actual behavior: with quota display type USD, the subscription purchase dialog shows "Online payment amount $203.93" and "Pay $203.93"; the Epay order is charged 203.93 yuan.
  • Impact: users see the wrong currency for the real charge (looks ~7x more expensive in USD).
  • Frequency: deterministic whenever display type is USD, CUSTOM or TOKENS.
  • Evidence that the problem is in new-api: subscription-purchase-dialog.tsx formats price_amount × priceRatio with formatLocalCurrencyAmount(), whose symbol comes from getBillingDisplayMeta (USD → $, CUSTOM → custom symbol, TOKENS → $). The backend charges plan.PriceAmount × operation_setting.Price (price per USD, in yuan) — RMB regardless of display type.
  • Applicable types: frontend only (web/src/features/subscriptions, web/src/lib/currency.ts); no billing, relay or deployment change.

Change

  • web/src/lib/currency.ts: new formatPaymentCurrencyAmount(amount, options?) — fixed CNY (Intl narrowSymbol → ¥), no exchange rate, reuses formatCurrencyValue/mergeOptions, defaults to at most 2 fraction digits (also below 1) and no abbreviation, '-' for null/undefined/NaN. Header doc and quick-reference table explain the difference from formatLocalCurrencyAmount() (that one follows the display type; a gateway amount's currency is decided by the gateway, Epay = RMB).
  • subscription-purchase-dialog.tsx: Epay "Online payment amount" and the Pay {{amount}} button use the new formatter.
  • No locale, Go or other call-site changes.

Research

  • Code paths: controller/subscription_payment_epay.go (subscriptionEpayMoney = payMoneyFromUSD = USD × operation_setting.Price); controller/topup.go getPayMoney (top-up amount is credit in USD units).
  • Alternatives: (A) add a "payment currency symbol" setting — not needed while Epay settles in RMB, listed as follow-up; (B) reuse formatLocalCurrencyAmount with a forced meta flag — a separate named function keeps the semantics explicit.
  • Not changed on purpose: wallet/.../payment-confirm-dialog.tsx "Topup Amount" is topupAmount × effectiveUsdExchangeRate, i.e. the purchased credit shown in the display currency (USD display → rate 1 → $10 for $10 credit), not the gateway charge; forcing ¥ there would be wrong. Its "You Pay" line (gateway amount) uses formatCurrency without a symbol and is shared with Stripe/Creem/Waffo, so it is also left as is.

Files

Path Why
web/src/lib/currency.ts new formatter + docs
web/src/features/subscriptions/components/dialogs/subscription-purchase-dialog.tsx use it for the Epay amount and button
web/src/lib/__tests__/payment-currency-amount.test.ts new unit tests
web/src/features/subscriptions/__tests__/purchase-dialog-epay-amount.test.tsx assert ¥, add USD-display case

Behavior

  • Before: display type USD, plan $27.94, price per USD 7.3 → "Online payment amount $203.96", "Pay $203.96".
  • After: "¥203.96" / "Pay ¥203.96" for every display type. Balance price ($27.94) unchanged.
  • Non-goals: other gateways, wallet dialog, locale-specific symbol placement (Intl CNY formatting, e.g. 203,93 ¥ in fr).

Verification

Run in web/ with Bun 1.4.0 on Windows:

  • bun install --frozen-lockfile → 1213 packages installed.
  • bun x --package @typescript/native-preview tsgo -b → exit 0 (a deliberately injected type error was reported, so the check is real).
  • bun x vitest run src/lib/__tests__/payment-currency-amount.test.ts src/features/subscriptions/__tests__/purchase-dialog-epay-amount.test.tsx → 2 files, 16 tests passed.
  • bun run test → Test Files 210 passed (210), Tests 2516 passed (2516).
  • bun run build → exit 0.
  • oxlint -c .oxlintrc.json on the 4 touched files → no diagnostics; oxfmt --check on them → "All matched files use the correct format". (Full bun run lint / format:check report pre-existing errors only in untouched files, e.g. scripts/sync-i18n.mjs, src/assets/**.)
  • Tests added or updated: see Files.
  • Not verified: not checked on the production UI or a deployed build; no manual browser check.

Risks

  • Failure modes: if an Epay merchant ever settles in a non-RMB currency, the symbol would be wrong.
  • Billing / quota / auth impact: none (display only).
  • Follow-ups: if Epay merchants with non-RMB settlement must be supported, add a "payment currency symbol" setting and feed it to formatPaymentCurrencyAmount.

Scope check

  • Single focused change: yes
  • Secrets included: no
  • Out of scope: no

🤖 Generated with Claude Code

…05-12)

The subscription purchase dialog rendered the Epay amount with
formatLocalCurrencyAmount(), whose symbol follows the admin quota display
type. With display type USD a 203.93 yuan Epay charge read "$203.93".
The Epay amount is plan USD price x operation_setting.Price (price per
USD, in yuan), i.e. always RMB, independent of the display type.

- web/src/lib/currency.ts: add formatPaymentCurrencyAmount(), fixed
  CNY/¥ for gateway (Epay) charges, reusing formatCurrencyValue and
  mergeOptions, default max two fraction digits, no abbreviation.
  Document how it differs from formatLocalCurrencyAmount() in the header
  and the quick reference table.
- subscription-purchase-dialog.tsx: the "Online payment amount" row and
  the "Pay {{amount}}" Epay button use the new formatter.
- tests: unit tests for the formatter under USD/CNY/CUSTOM/TOKENS,
  fraction digits and '-' for null/undefined/NaN; the purchase dialog
  test now asserts ¥73 / ¥10 and adds a USD-display case (¥203.96).

The wallet PaymentConfirmDialog "Topup Amount" is left unchanged: it is
topupAmount (credit in USD units) x the effective display exchange rate,
i.e. credit shown in the display currency, not the gateway charge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AdoreJc
AdoreJc merged commit e828817 into fork-main Nov 6, 2026
2 checks passed
AdoreJc added a commit that referenced this pull request Nov 12, 2026
…61112-13) (#33)

The site now settles fully in US dollars with 1:1 top-ups (production
options: Price=1, USDExchangeRate=1, quota_display_type=USD; Alipay and
WeChat Pay go through Stripe). Two earlier fork changes still hardcoded
RMB in the UI:

- T261109-14 (#17): the model marketplace "Recharge" price mode always
  showed CNY/¥ (USD price x group ratio x Price).
- T261105-12 (#7): formatPaymentCurrencyAmount always rendered the
  online payment amount in the subscription purchase dialog and its
  "Pay {{amount}}" button as ¥.

Both are now fixed USD/$:

- lib/currency.ts: formatPaymentCurrencyAmount uses USD/$ (still
  independent of the quota display type, no exchange rate applied);
  docs updated.
- pricing/lib/recharge-price.ts: RECHARGE_PRICE_CURRENCY_LABEL is USD;
  recharge prices stay USD price x group ratio x Price and are not
  divided by usd_exchange_rate. Card view, table view, group prices,
  per-request, tiered and task prices all go through this helper.
- pricing/components/dynamic-pricing-breakdown.tsx: tier prices in
  recharge mode use $ x Price.
- Comments in price.ts, dynamic-price.ts and the purchase dialog.

Fixed USD rather than following the quota display type: the amount is
USD x Price, i.e. the US dollars the site charges, so following a CNY
display type would show a USD amount with a ¥ symbol. Standard mode
(switch off) is unchanged. Display only; no backend billing or order
amount logic changes. No locale text referred to RMB, so locale files
are unchanged.

Tests: recharge-price, payment-currency-amount and purchase-dialog tests
now assert $ (Price=1.5 for the price != 1 case, a Price=1 production
case, and a CNY display site that must still show $ without x7);
existing recharge assertions in dynamic-price, model-cards,
task-price-display and viewer-groups updated from ¥ to $.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@AdoreJc
AdoreJc deleted the hq/T261105-12-epay-amount-cny-symbol branch November 14, 2026 10:59
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