fix(payment): localize checkout errors - #4841
Conversation
- Replace user-facing payment and top-up error strings with existing i18n keys.\n- Add missing payment and top-up message keys and locale entries.\n- Preserve payment flow, callback, and order creation behavior.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughReplaces hardcoded Chinese payment/top-up error messages with i18n-based localized responses, adds new i18n keys/translations, introduces centralized top-up i18n helpers, and updates subscription and top-up payment handlers (Creem, Epay, Stripe, Waffo, Waffo Pancake) to use the new keys. ChangesPayment and Top-up I18n Conversion
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
controller/topup_creem.go (1)
9-9: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winReplace direct
encoding/jsonwithcommonwrappers.This file violates the coding guideline requiring all JSON operations to use
common.Marshal()andcommon.Unmarshal(). The directencoding/jsonimport and four call sites (lines 80, 406, 447, and the import on line 9) must be updated.Proposed fix
import ( "bytes" "context" "crypto/hmac" "crypto/sha256" "encoding/hex" - "encoding/json" "errors" "fmt" "github.com/QuantumNous/new-api/common" "github.com/QuantumNous/new-api/i18n" @@ - err := json.Unmarshal([]byte(setting.CreemProducts), &products) + err := common.Unmarshal([]byte(setting.CreemProducts), &products) @@ - jsonData, err := json.Marshal(requestData) + jsonData, err := common.Marshal(requestData) @@ - err = json.Unmarshal(body, &checkoutResp) + err = common.Unmarshal(body, &checkoutResp)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@controller/topup_creem.go` at line 9, Replace the direct import of "encoding/json" in topup_creem.go with the project common package and update all JSON calls to use the wrappers: change json.Marshal(...) to common.Marshal(...) and json.Unmarshal(...) to common.Unmarshal(...). Specifically update the three call sites that currently use json (the marshal/unmarshal usages referenced in the review) and remove the unused "encoding/json" import; ensure error handling and variable types remain the same after swapping to common.Marshal/common.Unmarshal.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@controller/topup_creem.go`:
- Line 9: Replace the direct import of "encoding/json" in topup_creem.go with
the project common package and update all JSON calls to use the wrappers: change
json.Marshal(...) to common.Marshal(...) and json.Unmarshal(...) to
common.Unmarshal(...). Specifically update the three call sites that currently
use json (the marshal/unmarshal usages referenced in the review) and remove the
unused "encoding/json" import; ensure error handling and variable types remain
the same after swapping to common.Marshal/common.Unmarshal.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1234dfd4-c8a5-4bde-b276-69703d6cbaeb
📒 Files selected for processing (12)
controller/subscription_payment_creem.gocontroller/subscription_payment_epay.gocontroller/subscription_payment_stripe.gocontroller/topup.gocontroller/topup_creem.gocontroller/topup_stripe.gocontroller/topup_waffo.gocontroller/topup_waffo_pancake.goi18n/keys.goi18n/locales/en.yamli18n/locales/zh-CN.yamli18n/locales/zh-TW.yaml
- Replace direct encoding/json calls in Creem top-up flow. - Keep behavior unchanged while following common JSON helpers.
- Merge QuantumNous/new-api main into the payment checkout i18n PR branch. - Resolve Waffo Pancake checkout conflict while preserving localized errors.
51fdfc5 to
2b6f1df
Compare
变更描述 / Description
将 payment / topup / subscription checkout 链路中普通用户会直接看到的中文错误文案接入现有 i18n,包括参数错误、支付方式不存在、套餐未启用、金额过低、未配置 webhook/price/product、创建订单失败、拉起支付失败等。
这个 PR 只替换用户可见响应和补充对应 locale key,不改变支付提供方选择、订单创建、回调地址、支付链接生成或其他支付流程逻辑。
变更类型 / Type of change
关联任务 / Related Issue
提交前检查项 / Checklist
运行证明 / Proof of Work