Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("gb2312");

            p2_Order        = o.SysOrderNo;
            p3_Amt          = decimal.Parse(o.FaceValue.ToString(CultureInfo.InvariantCulture)).ToString("0.00");
            p4_verifyAmt    = "false";
            p5_Pid          = "product";
            p6_Pcat         = "producttype";
            p7_Pdesc        = "productdesc";
            p8_Url          = NotifyUrl;
            pa_MP           = "";
            pa7_cardAmt     = decimal.Parse(o.FaceValue.ToString(CultureInfo.InvariantCulture)).ToString("0.00");
            pa8_cardNo      = o.CardNo;
            pa9_cardPwd     = o.CardPass;
            pd_FrpId        = CardTypeNo(o.CardTypeId);
            pr_NeedResponse = "1";
            pz_userId       = SuppAccount;
            pz1_userRegTime = "";

            try
            {
                SZXResult result = SZX.AnnulCard(SuppKey, SuppAccount, p2_Order, p3_Amt, p4_verifyAmt, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url,
                                                 pa_MP, pa7_cardAmt, pa8_cardNo, pa9_cardPwd, pd_FrpId, pr_NeedResponse, pz_userId, pz1_userRegTime);

                callBack.Success = 1;

                callBack.SuppErrorCode = result.R1_Code;
                callBack.SuppErrorMsg  = result.Rq_ReturnMsg;

                if (result.R1_Code == "1")
                {
                    callBack.SummitStatus = 1;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                callBack.Success = 0;
            }
            return(callBack);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 超时未返回,切换通道重新提交
        /// </summary>
        private static void ProcessToggleInterface()
        {
            try
            {
                DateTime sdt = DateTime.Now.AddDays(-1);
                DateTime edt = DateTime.Now;

                DataTable data = BLL.Order.Card.Factory.Instance.GetToggleInterfaceList(sdt, edt);
                if (data != null)
                {
                    foreach (DataRow row in data.Rows)
                    {
                        string supporderid   = "";
                        string suppererrcode = "";
                        string supperrinfo   = "";

                        string  sysorderid = row["orderid"].ToString();
                        int     suppid     = int.Parse(row["supplierID"].ToString());
                        decimal refervalue = decimal.Parse(row["refervalue"].ToString());
                        var     supp       = (SupplierCode)suppid;

                        var o = new CardOrderSummitArgs()
                        {
                            SysOrderNo = sysorderid,
                            CardTypeId = int.Parse(row["typeId"].ToString()),
                            CardNo     = row["cardNo"].ToString(),
                            CardPass   = row["cardPwd"].ToString(),
                            FaceValue  = decimal.ToInt32(refervalue),
                            Attach     = "",
                            Source     = 3
                        };

                        OrderCardUtils.SendCard((SupplierCode)suppid, o);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
        }
Exemplo n.º 3
0
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            string supporderid = string.Empty;
            string errmsg      = string.Empty;

            string _orderid  = o.SysOrderNo;
            string _cardno   = o.CardNo;
            string _cardpwd  = o.CardPass;
            int    _typeId   = o.CardTypeId;
            int    cardvalue = o.FaceValue;

            //if (this.version == "v1.0")
            //{
            //    return this.CardSendV10(_orderid, _cardno, _cardpwd, _typeId, cardvalue, out supporderid, out errmsg);
            //}
            //if (this.version == "v2.5")
            //{
            return(this.CardSendV25(_orderid, _cardno, _cardpwd, _typeId, cardvalue, out supporderid, out errmsg));
            //}
            //return "-1";
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();
            var channel  = GetChannelInfo(o.CardTypeId, o.CardNo);

            if (string.IsNullOrEmpty(channel.PayChannel))
            {
                callBack.SuppErrorCode = "-1";
                callBack.SuppErrorMsg  = "不支持的卡种";

                callBack.Message = "不支持的卡种";
                return(callBack);
            }

            ReceB2COrderResponse raceResponse = ReceiveB2COrderRep(o.SysOrderNo, o.SysOrderNo, o.FaceValue);

            if (raceResponse == null || raceResponse.transStatus != "00")
            {
                callBack.SuppErrorCode = "-1";
                callBack.SuppErrorMsg  = "下单失败";

                callBack.Message = "下单失败";
                return(callBack);
            }

            b2CPaymentResponse b2CPayment = Payment(raceResponse.tokenId, raceResponse.sessionId, o.SysOrderNo, o.CardNo,
                                                    o.CardPass, o.CardTypeId, o.FaceValue);

            if (b2CPayment == null)
            {
                callBack.SuppErrorCode = "-1";
                callBack.SuppErrorMsg  = "支付失败";

                callBack.Message = "支付失败";
                return(callBack);
            }

            callBack.Success       = 1;
            callBack.SuppErrorCode = b2CPayment.returnInfo.errorCode;
            callBack.SuppErrorMsg  = b2CPayment.returnInfo.errorMsg;
            callBack.SuppTransNo   = b2CPayment.transNo;

            //if (b2CPayment.transStatus == "00"
            //    && string.IsNullOrEmpty(b2CPayment.returnInfo.errorCode))
            //{
            //    callBack.SummitStatus = 1;
            //}

            //if (b2CPayment.transStatus == "01")
            //{
            //    callBack.SummitStatus = 1;

            //    if (o.CardTypeId == 104
            //        || o.CardTypeId == 210)
            //    {
            //        callBack.OrderStatus  = 2;
            //    }
            //}

            if (!string.IsNullOrEmpty(b2CPayment.returnInfo.errorCode))
            {
                callBack.SummitStatus = 0;
                callBack.OrderStatus  = 0;
            }
            else
            {
                if (b2CPayment.transStatus == "00")
                {
                    callBack.SummitStatus = 1;
                }
                if (b2CPayment.transStatus == "01")
                {
                    callBack.SummitStatus = 1;

                    if (o.CardTypeId == 104 ||
                        o.CardTypeId == 210)
                    {
                        decimal paidAmount = 0M;

                        if (decimal.TryParse(b2CPayment.paidAmount, out paidAmount))
                        {
                            callBack.OrderStatus = 2;
                            callBack.SuccAmt     = paidAmount;
                        }
                    }
                }
            }

            return(callBack);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string opstate  = "-1";
            string puserkey = this.SuppKey;

            if (string.IsNullOrEmpty(this.PostCardUrl) ||
                string.IsNullOrEmpty(puserkey))
            {
                callBack.Success = 0;
                callBack.Message = "未配置网关";

                return(callBack);
            }

            string commitUrl = this.PostCardUrl + "?";
            string cardType  = GetCardType(o.CardTypeId).ToString();
            // string cardType = GetCardType(_typeId).ToString("0000") + cardvalue.ToString();
            string _restrict = "0";

            string plain = string.Format("type={0}&parter={1}&cardno={2}&cardpwd={3}&value={4}&restrict={5}&orderid={6}&callbackurl={7}"
                                         , cardType
                                         , SuppAccount
                                         , o.CardNo
                                         , o.CardPass
                                         , o.FaceValue
                                         , _restrict
                                         , o.SysOrderNo
                                         , notify_url);

            string sign = viviLib.Security.Cryptography.MD5(plain + SuppKey);

            try
            {
                var postData = new StringBuilder(plain);
                postData.AppendFormat("&sign={0}", sign);

                //LogWrite(commitUrl + postData.ToString());
                //LogWrite(postData.ToString());

                string retCode = WebClientHelper.GetString(commitUrl, postData.ToString(), "GET", System.Text.Encoding.GetEncoding("GB2312"), 10000);

                callBack.SuppCallBackText = retCode;
                callBack.SuppErrorCode    = retCode.Replace("opstate=", "");
                callBack.SuppErrorMsg     = GetMsgInfo(retCode, string.Empty);

                if (retCode == "opstate=1")
                {
                    callBack.SummitStatus = 1;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);

                callBack.Success = 0;
                callBack.Message = ex.Message;
            }
            return(callBack);
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            try
            {
                string commitUrl = PostCardUrl;
                string usercode  = SuppAccount;
                string cardno    = o.CardNo;
                string cardpass  = o.CardPass;
                string cardcode  = GetCardType(o.CardTypeId) + o.FaceValue.ToString();
                string mode      = "r";
                string version   = "1.0";
                string orderno   = o.SysOrderNo;
                string retaction = NotifyUrl;

                string datetime  = DateTime.Now.ToString("yyyyMMddHHmmss");
                string format    = "xml";
                string md5key    = SuppKey;
                string signsrc   = usercode + mode + version + orderno + cardcode + cardno + cardpass + retaction + datetime + format + md5key;
                string sign      = md5sign(signsrc).ToLower();
                string postParam = "usercode=" + usercode + "&mode=" + mode + "&version=" + version + "&orderno=" + orderno + "&cardcode=" + cardcode + "&cardno=" + cardno + "&cardpass="******"&retaction=" + retaction + "&datetime=" + datetime + "&format=" + format + "&sign=" + sign;

                SynsSummitLogger(commitUrl);
                SynsSummitLogger(postParam);

                System.Text.Encoding gbkEncoding = System.Text.Encoding.GetEncoding("GBK");
                byte[]     bs  = gbkEncoding.GetBytes(postParam);
                WebRequest req = (HttpWebRequest)WebRequest.Create(commitUrl);
                req.Timeout       = 50000;//设置超时时间(毫秒),最长的等待时间
                req.Method        = "POST";
                req.ContentType   = "application/x-www-form-urlencoded";
                req.ContentLength = bs.Length;
                using (System.IO.Stream reqStream = req.GetRequestStream())
                {
                    reqStream.Write(bs, 0, bs.Length);
                }
                var    sr     = new System.IO.StreamReader(req.GetResponse().GetResponseStream(), gbkEncoding);
                String retXml = sr.ReadToEnd();
                sr.Close();

                SynsSummitLogger(retXml);

                var doc = new System.Xml.XmlDocument();
                doc.LoadXml(retXml);

                string result = doc.GetElementsByTagName("result")[0].InnerText;
                string billid = doc.GetElementsByTagName("billid")[0].InnerText;
                string info   = doc.GetElementsByTagName("info")[0].InnerText;


                callBack.Success          = 1;
                callBack.SuppTransNo      = billid;
                callBack.SuppCallBackText = retXml;
                callBack.SuppErrorCode    = result;
                callBack.SuppErrorMsg     = info;

                if (!string.IsNullOrEmpty(result))
                {
                    if (result == "2001")
                    {
                        callBack.SummitStatus = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                viviLib.ExceptionHandling.ExceptionHandler.HandleException(ex);

                callBack.Success = 0;
                callBack.Message = ex.Message;
            }
            return(callBack);
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static CardSynchCallBack SendCard(
            SupplierCode supplier
            , CardOrderSummitArgs o)
        {
            var cardsend = new OrderCardSend()
            {
                orderid      = o.SysOrderNo,
                source       = o.Source,
                suppId       = (int)supplier,
                success      = 0,
                summitStatus = 0,
                orderStatus  = 1,
                typeid       = o.CardTypeId,
                facevalue    = o.FaceValue,
                cardno       = o.CardNo,
                cardpass     = o.CardPass,
                suppTransNo  = "",
                errCode      = "",
                errMsg       = "",
                responseText = "",
                initTime     = DateTime.Now,
                message      = ""
            };

            var callback = new CardSynchCallBack();

            switch (supplier)
            {
            case SupplierCode.OfCard:
                callback = OfCard.Card.Default.CardSend(o);
                break;

            case SupplierCode.Cared70:
                callback = Cared70.Card.Default.CardSend(o);
                break;
                #region 暂时用不到的接口
            //case SupplierCode.Card51:
            //    callback = Card.Default.CardSend(o);
            //    break;

            //case SupplierCode.HuiYuan:
            //    callback = HuiYuan.Card.Default.CardSend(o);
            //    break;

            //case SupplierCode.HuiSu:
            //    callback = HuiSu.Card.Default.CardSend(o);
            //    break;

            //case SupplierCode.Shengpay:
            //    callback = Shengpay.Card.Default.CardSend(o);
            //    break;

            //case SupplierCode.Card60866:
            //    callback = Card60866.Card.Default.CardSend(o);
            //    break;

            //case SupplierCode.TaoShang:
            //    callback = TaoShang.Card.Default.CardSend(o);
            //    break;

            case SupplierCode.Card15173:
                callback = Card15173.Card.Default.CardSend(o);
                break;
                #endregion
            }

            cardsend.orderStatus  = callback.OrderStatus;
            cardsend.errCode      = callback.SuppErrorCode;
            cardsend.errMsg       = callback.SuppErrorMsg;
            cardsend.responseText = callback.SuppCallBackText;
            cardsend.suppTransNo  = callback.SuppTransNo;
            cardsend.success      = callback.Success;
            cardsend.summitStatus = callback.SummitStatus;
            cardsend.completeTime = DateTime.Now;

            CardSendBll.Add(cardsend);

            return(callback);
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="response"></param>
        public static bool Finish(CardOrderSupplierResponse response)
        {
            string cacheKey = "OrderBankComplete" + response.SysOrderNo + response.SupplierId.ToString(CultureInfo.InvariantCulture);

            object flag = Cache.WebCache.GetCacheService().RetrieveObject(cacheKey);

            if (flag != null)
            {
                return(true);
            }

            var orderInfo = Cache.WebCache.GetCacheService().RetrieveObject(response.SysOrderNo) as OrderCardInfo;

            if (orderInfo == null)
            {
                orderInfo = BLL.Order.Card.Factory.Instance.GetModelByOrderId(response.SysOrderNo);
            }
            if (orderInfo == null)
            {
                return(false);
            }

            try
            {
                byte continueSubmit = 0;

                int seq = 1, continueSupp = 0;

                bool processFlag = true;

                if (response.Method == 1)
                {
                    if (response.OrderStatus != 2)
                    {
                        #region 继续提交
                        var suppInfo = BLL.Supplier.Factory.GetCacheModel(response.SupplierId);
                        if (suppInfo != null)
                        {
                            if (!string.IsNullOrEmpty(suppInfo.AsynsRetCode))
                            {
                                string[] arr = suppInfo.AsynsRetCode.Split(',');
                                if (arr.Any(s => s == response.SuppErrorCode))
                                {
                                    continueSubmit = 1;
                                }
                            }
                        }
                        #endregion
                    }

                    DataRow resultRow = BLL.Order.Card.Factory.Instance.CallbackInsert(response.SysOrderNo
                                                                                       , response.SupplierId
                                                                                       , response.OrderStatus
                                                                                       , response.SuppErrorCode
                                                                                       , response.SuppErrorMsg
                                                                                       , continueSubmit);

                    if (resultRow != null)
                    {
                        seq          = Convert.ToInt32(resultRow["seq"]);
                        continueSupp = Convert.ToInt32(resultRow["suppId"]);
                    }

                    if (continueSubmit == 1 && continueSupp > 0)
                    {
                        #region 再次提交
                        try
                        {
                            if (resultRow != null)
                            {
                                var o = new CardOrderSummitArgs()
                                {
                                    SysOrderNo = response.SysOrderNo,
                                    CardTypeId = Convert.ToInt32(resultRow["typeid"]),
                                    CardNo     = resultRow["cardno"].ToString(),
                                    CardPass   = resultRow["cardpass"].ToString(),
                                    FaceValue  = decimal.ToInt32(Convert.ToDecimal(resultRow["facevalue"])),
                                    Attach     = "",
                                    Source     = 2
                                };
                                var callBack = SendCard((SupplierCode)continueSupp, o);
                                if (callBack.SummitStatus == 1)
                                {
                                    processFlag = false;
                                }
                            }
                        }
                        catch
                        {
                        }
                        #endregion
                    }
                    else
                    {
                        processFlag = (seq == 1) || ((seq > 1) && (response.OrderStatus == 2));
                    }
                }

                if (processFlag)
                {
                    orderInfo = UpdateOrder(seq, orderInfo, response);

                    if (seq == 1 && orderInfo != null)
                    {
                        //APINotification.DoAsynchronousNotify(orderInfo);

                        APINotification.SynchronousNotifyX(orderInfo);
                    }
                }
                Cache.WebCache.GetCacheService().AddObject(cacheKey, response.OrderStatus, 5);

                return(true);
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);

                return(false);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 提交到点卡供应商接口
        /// </summary>
        /// <param name="supplier">供应商编号</param>
        /// <param name="orderid">订单ID</param>
        /// <param name="cardtype">卡类型</param>
        /// <param name="cardno">卡号</param>
        /// <param name="cardpass">卡密</param>
        /// <param name="attach"></param>
        /// <param name="facevalue">面值</param>
        /// <param name="source"></param>
        /// <returns></returns>
        public static CardSynchCallBack SynchSubmit(
            SupplierCode supplier
            , string orderid
            , int cardtype
            , string cardno
            , string cardpass
            , int facevalue
            , string attach
            , byte source)
        {
            var args = new CardOrderSummitArgs()
            {
                SysOrderNo = orderid,
                CardTypeId = cardtype,
                CardNo     = cardno,
                CardPass   = cardpass,
                FaceValue  = facevalue,
                Attach     = attach,
                Source     = source
            };

            var callBack = SendCard(supplier, args);

            if (callBack.Success == 0)
            {
                //todo:点卡切换通道提交,修改为按优先级高低排序
                #region 切换通道多次提交
                var supplierInfo = viviapi.BLL.Supplier.Factory.GetCacheModel((int)supplier);
                var channelInfo  = BLL.Channel.ChannelType.GetCacheModel(cardtype);

                if (channelInfo != null && supplierInfo != null)
                {
                    if (callBack.Success == 0 || CheckRetCode(callBack.SuppErrorCode, supplierInfo))
                    {
                        string suppList = channelInfo.SuppsWhenExceOccurred;
                        if (!string.IsNullOrEmpty(suppList))
                        {
                            string[] arr = suppList.Split(',');

                            foreach (string s in arr)
                            {
                                try
                                {
                                    callBack.SupplierId = int.Parse(s);

                                    var supplier2 = (SupplierCode)callBack.SupplierId;

                                    if (supplier2 == supplier)
                                    {
                                        continue;
                                    }
                                    callBack = SendCard(supplier2, args);

                                    if (callBack.Success == 1 && !CheckRetCode(callBack.SuppErrorCode, supplierInfo))
                                    {
                                        break;
                                    }
                                }
                                catch
                                {
                                    continue;
                                }
                            }
                        }
                    }
                }
                #endregion
            }

            return(callBack);
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string puserid   = this.SuppAccount;
            string puserkey  = this.SuppKey;
            string commitUrl = this.PostCardUrl + "?";

            string cardno   = o.CardNo;
            string cardpass = o.CardPass;
            string orderId  = o.SysOrderNo;

            string cardtype  = GetPaycardno(o.CardTypeId);
            string productid = GetCardType(o.CardTypeId, o.FaceValue);

            if (productid == "0")
            {
                productid = cardtype + o.FaceValue.ToString(CultureInfo.InvariantCulture);
            }

            string money = o.FaceValue.ToString(CultureInfo.InvariantCulture);

            string md5Str = MD5(string.Format("userid={0}&orderid={1}&typeid={2}&productid={3}&cardno={4}&cardpwd={5}&money={6}&url={7}&keyvalue={8}",
                                              puserid, orderId, cardtype, productid, cardno, cardpass, money, NotifyUrl, puserkey).ToLower());

            string postData = string.Format("userid={0}&orderid={1}&typeid={2}&productid={3}&cardno={4}&cardpwd={5}&money={6}&url={7}&sign={8}&ext={9}"
                                            , puserid, orderId, cardtype, productid, cardno, cardpass, money, NotifyUrl, md5Str, string.Empty);

            try
            {
                string callBackText = WebClientHelper.GetString(commitUrl.ToLower()
                                                                , postData
                                                                , "GET"
                                                                , Encoding.GetEncoding("GB2312")
                                                                , 5000);

                if (!string.IsNullOrEmpty(callBackText))
                {
                    string[] strings = callBackText.Split('&');

                    callBack.Success          = 1;
                    callBack.SuppCallBackText = callBackText;

                    string returncode    = strings[0].Replace("returncode=", string.Empty);
                    string returnorderid = strings[1].Replace("returnorderid=", string.Empty);
                    string sign          = strings[2].Replace("sign=", string.Empty);

                    callBack.SuppErrorCode = returncode;
                    callBack.SuppTransNo   = returnorderid;
                    callBack.SuppErrorMsg  = GetMsgInfo(returncode);

                    if (MD5(string.Format("returncode={0}&returnorderid={1}&keyvalue={2}", returncode, returnorderid, puserkey).ToLower()) == sign)
                    {
                        if (!string.IsNullOrEmpty(returncode) && returncode == "1")
                        {
                            callBack.SummitStatus = 1;
                        }
                    }
                    else
                    {
                        callBack.Message = "签名失败";
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                callBack.Success = 0;
                callBack.Message = ex.Message;
            }

            return(callBack);
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string commitUrl = this.PostCardUrl + "?";

            if (string.IsNullOrEmpty(PostCardUrl))
            {
                commitUrl = "http://it.51esales.net/gateway/zfgateway.asp?";
            }
            string cardno = GetCardNo(o.CardTypeId);
            string faceno = cardno + o.FaceValue.ToString("000");

            if (o.FaceValue >= 1000)
            {
                faceno = cardno + "000";
            }

            string remarks = string.Empty;
            string mark    = string.Empty;

            string md5Str = "customerid=" + SuppAccount + "&sdcustomno=" + o.SysOrderNo + "&noticeurl=" + NotifyUrl + "&mark=" + mark + "&key=" + SuppKey;
            string sign   = Cryptography.MD5(md5Str, "GB2312").ToUpper();

            try
            {
                var postData = new StringBuilder();
                postData.AppendFormat("&customerid={0}", SuppAccount);
                postData.AppendFormat("&sdcustomno={0}", o.SysOrderNo);
                postData.AppendFormat("&ordermoney={0}", o.FaceValue);
                postData.AppendFormat("&cardno={0}", cardno);
                postData.AppendFormat("&faceno={0}", faceno);
                postData.AppendFormat("&cardnum={0}", o.CardNo);
                postData.AppendFormat("&cardpass={0}", o.CardPass);
                postData.AppendFormat("&noticeurl={0}", NotifyUrl);
                postData.AppendFormat("&remarks={0}", remarks);
                postData.AppendFormat("&mark={0}", mark);
                postData.AppendFormat("&remoteip={0}", ServerVariables.TrueIP);
                postData.AppendFormat("&sign={0}", sign);

                callBack.Success = 0;

                SynsSummitLogger(commitUrl);

                SynsSummitLogger("postData:" + postData.ToString());

                string retXml = WebClientHelper.GetString(commitUrl, postData.ToString(), "GET", Encoding.GetEncoding("GB2312"), 10000);

                SynsSummitLogger(retXml);

                var response = new SynchResponse();
                if (!string.IsNullOrEmpty(retXml))
                {
                    response = GetSynchResponse(retXml);
                }

                if (!string.IsNullOrEmpty(response.State))
                {
                    callBack.Success          = 1;
                    callBack.SuppTransNo      = "";
                    callBack.SuppCallBackText = retXml;
                    callBack.SuppErrorCode    = response.Errcode;
                    callBack.SuppErrorMsg     = response.Errmsg;

                    if (response.State == "1")
                    {
                        callBack.SummitStatus = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                callBack.Success = 0;
                ExceptionHandler.HandleException(ex);
            }
            return(callBack);
        }
Exemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string agentID  = SuppAccount;
            string billID   = o.SysOrderNo;
            string billTime = DateTime.Now.ToString("yyyyMMddHHmmss");
            string cardType = GetCardType(o.CardTypeId);
            string cardData = o.CardNo + "," + o.CardPass + "," + o.FaceValue.ToString(CultureInfo.InvariantCulture);// Encode();

            cardData = card_Encode(cardData);

            string cardAMT  = o.FaceValue.ToString(CultureInfo.InvariantCulture);
            string clientIP = viviLib.Web.ServerVariables.TrueIP;

            string desc      = string.Empty;
            string extParam  = string.Empty;
            string timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss");

            string plain = string.Format("agent_id={0}&bill_id={1}&bill_time={2}&card_type={3}&card_data={4}&card_amt={5}&notify_url={6}&time_stamp={7}|||{8}"
                                         , agentID
                                         , billID
                                         , billTime
                                         , cardType
                                         , cardData
                                         , cardAMT
                                         , NotifyUrl
                                         , timeStamp
                                         , SuppKey);

            string sign = md5sign(plain).ToLower();

            try
            {
                string postUrl = string.Format("{9}?agent_id={0}&bill_id={1}&bill_time={2}&card_type={3}&card_data={4}&card_amt={5}&notify_url={6}&time_stamp={7}&sign={8}"
                                               , agentID
                                               , billID
                                               , billTime
                                               , cardType
                                               , cardData
                                               , cardAMT
                                               , NotifyUrl
                                               , timeStamp
                                               , sign
                                               , PostCardUrl);

                SynsSummitLogger(postUrl);

                string callBackText = WebClientHelper.GetString(postUrl, null, "get", System.Text.Encoding.GetEncoding("gbk"));

                SynsSummitLogger(callBackText);

                callBack.Success          = 1;
                callBack.SuppCallBackText = callBackText;

                if (!string.IsNullOrEmpty(callBackText))
                {
                    string[] results = callBackText.Split('&');
                    if (results.Length > 2)
                    {
                        string retCode = results[0].Replace("ret_code=", "");

                        callBack.SuppErrorCode = retCode;
                        callBack.SuppErrorMsg  = results[1];

                        if (retCode == "0")
                        {
                            callBack.SummitStatus = 1;
                        }
                        if (retCode == "99")
                        {
                            callBack.SummitStatus = 1;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                viviLib.ExceptionHandling.ExceptionHandler.HandleException(ex);

                callBack.Success = 0;
                callBack.Message = ex.Message;
            }
            return(callBack);
        }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_orderid"></param>
        /// <param name="_cardno"></param>
        /// <param name="_cardpwd"></param>
        /// <param name="_typeId"></param>
        /// <param name="cardvalue"></param>
        /// <param name="supporderid"></param>
        /// <param name="errmsg"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            //string _orderid, string _cardno, string _cardpwd, int _typeId, int cardvalue, out string supporderid, out string errmsg
            var callBack = new CardSynchCallBack();

            HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("gb2312");


            string commitUrl = this.PostCardUrl + "?";

            if (string.IsNullOrEmpty(PostCardUrl))
            {
                commitUrl = "http://zl.15173.net/AdvancedInterface.aspx?";
            }
            string payType   = GetPayType(o.CardTypeId);
            string ka_type1  = GetCardType(o.CardTypeId, o.FaceValue);
            string attach    = string.Empty;
            string zidy_code = string.Empty;

            string plain = String.Format("bargainor_id={0}&sp_billno={1}&pay_type={2}&return_url={3}&attach={4}&key={5}"
                                         , SuppAccount
                                         , o.SysOrderNo
                                         , payType
                                         , NotifyUrl
                                         , attach
                                         , SuppKey
                                         );

            SynsSummitLogger("Card15173明文:" + plain);
            string sign = viviLib.Security.Cryptography.MD5(plain).ToUpper();

            SynsSummitLogger("Card15173密文:" + sign);
            try
            {
                System.Text.StringBuilder postData = new StringBuilder();
                postData.AppendFormat("&bargainor_id={0}", SuppAccount);                                     //商户ID
                postData.AppendFormat("&sp_billno={0}", o.SysOrderNo);                                       //商户订单号
                postData.AppendFormat("&total_fee={0}", o.FaceValue.ToString(CultureInfo.InvariantCulture)); //交易金额
                postData.AppendFormat("&pay_type={0}", payType);
                postData.AppendFormat("&return_url={0}", NotifyUrl);
                postData.AppendFormat("&select_url={0}", NotifyUrl);
                //postData.AppendFormat("&ka_type1={0}", ka_type1);
                postData.AppendFormat("&ka_number1={0}", o.CardNo);
                postData.AppendFormat("&ka_password1={0}", o.CardPass);
                postData.AppendFormat("&attach={0}", attach);
                postData.AppendFormat("&zidy_code={0}", zidy_code);
                postData.AppendFormat("&sign={0}", sign);

                callBack.Success = 0;

                SynsSummitLogger(commitUrl);
                SynsSummitLogger("postData:" + postData.ToString());

                string retCode = viviLib.Web.WebClientHelper.GetString(commitUrl, postData.ToString(), "GET", System.Text.Encoding.GetEncoding("GB2312"), 10000);
                SynsSummitLogger("retCode:" + retCode);


                if (retCode.ToUpper() == "OK")
                {
                    callBack.Success          = 1;
                    callBack.SuppTransNo      = "";
                    callBack.SuppCallBackText = retCode;
                    callBack.SuppErrorCode    = "";
                    callBack.SuppErrorMsg     = "";
                    //opstate = "0";
                }
                else
                {
                    callBack.SuppTransNo      = "";
                    callBack.SuppCallBackText = retCode;
                    callBack.SuppErrorCode    = retCode;
                    callBack.SuppErrorMsg     = GetMsgInfo(retCode);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);

                callBack.Success = 0;
                callBack.Message = ex.Message;
            }
            return(callBack);
        }
Exemplo n.º 14
0
        /// <summary>
        /// http://service.800j.com/Consign/HuisuRecycleCardSubmit.aspx
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public CardSynchCallBack CardSend(CardOrderSummitArgs o)
        {
            var callBack = new CardSynchCallBack();

            string postUrl = PostCardUrl;

            if (string.IsNullOrEmpty(postUrl))
            {
                postUrl = "http://service.800j.com/Consign/HuisuRecycleCardSubmit.aspx";
            }

            string agentID  = SuppAccount;
            string billID   = o.SysOrderNo;
            string billTime = DateTime.Now.ToString("yyyyMMddHHmmss");
            string cardType = GetCardType(o.CardTypeId);
            string cardData = o.CardNo + "," + o.CardPass + "," + o.FaceValue.ToString(CultureInfo.InvariantCulture);// Encode();

            cardData = card_Encode(cardData);

            string cardPrice = o.FaceValue.ToString(CultureInfo.InvariantCulture);
            string clientIP  = ServerVariables.TrueIP;

            string desc      = string.Empty;
            string extParam  = string.Empty;
            string timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss");

            string plain = string.Format("agent_id={0}&bill_id={1}&bill_time={2}&card_type={3}&card_data={4}&card_price={5}&notify_url={6}&time_stamp={7}|||{8}"
                                         , agentID
                                         , billID
                                         , billTime
                                         , cardType
                                         , cardData
                                         , cardPrice
                                         , NotifyUrl
                                         , timeStamp
                                         , SuppKey);

            string sign = Md5Sign(plain).ToLower();

            try
            {
                postUrl = string.Format("{9}?agent_id={0}&bill_id={1}&bill_time={2}&card_type={3}&card_data={4}&card_price={5}&notify_url={6}&time_stamp={7}&sign={8}"
                                        , agentID
                                        , billID
                                        , billTime
                                        , cardType
                                        , cardData
                                        , cardPrice
                                        , NotifyUrl
                                        , timeStamp
                                        , sign
                                        , postUrl);

                SynsSummitLogger(postUrl);

                string callBackText = WebClientHelper.GetString(postUrl, null, "get", Encoding.GetEncoding("gbk"));

                SynsSummitLogger(callBackText);

                callBack.SuppCallBackText = callBackText;

                if (!string.IsNullOrEmpty(callBackText))
                {
                    string[] results = callBackText.Split('&');
                    if (results.Length > 2)
                    {
                        string retCode    = GetValue(results[0]);
                        string billStatus = GetValue(results[4]);

                        callBack.SuppErrorCode = retCode + "|" + billStatus;
                        callBack.SuppErrorMsg  = GetValue(results[7]);
                        callBack.SuppTransNo   = GetValue(results[3]);

                        if (retCode == "0" || retCode == "99")
                        {
                            callBack.Success = 1;

                            if (billStatus == "0" || billStatus == "1")
                            {
                                callBack.SummitStatus = 1;
                            }
                            if (billStatus == "2")
                            {
                                callBack.SummitStatus = 1;
                                callBack.OrderStatus  = 2;
                            }
                            if (billStatus == "-1")
                            {
                                callBack.SummitStatus = 0;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);

                callBack.Success = 0;
                callBack.Message = ex.Message;
            }
            return(callBack);
        }