Skip to content

feat(payment): 支持为 Epay 支付宝和微信分别配置渠道 ID - #8519

Open
consider908 wants to merge 1 commit into
QuantumNous:mainfrom
consider908:codex/epay-channel-id
Open

consider908 wants to merge 1 commit into
QuantumNous:mainfrom
consider908:codex/epay-channel-id

Conversation

@consider908

@consider908 consider908 commented Dec 1, 2026 •

Copy link
Copy Markdown

Agent: Codex 0.171.0-alpha.13.2 · model ID unknown · Codex Desktop (Windows) · 2026-12-01 UTC

Closes #8518

Request summary

在 Epay 网关里分别配置支付宝和微信渠道 ID。两项均可留空。下单时仅在所选方式配置了渠道 ID 时发送 cid。

Summary

钱包充值和订阅购买共用 newEpayOrder,在 MD5 或 RSA 签名前确定下单参数。本次代码由 AI 辅助编写。

钱包充值 / 订阅购买
  组装 Epay 下单表单
  按 type 读取渠道 ID:alipay → 支付宝,wxpay → 微信
  去除首尾空格后有值 → 加入 cid
  对最终表单签名并返回支付地址

Evidence

修改前 修改后
原 Epay 配置页 支付宝渠道 ID 为 0012,微信渠道 ID 留空
  • Before: 在 04dfcbb71,充值和订阅均调用 client.Purchase,其下单表单没有 cid。
  • After: 开发阶段运行 go test ./controller -run 'Epay|PaymentWebhook' -count=1。配置 0012 后,订单保留前导零,签名可验证。渠道 ID 为空或只含空格时,MD5 表单和签名与原 SDK 输出一致。
  • bun run test src/features/system-settings/integrations/__tests__/epay-sign-settings.test.tsx 的 4 项用例通过,覆盖保存支付宝渠道 ID 和清空微信渠道 ID。bun run typecheck 和 bun run build 通过。
  • Windows 上运行完整 go test ./controller ./setting/operation_setting -count=1 时,部分认证和审计用例在清理仍被占用的临时 audit.db 时失败。提交时沿用上述结果。

Merge Danger

Door: Two-way。清空渠道 ID 即可恢复原下单参数,无需数据库迁移。

Blast Radius: 支付。涉及 Epay 钱包充值、订阅下单和管理端配置页。

Summary by CodeRabbit

  • New Features
    • Added optional channel ID settings for Alipay and WeChat Pay in the Epay billing settings. Each value can be configured independently, and surrounding whitespace is removed when saving.
    • Epay payments and subscription payments now use the configured channel ID for the selected Alipay or WeChat Pay method. Other payment methods are unaffected.
    • Added translations for the new channel ID settings in supported languages.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Epay settings now support separate Alipay and WeChat Pay channel IDs. Top-up and subscription order creation add the configured ID for the selected payment method before signing the order.

Changes

Epay channel IDs

