service/app/mix/controller/applepay_callback.go

34 lines
774 B
Go

package controller
import (
"encoding/json"
"github.com/gin-gonic/gin"
"io/ioutil"
"net/http"
"service/app/mix/service"
"service/library/logger"
"service/library/payclients/applepaycli"
)
func ApplepayCallback(ctx *gin.Context) {
var notify = applepaycli.ApplepayRevenueNotify{}
buf, err := ioutil.ReadAll(ctx.Request.Body)
logger.Info("ApplepayCallback body: %v", string(buf))
err = json.Unmarshal(buf, &notify)
if err != nil {
logger.Error("arg parse fail: %v", err)
ReplyJsonError(ctx, http.StatusBadRequest, "参数解析失败")
return
}
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")
}