public WechatPayNotifyResponse PayNotify(string xmlContent) { WechatPayNotifyResponse response = new WechatPayNotifyResponse(); Yw_PayLog log = new Yw_PayLog(); try { BeginLog(log, 0, "", PayLogStepEnum.微信支付回调, xmlContent); Dictionary <string, string> notify = ParseXml(xmlContent); response.IsSuccess = false; response.ReturnCode = notify.ContainsKey("return_code") ? notify["return_code"] : ""; response.ReturnMsg = notify.ContainsKey("return_msg") ? notify["return_msg"] : ""; response.AppId = notify.ContainsKey("appid") ? notify["appid"] : ""; response.MchId = notify.ContainsKey("mch_id") ? notify["mch_id"] : ""; response.ResultCode = notify.ContainsKey("result_code") ? notify["result_code"] : ""; response.ErrCode = notify.ContainsKey("err_code") ? notify["err_code"] : ""; response.ErrCodeDes = notify.ContainsKey("err_code_des") ? notify["err_code_des"] : ""; response.TradeType = notify.ContainsKey("trade_type") ? notify["trade_type"] : ""; response.OpenId = notify.ContainsKey("openid") ? notify["openid"] : ""; response.TotalFee = int.Parse(notify["total_fee"]); response.TransactionId = notify.ContainsKey("transaction_id") ? notify["transaction_id"] : ""; response.OutTradeNo = notify.ContainsKey("out_trade_no") ? notify["out_trade_no"] : ""; BeginLog(log, 0, response.OutTradeNo, PayLogStepEnum.微信支付回调, xmlContent); if (CheckSign(notify)) { if (response.ReturnCode == "SUCCESS" && response.ResultCode == "SUCCESS") { StudentOrderBll bll = new StudentOrderBll(); bll.OrderPayCallback(response.OutTradeNo, response.TransactionId, CashPayTypeEnum.微信, (decimal)(response.TotalFee * 1.0 / 100)); response.IsSuccess = true; EndLog(log, "Success", 1); SaveLog(log); } return(response); } throw new AbhsException(ErrorCodeEnum.WechatPayNotifyError, AbhsErrorMsg.ConstWechatPayNotifyError, 0); } catch (Exception ex) { EndLog(log, "Fail," + ex.Message + "|" + ex.StackTrace, 0); SaveLog(log); throw; } }
public void OrderPayCallbackTest() { StudentOrderBll bll = new StudentOrderBll(); bll.OrderPayCallback("611003114584610026211", "1004400740201409030005092168", CashPayTypeEnum.微信, 500); }