Skip to content

feat: allow stripe promotion code - #1887

Merged
seefs001 merged 79 commits into
QuantumNous:alphafrom
seefs001:fix/stripe
Sep 27, 2025
Merged

feat: allow stripe promotion code #1887
seefs001 merged 79 commits into
QuantumNous:alphafrom
seefs001:fix/stripe

Conversation

@seefs001

@seefs001 seefs001 commented Sep 27, 2025

Copy link
Copy Markdown
Collaborator

#1869

Summary by CodeRabbit

  • New Features

    • Added a toggle in Payment Settings to allow entering promotion codes during Stripe checkout.
    • Stripe checkout now supports promotion code entry when this option is enabled.
  • Localization

    • Added English and Chinese translations for the new Stripe promotion codes setting.

heimoshuiyu and others added 30 commits September 11, 2025 10:34
feat: 支持即梦视频3.0,支持文生图, 图生图, 首尾帧生图
fix: openai responses api 未统计图像生成调用计费
fix: VolcEngine渠道-图片生成 API-渠道测试报错
Unify the setup initialization endpoint’s error contract to match the rest
of the project and keep the frontend unchanged.

Changes
- controller/setup.go: Return HTTP 200 with {success:false, message} for all
  predictable errors in POST /api/setup, including:
  - already initialized
  - invalid payload
  - username too long
  - password mismatch
  - password too short
  - password hashing failure
  - root user creation failure
  - option persistence failures (SelfUseModeEnabled, DemoSiteEnabled)
  - setup record creation failure
- web/src/components/setup/SetupWizard.jsx: Restore catch handler to the
  previous generic toast (frontend logic unchanged).
- web/src/helpers/utils.jsx: Restore the original showError implementation
  (no Axios response.data parsing required).

Why
- Keep API behavior consistent across endpoints so the UI can rely on the
  success flag and message in the normal .then() flow instead of falling
  into Axios 4xx errors that only show a generic "400".

Impact
- UI now displays specific server messages during initialization without
  frontend adaptations.
- Note: clients relying solely on HTTP status codes for error handling
  should inspect the JSON body (success/message) instead.

No changes to the happy path; initialization success responses are unchanged.
🛠️ fix: Align setup API errors to HTTP 200 with {success:false, message}
- Added useRef to manage dropdown positioning in UserArea component.
- Wrapped Dropdown in a div with a ref to ensure correct popup container.
- Minor adjustments to maintain existing functionality and styling.
# Conflicts:
#	service/cf_worker.go
feat: implement SSRF protection settings and update related references
seefs001 and others added 21 commits September 22, 2025 12:56
…nd-seperator

feat: add thousand separators to token display in dashboard
fix(UserArea): Enhance UserArea dropdown positioning with useRef
feat: add jsconfig.json and configure path aliases
feat: add date range preset constants and use them in the log filter
feat: 新增支持目前已发布的amazon nova model
fix: add missing fields to Gemini request
…el-button

feat: `获取模型列表`按钮白名单
fix: 修复多行代码复制换行丢失问题 & 优化API参数处理#1828
@coderabbitai

coderabbitai Bot commented Sep 27, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a configurable Stripe promotion-codes toggle end-to-end: new setting variable, option map wiring, controller enabling AllowPromotionCodes in Stripe Checkout sessions, and UI controls plus i18n entries to expose the toggle.

Changes

Cohort / File(s) Summary
Stripe checkout controller
controller/topup_stripe.go
Passes AllowPromotionCodes to Stripe CheckoutSessionParams, bound to setting.StripePromotionCodesEnabled.
Settings option map (backend)
model/option.go
Adds StripePromotionCodesEnabled to InitOptionMap and updateOptionMap for initialization and runtime updates.
Stripe settings variable (backend)
setting/payment_stripe.go
Introduces global StripePromotionCodesEnabled bool (default false).
Frontend settings components
web/src/components/settings/PaymentSetting.jsx, web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx
Adds state, form Switch, and submit logic for StripePromotionCodesEnabled.
i18n locales
web/src/i18n/locales/en.json, web/src/i18n/locales/zh.json
Adds translation key/value for “Allow entering promotion codes during Stripe checkout”; minor JSON punctuation fix in zh.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant FE as Frontend (Settings UI)
  participant API as API Server
  participant C as Controller (genStripeLink)
  participant S as Stripe

  rect rgb(240,248,255)
    Note over FE,API: Configure setting
    U->>FE: Toggle "Allow promotion codes"
    FE->>API: PUT /options { StripePromotionCodesEnabled: true|false }
    API->>API: updateOptionMap parses and saves
    API-->>FE: 200 OK
  end

  rect rgb(245,255,250)
    Note over U,S: Checkout flow
    U->>FE: Start Stripe top-up
    FE->>API: POST /topup/stripe/session
    API->>C: genStripeLink()
    C->>C: Read setting.StripePromotionCodesEnabled
    C->>S: Create Checkout Session { AllowPromotionCodes: bool }
    S-->>C: Session URL
    C-->>FE: Session URL
    FE-->>U: Redirect to Stripe Checkout
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • creamlike1024
  • Calcium-Ion