Layer / File(s) Summary
Channel ID settings contract
setting/operation_setting/payment_setting.go
Adds separate Alipay and WeChat Pay channel ID settings and an accessor that trims values and returns the ID for the selected method.
Payment settings interface
web/src/features/system-settings/billing/*, web/src/features/system-settings/integrations/payment-settings-section.tsx, web/src/features/system-settings/integrations/__tests__/epay-sign-settings.test.tsx, web/src/features/system-settings/types.ts, web/src/i18n/locales/*.json
Adds optional channel ID inputs and save handling, includes the fields in billing settings, and adds or relocates locale entries. The test checks trimmed Alipay input and clearing the WeChat Pay ID.
Epay order construction
controller/topup.go, controller/subscription_payment_epay.go, controller/payment_webhook_availability_test.go
Routes top-up and subscription orders through newEpayOrder. The helper adds a configured channel ID before signing and selects the standard or RSA purchase path. Tests cover channel selection and RSA mode.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant RequestEpay
  participant SubscriptionRequestEpay
  participant newEpayOrder
  participant EpayChannelID
  participant EpayGateway
  RequestEpay->>newEpayOrder: Create top-up order
  SubscriptionRequestEpay->>newEpayOrder: Create subscription order
  newEpayOrder->>EpayChannelID: Read selected payment method channel ID
  EpayChannelID-->>newEpayOrder: Return trimmed ID or empty value
  newEpayOrder->>EpayGateway: Submit signed order through selected purchase path
Loading

Possibly related PRs

  • QuantumNous/new-api#8291: Changes Epay signing modes and settings, which interact with the signed order parameters and payment settings contract.

Suggested reviewers: calcium-ion, t0ng7u, quentinhsu

Merge Risk: Minimal · up to 0fa08

This change adds optional Alipay and WeChat Pay channel IDs for Epay orders on wallet top-ups and subscriptions. Blank values leave existing orders unchanged. No merge-blocking risk was found in the reviewed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title is in Chinese and says the PR adds support for configuring separate Epay channel IDs for Alipay and WeChat Pay. The changeset does this: it adds EpayAlipayChannelID and EpayWxpayChannelID se…
Linked Issues check Passed [#8518] requires separate optional Epay channel IDs for alipay and wxpay, sent as cid on wallet top-ups and subscription orders when set, and omitted when blank. The reviewed diff from merge base 04df…
Out of Scope Changes check Passed The core changes map directly to #8518: the settings fields, EpayChannelID, newEpayOrder, the subscription and top-up call sites, the settings UI, and related tests. The locale files (en, fr, ja, ru, …
Full details: Title check

Explanation

The title is in Chinese and says the PR adds support for configuring separate Epay channel IDs for Alipay and WeChat Pay. The changeset does this: it adds EpayAlipayChannelID and EpayWxpayChannelID settings, a EpayChannelID helper, a newEpayOrder helper that adds cid only when set, and the matching settings UI, types, and locale strings. The title is concise, specific, and names the primary change.

Full details: Linked Issues check

Explanation

[#8518] requires separate optional Epay channel IDs for alipay and wxpay, sent as cid on wallet top-ups and subscription orders when set, and omitted when blank. The reviewed diff from merge base 04dfcbb to head 0fa0873 implements this as follows:

  • setting/operation_setting/payment_setting.go adds EpayAlipayChannelID and EpayWxpayChannelID. EpayChannelID(paymentType) trims whitespace and returns the matching ID for "alipay" or "wxpay", or an empty string otherwise.
  • controller/topup.go adds newEpayOrder. It adds cid to the signed parameters only when EpayChannelID returns a non-empty value. RequestEpay calls this helper instead of client.Purchase.
  • controller/subscription_payment_epay.go routes SubscriptionRequestEpay through newEpayOrder, so wallet top-ups and subscriptions share the same logic.
  • The web settings form (payment-settings-section.tsx, section-registry.tsx, billing/index.tsx, types.ts) adds and saves both fields. Blank values are allowed.
  • Go tests cover channel selection, trimming, and blank or custom-method cases. A frontend test covers saving the Alipay ID and clearing the WeChat Pay ID.
    The summary establishes this behavior. I did not run the tests. Test results cited in the PR description are author-reported.
Full details: Out of Scope Changes check

Explanation

The core changes map directly to #8518: the settings fields, EpayChannelID, newEpayOrder, the subscription and top-up call sites, the settings UI, and related tests. The locale files (en, fr, ja, ru, vi, zh-TW, zh) add the two channel-ID labels and reorder existing entries such as "Plugin routes", "{{on}} of {{total}} on", and the trailing comma after "Zoom". The reordering touches keys unrelated to this feature. It changes no runtime behavior. It appears to be a side effect of locale file maintenance, not a functional change. The removal of the unused strconv import is a required cleanup.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the channel names,
Alipay, WeChat, both have lanes.
A trimmed ID joins the signed request,
Or none is sent when left at rest.
The order hops along its way,
Then nibbles clover to end the day.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6f306d00-04de-494b-9021-32871bfec02e
Commits

Reviewing files that changed from the base of the PR and between 04dfcbb and 0fa0873.

Files selected for processing: 16

  • controller/payment_webhook_availability_test.go
  • controller/subscription_payment_epay.go
  • controller/topup.go
  • setting/operation_setting/payment_setting.go
  • web/src/features/system-settings/billing/index.tsx
  • web/src/features/system-settings/billing/section-registry.tsx
  • web/src/features/system-settings/integrations/__tests__/epay-sign-settings.test.tsx
  • web/src/features/system-settings/integrations/payment-settings-section.tsx
  • web/src/features/system-settings/types.ts
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/ru.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/zh-TW.json
  • web/src/i18n/locales/zh.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
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.

功能请求:为 Epay 支付宝和微信下单分别指定渠道 ID

1 participant