service/app/mix/controller/applepay_callback.go

34 lines
774 B
Go
Raw Normal View History

2024-06-05 10:52:59 +08:00
package controller
import (
"encoding/json"
"github.com/gin-gonic/gin"
"io/ioutil"
"net/http"
2024-06-09 00:02:37 +08:00
"service/app/mix/service"
2024-06-05 10:52:59 +08:00
"service/library/logger"
2024-06-09 00:02:37 +08:00
"service/library/payclients/applepaycli"
2024-06-05 10:52:59 +08:00
)
func ApplepayCallback(ctx *gin.Context) {
2024-06-09 00:02:37 +08:00
var notify = applepaycli.ApplepayRevenueNotify{}
2024-06-05 10:52:59 +08:00
buf, err := ioutil.ReadAll(ctx.Request.Body)
logger.Info("ApplepayCallback body: %v", string(buf))
2024-06-09 00:02:37 +08:00
err = json.Unmarshal(buf, &notify)
2024-06-05 10:52:59 +08:00
if err != nil {
logger.Error("arg parse fail: %v", err)
ReplyJsonError(ctx, http.StatusBadRequest, "参数解析失败")
return
}
2024-06-09 00:02:37 +08:00
err = service.DefaultService.ApplepayCallback(ctx, notify)
if err != nil {
logger.Error("ApplepayCallback fail: %v", err)
ReplyJsonError(ctx, -1, err.Error())
return
}
ctx.String(200, "success")
2024-06-05 10:52:59 +08:00
}