func (e Example) DemoPostAction(ctx *kmgHttp.Context) { ctx.MustPost() b := kmgYaml.MustMarshal(ctx.GetInMap()) ctx.WriteString(kmgBootstrap.NewWrap("DemoPostAction", kmgBootstrap.Pre(` You send me a HTTP POST Request `+string(b))).HtmlRender()) }
func (ot *OverseaTrade) mustNotifyActionV2(ctx *kmgHttp.Context, f func(info OverseaTradeTransaction)) { kmgLog.Log("Alipay", "Oversea PayNotifyAction", ctx.GetInMap()) var err error ctx.MustPost() info := OverseaTradeTransaction{} //info.NotifyId = ctx.MustInStr("notify_id") 这两项没有什么意义. //info.NotifyTime = kmgTime.MustFromMysqlFormatInLocation(ctx.MustInStr("notify_time"), kmgTime.BeijingZone) info.OutTradeNo = ctx.MustInStr("out_trade_no") info.Currency = ctx.MustInStr("currency") info.TotalFee, err = kmgStrconv.ParseFloat64(ctx.MustInStr("total_fee")) if err != nil { panic(err) } info.TradeStatus = OverseaTradeStatus(ctx.MustInStr("trade_status")) info.TradeNo = ctx.MustInStr("trade_no") err = ot.md5Verify(ctx.GetInMap()) if err != nil { panic(err) } err = ot.VerifyNotify(ctx.MustInStr("notify_id")) if err != nil { panic(err) } // 向支付宝询问这个订单的情况 oInfo := ot.MustSingleTransactionQuery(info.OutTradeNo) if oInfo.TradeStatus != info.TradeStatus { panic("两次查询订单状态不一致") } info.Subject = oInfo.Subject f(info) ctx.WriteString("success") }