Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        public void CardNotify()
        {
            HttpRequest req = HttpContext.Current.Request;

            AsynsRetLogger(req.RawUrl);

            if (req.Form.Count > 0)
            {
                string data = WebClientHelper.FormatRequestData(req.Form, System.Text.Encoding.Default);
                AsynsRetLogger(data);
            }

            String state      = req["state"].Trim();                                                                                                  //商户在51支付网关上的订单状态,0为失败,1为成功
            String customerid = req["customerid"].Trim();                                                                                             //商户在51支付网关上的ID
            String sd51No     = req["sd51no"].Trim();                                                                                                 //51支付订单流水号
            String sdcustomno = req["sdcustomno"].Trim();                                                                                             //商户提交的订单流水号
            String ordermoney = req["ordermoney"].Trim();                                                                                             //商户订单金额,注意可能与商户时提交不一致,51支付结果是以卡的面值来结算的
            String mark       = req["mark"].Trim();                                                                                                   //商户自定义原样返回
            String sign       = req["sign"].Trim();                                                                                                   //51支付提交过来的MD5签名
            String des        = req["des"].Trim();                                                                                                    //
            String signText   = "customerid=" + customerid + "&sd51no=" + sd51No + "&sdcustomno=" + sdcustomno + "&mark=" + mark + "&key=" + SuppKey; //'生成MD5签名
            String localSign  = Cryptography.MD5(signText);

            try
            {
                if (localSign == sign)
                {
                    int    status  = state == "1" ? 2: 4;
                    string opstate = "0";
                    string viewMsg = "支付成功";
                    if (status == 4)
                    {
                        opstate = "99";
                        viewMsg = "其它错误";
                    }

                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = sd51No,
                        SysOrderNo    = sdcustomno,
                        OrderAmt      = decimal.Parse(ordermoney),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = state,
                        SuppErrorMsg  = des,
                        Opstate       = opstate,
                        ViewMsg       = viewMsg,
                        Method        = 1
                    };

                    OrderCardUtils.SuppNotify(response, Succflag);
                }
                else
                {
                    HttpContext.Current.Response.Write(signText);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 处理完成,返回通知
        /// </summary>
        public void Notify()
        {
            AsynsRetLogger(HttpContext.Current.Request.RawUrl);

            if (HttpContext.Current.Request.Form.Count > 0)
            {
                string data = WebClientHelper.FormatRequestData(HttpContext.Current.Request.Form, System.Text.Encoding.Default);
                AsynsRetLogger(data);
            }

            try
            {
                string md5key       = SuppKey;
                int    status       = 4;
                string opstate      = "-1";
                string usercode     = HttpContext.Current.Request.Form["usercode"];
                string mode         = HttpContext.Current.Request.Form["mode"];
                string version      = HttpContext.Current.Request.Form["version"];
                string orderno      = HttpContext.Current.Request.Form["orderno"]; //本系统内部单号
                string billid       = HttpContext.Current.Request.Form["billid"];  //欧飞单号
                string result       = HttpContext.Current.Request.Form["result"];  //返回处理结果代码
                string info         = HttpContext.Current.Request.Form["info"];    //交易情况说明
                string value        = HttpContext.Current.Request.Form["value"];   //面值
                string accountvalue = HttpContext.Current.Request.Form["accountvalue"];
                string datetime     = HttpContext.Current.Request.Form["datetime"];
                string sign         = HttpContext.Current.Request.Form["sign"];

                string srcStr = usercode + mode + version + orderno + billid + result + info + value + accountvalue + datetime + md5key;
                string md5str = md5sign(srcStr);

                if (md5str.ToLower() == sign.ToLower())
                {      //status=2 支付成功 status=4支付失败
                    status = (result == "2000" || result == "2011") ? 2 : 4;
                    if (status == 2)
                    {
                        opstate = "0";
                    }
                    else
                    {
                        opstate = ConvertCode(result);
                    }
                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = billid,
                        SysOrderNo    = orderno,
                        OrderAmt      = decimal.Parse(value),
                        SuppAmt       = decimal.Parse(accountvalue),
                        OrderStatus   = status,
                        SuppErrorCode = result,
                        Opstate       = opstate,
                        SuppErrorMsg  = info,
                        ViewMsg       = info,
                        Method        = 1
                    };

                    OrderCardUtils.SuppNotify(response, Succflag);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            HttpRequest req = HttpContext.Current.Request;

            AsynsRetLogger(req.RawUrl);
            if (req.Form.Count > 0)
            {
                string data = WebClientHelper.FormatRequestData(req.Form, System.Text.Encoding.Default);
                AsynsRetLogger(data);
            }

            String pay_result     = req["pay_result"].Trim();     //交易结果0为成功,3为失败
            String bargainor_id   = req["bargainor_id"].Trim();   //15173交易订单号
            String transaction_id = req["transaction_id"].Trim(); //商户ID
            String sp_billno      = req["sp_billno"].Trim();      //商户请求交易时候提交的订单号
            String total_fee      = req["total_fee"].Trim();      //实际交易交易金额(注意:可能和商户请求交易提交过来的total_fee不一样!)
            String sign           = req["sign"].Trim();
            String attach         = req["attach"].Trim();
            String pay_info       = req["pay_info"].Trim();//交易类型中文说明

            //'生成MD5签名
            String sign_text = String.Format("pay_result={0}&bargainor_id={1}&sp_billno={2}&total_fee={3}&attach={4}&key={5}"
                                             , pay_result
                                             , bargainor_id
                                             , sp_billno
                                             , total_fee
                                             , attach
                                             , SuppKey);

            String localSign = viviLib.Security.Cryptography.MD5(sign_text).ToUpper();

            try
            {
                if (localSign == sign)
                {
                    string viewMsg = string.Empty;
                    string opstate = "-1";
                    int    status  = 4;

                    if (pay_result == "0")
                    {
                        opstate = "0";
                        status  = 2;
                        viewMsg = "支付成功";
                    }
                    else
                    {
                        viewMsg = "支付失败";
                    }
                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = bargainor_id,
                        SysOrderNo    = sp_billno,
                        OrderAmt      = decimal.Parse(total_fee),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = status.ToString(),
                        Opstate       = opstate,
                        SuppErrorMsg  = viewMsg,
                        ViewMsg       = viewMsg,
                        Method        = 1
                    };
                    OrderCardUtils.SuppNotify(response, Succflag);
                    //BLL.OrderCard bll = new viviapi.BLL.OrderCard();
                    //bll.ReceiveSuppResult(SuppId, sp_billno, transaction_id, status, opstate, pay_result, decimal.Parse(total_fee), 0M, pay_result);
                    //HttpContext.Current.Response.Write("OK");
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                HttpContext.Current.Response.Write("error");
            }
        }