- package controller
-
- import (
- "strings"
-
- "github.com/QuantumNous/new-api/setting"
- "github.com/QuantumNous/new-api/setting/operation_setting"
- )
-
- // isStripeTopUpEnabled 检查 Stripe 支付是否已启用(三项配置缺一不可)
- func isStripeTopUpEnabled() bool {
- return strings.TrimSpace(setting.StripeApiSecret) != "" &&
- strings.TrimSpace(setting.StripeWebhookSecret) != "" &&
- strings.TrimSpace(setting.StripePriceId) != ""
- }
-
- // isStripeWebhookEnabled 检查 Stripe Webhook 是否可接收
- func isStripeWebhookEnabled() bool {
- return isStripeTopUpEnabled()
- }
-
- // isCreemTopUpEnabled 检查 Creem 支付是否已启用
- func isCreemTopUpEnabled() bool {
- products := strings.TrimSpace(setting.CreemProducts)
- return strings.TrimSpace(setting.CreemApiKey) != "" &&
- products != "" &&
- products != "[]"
- }
-
- // isCreemWebhookEnabled 检查 Creem Webhook 是否可接收
- func isCreemWebhookEnabled() bool {
- return isCreemTopUpEnabled() && strings.TrimSpace(setting.CreemWebhookSecret) != ""
- }
-
- // isWechatPayWebhookEnabled 检查微信支付 Webhook 是否可接收
- func isWechatPayWebhookEnabled() bool {
- return setting.IsWechatPayConfigured()
- }
-
- // isAlipayWebhookEnabled 检查支付宝 Webhook 是否可接收
- func isAlipayWebhookEnabled() bool {
- return setting.IsAlipayConfigured()
- }
-
- // isEpayTopUpEnabled 检查易支付是否已启用
- func isEpayTopUpEnabled() bool {
- return strings.TrimSpace(operation_setting.PayAddress) != "" &&
- strings.TrimSpace(operation_setting.EpayId) != "" &&
- strings.TrimSpace(operation_setting.EpayKey) != ""
- }
-
- // isEpayWebhookEnabled 检查易支付 Webhook 是否可接收
- func isEpayWebhookEnabled() bool {
- return isEpayTopUpEnabled() && len(operation_setting.PayMethods) > 0
- }
|