面包店
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

svc_alipay_callback.go 653 B

9 个月前
12345678910111213141516171819202122232425262728
  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/pay/md"
  6. "applet/app/utils/logx"
  7. "github.com/gin-gonic/gin"
  8. )
  9. // 支付宝回调处理
  10. func AlipayCallback(c *gin.Context) (string, error) {
  11. data, ok := c.Get("callback")
  12. if data == nil || !ok {
  13. return "", e.NewErrCode(e.ERR_INVALID_ARGS)
  14. }
  15. args := data.(*md.AliPayCallback)
  16. _, ok = db.DBs[args.MasterID]
  17. if !ok {
  18. return "", logx.Warn("Alipay Failed : master_id not found")
  19. }
  20. c.Set("mid", args.MasterID)
  21. // 回调交易状态失败
  22. if args.TradeStatus != "TRADE_SUCCESS" {
  23. return "", logx.Warn("Alipay Failed : trade status failed")
  24. }
  25. return args.OutTradeNo, nil
  26. }