From 82016579db2a808a6d65381d3d4aa71be9718201 Mon Sep 17 00:00:00 2001 From: xiezhouwei Date: Tue, 9 Jun 2026 14:35:37 +0800 Subject: [PATCH] fix(payment): resolve payment settings save logic and enable persistence - Fix Bug 1: Always save all provider-specific fields regardless of currently selected provider in dropdown, preventing data loss when switching between Alipay/WeChat/ePay/Yipay configurations - Fix Bug 2: Add EpayEnabled/YipayEnabled backend Go variables and OptionMap entries so enable/disable checkboxes persist across page reloads - Fix white screen crash by wrapping orphan Col elements in proper Row - Add EpayEnabled/YipayEnabled to PaymentSetting.jsx initial state - Remove duplicate payment card imports for Stripe/Creem/Waffo/Alipay/Wechat --- $null | 1 + model/option.go | 6 + setting/operation_setting/payment_setting.go | 2 + .../components/settings/PaymentSetting.jsx | 34 +- web/src/components/topup/RechargeCard.jsx | 32 +- web/src/components/topup/index.jsx | 30 +- .../topup/modals/PaymentMethodSelectModal.jsx | 10 +- .../Payment/SettingsPaymentGateway.jsx | 448 +++++++++--------- 8 files changed, 277 insertions(+), 286 deletions(-) create mode 100644 $null diff --git a/$null b/$null new file mode 100644 index 0000000..6e4b3b7 --- /dev/null +++ b/$null @@ -0,0 +1 @@ +ERROR: The process "main.exe" not found. diff --git a/model/option.go b/model/option.go index f65a4ff..a0ec28a 100644 --- a/model/option.go +++ b/model/option.go @@ -102,6 +102,8 @@ func InitOptionMap() { common.OptionMap["YipayReturnUrl"] = operation_setting.YipayReturnUrl common.OptionMap["YipayRequestURL"] = operation_setting.YipayRequestURL common.OptionMap["YipayChannelExtra"] = operation_setting.YipayChannelExtra + common.OptionMap["EpayEnabled"] = strconv.FormatBool(operation_setting.EpayEnabled) + common.OptionMap["YipayEnabled"] = strconv.FormatBool(operation_setting.YipayEnabled) common.OptionMap["Price"] = strconv.FormatFloat(operation_setting.Price, 'f', -1, 64) common.OptionMap["USDExchangeRate"] = strconv.FormatFloat(operation_setting.USDExchangeRate, 'f', -1, 64) common.OptionMap["MinTopUp"] = strconv.Itoa(operation_setting.MinTopUp) @@ -495,6 +497,10 @@ func updateOptionMap(key string, value string) (err error) { case "YipayChannelExtra": operation_setting.YipayChannelExtra = strings.TrimSpace(value) common.OptionMap[key] = operation_setting.YipayChannelExtra + case "EpayEnabled": + operation_setting.EpayEnabled = value == "true" + case "YipayEnabled": + operation_setting.YipayEnabled = value == "true" case "Price": operation_setting.Price, _ = strconv.ParseFloat(value, 64) case "USDExchangeRate": diff --git a/setting/operation_setting/payment_setting.go b/setting/operation_setting/payment_setting.go index 765c5e9..0b0fcc4 100644 --- a/setting/operation_setting/payment_setting.go +++ b/setting/operation_setting/payment_setting.go @@ -8,6 +8,8 @@ var CustomCallbackAddress = "" var EpayId = "" var EpayKey = "" var YipayAppSecret = "" +var EpayEnabled = false +var YipayEnabled = false var OnlinePayProvider = "yipay" var Price = 7.3 var MinTopUp = 1 diff --git a/web/src/components/settings/PaymentSetting.jsx b/web/src/components/settings/PaymentSetting.jsx index 92a11d3..11a808a 100644 --- a/web/src/components/settings/PaymentSetting.jsx +++ b/web/src/components/settings/PaymentSetting.jsx @@ -21,11 +21,7 @@ import React, { useEffect, useState } from "react"; import { Card, Spin } from "@douyinfe/semi-ui"; import SettingsGeneralPayment from "../../pages/Setting/Payment/SettingsGeneralPayment"; import SettingsPaymentGateway from "../../pages/Setting/Payment/SettingsPaymentGateway"; -import SettingsPaymentGatewayStripe from "../../pages/Setting/Payment/SettingsPaymentGatewayStripe"; -import SettingsPaymentGatewayCreem from "../../pages/Setting/Payment/SettingsPaymentGatewayCreem"; -import SettingsPaymentGatewayWaffo from "../../pages/Setting/Payment/SettingsPaymentGatewayWaffo"; -import SettingsPaymentGatewayAlipay from "../../pages/Setting/Payment/SettingsPaymentGatewayAlipay"; -import SettingsPaymentGatewayWechat from "../../pages/Setting/Payment/SettingsPaymentGatewayWechat"; + import { API, showError, toBoolean } from "../../helpers"; import { useTranslation } from "react-i18next"; @@ -45,6 +41,8 @@ const PaymentSetting = () => { YipayReturnUrl: "", YipayChannelExtra: "", YipayRequestURL: "", + EpayEnabled: false, + YipayEnabled: false, Price: 7.3, MinTopUp: 1, TopupGroupRatio: "", @@ -53,13 +51,6 @@ const PaymentSetting = () => { AmountOptions: "", AmountDiscount: "", - StripeApiSecret: "", - StripeWebhookSecret: "", - StripePriceId: "", - StripeUnitPrice: 8.0, - StripeMinTopUp: 1, - StripePromotionCodesEnabled: false, - AlipayEnabled: false, AlipayAppId: "", AlipayPrivateKey: "", @@ -131,10 +122,6 @@ const PaymentSetting = () => { break; case "Price": case "MinTopUp": - case "StripeUnitPrice": - case "StripeMinTopUp": - newInputs[item.key] = parseFloat(item.value); - break; case "YipayAppSecret": newInputs[item.key] = item.value != null && item.value !== undefined @@ -181,21 +168,6 @@ const PaymentSetting = () => { - - - - - - - - - - - - - - - ); diff --git a/web/src/components/topup/RechargeCard.jsx b/web/src/components/topup/RechargeCard.jsx index 0a44bc3..d68598c 100644 --- a/web/src/components/topup/RechargeCard.jsx +++ b/web/src/components/topup/RechargeCard.jsx @@ -70,6 +70,8 @@ const RechargeCard = ({ statusLoading, topupInfo, onOpenHistory, + enableAlipayTopUp, + enableWechatPayTopUp, enableWaffoTopUp, waffoTopUp, waffoPayMethods, @@ -213,13 +215,15 @@ const RechargeCard = ({ ) : enableOnlineTopUp || enableStripeTopUp || enableCreemTopUp || + enableAlipayTopUp || + enableWechatPayTopUp || enableWaffoTopUp ? (
(onlineFormApiRef.current = api)} initValues={{ topUpCount: topUpCount }} >
- {(enableOnlineTopUp || enableStripeTopUp || enableWaffoTopUp) && ( + {(enableOnlineTopUp || enableStripeTopUp || enableWaffoTopUp || enableAlipayTopUp || enableWechatPayTopUp) && ( {payMethods && - payMethods.filter((m) => m.type !== 'waffo').length > 0 && ( + payMethods.filter((m) => m.type !== 'waffo' && m.type !== 'custom1').length > 0 && ( {payMethods - .filter((m) => m.type !== 'waffo') + .filter((m) => m.type !== 'waffo' && m.type !== 'custom1') .map((payMethod) => { const minTopupVal = Number(payMethod.min_topup) || 0; const isStripe = payMethod.type === 'stripe'; + const isAlipay = payMethod.type === 'alipay'; + const isWechat = payMethod.type === 'wxpay'; const disabled = - (!enableOnlineTopUp && !isStripe) || + (!enableOnlineTopUp && !isStripe && !isAlipay && !isWechat) || (!enableStripeTopUp && isStripe) || + (!enableAlipayTopUp && isAlipay) || + (!enableWechatPayTopUp && isWechat) || minTopupVal > Number(topUpCount || 0); const buttonEl = (