/// <summary> /// /// </summary> /// <param name="callBackText"></param> /// <returns></returns> public bool Finish(string callBackText) { bool result = false; try { if (!string.IsNullOrEmpty(callBackText)) { string retcode = ""; string retmsg = ""; string orderid = ""; string cardnumber = ""; string cardpwd = ""; string storagetime = ""; string usetime = ""; string usestatus = ""; string customerorderid = ""; string settleparvalue = ""; string settlediscount = ""; string settlemoney = ""; #region xml var xmlDocument = new XmlDocument(); xmlDocument.LoadXml(callBackText); var xmlNodeList = xmlDocument.SelectSingleNode("Root/Ret"); if (xmlNodeList != null) { foreach (XmlNode list in xmlNodeList) { switch (list.Name.ToLower()) { case "retcode": retcode = list.InnerText; break; case "retmsg": retmsg = list.InnerText; break; } } } xmlNodeList = xmlDocument.SelectSingleNode("Root/Card"); if (xmlNodeList != null) { foreach (XmlNode list in xmlNodeList) { switch (list.Name.ToLower()) { case "orderid": orderid = list.InnerText; break; case "cardnumber": cardnumber = list.InnerText; break; case "storagetime": storagetime = list.InnerText; break; case "usetime": usetime = list.InnerText; break; case "usestatus": usestatus = list.InnerText; break; case "customerorderid": customerorderid = list.InnerText; break; case "settleparvalue": settleparvalue = list.InnerText; break; case "settlediscount": settlediscount = list.InnerText; break; case "settlemoney": settlemoney = list.InnerText; break; } } } #endregion if (retcode == "30001") { #region int status = 0; string opstate = ""; decimal orderAmt = 0M; string msg = "", viewMsg = ""; switch (usestatus) { case "4": orderAmt = decimal.Parse(settleparvalue); status = 2; opstate = "0"; msg = "支付成功"; viewMsg = msg; break; case "1": case "5": status = 4; opstate = ConvertCode(retcode); msg = retmsg; viewMsg = SellCard20.GetMsgToUserView(opstate); break; } if (status > 0) { var response = new CardOrderSupplierResponse() { SupplierId = SuppId, SuppTransNo = orderid, SysOrderNo = customerorderid, OrderAmt = orderAmt, SuppAmt = 0M, OrderStatus = status, SuppErrorCode = retcode, Opstate = opstate, SuppErrorMsg = msg, ViewMsg = viewMsg, Method = 1 }; OrderCardUtils.Finish(response); result = true; } #endregion } } } catch (Exception ex) { ExceptionHandler.HandleException(ex); } return(result); }
/// <summary> /// /// </summary> public void Notify() { try { int status = 0; string msg = ""; string viewMsg = ""; string opstate = ""; decimal orderAmt = 0M; string canresubmit = HttpContext.Current.Request.Form["canresubmit"]; string customerorderid = HttpContext.Current.Request.Form["customerorderid"]; string remark = HttpContext.Current.Request.Form["remark"]; string settleparvalue = HttpContext.Current.Request.Form["settleparvalue"]; string usestatus = HttpContext.Current.Request.Form["usestatus"]; string sign = HttpContext.Current.Request.Form["sign"]; string plain = string.Format("canresubmit={5}customerorderid={0}remark={1}settleparvalue={2}usestatus={3}{4}" , customerorderid , remark , settleparvalue , usestatus , suppKey , canresubmit ); log("Notify plain " + plain); string localsign = viviLib.Security.Cryptography.MD5(plain, "utf-8"); log("Notify localsign " + localsign); log("Notify sign " + sign); if (String.Equals(localsign, sign, StringComparison.CurrentCultureIgnoreCase)) { switch (usestatus.ToLower()) { case "4": orderAmt = decimal.Parse(settleparvalue); status = 2; opstate = "0"; msg = "支付成功"; viewMsg = msg; break; case "1": case "5": status = 4; opstate = "99"; msg = remark; viewMsg = SellCard20.GetMsgToUserView(opstate); break; } if (status > 0) { var response = new CardOrderSupplierResponse() { SupplierId = SuppId, SuppTransNo = "", SysOrderNo = customerorderid, OrderAmt = orderAmt, SuppAmt = 0M, OrderStatus = status, SuppErrorCode = "99", Opstate = opstate, SuppErrorMsg = msg, ViewMsg = viewMsg, Method = 1 }; string backXML = string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?> <root> <ret> <status>{0}</status> </ret> </root>", "true"); OrderCardUtils.SuppNotify(response, backXML); } } } catch (Exception ex) { ExceptionHandler.HandleException(ex); HttpContext.Current.Response.Write("error"); //HttpContext.Current.Response.End(); } }