mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-06-07 22:09:57 +00:00
💸 chore: Align subscription pricing display with global currency settings
Unify subscription price rendering to use the site-wide currency symbol/rate on the wallet and admin views. Make subscription plan currency read-only in the editor and force USD on create/update to avoid drift. Use global currency display type when creating Creem checkout payloads.
This commit is contained in:
@@ -149,6 +149,7 @@ func AdminCreateSubscriptionPlan(c *gin.Context) {
|
||||
if req.Plan.Currency == "" {
|
||||
req.Plan.Currency = "USD"
|
||||
}
|
||||
req.Plan.Currency = "USD"
|
||||
if req.Plan.DurationUnit == "" {
|
||||
req.Plan.DurationUnit = model.SubscriptionDurationMonth
|
||||
}
|
||||
@@ -215,6 +216,7 @@ func AdminUpdateSubscriptionPlan(c *gin.Context) {
|
||||
if req.Plan.Currency == "" {
|
||||
req.Plan.Currency = "USD"
|
||||
}
|
||||
req.Plan.Currency = "USD"
|
||||
if req.Plan.DurationUnit == "" {
|
||||
req.Plan.DurationUnit = model.SubscriptionDurationMonth
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/QuantumNous/new-api/common"
|
||||
"github.com/QuantumNous/new-api/model"
|
||||
"github.com/QuantumNous/new-api/setting"
|
||||
"github.com/QuantumNous/new-api/setting/operation_setting"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/thanhpk/randstr"
|
||||
)
|
||||
@@ -74,11 +75,20 @@ func SubscriptionRequestCreemPay(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Reuse Creem checkout generator by building a lightweight product reference.
|
||||
currency := "USD"
|
||||
switch operation_setting.GetGeneralSetting().QuotaDisplayType {
|
||||
case operation_setting.QuotaDisplayTypeCNY:
|
||||
currency = "CNY"
|
||||
case operation_setting.QuotaDisplayTypeUSD:
|
||||
currency = "USD"
|
||||
default:
|
||||
currency = "USD"
|
||||
}
|
||||
product := &CreemProduct{
|
||||
ProductId: plan.CreemProductId,
|
||||
Name: plan.Title,
|
||||
Price: plan.PriceAmount,
|
||||
Currency: plan.Currency,
|
||||
Currency: currency,
|
||||
Quota: 0,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user