Skip to content

feat(admin): add create-and-redeem endpoint for payment integrations#685

Open
touwaeriol wants to merge 4 commits intoWei-Shaw:mainfrom
touwaeriol:pr/admin-create-and-redeem-docs
Open

feat(admin): add create-and-redeem endpoint for payment integrations#685
touwaeriol wants to merge 4 commits intoWei-Shaw:mainfrom
touwaeriol:pr/admin-create-and-redeem-docs

Conversation

@touwaeriol
Copy link
Contributor

@touwaeriol touwaeriol commented Feb 28, 2026

背景 / Background

为 sub2api 集成外部支付系统补齐服务端充值接口与前端参数透传能力,并提供可交付的中英双语单文件 API 文档。
This PR completes backend recharge integration APIs and frontend parameter passthrough for external payment systems, with a deliverable single-file bilingual API documentation.

改动目的 / Purpose

  1. 支持支付成功后“一步创建并兑换”充值码,减少中间态与人工操作。
  2. 支持购买页自动透传当前用户标识与会话参数。
  3. 提供中英双语、可下载的集成文档。
  4. 统一“充值/订阅”入口文案与图标实现方式,减少局部硬编码。

变更内容 / What Changed

A. 核心功能(原范围) / Core Features (original scope)

中文

  • 新增后端接口:POST /api/v1/admin/redeem-codes/create-and-redeem
  • 包裹在 executeAdminIdempotentJSON 中,要求 Idempotency-Key
  • 幂等语义:
    • code + 同用户 => 200
    • code + 不同用户 => 409
  • RedeemService 支持外部传入确定性 code,用于支付订单映射
  • 购买页 URL 统一追加 query 参数(iframe 与新窗口一致):
    • user_id
    • token
    • theme
    • ui_mode=embedded

English

  • Added backend endpoint: POST /api/v1/admin/redeem-codes/create-and-redeem
  • Wrapped with executeAdminIdempotentJSON, requiring Idempotency-Key
  • Idempotency behavior:
    • same code + same user => 200
    • same code + different user => 409
  • Extended RedeemService to support caller-provided deterministic code
  • Purchase URL now appends query params consistently (iframe and new-tab):
    • user_id
    • token
    • theme
    • ui_mode=embedded

B. 本次补充优化 / Additional improvements

中文

  • ADMIN_PAYMENT_INTEGRATION_API.md 升级为中英双语单文件
  • 导航文案统一:购买订阅 -> 充值/订阅
  • 系统设置文案统一:购买订阅页面 -> 充值/订阅页面
  • /purchase 图标优化为“充值语义(卡片 + 加号)”
  • 图标实现改为复用统一图标映射(Icon.vuerechargeSubscription),不再在侧边栏局部写 SVG 路径

English

  • Upgraded ADMIN_PAYMENT_INTEGRATION_API.md to a single-file bilingual document
  • Unified nav copy: Purchase Subscription -> Recharge / Subscription
  • Unified settings copy: Purchase Subscription Page -> Recharge / Subscription Page
  • Updated /purchase icon to a recharge-oriented icon (card + plus)
  • Switched icon implementation to shared icon mapping (rechargeSubscription in Icon.vue) instead of local SVG path in sidebar

文档 / Docs

验证 / Validation

  • go test ./internal/handler/admin -run TestRedeemHandlerEndpoints -count=1
  • go test ./internal/server/routes -count=1
  • go test ./internal/service -run TestRedeem -count=1
  • pnpm --dir frontend run typecheck

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