12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package api
- import (
- "fmt"
- "net/http"
- "github.com/gin-gonic/gin"
- )
- func PayMulti(r *GinRouter) {
- r.POST("/multi/alipay/callback", MultiAliCallBack)
- r.POST("/multi/wechat/callback", MultiWechatCallBack)
- }
- func MultiAliCallBack(c *gin.Context, apictx *ApiSession) (interface{}, error) {
- fmt.Println(c)
- // 默认走阿里支付
- pay := PayMod(ALIPAY, MULTI)
- res, err := pay.CallBack(c.Request)
- if err != nil {
- return false, NewError(err.Error())
- }
- c.String(http.StatusOK, res.(string))
- return nil, nil
- }
- func MultiWechatCallBack(c *gin.Context, apictx *ApiSession) (interface{}, error) {
- // 微信回调
- pay := PayMod(WECHATPAY, MULTI)
- res, err := pay.CallBack(c.Request)
- if err != nil {
- // return false, NewError(err.Error())
- c.JSON(http.StatusOK, gin.H{"code": res, "message": err.Error()})
- }
- c.JSON(http.StatusOK, gin.H{"code": res, "message": "成功"})
- // c.JSON(http.StatusOK, &wechat.V3NotifyRsp{Code: res.(string), Message: err.Error()})
- return nil, nil
- }
|