You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 rivejä
1.7 KiB

  1. package controller
  2. import (
  3. "strings"
  4. "github.com/QuantumNous/new-api/setting"
  5. "github.com/QuantumNous/new-api/setting/operation_setting"
  6. )
  7. // isStripeTopUpEnabled 检查 Stripe 支付是否已启用(三项配置缺一不可)
  8. func isStripeTopUpEnabled() bool {
  9. return strings.TrimSpace(setting.StripeApiSecret) != "" &&
  10. strings.TrimSpace(setting.StripeWebhookSecret) != "" &&
  11. strings.TrimSpace(setting.StripePriceId) != ""
  12. }
  13. // isStripeWebhookEnabled 检查 Stripe Webhook 是否可接收
  14. func isStripeWebhookEnabled() bool {
  15. return isStripeTopUpEnabled()
  16. }
  17. // isCreemTopUpEnabled 检查 Creem 支付是否已启用
  18. func isCreemTopUpEnabled() bool {
  19. products := strings.TrimSpace(setting.CreemProducts)
  20. return strings.TrimSpace(setting.CreemApiKey) != "" &&
  21. products != "" &&
  22. products != "[]"
  23. }
  24. // isCreemWebhookEnabled 检查 Creem Webhook 是否可接收
  25. func isCreemWebhookEnabled() bool {
  26. return isCreemTopUpEnabled() && strings.TrimSpace(setting.CreemWebhookSecret) != ""
  27. }
  28. // isWechatPayWebhookEnabled 检查微信支付 Webhook 是否可接收
  29. func isWechatPayWebhookEnabled() bool {
  30. return setting.IsWechatPayConfigured()
  31. }
  32. // isAlipayWebhookEnabled 检查支付宝 Webhook 是否可接收
  33. func isAlipayWebhookEnabled() bool {
  34. return setting.IsAlipayConfigured()
  35. }
  36. // isEpayTopUpEnabled 检查易支付是否已启用
  37. func isEpayTopUpEnabled() bool {
  38. return strings.TrimSpace(operation_setting.PayAddress) != "" &&
  39. strings.TrimSpace(operation_setting.EpayId) != "" &&
  40. strings.TrimSpace(operation_setting.EpayKey) != ""
  41. }
  42. // isEpayWebhookEnabled 检查易支付 Webhook 是否可接收
  43. func isEpayWebhookEnabled() bool {
  44. return isEpayTopUpEnabled() && len(operation_setting.PayMethods) > 0
  45. }