feat: add PaymentMethod field to TopUp model and enhance payment method validation in topup controllers

This commit is contained in:
CaIon
2026-04-15 21:17:49 +08:00
parent b2a40d3381
commit 8aaec8b1cc
4 changed files with 39 additions and 15 deletions
+4
View File
@@ -340,6 +340,10 @@ func EpayNotify(c *gin.Context) {
log.Printf("易支付回调未找到订单: %v", verifyInfo)
return
}
if topUp.PaymentMethod == "stripe" || topUp.PaymentMethod == "creem" || topUp.PaymentMethod == "waffo" {
log.Printf("易支付回调订单支付方式不匹配: %s, 订单号: %s", topUp.PaymentMethod, verifyInfo.ServiceTradeNo)
return
}
if topUp.Status == "pending" {
topUp.Status = "success"
err := topUp.Update()
+7 -6
View File
@@ -108,12 +108,13 @@ func (*CreemAdaptor) RequestPay(c *gin.Context, req *CreemPayRequest) {
// 先创建订单记录,使用产品配置的金额和充值额度
topUp := &model.TopUp{
UserId: id,
Amount: selectedProduct.Quota, // 充值额度
Money: selectedProduct.Price, // 支付金额
TradeNo: referenceId,
CreateTime: time.Now().Unix(),
Status: common.TopUpStatusPending,
UserId: id,
Amount: selectedProduct.Quota, // 充值额度
Money: selectedProduct.Price, // 支付金额
TradeNo: referenceId,
PaymentMethod: PaymentMethodCreem,
CreateTime: time.Now().Unix(),
Status: common.TopUpStatusPending,
}
err = topUp.Insert()
if err != nil {
+5
View File
@@ -234,6 +234,11 @@ func sessionAsyncPaymentFailed(event stripe.Event) {
return
}
if topUp.PaymentMethod != PaymentMethodStripe {
log.Printf("异步支付失败,订单支付方式不匹配: %s, ref: %s", topUp.PaymentMethod, referenceId)
return
}
if topUp.Status != common.TopUpStatusPending {
log.Printf("异步支付失败,订单状态非pending: %s, ref: %s", topUp.Status, referenceId)
return