diff --git a/wechat/bc/h.go b/wechat/bc/h.go index 9f0484b..5e87433 100644 --- a/wechat/bc/h.go +++ b/wechat/bc/h.go @@ -8,7 +8,7 @@ import ( "github.com/twiglab/crm/wechat/web" ) -func X() http.HandlerFunc { +func BusiCircleAuth() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { req, err := wechat.V3ParseNotify(r) if err != nil { @@ -22,3 +22,33 @@ func X() http.HandlerFunc { } } } + +func BusiCirclePayment() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + req, err := wechat.V3ParseNotify(r) + if err != nil { + _ = web.JsonTo(http.StatusInternalServerError, &wechat.V3NotifyRsp{Code: gopay.FAIL, Message: err.Error()}, w) + return + } + ca := BusinessCirclePaymentSource{} + if err := req.DecryptCipherTextToStruct("", &ca); err != nil { + _ = web.JsonTo(http.StatusInternalServerError, &wechat.V3NotifyRsp{Code: gopay.FAIL, Message: err.Error()}, w) + return + } + } +} + +func BusiCircleRefund() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + req, err := wechat.V3ParseNotify(r) + if err != nil { + _ = web.JsonTo(http.StatusInternalServerError, &wechat.V3NotifyRsp{Code: gopay.FAIL, Message: err.Error()}, w) + return + } + ca := BusinessCircleRefundSource{} + if err := req.DecryptCipherTextToStruct("", &ca); err != nil { + _ = web.JsonTo(http.StatusInternalServerError, &wechat.V3NotifyRsp{Code: gopay.FAIL, Message: err.Error()}, w) + return + } + } +}