Poem

A rabbit flips a promo switch—how nice!
Stripe now accepts those secret price slices.
From UI to server, the path is clean,
A toggle hops through every scene.
Boop the code, redeem delight—
Discounts dance in checkout’s light. 🐇💳

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly summarizes the primary change of enabling Stripe promotion codes and follows the conventional “feat:” prefix. It directly relates to the core functionality added in the changeset without including extraneous details or jargon. The phrasing is clear, concise, and specific enough for teammates scanning the history to grasp the purpose at a glance. Therefore, it meets the criteria for an effective pull request title.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5197d87 and ad72500.

📒 Files selected for processing (7)
  • controller/topup_stripe.go (1 hunks)
  • model/option.go (2 hunks)
  • setting/payment_stripe.go (1 hunks)
  • web/src/components/settings/PaymentSetting.jsx (1 hunks)
  • web/src/i18n/locales/en.json (1 hunks)
  • web/src/i18n/locales/zh.json (1 hunks)
  • web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
controller/topup_stripe.go (1)
setting/payment_stripe.go (1)
  • StripePromotionCodesEnabled (8-8)
model/option.go (2)
common/constants.go (1)
  • OptionMap (36-36)
setting/payment_stripe.go (1)
  • StripePromotionCodesEnabled (8-8)
web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx (1)
web/src/components/settings/PaymentSetting.jsx (1)
  • inputs (30-49)

Comment on lines +67 to +70
StripePromotionCodesEnabled:
props.options.StripePromotionCodesEnabled !== undefined
? props.options.StripePromotionCodesEnabled
: false,

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.

⚠️ Potential issue | 🔴 Critical

Convert StripePromotionCodesEnabled to a boolean before storing

props.options.StripePromotionCodesEnabled comes back as the string 'true'/'false'. Storing that string causes the switch to render as enabled (any non-empty string is truthy) and, worse, always serializes back to 'true' on submit. We end up flipping the setting on for anyone who tries to leave it off. Parse the incoming option into a real boolean before placing it in state/origin.

-        StripePromotionCodesEnabled:
-          props.options.StripePromotionCodesEnabled !== undefined
-            ? props.options.StripePromotionCodesEnabled
-            : false,
+        StripePromotionCodesEnabled:
+          props.options.StripePromotionCodesEnabled !== undefined
+            ? props.options.StripePromotionCodesEnabled === true ||
+              props.options.StripePromotionCodesEnabled === 'true'
+            : false,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
StripePromotionCodesEnabled:
props.options.StripePromotionCodesEnabled !== undefined
? props.options.StripePromotionCodesEnabled
: false,
StripePromotionCodesEnabled:
props.options.StripePromotionCodesEnabled !== undefined
? props.options.StripePromotionCodesEnabled === true ||
props.options.StripePromotionCodesEnabled === 'true'
: false,
🤖 Prompt for AI Agents
In web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx around lines
67 to 70, StripePromotionCodesEnabled is being set from props.options as a
string ('true'/'false') which results in incorrect truthy behavior and wrong
serialization; convert the incoming value to a real boolean before placing it in
state/origin (e.g., check for strict boolean true or compare the string to
'true' or use JSON.parse-like conversion) so the switch renders correctly and
submits the correct boolean value.

@seefs001
seefs001 changed the base branch from main to alpha September 27, 2025 07:46
@seefs001
seefs001 merged commit a498da7 into QuantumNous:alpha Sep 27, 2025
1 check passed
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
jiutubaba pushed a commit to jiutubaba/fx-api that referenced this pull request May 17, 2026
The hardcoded codex CLI version (0.104.0) causes upstream rejection
when using gpt-5.5 with compact, as the server treats the request
as an outdated client and returns 400/502.

Update codexCLIVersion, codexCLIUserAgent, and openAICodexProbeVersion
to 0.125.0 to match the current Codex CLI release.

Fixes QuantumNous#1933, QuantumNous#1887, QuantumNous#1865
Related: QuantumNous#1609, QuantumNous#1298, QuantumNous#849
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.

10 participants