func VerifyCharge(orderId int) bool { order, ok := dao.GetOrder(orderId) if !ok { return false } if order.PayStatus == consts.PAY_STATUS_SUCC || order.PayStatus == consts.PAY_STATUS_FAIL { schan.SendPayMessage(order) return true } sdkInst, ok := sdkMap[order.SdkType] if !ok { return false } schan.SendPayMessage((*sdkInst).VerifyCharge(order)) return true }
func startNotifyListener(sdk *SDKCharger) { if (*sdk).GetListenPath() == "" || (*sdk).GetListenPort() <= 0 { return } pathStr := fmt.Sprintf("/%s", (*sdk).GetListenPath()) portStr := fmt.Sprintf(":%d", (*sdk).GetListenPort()) http.HandleFunc(pathStr, func(w http.ResponseWriter, r *http.Request) { defer func() { if x := recover(); x != nil { } }() bytes := make([]byte, 1024) n, err := r.Body.Read(bytes) utils.Panic(err) bodyBytes := bytes[:n] rOrder := (*sdk).ConfirmNotify(w, bodyBytes) schan.SendPayMessage(rOrder) }) http.ListenAndServe(portStr, nil) }