/// <summary> /// 支付宝 返回 前端订单交易信息 get /// </summary> /// <param name="context"></param> /// <returns></returns> public ZFBReturnPara_Model ZFBCallBack(HttpContext context, bool isTouch) { ZFBReturnPara_Model zfbpara = new ZFBReturnPara_Model(); Dictionary <string, string> sPara = GetRequestInputStream(context); if (sPara.Count > 0)//判断是否有带返回参数 { Com.Alipay.Touch.Notify aliNotify = new Com.Alipay.Touch.Notify(); bool verifyResult = aliNotify.VerifyNotify(sPara, sPara["sign"]); if (verifyResult)//验证成功 { //XML解析notify_data数据 try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(sPara["notify_data"]); //商户订单号 string out_trade_no = xmlDoc.SelectSingleNode("/notify/out_trade_no").InnerText; //支付宝交易号 string trade_no = xmlDoc.SelectSingleNode("/notify/trade_no").InnerText; //交易状态 string trade_status = xmlDoc.SelectSingleNode("/notify/trade_status").InnerText; //交易状态 string total_fee = xmlDoc.SelectSingleNode("/notify/total_fee").InnerText; if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS") { zfbpara.trade_no = trade_no; zfbpara.order_no = out_trade_no; zfbpara.total_fee = total_fee; zfbpara.ispaysuccess = (trade_status == "TRADE_SUCCESS" || trade_status == "TRADE_FINISHED") ? true : false; zfbpara.isallreturn = false; zfbpara.iscallbacksuccess = true; zfbpara.sendzfbcallbackmessage = "success"; } else { zfbpara.sendzfbcallbackmessage = "fail"; } } catch (Exception exc) { zfbpara.sendzfbcallbackmessage = exc.Message; } } else//验证失败 { zfbpara.sendzfbcallbackmessage = "fail"; } } else { zfbpara.sendzfbcallbackmessage = "无通知参数"; } return(zfbpara); }
/// <summary> /// 支付宝 返回 前端订单交易信息 get /// </summary> /// <param name="context"></param> /// <returns></returns> public ZFBReturnPara_Model ZFBCallBack(HttpContext context, bool isTouch) { ZFBReturnPara_Model zfbpara = new ZFBReturnPara_Model(); Dictionary<string, string> sPara = GetRequestInputStream(context); if (sPara.Count > 0)//判断是否有带返回参数 { Com.Alipay.Touch.Notify aliNotify = new Com.Alipay.Touch.Notify(); bool verifyResult = aliNotify.VerifyNotify(sPara, sPara["sign"]); if (verifyResult)//验证成功 { //XML解析notify_data数据 try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(sPara["notify_data"]); //商户订单号 string out_trade_no = xmlDoc.SelectSingleNode("/notify/out_trade_no").InnerText; //支付宝交易号 string trade_no = xmlDoc.SelectSingleNode("/notify/trade_no").InnerText; //交易状态 string trade_status = xmlDoc.SelectSingleNode("/notify/trade_status").InnerText; //交易状态 string total_fee = xmlDoc.SelectSingleNode("/notify/total_fee").InnerText; if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS") { zfbpara.trade_no = trade_no; zfbpara.order_no = out_trade_no; zfbpara.total_fee = total_fee; zfbpara.ispaysuccess = (trade_status == "TRADE_SUCCESS" || trade_status == "TRADE_FINISHED") ? true : false; zfbpara.isallreturn = false; zfbpara.iscallbacksuccess = true; zfbpara.sendzfbcallbackmessage = "success"; } else { zfbpara.sendzfbcallbackmessage = "fail"; } } catch (Exception exc) { zfbpara.sendzfbcallbackmessage = exc.Message; } } else//验证失败 { zfbpara.sendzfbcallbackmessage = "fail"; } } else { zfbpara.sendzfbcallbackmessage = "无通知参数"; } return zfbpara; }