support wechat and alipay payment for mobile page

This commit is contained in:
RockYang
2024-09-30 16:20:40 +08:00
parent 8923e938d2
commit 5a04a935be
8 changed files with 120 additions and 45 deletions

View File

@@ -138,12 +138,22 @@ func (h *PaymentHandler) Pay(c *gin.Context) {
} else {
notifyURL = fmt.Sprintf("%s/api/payment/notify/wechat", data.Host)
}
payURL, err = h.wechatPayService.PayUrlNative(payment.WechatPayParams{
OutTradeNo: orderNo,
TotalFee: int(amount * 100),
Subject: product.Name,
NotifyURL: notifyURL,
})
if data.Device == "wechat" {
payURL, err = h.wechatPayService.PayUrlH5(payment.WechatPayParams{
OutTradeNo: orderNo,
TotalFee: int(amount * 100),
Subject: product.Name,
NotifyURL: notifyURL,
ClientIP: c.ClientIP(),
})
} else {
payURL, err = h.wechatPayService.PayUrlNative(payment.WechatPayParams{
OutTradeNo: orderNo,
TotalFee: int(amount * 100),
Subject: product.Name,
NotifyURL: notifyURL,
})
}
if err != nil {
resp.ERROR(c, err.Error())
return