hi-server/pkg/payment/platform.go
shanshanzhong 00255a7118
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
feat: 新增多密码验证支持及架构文档
refactor: 重构用户模型和密码验证逻辑
feat(epay): 添加支付类型支持
docs: 添加安装和配置指南文档
fix: 修复优惠券过期检查逻辑
perf: 优化设备解绑缓存清理流程
test: 添加密码验证测试用例
chore: 更新依赖版本
2025-10-27 18:54:07 -07:00

85 lines
1.8 KiB
Go

package payment
import "github.com/perfect-panel/server/internal/types"
type Platform int
const (
Stripe Platform = iota
AlipayF2F
EPay
Balance
CryptoSaaS
UNSUPPORTED Platform = -1
)
var platformNames = map[string]Platform{
"CryptoSaaS": CryptoSaaS,
"Stripe": Stripe,
"AlipayF2F": AlipayF2F,
"EPay": EPay,
"balance": Balance,
"unsupported": UNSUPPORTED,
}
func (p Platform) String() string {
for k, v := range platformNames {
if v == p {
return k
}
}
return "unsupported"
}
func ParsePlatform(s string) Platform {
if p, ok := platformNames[s]; ok {
return p
}
return UNSUPPORTED
}
func GetSupportedPlatforms() []types.PlatformInfo {
return []types.PlatformInfo{
{
Platform: Stripe.String(),
PlatformUrl: "https://stripe.com",
PlatformFieldDescription: map[string]string{
"public_key": "Publishable key",
"secret_key": "Secret key",
"webhook_secret": "Webhook secret",
"payment": "Payment Method, only supported card/alipay/wechat_pay",
},
},
{
Platform: AlipayF2F.String(),
PlatformUrl: "https://alipay.com",
PlatformFieldDescription: map[string]string{
"app_id": "App ID",
"private_key": "Private Key",
"public_key": "Public Key",
"invoice_name": "Invoice Name",
"sandbox": "Sandbox Mode",
},
},
{
Platform: EPay.String(),
PlatformUrl: "",
PlatformFieldDescription: map[string]string{
"pid": "PID",
"url": "URL",
"key": "Key",
"type": "Type",
},
},
{
Platform: CryptoSaaS.String(),
PlatformUrl: "https://t.me/CryptoSaaSBot",
PlatformFieldDescription: map[string]string{
"endpoint": "API Endpoint",
"account_id": "Account ID",
"secret_key": "Secret Key",
},
},
}
}