/// <summary>
        /// 订单支付成功商家异步
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public LineResponsePara LinePayCallBack(HttpContext context)
        {
            var    responseForm = context.Request.Form;
            string orderNumber  = responseForm["outOrderId"].IsNull()
                ? string.Empty : responseForm["outOrderId"];

            var response = new LineResponsePara()
            {
                isPaySuccess = false,
                orderNumber  = orderNumber,
                paymentMoney = 0,
                resultMsg    = string.Empty
            };

            try
            {
                RSAOperate Rdaop = new RSAOperate();
                //处理传输过来的流
                Stream       responseStream = context.Request.InputStream;
                StreamReader readStream     = new StreamReader(responseStream, System.Text.Encoding.UTF8);
                string       RequestStream  = readStream.ReadToEnd();
                readStream.Close();


                if (!string.IsNullOrEmpty(RequestStream))
                {
                    string RSAChar = Rdaop.GetUrlParamString(RequestStream, RSASign.GetNoticeRSAParamSort()) + ProperConst.Key;
                    if (Rdaop.GetIsSafty(Rdaop.GetjosnValue(RequestStream, "sign"), RSAChar)) //判断是否报文加密后能够匹配
                    {
                        lock (lockobject)                                                     //此处建议使用lock锁机制,进行并发控制,防止重复数据混乱
                        {
                            response.isPaySuccess = true;
                            response.orderNumber  = responseForm["orderNumber"].IsNull()
                                                   ? string.Empty : responseForm["orderNumber"];
                            response.paymentMoney = responseForm["totalAmount"].IsNull() ? (decimal)0.00
                                                  : AlipayConfig.MoneyFormatDco(responseForm["totalAmount"]);;
                            response.resultMsg = "支付成功";
                        }
                    }
                    else
                    {
                        response.resultMsg = "返回报文加密信息存在异常";
                        context.Response.Write("{\"code\":\"01\",\"msg\":\"返回报文加密信息存在异常\"}");
                    }
                }
                else
                {
                    response.resultMsg = "返回报文为空存在异常";
                    context.Response.Write("{\"code\":\"02\",\"msg\":\"返回报文为空存在异常\"}");
                }
            }
            catch (Exception ex)
            {
                response.resultMsg = "报文异常" + ex.Message;
                context.Response.Write("{\"code\":\"03\",\"msg\":\"报文异常\"}");
            }

            return(response);
        }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 public void Notify()
 {
     try
     {
         RSAOperate Rdaop = new RSAOperate(SuppId);
         //处理传输过来的流
         Stream       responseStream = HttpContext.Current.Request.InputStream;
         StreamReader readStream     = new StreamReader(responseStream, System.Text.Encoding.UTF8);
         string       RequestStream  = readStream.ReadToEnd();
         readStream.Close();
         if (!string.IsNullOrEmpty(RequestStream))
         {
             string RSAChar = Rdaop.GetUrlParamString(RequestStream, Demo.Class.RSASign.GetNoticeRSAParamSort()) + "&KEY=" + SuppKey;
             if (Rdaop.GetIsSafty(Rdaop.GetjosnValue(RequestStream, "sign"), RSAChar)) //判断是否报文加密后能够匹配
             {
                 lock (lockobject)                                                     //此处建议使用lock锁机制,进行并发控制,防止重复数据混乱
                 {
                     //此处由用户自己进行返回单据信息进行处理
                     //可以用Rdaop.GetjosnValue(RequestStream, "sign")类似   获取对应单据信息,进行单据信息在客户端服务器处理
                     //todo:中联信息返回待完成
                     string billno      = Rdaop.GetjosnValue(RequestStream, "outOrderId");
                     string zlineBillno = Rdaop.GetjosnValue(RequestStream, "instructCode");
                     string amount      = Rdaop.GetjosnValue(RequestStream, "totalAmount");//
                     string msg         = "";
                     string opstate     = "-1";
                     int    status      = 4;
                     //判断交易是否成功
                     if (Convert.ToDecimal(amount) > 0)
                     {
                         opstate = "0";
                         status  = 2;
                     }
                     OrderBankUtils.SuppNotify(SuppId
                                               , billno
                                               , zlineBillno
                                               , status
                                               , opstate
                                               , msg
                                               , decimal.Parse(amount) / 100m
                                               , 0M
                                               , Succflag
                                               , Failflag);
                 }
             }
             else
             {
                 HttpContext.Current.Response.Write("{\"code\":\"00\",\"msg\":\"返回报文加密信息存在异常\"}");//00表示已经收到报文
             }
         }
         else
         {
             HttpContext.Current.Response.Write("{\"code\":\"00\",\"msg\":\"返回报文为空存在异常\"}");//00表示已经收到报文
         }
     }
     catch (Exception eh)
     {
         HttpContext.Current.Response.Write("{\"code\":\"00\",\"msg\":\"报文异常\"}");//00表示已经收到报文
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         RSAOperate Rdaop = new RSAOperate();
         QueryParam = ProperConst.payUrl;
         signValue  = Rdaop.GetUrlParamString(Request.Form, MD5.GetPayRSAParamSort());
         sign       = MD5.md5Sign(signValue + ProperConst.Key);
     }
 }
        /// <summary>
        /// 订单支付表单HTML字符串生成
        /// </summary>
        /// <param name="context">请求上下文对象</param>
        /// <param name="para">订单相关参数</param>
        /// <returns></returns>
        public string LinePaySendRequestWriter(LineRequestPara para)
        {
            string     key       = string.Empty;
            string     keyValue  = string.Empty;
            string     signValue = string.Empty;
            string     sign      = string.Empty;
            RSAOperate Rdaop     = new RSAOperate();

            Dictionary <string, string> dic = new Dictionary <string, string>()
            {
                { "outOrderId", para.outOrderId },
                { "totalAmount", para.totalAmount.ToString() },
                { "goodsName", para.goodsName },
                { "goodsExplain", para.goodsExplain },
                { "merUrl", para.merUrl },
                { "noticeUrl", para.noticeUrl },
                { "bankCardType", para.bankCardType },
                { "bankCode", para.bankCode },
                { "orderCreateTime", para.orderCreateTime },
                { "lastPayTime", para.lastPayTime }
            };


            signValue = Rdaop.GetUrlParamString(CreateRquestUrlPara(para), RSASign.GetPayRSAParamSort());
            //提交参数加密
            sign = RSASign.GetMD5RSA(signValue + ProperConst.Key);

            var paraSort = RSASign.GetPayParamSort().ToList();


            StringBuilder writer = new StringBuilder();

            writer.Append(" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> ");
            writer.Append(" <html xmlns=\"http://www.w3.org/1999/xhtml\" > ");
            writer.Append(" <head runat=\"server\"><title>中联信通支付</title> ");
            writer.Append(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/> ");
            writer.Append(" </head><body> ");
            writer.AppendFormat(" <form id=\"formpay\" method=\"post\" action=\"{0}\"> ", ProperConst.payUrl);

            paraSort.ForEach(k =>
            {
                key = k;
                if (key == "merchantCode")
                {
                    keyValue = ProperConst.merchantCode;
                }
                else
                {
                    keyValue = dic[key];
                }

                writer.AppendFormat(" <input type=\"text\" name=\"{0}\" style=\"display:none;\" value=\"{1}\"/> ",
                                    key, keyValue);
            });

            writer.AppendFormat(" <input type=\"text\" name=\"sign\"  style=\"display:none;\" value=\"{0}\"/> ", sign);
            writer.Append(" </form> ");
            writer.Append(" <script type=\"text/javascript\"> document.getElementById(\"formpay\").submit();</script> ");

            return(writer.ToString());
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="orderAmt"></param>
        /// <param name="bankcode"></param>
        /// <param name="autoSubmit"></param>
        /// <returns></returns>
        public string PayBank(string orderid, decimal orderAmt, string bankcode, bool autoSubmit)
        {
            //        <form id="form1" method="post" action="https://payment.kklpay.com/ebank/pay.do">
            //    <input type="text" name="merchantCode" style=" display:none;" value="1000000183"/>
            //    <input type="text" name="outOrderId" style=" display:none;" value="123123321123yhg"/>
            //    <input type="text" name="totalAmount" style=" display:none;" value="1"/>
            //    <input type="text" name="goodsName" style=" display:none;" value="goodsName"/>
            //    <input type="text" name="goodsExplain" style=" display:none;" value="goodsExplain"/>
            //    <input type="text" name="orderCreateTime" style=" display:none;" value="20150210213410"/>
            //    <input type="text" name="lastPayTime" style=" display:none;" value=""/>
            //    <input type="text" name="merUrl" style=" display:none;" value="http://www.baidu.com/Demo/Rec.aspx"/>
            //    <input type="text" name="noticeUrl" style=" display:none;" value="http://www.baidu.com/Demo/SynNotice.aspx"/>
            //    <input type="text" name="bankCode" style=" display:none;" value="BOC"/>
            //    <input type="text" name="bankCardType" style=" display:none;" value="00"/>
            //<input type="text" name="sign"  style=" display:none;" value="3C72DF74572665A22EA0E190E65869EA"/>
            //</form>
            //<script type="text/javascript"> document.getElementById("form1").submit();</script>


            //提交地址
            string form_url = PostBankUrl;
            //商户号
            string Mer_code = SuppAccount;
            string Mer_key  = SuppKey;
            //商户订单编号
            string Billno = orderid;
            //订单金额(分)
            string Amount = decimal.Round(orderAmt * 100, 0).ToString();

            string              keyValue   = string.Empty;
            string              key        = string.Empty;
            string              sign       = string.Empty;
            string              signValue  = string.Empty;
            RSAOperate          Rdaop      = new RSAOperate(SuppId);
            NameValueCollection collection = new NameValueCollection();

            collection.Add("merchantCode", Mer_code);
            collection.Add("outOrderId", Billno);
            collection.Add("totalAmount", Amount);
            collection.Add("orderCreateTime", DateTime.Now.ToString("yyyyMMddhhmmss"));
            collection.Add("lastPayTime", DateTime.Now.ToString("yyyyMMddhhmmss"));
            collection.Add("merUrl", Returnurl);
            collection.Add("noticeUrl", NotifyUrl);
            collection.Add("bankCode", GetBankCode(bankcode));
            collection.Add("bankCardType", "00");
            collection.Add("goodsName", "goodsname");
            collection.Add("goodsExplain", "explain");
            signValue = Rdaop.GetUrlParamString(collection, RSASign.GetPayRSAParamSort());
            sign      = RSASign.GetMD5RSA(signValue + "&KEY=" + SuppKey);
            collection.Add("sign", sign);
            SynsSummitLogger("plain: " + signValue);
            SynsSummitLogger("SignMD5: " + sign);

            string postForm = "<form name=\"form1\" id=\"form1\" method=\"post\" action=\"" + PostBankUrl + "\">";

            for (int i = 0; i < RSASign.GetPayParamSort().Length; i++)
            {
                key = RSASign.GetPayParamSort()[i];
                if (key == "merchantCode")
                {
                    keyValue = Mer_code;
                }
                else
                {
                    keyValue = collection[RSASign.GetPayParamSort()[i]];
                }

                postForm += "<input type=\"text\" name=\"" + key + "\" style=\" display:none;\" value=\"" + keyValue + "\"/>";
            }

            postForm += "<input type=\"text\" name=\"sign\"  style=\" display:none;\" value=\"" + sign + "\"/></form>";


            if (autoSubmit == true)
            {
                //自动提交该表单到测试网关
                postForm +=
                    "<script type=\"text/javascript\" language=\"javascript\">setTimeout(\"document.getElementById('form1').submit();\",100);</script>";
            }

            SynsSummitLogger("SignMD5: " + postForm);
            return(postForm);
        }
Exemple #6
0
        /// <summary>
        /// 同步返回信息
        /// </summary>
        public void ReturnBank()
        {
            //<form action="http://pay.wengpay.com/return/zline/bank.aspx" id="form1" method="post">

            //<input type="hidden" name="sign" id="sign" value="CF83653CA3C0CC2DFD79C58E0C718C9D" />//签名

            //<input type="hidden" name="result" id="result" value="" />

            //<input type="hidden" name="transType" id="transType" value="00200" />//交易类型

            //<input type="hidden" name="instructCode" id="instructCode" value="11001455960" />//交易订单号

            //<input type="hidden" name="waitTime" id="waitTime" value="" />

            //<input type="hidden" name="autoJump" id="autoJump" value="1" />

            //<input type="hidden" name="transTime" id="transTime" value="20151007221549" />//交易时间

            //<input type="hidden" name="totalAmount" id="totalAmount" value="100" />//消费金额

            //<input type="hidden" name="merchantCode" id="merchantCode" value="1000000183" />//商户号

            //<input type="hidden" name="outOrderId" id="outOrderId" value="B4687724001572971251" />//商户订单
            try
            {
                RSAOperate Rdaop = new RSAOperate(SuppId);

                NameValueCollection collection = new NameValueCollection();
                collection.Add("sign", HttpContext.Current.Request.Form["sign"]);
                collection.Add("transType", HttpContext.Current.Request.Form["transType"]);
                collection.Add("instructCode", HttpContext.Current.Request.Form["instructCode"]);
                collection.Add("transTime", HttpContext.Current.Request.Form["transTime"]);
                collection.Add("totalAmount", HttpContext.Current.Request.Form["totalAmount"]);
                collection.Add("merchantCode", HttpContext.Current.Request.Form["merchantCode"]);
                collection.Add("outOrderId", HttpContext.Current.Request.Form["outOrderId"]);
                string sign    = HttpContext.Current.Request.Form["sign"];
                string RSAChar = Rdaop.GetUrlParamString(collection, Demo.Class.RSASign.GetNoticeRSAParamSort()) + "&KEY=" + SuppKey;
                if (sign == RSASign.GetMD5RSA(RSAChar))//判断是否报文加密后能够匹配
                {
                    string billno = HttpContext.Current.Request.Form["outOrderId"];
                    //中联订单号
                    string zlineBillno = HttpContext.Current.Request.Form["instructCode"];
                    //消费金额
                    string amount  = HttpContext.Current.Request.Form["totalAmount"];//
                    string msg     = "";
                    string opstate = "-1";
                    int    status  = 4;
                    //判断交易是否成功
                    if (Convert.ToDecimal(amount) > 0)
                    {
                        opstate = "0";
                        status  = 2;
                    }

                    OrderBankUtils.SuppPageReturn(SuppId
                                                  , billno
                                                  , zlineBillno
                                                  , status
                                                  , opstate
                                                  , string.Empty
                                                  , decimal.Parse(amount) / 100m, 0M);
                }
                else
                {
                    HttpContext.Current.Response.Write("返回报文加密信息存在异常");//00表示已经收到报文
                }
            }
            catch (Exception eh)
            {
                HttpContext.Current.Response.Write("报文异常" + eh.Message);//00表示已经收到报文
            }
        }