feat: 更新支付模块 (Stripe/PayPal/PingPong) 和 uni-app 配置

This commit is contained in:
TradeMate Dev
2026-06-16 13:32:50 +08:00
parent e5b1e7d588
commit 15d172e825
17 changed files with 1254 additions and 12 deletions
+17 -2
View File
@@ -35,14 +35,29 @@ GATEWAY_MAP: Dict[str, PaymentGateway] = {}
def init_gateways():
if settings.PAY_API_KEY:
GATEWAY_MAP["unified"] = UnifiedPayService()
if settings.STRIPE_SECRET_KEY:
from app.services.stripe_pay import StripePaymentService
GATEWAY_MAP["stripe"] = StripePaymentService()
if settings.PAYPAL_CLIENT_ID and settings.PAYPAL_CLIENT_SECRET:
from app.services.paypal_pay import PayPalPaymentService
GATEWAY_MAP["paypal"] = PayPalPaymentService()
if settings.PINGPONG_CLIENT_ID and settings.PINGPONG_ACC_ID and settings.PINGPONG_SECRET_KEY:
from app.services.pingpong_pay import PingPongCheckoutService
GATEWAY_MAP["pingpong"] = PingPongCheckoutService()
def get_gateway(pay_type: str) -> PaymentGateway:
gw = GATEWAY_MAP.get("unified")
if pay_type in ("card", "stripe", "alipay_stripe", "wechat_stripe"):
gw = GATEWAY_MAP.get("stripe") or gw
if pay_type in ("paypal",):
gw = GATEWAY_MAP.get("paypal") or gw
if pay_type in ("pingpong",):
gw = GATEWAY_MAP.get("pingpong") or gw
if not gw:
raise ValueError("支付网关未配置,请设置 PAY_API_KEY")
raise ValueError("支付网关未配置,请设置 PAY_API_KEY / STRIPE_SECRET_KEY / PAYPAL_CLIENT_ID / PINGPONG 配置")
if not gw.supports(pay_type):
raise ValueError(f"支付方式 {pay_type} 不被支持(仅支持 alipay/wechat")
raise ValueError(f"支付方式 {pay_type} 不被支持")
return gw