Skip to content

Show Creem webhook callback URL - #3241

Closed
asdv23 wants to merge 5393 commits into
QuantumNous:mainfrom
qi-dao:codex/creem-webhook-readonly
Closed

Show Creem webhook callback URL#3241
asdv23 wants to merge 5393 commits into
QuantumNous:mainfrom
qi-dao:codex/creem-webhook-readonly

Conversation

@asdv23

@asdv23 asdv23 commented Mar 13, 2026

Copy link
Copy Markdown

Summary

  • add a payment webhook URL helper with focused tests
  • show the Creem webhook callback URL in the settings page
  • localize the webhook label and use a caller-provided fallback base label

Test Plan

  • node --test web/src/helpers/paymentWebhook.test.mjs
  • npx eslint src/helpers/paymentWebhook.js src/helpers/paymentWebhook.test.mjs src/pages/Setting/Payment/SettingsPaymentGatewayCreem.jsx

Summary by CodeRabbit

  • New Features

    • Added webhook URL functionality to payment gateway settings, with automatic generation and fallback handling for different server configurations.
    • Webhook URL is now displayed in the Creem payment settings interface.
  • Localization

    • Added webhook label translations for English, French, Japanese, Russian, Vietnamese, Simplified Chinese, and Traditional Chinese.
  • Tests

    • Added comprehensive test coverage for webhook URL generation with various configuration scenarios.

Calcium-Ion and others added 30 commits February 6, 2026 16:16
🔒 fix(security): sanitize AI-generated HTML to prevent XSS in playground
…idation

- Add configurable per-user token creation limit (max_user_tokens)
- Sanitize search input patterns to prevent expensive queries
- Add per-user search rate limiting (by user ID)
- Add pagination to search endpoint with strict page size cap
- Skip empty search fields instead of matching nothing
- Hide internal errors from API responses
- Fix Interface2String float64 formatting causing config parse failures
- Add float-string fallback in config system for int/uint fields
fix: harden token search with pagination, rate limiting and input validation
- Change ESCAPE character from '\' to '!' for compatibility with MySQL/PostgreSQL/SQLite
- Adjust sanitization logic to escape '!' and '_' correctly, improving input validation for search queries
fix: /v1/chat/completions -> /v1/responses json_schema
将散落在多个文件中的预扣费/结算/退款逻辑抽象为统一的 BillingSession 生命周期管理:

- 新增 BillingSettler 接口 (relay/common/billing.go) 避免循环引用
- 新增 FundingSource 接口 + WalletFunding / SubscriptionFunding 实现 (service/funding_source.go)
- 新增 BillingSession 封装预扣/结算/退款原子操作 (service/billing_session.go)
- 新增 SettleBilling 统一结算辅助函数,替换各 handler 中的 quotaDelta 模式
- 重写 PreConsumeBilling 为 BillingSession 工厂入口
- controller/relay.go 退款守卫改用 BillingSession.Refund()

修复的 Bug:
- 令牌额度泄漏:PreConsumeTokenQuota 成功但 DecreaseUserQuota 失败时未回滚
- 订阅退款遗漏:FinalPreConsumedQuota=0 但 SubscriptionPreConsumed>0 时跳过退款
- 订阅多扣费:subConsume 强制为 1 但 FinalPreConsumedQuota 不同步
- 退款路径不统一:钱包/订阅退款逻辑现统一由 FundingSource.Refund 分派
- Settle 部分失败保护:新增 fundingSettled 标记,资金来源提交后
  令牌调整失败不再导致 Refund 误退已结算的资金
- 订阅多扣费修复:trySubscription 传 subConsume 而非 preConsumedQuota
  给 preConsume,保证三者(amount/preConsume/FinalPreConsumedQuota)一致
- 令牌回滚错误记录:preConsume 中 funding 失败时令牌回滚错误不再丢弃
- 移除钱包路径死代码:用户额度不足的 strings.Contains 匹配不可能命中
- WalletFunding.Refund 不重试:IncreaseUserQuota 非幂等,重试会多退
…e recharge card tabs

- Defaulting to subscriptions when available and avoiding initial flash when no plans exist.
- Adjust the wide-screen layout to place wallet and invite sections side by side, simplify the subscription header and controls, and add padding to prevent card borders from clipping.
- Update related i18n strings by adding the new tab label and removing the obsolete subscription blurb.
…iption-card-when-no-plans

✨ refactor(wallet): Top-up layout to embed subscription plans into the recharge card tabs
…-session

refactor: 抽象统一计费会话 BillingSession
Add a lightweight active-subscription check to skip subscription pre-consume when none exist, reducing unnecessary transactions and locks. In the subscription UI, disable subscription-first options when no active plan is available, show the effective fallback to wallet with a clear notice, and distinguish “invalidated” from “expired” states. Update i18n strings across supported locales to reflect the new messages and status labels.
Aligns the error variable types in the subscription-first path so that quota fallback checks use the correct NewAPIError.
This prevents build failures and preserves the intended wallet fallback when subscription pre-consume returns an insufficient quota error.
Routes quota alerts through a subscription-specific check when billing from subscriptions, preventing wallet-based thresholds from triggering false warnings.
Updates the notification settings description and localization keys to clarify that both wallet and subscription balances are monitored.
…n-quota-notify

