Skip to content

fix(wallet): read topup gateway flags from topupInfo instead of status#4599

Open
ImogeneOctaviap794 wants to merge 1 commit intoQuantumNous:mainfrom
ImogeneOctaviap794:fix/subscription-payment-source
Open

fix(wallet): read topup gateway flags from topupInfo instead of status#4599
ImogeneOctaviap794 wants to merge 1 commit intoQuantumNous:mainfrom
ImogeneOctaviap794:fix/subscription-payment-source

Conversation

@ImogeneOctaviap794
Copy link
Copy Markdown

@ImogeneOctaviap794 ImogeneOctaviap794 commented May 3, 2026

📝 变更描述 / Description

修复新前端(default frontend)订阅卡片中支付网关判断错误的 bug。

问题表现

管理员已正确配置在线支付(如易支付 EPay)后,余额充值正常工作,但点击订阅套餐"立即订阅"时,购买弹窗仍提示:

管理员未开启在线支付功能,请联系管理员配置。

经典前端(web/classic)和同一页面的余额充值卡片均不受影响,仅新前端的订阅卡片有此问题。

根因

web/default/src/features/wallet/components/subscription-plans-card.tsxenableStripeenableOnlineTopUp 错误地从 status?./api/status 接口)读取,但这两个开关 仅存在于 /api/user/topup/info(即组件已通过 props 传入的 topupInfo);/api/status 根本不暴露这两个字段。

// before
const enableStripe      = !!status?.enable_stripe_topup    // 永远 undefined
const enableCreem       = !!topupInfo?.enable_creem_topup  // 已正确
const enableOnlineTopUp = !!status?.enable_online_topup    // 永远 undefined

因此 hasStripehasEpay 永远为 false,购买弹窗判定 hasAnyPayment === false,展示"未开启"横幅,唯独 Creem(已正确从 topupInfo 读取)能用。

修复

将这两行的来源从 status?. 改为 topupInfo?.,与同文件内 enableCreem、同页面的 recharge-form-card.tsxtopupInfo?.enable_online_topup || topupInfo?.enable_stripe_topup)以及经典前端 web/classicSubscriptionPlansCard / SubscriptionPurchaseModal 行为完全一致。同时移除随之不再使用的 useStatus 导入。

- const enableStripe      = !!status?.enable_stripe_topup
+ const enableStripe      = !!topupInfo?.enable_stripe_topup
  const enableCreem       = !!topupInfo?.enable_creem_topup
- const enableOnlineTopUp = !!status?.enable_online_topup
+ const enableOnlineTopUp = !!topupInfo?.enable_online_topup

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动(仅 1 个文件 +2/-4)。
  • 本地验证: 已基于 v1.0.0-rc.2 在生产环境构建镜像并部署,复现 bug → 应用修复 → 订阅购买弹窗的易支付选择框与"支付"按钮正常出现,已验证通过。
  • 安全合规: 代码中无敏感凭据,符合项目代码规范,无类型与 lint 问题引入。

📸 运行证明 / Proof of Work

复现步骤

  1. 在管理员后台仅启用易支付(EPay),不启用 Stripe / Creem。
  2. 创建任一订阅套餐(无需配置 stripe_price_id / creem_product_id)。
  3. 用普通用户登录 → 钱包页 → 订阅 Tab → 点击"立即订阅"。
  4. 修复前:弹窗显示"管理员未开启在线支付功能,请联系管理员配置"。
  5. 修复后:弹窗正常显示"选择支付方式"下拉框 + "支付"按钮,可发起易支付。

对照参考(证明修复方向正确)

  • 同一页面 web/default/src/features/wallet/components/recharge-form-card.tsx:113-117 已正确从 topupInfo 读取相同两个字段。
  • 经典前端 web/classic/src/components/topup/index.jsx:636-637 同样从 data.enable_*_topup(即 topup-info 接口)读取。
  • 后端 controller/user/topup.goGetUserTopUpInfo 返回 enable_online_topup / enable_stripe_topup / enable_creem_topup/api/status 接口不暴露这些字段。

Diff 大小

仅一个文件,+2/-4 行:web/default/src/features/wallet/components/subscription-plans-card.tsx

Summary by CodeRabbit

  • Refactor
    • Updated the subscription plans component to streamline how feature availability flags are determined, with no impact to user-facing functionality.

The /api/status endpoint does not expose enable_stripe_topup or
enable_online_topup; these flags only exist on /api/user/topup/info
(which is already passed in as the topupInfo prop).

As a result, on the subscription plans card the EPay/Stripe payment
buttons were always hidden and users saw 'Online payment is not enabled'
even when the admin had configured EPay (only Creem worked, since it
already read from topupInfo). The classic frontend and the wallet
recharge form on the same page already read these flags from topupInfo,
so this aligns subscription with that behavior.

Also drop the now-unused useStatus import.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 58e7ca9f-1cbe-46b3-9b8b-3fcb556a8bb8

📥 Commits

Reviewing files that changed from the base of the PR and between dac55f0 and c312f29.

📒 Files selected for processing (1)
  • web/default/src/features/wallet/components/subscription-plans-card.tsx

Walkthrough

The SubscriptionPlansCard component no longer imports the useStatus hook. Feature-availability flags (enableStripe, enableCreem, enableOnlineTopUp) are now derived from topupInfo instead of status, reducing coupling to the status hook.

Changes

Feature Flag Sourcing Refactor

Layer / File(s) Summary
Hook Dependency Removal
web/default/src/features/wallet/components/subscription-plans-card.tsx
Removed useStatus import (lines 3–6).
Feature Flag Derivation
web/default/src/features/wallet/components/subscription-plans-card.tsx
Refactored lines 62–81 to source enableStripe, enableCreem, and enableOnlineTopUp from topupInfo fields instead of the status hook.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • Calcium-Ion

Poem

🐰 A hook we say goodbye to, with flags so fine,
From status they leap to topupInfo's design,
One component, cleaner, a simpler dance,
No useStatus needed, a lighter prance!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: reading topup gateway flags from topupInfo instead of status in the subscription-plans-card component.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

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