payment_setting_old.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. 此文件为旧版支付设置文件,如需增加新的参数、变量等,请在 payment_setting.go 中添加
  3. This file is the old version of the payment settings file. If you need to add new parameters, variables, etc., please add them in payment_setting.go
  4. */
  5. package operation_setting
  6. import (
  7. "one-api/common"
  8. )
  9. var PayAddress = ""
  10. var CustomCallbackAddress = ""
  11. var EpayId = ""
  12. var EpayKey = ""
  13. var Price = 7.3
  14. var MinTopUp = 1
  15. var USDExchangeRate = 7.3
  16. var PayMethods = []map[string]string{
  17. {
  18. "name": "支付宝",
  19. "color": "rgba(var(--semi-blue-5), 1)",
  20. "type": "alipay",
  21. },
  22. {
  23. "name": "微信",
  24. "color": "rgba(var(--semi-green-5), 1)",
  25. "type": "wxpay",
  26. },
  27. {
  28. "name": "自定义1",
  29. "color": "black",
  30. "type": "custom1",
  31. "min_topup": "50",
  32. },
  33. }
  34. func UpdatePayMethodsByJsonString(jsonString string) error {
  35. PayMethods = make([]map[string]string, 0)
  36. return common.Unmarshal([]byte(jsonString), &PayMethods)
  37. }
  38. func PayMethods2JsonString() string {
  39. jsonBytes, err := common.Marshal(PayMethods)
  40. if err != nil {
  41. return "[]"
  42. }
  43. return string(jsonBytes)
  44. }
  45. func ContainsPayMethod(method string) bool {
  46. for _, payMethod := range PayMethods {
  47. if payMethod["type"] == method {
  48. return true
  49. }
  50. }
  51. return false
  52. }