🔔 feat: Add subscription-aware quota notifications and update UI copy
…-preference-fallback

✨ chore: Improve subscription billing fallback and UI states
…tumNous#2881)

当上游为 AWS Bedrock 时,message_delta 的 usage 可能缺少 input_tokens、
cache_creation_input_tokens、cache_read_input_tokens 等字段,导致与原生
Anthropic 格式不一致。从 message_start 积累的 claudeInfo 中补全这些字段后
重新序列化,确保客户端收到一致的 usage 格式。
Modified the formatUserLogs function to include a startIdx parameter, allowing for more flexible log ID assignment. Updated calls to this function in GetLogByTokenId and GetUserLogs to pass the appropriate starting index.
pigletfly and others added 26 commits March 6, 2026 15:44
…es-body-no-retry

fix(relay): skip retries for bad response body errors
Keep the model pricing editor wording aligned with the new price-based UI while exposing cache, image, and audio pricing in the marketplace so users can see the full configured pricing model.
Introduce a billing display mode feature allowing users to toggle between price and ratio views. Update relevant components and hooks to support this new functionality, ensuring consistent pricing information is displayed across the application.
Add siteDisplayType prop across various pricing components to conditionally render pricing information based on the selected display type. This update enhances the user experience by ensuring that pricing details are accurately represented according to the chosen display mode, particularly for token-based views.
为渠道参数覆盖可视化规则提供拖拽排序支持
…4f8a4248b0ab3b03ba703796ea3

fix: kling risk fail return openAIVideo error
…ride-beta-header-append

feat:support $keep_only_declared and deduped $append for header override
chore: update model lists for frequently used channels
@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a payment webhook URL helper function that constructs normalized URLs for payment providers and integrates it into the Creem payment gateway settings UI. Includes unit tests and translation entries across six locales for the new "Webhook" label.

Changes

Cohort / File(s) Summary
Webhook URL Helper
web/src/helpers/paymentWebhook.js, web/src/helpers/paymentWebhook.test.mjs
New utility function getPaymentWebhookUrl() that normalizes server addresses, handles fallback labels, and constructs standardized webhook URLs. Comprehensive unit tests verify URL construction, fallback logic, trailing slash normalization, and relative path defaults.
Localization Entries
web/src/i18n/locales/en.json, fr.json, ja.json, ru.json, vi.json, zh-CN.json, zh-TW.json
Added translation entry for "Webhook 填:" label across 7 locale files with localized equivalents (e.g., "Webhook:" in English, "Webhook :" in French).
Payment Gateway Settings UI
web/src/pages/Setting/Payment/SettingsPaymentGatewayCreem.jsx
Integrated webhook URL helper; now calls getPaymentWebhookUrl() with server address and fallback label, then displays the computed webhook URL in a Banner component within the Creem settings form.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • 新增 creem 支付 #1823 — Implements Creem payment gateway endpoints and settings component; this PR adds the webhook URL helper and display that complements the Creem integration foundation.

Suggested reviewers

  • seefs001

Poem

🐰 A helper hops to build the hook,
With fallback charm and tested look,
Webhooks now dance in seven tongues,
While settings sing of URLs strung!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: adding display of the Creem webhook callback URL on the settings page, which is the primary purpose of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/i18n/locales/vi.json`:
- Line 2667: The Vietnamese translation for the key "Webhook 填:" should preserve
the "fill in" action to match other prompts; update the value for the string
"Webhook 填:" to a consistent phrase such as "Điền Webhook:" or "Điền vào
Webhook:" so it aligns with existing "Điền …" prompts in the locale file.

In `@web/src/i18n/locales/zh-TW.json`:
- Line 1928: Replace the current zh-TW translation value "Webhook 填:" with a
neutral, read-only label such as "Webhook:" (or "Webhook(只讀):" if you want to
explicitly indicate read-only); locate the "Webhook 填:" entry in the zh-TW.json
file and update the value accordingly so the displayed callback URL no longer
implies user input.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 92033ca6-34f4-4819-8704-6110784e6820

📥 Commits

Reviewing files that changed from the base of the PR and between 4e1b05e and 0079b8f.

📒 Files selected for processing (10)
  • web/src/helpers/paymentWebhook.js
  • web/src/helpers/paymentWebhook.test.mjs
  • 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-CN.json
  • web/src/i18n/locales/zh-TW.json
  • web/src/pages/Setting/Payment/SettingsPaymentGatewayCreem.jsx

Comment thread web/src/i18n/locales/vi.json
Comment thread web/src/i18n/locales/zh-TW.json
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.