Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bd6f4dee
authored
Sep 27, 2025
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: allow stripe promotion code
parent
e6525eea
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
2 deletions
+34
-2
controller/topup_stripe.go
+2
-1
model/option.go
+3
-0
setting/payment_stripe.go
+1
-0
web/src/components/settings/PaymentSetting.jsx
+1
-0
web/src/i18n/locales/en.json
+1
-0
web/src/i18n/locales/zh.json
+2
-1
web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx
+24
-0
No files found.
controller/topup_stripe.go
View file @
bd6f4dee
...
...
@@ -225,7 +225,8 @@ func genStripeLink(referenceId string, customerId string, email string, amount i
Quantity
:
stripe
.
Int64
(
amount
),
},
},
Mode
:
stripe
.
String
(
string
(
stripe
.
CheckoutSessionModePayment
)),
Mode
:
stripe
.
String
(
string
(
stripe
.
CheckoutSessionModePayment
)),
AllowPromotionCodes
:
stripe
.
Bool
(
setting
.
StripePromotionCodesEnabled
),
}
if
""
==
customerId
{
...
...
model/option.go
View file @
bd6f4dee
...
...
@@ -82,6 +82,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"StripeWebhookSecret"
]
=
setting
.
StripeWebhookSecret
common
.
OptionMap
[
"StripePriceId"
]
=
setting
.
StripePriceId
common
.
OptionMap
[
"StripeUnitPrice"
]
=
strconv
.
FormatFloat
(
setting
.
StripeUnitPrice
,
'f'
,
-
1
,
64
)
common
.
OptionMap
[
"StripePromotionCodesEnabled"
]
=
strconv
.
FormatBool
(
setting
.
StripePromotionCodesEnabled
)
common
.
OptionMap
[
"TopupGroupRatio"
]
=
common
.
TopupGroupRatio2JSONString
()
common
.
OptionMap
[
"Chats"
]
=
setting
.
Chats2JsonString
()
common
.
OptionMap
[
"AutoGroups"
]
=
setting
.
AutoGroups2JsonString
()
...
...
@@ -330,6 +331,8 @@ func updateOptionMap(key string, value string) (err error) {
setting
.
StripeUnitPrice
,
_
=
strconv
.
ParseFloat
(
value
,
64
)
case
"StripeMinTopUp"
:
setting
.
StripeMinTopUp
,
_
=
strconv
.
Atoi
(
value
)
case
"StripePromotionCodesEnabled"
:
setting
.
StripePromotionCodesEnabled
=
value
==
"true"
case
"TopupGroupRatio"
:
err
=
common
.
UpdateTopupGroupRatioByJSONString
(
value
)
case
"GitHubClientId"
:
...
...
setting/payment_stripe.go
View file @
bd6f4dee
...
...
@@ -5,3 +5,4 @@ var StripeWebhookSecret = ""
var
StripePriceId
=
""
var
StripeUnitPrice
=
8.0
var
StripeMinTopUp
=
1
var
StripePromotionCodesEnabled
=
false
web/src/components/settings/PaymentSetting.jsx
View file @
bd6f4dee
...
...
@@ -45,6 +45,7 @@ const PaymentSetting = () => {
StripePriceId
:
''
,
StripeUnitPrice
:
8.0
,
StripeMinTopUp
:
1
,
StripePromotionCodesEnabled
:
false
,
});
let
[
loading
,
setLoading
]
=
useState
(
false
);
...
...
web/src/i18n/locales/en.json
View file @
bd6f4dee
...
...
@@ -837,6 +837,7 @@
"确定要充值 $"
:
"Confirm to top up $"
,
"微信/支付宝 实付金额:"
:
"WeChat/Alipay actual payment amount:"
,
"Stripe 实付金额:"
:
"Stripe actual payment amount:"
,
"允许在 Stripe 支付中输入促销码"
:
"Allow entering promotion codes during Stripe checkout"
,
"支付中..."
:
"Paying"
,
"支付宝"
:
"Alipay"
,
"收益统计"
:
"Income statistics"
,
...
...
web/src/i18n/locales/zh.json
View file @
bd6f4dee
...
...
@@ -32,5 +32,6 @@
"端口配置详细说明"
:
"限制外部请求只能访问指定端口。支持单个端口(80, 443)或端口范围(8000-8999)。空列表允许所有端口。默认包含常用Web端口。"
,
"输入端口后回车,如:80 或 8000-8999"
:
"输入端口后回车,如:80 或 8000-8999"
,
"更新SSRF防护设置"
:
"更新SSRF防护设置"
,
"域名IP过滤详细说明"
:
"⚠️此功能为实验性选项,域名可能解析到多个 IPv4/IPv6 地址,若开启,请确保 IP 过滤列表覆盖这些地址,否则可能导致访问失败。"
"域名IP过滤详细说明"
:
"⚠️此功能为实验性选项,域名可能解析到多个 IPv4/IPv6 地址,若开启,请确保 IP 过滤列表覆盖这些地址,否则可能导致访问失败。"
,
"允许在 Stripe 支付中输入促销码"
:
"允许在 Stripe 支付中输入促销码"
}
web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx
View file @
bd6f4dee
...
...
@@ -45,6 +45,7 @@ export default function SettingsPaymentGateway(props) {
StripePriceId
:
''
,
StripeUnitPrice
:
8.0
,
StripeMinTopUp
:
1
,
StripePromotionCodesEnabled
:
false
,
});
const
[
originInputs
,
setOriginInputs
]
=
useState
({});
const
formApiRef
=
useRef
(
null
);
...
...
@@ -63,6 +64,10 @@ export default function SettingsPaymentGateway(props) {
props
.
options
.
StripeMinTopUp
!==
undefined
?
parseFloat
(
props
.
options
.
StripeMinTopUp
)
:
1
,
StripePromotionCodesEnabled
:
props
.
options
.
StripePromotionCodesEnabled
!==
undefined
?
props
.
options
.
StripePromotionCodesEnabled
:
false
,
};
setInputs
(
currentInputs
);
setOriginInputs
({
...
currentInputs
});
...
...
@@ -114,6 +119,16 @@ export default function SettingsPaymentGateway(props) {
value
:
inputs
.
StripeMinTopUp
.
toString
(),
});
}
if
(
originInputs
[
'StripePromotionCodesEnabled'
]
!==
inputs
.
StripePromotionCodesEnabled
&&
inputs
.
StripePromotionCodesEnabled
!==
undefined
)
{
options
.
push
({
key
:
'StripePromotionCodesEnabled'
,
value
:
inputs
.
StripePromotionCodesEnabled
?
'true'
:
'false'
,
});
}
// 发送请求
const
requestQueue
=
options
.
map
((
opt
)
=>
...
...
@@ -225,6 +240,15 @@ export default function SettingsPaymentGateway(props) {
placeholder=
{
t
(
'例如:2,就是最低充值2$'
)
}
/>
</
Col
>
<
Col
xs=
{
24
}
sm=
{
24
}
md=
{
8
}
lg=
{
8
}
xl=
{
8
}
>
<
Form
.
Switch
field=
'StripePromotionCodesEnabled'
size=
'default'
checkedText=
'|'
uncheckedText=
'〇'
label=
{
t
(
'允许在 Stripe 支付中输入促销码'
)
}
/>
</
Col
>
</
Row
>
<
Button
onClick=
{
submitStripeSetting
}
>
{
t
(
'更新 Stripe 设置'
)
}
</
Button
>
</
Form
.
Section
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment