Skip to content

feat(billing): connect subscription checkout to payment APIs - #956

Merged
xiaocheny214 merged 9 commits into
1024XEngineer:mainfrom
huyanxius:feat/payment-checkout
Oct 15, 2026
Merged

xiaocheny214 merged 9 commits into
1024XEngineer:mainfrom
huyanxius:feat/payment-checkout

Conversation

@huyanxius

Copy link
Copy Markdown
Collaborator

在原订阅与充值页面接入现有账单接口,支持套餐购买、积分充值、收银台跳转和支付结果查询,保留原页面布局与样式。

Why

原购买按钮只打开“支付还没有接入”的提示,套餐和会员档位也是固定值。后端 #954 已提供商品、订单及订阅接口,需要补齐前端调用与订单状态处理。

Changes

  • 套餐价格、积分、会员档位和账期采用服务端数据;展示长期积分与本期积分。
  • 支持支付宝、微信支付选择并使用真实品牌图标;套餐下单传商品编号,自定义充值传整数分。
  • 支持回跳查单、待支付订单续付、关单及分页订单记录;只有后端确认支付后才刷新权益。
  • 拦截重复提交、无效付款地址和过期订单;下单价格变化时要求重新确认。

Implementation

  • entities/bill 负责账单契约与传输映射,复用共享认证和 API 客户端。
  • features/billing 负责资源加载、订单轮询与提交状态;写请求关闭认证后的自动重放,避免重复下单。
  • 页面复用现有组件与 subscription.css,该样式文件无改动;新增控件使用 Tailwind 与现有 token。
  • 回跳参数只提供订单编号,成功状态和关单结果均重新向后端核对;旧请求不能覆盖新订单。
  • 本地 mock 预览未入仓,HTTP 替身仅供测试,正式入口默认调用真实账单接口。

Verification

  • npm test -- src/entities/bill/api.test.ts src/features/billing/index.test.ts src/pages/subscription/index.test.tsx src/app/layout/app-header.test.tsx:4 个文件、57 项测试通过。
  • ./node_modules/.bin/oxlint src/entities/bill src/entities/index.ts src/features/billing src/pages/subscription src/test/bill-backend.ts src/app/layout/app-header.tsx src/app/layout/app-header.test.tsx:通过;本次变更文件的 oxfmt --check 通过。
  • VITE_API_BASE_URL=/api npm run build:类型检查与生产构建通过;仅有既有大包体积提示。
  • 真实浏览器检查原页面、支付渠道图标及本地模拟回跳后的订阅与余额更新。
  • 核对生产构建包含真实账单接口且不包含 mock 收银台、测试订单或预览入口;原页面 CSS 与基线一致。

Scope

本 PR 仅交付前端接入,不包含后端部署或商户配置。当前环境尚未部署 #954 的支付接口;真实网关下单、付款和异步回调尚未验证,后续由队友部署后联调验收。

Related Issues

Closes #955

Refs #947

Refs #954

The checkout needs the existing backend billing contract.

Map products, subscriptions and orders through the shared API client.

Keep money in integer fen and disable automatic mutation replay.
Payment state must follow the backend order lifecycle.

Add billing resources with stale-response guards and sequential polling.

Prevent duplicate submissions and re-read orders after close attempts.
Checkout needs recognizable Alipay and WeChat Pay choices.

Bundle the official source artwork with its provenance and license notice.

Render payment branding locally without an external image request.
Purchases need channel selection and a resumable order view.

Add checkout and history components using the existing dialog styling.

Require server-confirmed status before presenting a completed payment.
The purchase controls currently stop at a placeholder dialog.

Bind the original page to products, checkout, subscription balances and order history.

Preserve the stylesheet and recover orders from return parameters.
The account menu always labels the subscription as Free.

Read the subscription when the authenticated account menu opens.

Display the actual tier and link existing members to subscription management.
The frontend adapter must match the existing billing responses.

Exercise request payloads and response mapping through an isolated HTTP fixture.

Cover authenticated creation, server prices, pagination and close requests.
Payment returns and delayed requests must not create false success.

Exercise polling, stale responses, duplicate clicks, price changes and close compensation.

Verify the page follows server state across checkout failures and returns.
The account menu must reflect existing paid membership.

Inject the billing HTTP fixture and assert the Pro management link.

Keep unrelated account tests isolated from live billing requests.
@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
windup Ready Ready Preview Oct 15, 2026 1:07pm UTC

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #956   +/-   ##
=======================================
  Coverage   91.01%   91.01%           
=======================================
  Files         205      205           
  Lines       14231    14231           
=======================================
  Hits        12953    12953           
  Misses       1278     1278           
Flag Coverage Δ
backend 91.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One reportable checkout state defect was found in the fixed pull request. Focused tests could not be executed because frontend dependencies are not installed (vitest: not found); no unrelated issues were identified.

Reviewed head commit: 84f8642af38dff3058f64814d40ded5351159bcf

  • [P1] Switch to the created order after checkout (frontend/src/pages/subscription/checkout-dialog.tsx:75-80) — see inline comment

Comment thread frontend/src/pages/subscription/checkout-dialog.tsx
@xiaocheny214
xiaocheny214 self-requested a review October 15, 2026 13:30
@xiaocheny214
xiaocheny214 merged commit 9a5fd4f into 1024XEngineer:main Oct 15, 2026
11 checks passed

This branch was successfully deployed

1 active deployment
Preview — 84f8642a Deployed Oct 15, 2026 by vercel[bot]
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.

[Feature]: connect the existing subscription page to billing APIs

2 participants