예제 #1
0
        /// <summary>
        /// 掌柜通支付通知信息
        /// </summary>
        /// <param name="data"></param>
        public void Notify(string data)
        {
            data = AESUtil.Decrypt(data, MerchantKey);

            PayResultJson result  = Newtonsoft.Json.JsonConvert.DeserializeObject <PayResultJson>(data);
            string        opstate = "1";
            ///支付结果回调验签
            bool r = Digest.PayResultVerifyHMAC(result.customernumber, result.requestid, result.code, result.notifytype, result.externalid, result.amount, result.cardno, this.MerchantKey, result.hmac);

            if (r)
            {
                if (result.code == 1)
                {
                    decimal amt = 0;
                    string  msg = string.Empty;
                    if (decimal.TryParse(result.amount, out amt))
                    {
                        opstate = "0";
                        msg     = "成功";
                    }
                    OrderBankUtils.SuppNotify(suppid, "", result.requestid
                                              , 2
                                              , opstate
                                              , msg
                                              , amt
                                              , amt
                                              , "Success"
                                              , "Failure");
                }
            }
        }
예제 #2
0
        public void ReturnBank()
        {
            HttpRequest request         = HttpContext.Current.Request;
            string      orderId         = request.QueryString["orderid"];
            string      str2            = request.QueryString["opstate"];
            string      s               = request.QueryString["ovalue"];
            string      str4            = request.QueryString["sign"];
            string      supplierOrderId = request.QueryString["ekaorderid"];
            string      str6            = request.QueryString["ekatime"];
            string      str8            = Cryptography.MD5(string.Format("orderid={0}&opstate={1}&ovalue={2}{3}", new object[] { orderId, str2, s, base.SuppKey }));

            try
            {
                if (str8 == str4)
                {
                    string opstate = "-1";
                    int    status  = 4;
                    if (str2.ToLower() == "0")
                    {
                        opstate = "0";
                        status  = 2;
                    }
                    OrderBankUtils.SuppNotify(suppId, orderId, supplierOrderId, status, opstate, "", decimal.Parse(s), 0M, "opstate=0", "opstate=-1");
                    HttpContext.Current.Response.Write("opstate=0");
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
            }
        }
예제 #3
0
        public void Notify2()
        {
            string key = GetFormString("key", string.Empty);
            string ddh = GetFormString("ddh", string.Empty);
            string cny = GetFormString("cny", "0");
            string a1  = GetFormString("a1", string.Empty);
            string a3  = GetFormString("a3", string.Empty);

            //-----------------------------------------------------------------

            if (a3 != "1")
            {
                return;
            }

            if (key == SuppKey)
            {
                decimal result = 0M;
                if (decimal.TryParse(cny, out result))
                {
                    OrderBankUtils.SuppNotify(SuppId
                                              , a1
                                              , ddh
                                              , 2
                                              , "0"
                                              , "msg"
                                              , result
                                              , 0M
                                              , "ok"
                                              , "fail");
                }
            }
        }
예제 #4
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表示已经收到报文
     }
 }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        public void ReturnBank()
        {
            //接收数据
            string billno        = HttpContext.Current.Request["billno"];
            string amount        = HttpContext.Current.Request["amount"];
            string currency_type = HttpContext.Current.Request["Currency_type"];
            string mydate        = HttpContext.Current.Request["date"];
            string succ          = HttpContext.Current.Request["succ"];
            string msg           = HttpContext.Current.Request["msg"];
            string attach        = HttpContext.Current.Request["attach"];
            string ipsbillno     = HttpContext.Current.Request["ipsbillno"];
            string retEncodeType = HttpContext.Current.Request["retencodetype"];
            string signature     = HttpContext.Current.Request["signature"];

            //签名原文
            string content = billno + amount + mydate + succ + ipsbillno + currency_type;

            //签名是否正确
            Boolean verify = false;

            if (retEncodeType == "17")
            {
                string plain = "billno{0}currencytype{1}amount{2}date{3}succ{4}ipsbillno{5}retencodetype{6}{7}";
                plain = string.Format(plain, billno, currency_type, amount, mydate, succ, ipsbillno, retEncodeType, SuppKey);
                string signature1 = Cryptography.MD5(plain);
                if (signature1 == signature)
                {
                    verify = true;
                }
            }

            string info = "支付失败" + msg;

            //判断签名验证是否通过
            if (verify == true)
            {
                string opstate = "-1";
                int    status  = 4;
                //判断交易是否成功
                if (succ == "Y")
                {
                    info    = "支付成功";
                    opstate = "0";
                    status  = 2;
                }

                OrderBankUtils.SuppPageReturn(SuppId
                                              , billno
                                              , ipsbillno
                                              , status
                                              , opstate
                                              , info
                                              , decimal.Parse(amount), 0M);
            }
            else
            {
                HttpContext.Current.Response.Write("签名不正确!");
            }
        }
예제 #6
0
        public void Notify(HttpContext context)
        {
            string opstate = "-1";
            int    status  = 4;

            HttpRequest Request = context.Request;

            #region 获取参数值
            string result        = Request["result"];
            string pay_message   = Request["pay_message"];
            string agent_id      = Request["agent_id"];
            string jnet_bill_no  = Request["jnet_bill_no"];
            string agent_bill_id = Request["agent_bill_id"];
            string pay_type      = Request["pay_type"];
            string pay_amt       = Request["pay_amt"];
            string remark        = Request["remark"];
            string returnSign    = Request["sign"];

            //获取签名
            StringBuilder sbSign = new StringBuilder();
            sbSign.Append("result=" + result)
            .Append("&agent_id=" + agent_id)
            .Append("&jnet_bill_no=" + jnet_bill_no)
            .Append("&agent_bill_id=" + agent_bill_id)
            .Append("&pay_type=" + pay_type)
            .Append("&pay_amt=" + pay_amt)
            .Append("&remark=" + remark)
            .Append("&key=" + this.SuppKey);


            string sign = FormsAuthentication.HashPasswordForStoringInConfigFile(sbSign.ToString(), "md5").ToLower();

            #endregion

            if (returnSign.Equals(sign))
            {
                string msg = pay_message;

                if (result == "1")
                {
                    msg     = "支付成功";
                    opstate = "0";
                    status  = 2;
                }
                decimal tranAmt = 0M;
                decimal.TryParse(pay_amt, out tranAmt);
                OrderBankUtils.SuppNotify(suppid
                                          , agent_bill_id
                                          , jnet_bill_no
                                          , status
                                          , opstate
                                          , msg
                                          , tranAmt, tranAmt
                                          , Succflag
                                          , Failflag);
            }
        }
예제 #7
0
        /// <summary>
        ///
        /// </summary>
        public void Return()
        {
            string opstate = "-1";
            int    status  = 4;

            BuyCallbackResult result = Buy.VerifyCallback(SuppAccount
                                                          , SuppKey
                                                          , FormatQueryString.GetQueryString("r0_Cmd")
                                                          , FormatQueryString.GetQueryString("r1_Code")
                                                          , FormatQueryString.GetQueryString("r2_TrxId")
                                                          , FormatQueryString.GetQueryString("r3_Amt")
                                                          , FormatQueryString.GetQueryString("r4_Cur")
                                                          , FormatQueryString.GetQueryString("r5_Pid")
                                                          , FormatQueryString.GetQueryString("r6_Order")
                                                          , FormatQueryString.GetQueryString("r7_Uid")
                                                          , FormatQueryString.GetQueryString("r8_MP")
                                                          , FormatQueryString.GetQueryString("r9_BType")
                                                          , FormatQueryString.GetQueryString("rp_PayDate")
                                                          , FormatQueryString.GetQueryString("hmac"));

            if (string.IsNullOrEmpty(result.ErrMsg))
            {
                string msg = "支付失败";

                if (result.R1_Code == "1")
                {
                    msg     = "支付成功";
                    opstate = "0";
                    status  = 2;
                }
                decimal tranAmt = 0M;
                decimal.TryParse(result.R3_Amt, out tranAmt);

                if (result.R9_BType == "1")
                {
                    OrderBankUtils.SuppPageReturn(SuppId
                                                  , result.R6_Order
                                                  , result.R2_TrxId
                                                  , status
                                                  , opstate
                                                  , msg
                                                  , tranAmt, 0M);
                }
                else if ((result.R9_BType == "2") || (result.R9_BType == "3"))
                {
                    OrderBankUtils.SuppNotify(SuppId
                                              , result.R6_Order
                                              , result.R2_TrxId
                                              , status
                                              , opstate
                                              , msg
                                              , tranAmt, tranAmt
                                              , Succflag
                                              , Failflag);
                }
            }
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            string callbackText = "";

            SortedDictionary <string, string> sPara = GetRequestPost();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                string partner = SuppAccount;
                //string pusername = suppUserName;
                string key = SuppKey;

                Notify aliNotify = new Notify();

                bool verifyResult = aliNotify.Verify(sPara, HttpContext.Current.Request.Form["notify_id"], HttpContext.Current.Request.Form["sign"]);
                if (verifyResult)//验证成功
                {
                    string  opstate = "-1";
                    int     status  = 4;
                    string  msg     = "支付失败";
                    decimal result  = 0M;

                    string out_trade_no = HttpContext.Current.Request.Form["out_trade_no"];
                    string trade_no     = HttpContext.Current.Request.Form["trade_no"];
                    string trade_status = HttpContext.Current.Request.Form["trade_status"];
                    string total_fee    = HttpContext.Current.Request.Form["total_fee"];

                    if (HttpContext.Current.Request.Form["trade_status"] == "TRADE_FINISHED" ||
                        HttpContext.Current.Request.Form["trade_status"] == "TRADE_SUCCESS")
                    {
                        if (decimal.TryParse(total_fee, out result))
                        {
                            msg     = "成功";
                            opstate = "0";
                            status  = 2;
                        }
                    }
                    else
                    {
                        msg = "trade_status=" + HttpContext.Current.Request.Form["trade_status"];
                    }

                    OrderBankUtils.SuppNotify(SuppId
                                              , out_trade_no
                                              , trade_no
                                              , status
                                              , opstate
                                              , msg
                                              , result, 0M
                                              , Succflag
                                              , Failflag);
                }
            }
        }
예제 #9
0
        /// <summary>
        ///
        /// </summary>
        public void ReturnBank()
        {
            string merchantCode = HttpContext.Current.Request.QueryString[MERCHANT_CODE];
            string notifyType   = HttpContext.Current.Request.QueryString[NOTIFY_TYPE];
            string orderNo      = HttpContext.Current.Request.QueryString[ORDER_NO];
            string orderAmount  = HttpContext.Current.Request.QueryString[ORDER_AMOUNT];
            string orderTime    = HttpContext.Current.Request.QueryString[ORDER_TIME];
            string returnParams = HttpContext.Current.Request.QueryString[RETURN_PARAMS];
            string tradeNo      = HttpContext.Current.Request.QueryString[TRADE_NO];
            string tradeTime    = HttpContext.Current.Request.QueryString[TRADE_TIME];
            string tradeStatus  = HttpContext.Current.Request.QueryString[TRADE_STATUS];
            string sign         = HttpContext.Current.Request.QueryString[SIGN];

            KeyValues kvs = new KeyValues();

            kvs.add(new KeyValue(MERCHANT_CODE, merchantCode));
            kvs.add(new KeyValue(NOTIFY_TYPE, notifyType));
            kvs.add(new KeyValue(ORDER_NO, orderNo));
            kvs.add(new KeyValue(ORDER_AMOUNT, orderAmount));
            kvs.add(new KeyValue(ORDER_TIME, orderTime));
            kvs.add(new KeyValue(RETURN_PARAMS, returnParams));
            kvs.add(new KeyValue(TRADE_NO, tradeNo));
            kvs.add(new KeyValue(TRADE_TIME, tradeTime));
            kvs.add(new KeyValue(TRADE_STATUS, tradeStatus));

            String _sign = kvs.sign(THConfig.merchantKey, THConfig.charset);
            string info  = "支付失败";

            if (_sign == sign)
            {
                string opstate = "-1";
                int    status  = 4;
                if ("success" == tradeStatus)
                {
                    info    = "支付成功";
                    opstate = "0";
                    status  = 2;
                }
                OrderBankUtils.SuppPageReturn(SuppId
                                              , orderNo
                                              , tradeNo
                                              , status
                                              , opstate
                                              , info
                                              , decimal.Parse(orderAmount), 0M);

                //这个success字符串在支付成功的情况下必须填入,因为交易平台回调商户的后台通知地址后,会通过返回的内容中包含success来判别商户是否收到通知,并成功告知交易平台。
                //这个success字符串只有在商户后台通知时必须填写,页面通知可不填写。
            }
            else
            {
                HttpContext.Current.Response.Write("签名不正确!");
            }
        }
예제 #10
0
        public void Notify()
        {
            HttpRequest request         = HttpContext.Current.Request;
            string      orderId         = request.QueryString["orderid"];
            string      opstate         = request.QueryString["opstate"];
            string      ovalue          = request.QueryString["ovalue"];
            string      sign            = request.QueryString["sign"];
            string      supplierOrderId = request.QueryString["sysorderid"];
            string      str6            = request.QueryString["completiontime"];
            string      attach          = request.QueryString["attach"];
            string      msg             = request.QueryString["msg"];
            string      str8            = Cryptography.MD5(string.Format("orderid={0}&opstate={1}&ovalue={2}{3}", new object[] { orderId, opstate, ovalue, base.SuppKey }));

            try
            {
                if (str8 == sign)
                {
                    string opstate1 = "-1";
                    int    status   = 4;
                    if (opstate.ToLower() == "0")
                    {
                        opstate1 = "0";
                        status   = 2;
                    }
                    string viewMsg = "成功";

                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = suppId,
                        SuppTransNo   = supplierOrderId,
                        SysOrderNo    = orderId,
                        OrderAmt      = decimal.Parse(ovalue),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = opstate,
                        Opstate       = opstate1,
                        SuppErrorMsg  = viewMsg,
                        ViewMsg       = viewMsg,
                        Method        = 1
                    };


                    OrderBankUtils.SuppNotify(suppId, orderId, supplierOrderId, status, opstate, "", decimal.Parse(ovalue), 0M, "opstate=0", "opstate=-1");

                    HttpContext.Current.Response.Write("opstate=0");
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
            }
        }
예제 #11
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            string merchantCode = HttpContext.Current.Request.QueryString[MERCHANT_CODE];
            string notifyType   = HttpContext.Current.Request.QueryString[NOTIFY_TYPE];
            string orderNo      = HttpContext.Current.Request.QueryString[ORDER_NO];
            string orderAmount  = HttpContext.Current.Request.QueryString[ORDER_AMOUNT];
            string orderTime    = HttpContext.Current.Request.QueryString[ORDER_TIME];
            string returnParams = HttpContext.Current.Request.QueryString[RETURN_PARAMS];
            string tradeNo      = HttpContext.Current.Request.QueryString[TRADE_NO];
            string tradeTime    = HttpContext.Current.Request.QueryString[TRADE_TIME];
            string tradeStatus  = HttpContext.Current.Request.QueryString[TRADE_STATUS];
            string sign         = HttpContext.Current.Request.QueryString[SIGN];

            KeyValues kvs = new KeyValues();

            kvs.add(new KeyValue(MERCHANT_CODE, merchantCode));
            kvs.add(new KeyValue(NOTIFY_TYPE, notifyType));
            kvs.add(new KeyValue(ORDER_NO, orderNo));
            kvs.add(new KeyValue(ORDER_AMOUNT, orderAmount));
            kvs.add(new KeyValue(ORDER_TIME, orderTime));
            kvs.add(new KeyValue(RETURN_PARAMS, returnParams));
            kvs.add(new KeyValue(TRADE_NO, tradeNo));
            kvs.add(new KeyValue(TRADE_TIME, tradeTime));
            kvs.add(new KeyValue(TRADE_STATUS, tradeStatus));

            String _sign = kvs.sign(THConfig.merchantKey, THConfig.charset);

            if (_sign == sign)
            {
                string opstate = "-1";
                int    status  = 4;
                if ("success" == tradeStatus)
                {
                    opstate = "0";
                    status  = 2;
                }

                OrderBankUtils.SuppNotify(SuppId
                                          , orderNo
                                          , tradeNo
                                          , status
                                          , opstate
                                          , tradeStatus
                                          , decimal.Parse(orderAmount), decimal.Parse(orderAmount)
                                          , Succflag
                                          , Failflag);
            }
            else
            {
                HttpContext.Current.Response.Write("fail");
            }
        }
예제 #12
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            string state      = HttpContext.Current.Request["state"];
            string customerid = HttpContext.Current.Request["customerid"];
            string sd51no     = HttpContext.Current.Request["sd51no"];
            string sdcustomno = HttpContext.Current.Request["sdcustomno"];
            string ordermoney = HttpContext.Current.Request["ordermoney"];
            string cardno     = HttpContext.Current.Request["cardno"];
            string mark       = HttpContext.Current.Request["mark"];//1:成功 2:失败
            string sign       = HttpContext.Current.Request["sign"];
            string resign     = HttpContext.Current.Request["resign"];
            string des        = HttpContext.Current.Request["des"];
            //签名是否正确
            Boolean verify = false;
            string  plain  = "customerid={0}&sd51no={1}&sdcustomno={2}&key={3}";

            plain = string.Format(plain, customerid, sd51no, sdcustomno, SuppKey);
            string sign1 = Cryptography.MD5(plain).ToUpper();

            this.LogWrite("51Alipay_abc校验:plain=" + plain + "\t sign1:" + sign1 + "\t sign:" + sign);
            if (sign1 == sign)
            {
                verify = true;
            }
            //判断签名验证是否通过
            this.LogWrite("51Alipay_abc校验:" + verify);
            if (verify == true)
            {
                string opstate = "-1";
                int    status  = 4;
                //判断交易是否成功
                if (state == "1")
                {
                    opstate = "0";
                    status  = 2;
                }
                this.LogWrite("51Alipay_abc金额:" + ordermoney);
                OrderBankUtils.SuppNotify(SuppId
                                          , sdcustomno
                                          , sd51no
                                          , status
                                          , opstate
                                          , state
                                          , Convert.ToDecimal(ordermoney), Convert.ToDecimal(ordermoney)
                                          , Succflag
                                          , Failflag);
            }
            else
            {
                HttpContext.Current.Response.Write("fail");
            }
        }
예제 #13
0
        /// <summary>
        ///
        /// </summary>
        public void ReturnBank()
        {
            //接收数据
            string orderId = HttpContext.Current.Request["sdcustomno"];
            string status  = HttpContext.Current.Request["state"];//1:成功 2:失败
            string tradeNo = HttpContext.Current.Request["sd51no"];
            string sign    = HttpContext.Current.Request["sign"];

            //签名是否正确
            Boolean verify = false;

            string plain = "sdcustomno={0}&state={1}&sd51no={2}&key={3}";

            plain = string.Format(plain, orderId, status, tradeNo, SuppKey);
            string signature1 = Cryptography.MD5(plain).ToUpper();

            if (signature1 == sign)
            {
                verify = true;
            }


            string info = "支付失败";

            //判断签名验证是否通过
            if (verify == true)
            {
                string opstate = "-1";
                int    status1 = 4;
                //判断交易是否成功
                if (status == "1")
                {
                    info    = "支付成功";
                    opstate = "0";
                    status1 = 2;
                }
                return;

                OrderBankUtils.SuppPageReturn(
                    SuppId
                    , orderId
                    , tradeNo
                    , status1
                    , opstate
                    , info
                    , 0m, 0M);
            }
            else
            {
                HttpContext.Current.Response.Write("签名不正确!");
            }
        }
예제 #14
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            string state      = HttpContext.Current.Request["state"];
            string customerid = HttpContext.Current.Request["customerid"];
            string sd51no     = HttpContext.Current.Request["sd51no"];
            string sdcustomno = HttpContext.Current.Request["sdcustomno"];
            string ordermoney = HttpContext.Current.Request["ordermoney"];
            string cardno     = HttpContext.Current.Request["cardno"];
            string mark       = HttpContext.Current.Request["mark"];
            string sign       = HttpContext.Current.Request["sign"];
            string resign     = HttpContext.Current.Request["resign"];
            string des        = HttpContext.Current.Request["des"];
            //签名是否正确
            Boolean verify = false;

            string plain = "customerid={0}&sd51no={1}&sdcustomno={2}&mark={3}&key={4}";

            plain = string.Format(plain, customerid, sd51no, sdcustomno, mark, SuppKey);
            string sign1 = Cryptography.MD5(plain).ToUpper().ToString();

            if (sign1 == sign)
            {
                verify = true;
            }
            //判断签名验证是否通过
            if (verify == true)
            {
                string opstate = "-1";
                int    status  = 4;
                //判断交易是否成功
                if (state == "1")
                {
                    opstate = "0";
                    status  = 2;
                }

                OrderBankUtils.SuppNotify(SuppId
                                          , sdcustomno
                                          , sd51no
                                          , status
                                          , opstate
                                          , des
                                          , decimal.Parse(ordermoney), decimal.Parse(ordermoney)
                                          , Succflag
                                          , Failflag);
            }
            else
            {
                HttpContext.Current.Response.Write("fail");
            }
        }
예제 #15
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            HttpRequest req = HttpContext.Current.Request;

            string _orderid   = req.QueryString["orderid"];
            string _opstate   = req.QueryString["opstate"];
            string _ovalue    = req.QueryString["ovalue"];
            string _sign      = req.QueryString["sign"];
            string sysorderid = req.QueryString["sysorderid"];
            string systime    = req.QueryString["systime"];

            string plain     = string.Format("orderid={0}&opstate={1}&ovalue={2}{3}", _orderid, _opstate, _ovalue, SuppKey);
            String localSign = viviLib.Security.Cryptography.MD5(plain);

            try
            {
                if (localSign == _sign)
                {
                    string  opstate = "-1";
                    int     status  = 4;
                    decimal realAmt = 0M;
                    if (_opstate.ToLower() == "0")
                    {
                        opstate = "0";
                        status  = 2;
                        realAmt = decimal.Parse(_ovalue);
                    }
                    OrderBankUtils.SuppNotify(SuppId
                                              , _orderid
                                              , sysorderid
                                              , status
                                              , opstate
                                              , ""
                                              , realAmt
                                              , 0M
                                              , "opstate=0"
                                              , "opstate=-1");
                    //BankUtils bll = new BankUtils();
                    //bll.DoBankComplete(suppId, _orderid, _ekaorderid, status, opstate, string.Empty, decimal.Parse(_ovalue), 0M, true, false);
                    HttpContext.Current.Response.Write("opstate=0");
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                viviLib.ExceptionHandling.ExceptionHandler.HandleException(ex);
            }
        }
예제 #16
0
        public void Notify()
        {
            string tradeNo = GetQueryString("tradeNo", string.Empty);   //支付宝交易号
            string Money   = GetQueryString("Money", "0");              //付款金额
            string title   = GetQueryString("title", string.Empty);     //付款说明,一般是网站用户名
            string memo    = GetQueryString("memo", string.Empty);      //备注
            string Sign    = GetQueryString("Sign", string.Empty);      //签名
            //-----------------------------------------------------------------

            //此处请修改为自己的商户ID (将100修改为您自己的数字ID)
            string WebID = SuppAccount;

            //此处请修改为自己的商户Key (Key = "ABCD" ,修改""号内 ABCD 为您的密钥)
            string Key = SuppKey;

            if (Sign.ToUpper() != Cryptography.MD5(WebID + Key + tradeNo + Money + title + memo).ToUpper())
            {
                HttpContext.Current.Response.Write("Fail");
            }
            else
            {
                /*付款成功
                 ********************************************************************
                 * 会员使用支付宝付款时,可以放2个参数,分别是“付款说明”(title)和“备注”(memo),您可以灵活使用这2个参数进行自动发货
                 * $UserName	=	$title	'如充值的用户名放在title中
                 * $remark	=	$memo	'如充值类型放在memo中(付款成功后是开通VIP还是开通其它服务等不同类型)
                 *******************************************************************
                 *
                 *******************************************************************
                 * 为了防止用户填错“付款说明”或“备注”导致充值失败,您可以先检查用户名是否存在,再决定自动发货,以解决这个问题
                 * UserNameIsExist	=	true;	//此处修改为您的检测代码,当然如果您觉得没有必要,也可以不检测
                 */

                decimal result = 0M;

                decimal.TryParse(Money, out result);

                OrderBankUtils.SuppNotify(SuppId
                                          , title
                                          , tradeNo
                                          , 2
                                          , "0"
                                          , "msg"
                                          , result
                                          , 0M
                                          , "Success"
                                          , "IncorrectOrder");
            }
        }
예제 #17
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            string MerchantID     = HttpContext.Current.Request.Params["MerchantID"];        //商户号
            string TransID        = HttpContext.Current.Request.Params["TransID"];           //商户流水号
            string Result         = HttpContext.Current.Request.Params["Result"];            //支付结果(1:成功,0:失败)
            string resultDesc     = HttpContext.Current.Request.Params["resultDesc"];        //支付结果描述
            string factMoney      = HttpContext.Current.Request.Params["factMoney"];         //实际成交金额
            string additionalInfo = HttpContext.Current.Request.Params["additionalInfo"];    //订单附加消息
            string SuccTime       = HttpContext.Current.Request.Params["SuccTime"];          //交易成功时间
            string Md5Sign        = HttpContext.Current.Request.Params["Md5Sign"].ToLower(); //md5签名

            string _Md5Key   = this.SuppKey;
            string _WaitSign = MerchantID + TransID + Result + resultDesc + factMoney + additionalInfo + SuccTime + _Md5Key;

            if (Md5Sign.ToLower() == Md5Encrypt(_WaitSign).ToLower())
            {
                decimal tranAmt = 0M;
                string  _info   = "支付失败 原因" + GetErrorInfo(Result, resultDesc);
                string  opstate = "-1";
                int     status  = 4;

                if (Result.Equals("1"))
                {
                    _info   = "支付成功";
                    opstate = "0";
                    status  = 2;
                    tranAmt = decimal.Parse(factMoney) / 100M;
                }

                string returnUrl = string.Empty;


                OrderBankUtils.SuppNotify(SuppId
                                          , TransID
                                          , SuccTime
                                          , status
                                          , opstate
                                          , string.Empty
                                          , tranAmt, 0M
                                          , Succflag
                                          , Failflag);
            }
            else
            {
                HttpContext.Current.Response.Write("Md5CheckFail");
                HttpContext.Current.Response.End();
            }
        }
예제 #18
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            String MD5key      = SuppKey;
            String BillNo      = System.Web.HttpContext.Current.Request.Params["BillNo"].ToString();
            String Amount      = System.Web.HttpContext.Current.Request.Params["Amount"].ToString();
            String Succeed     = System.Web.HttpContext.Current.Request.Params["Succeed"].ToString();
            String Result      = System.Web.HttpContext.Current.Request.Params["Result"].ToString();
            String SignMD5info = System.Web.HttpContext.Current.Request.Params["SignMD5info"].ToString();


            String md5src = BillNo + "&" + Amount + "&" + Succeed + "&" + MD5key;

            String md5sign;

            md5sign = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(md5src, "MD5");

            if (SignMD5info == md5sign)
            {
                if (Succeed == "88")
                {
                    string  opstate = "-1";
                    decimal realAmt = 0M;
                    int     status  = 4;
                    opstate = "0";
                    status  = 2;

                    realAmt = decimal.Parse(Amount);
                    OrderBankUtils.SuppNotify(SuppId
                                              , BillNo
                                              , ""
                                              , status
                                              , opstate
                                              , Result
                                              , realAmt
                                              , 0M
                                              , "ok"
                                              , "Fail");
                }
                else
                {
                    HttpContext.Current.Response.Write("Fail");
                }
            }
            else
            {
                HttpContext.Current.Response.Write("签名不正确!");
            }
        }
예제 #19
0
        public void Notify()
        {
            try
            {
                LogWrite("Notify");

                resHandler = new ClientResponseHandler(HttpContext.Current);

                LogWrite("isTenpaySign");

                if (this.resHandler.isTenpaySign())
                {
                    string  opstate = "-1";
                    int     status  = 4;
                    string  msg     = "支付失败";
                    decimal result  = 0M;

                    if (int.Parse(resHandler.getParameter("status").ToString())
                        == 0 && int.Parse(resHandler.getParameter("result_code").ToString()) == 0)
                    {
                        //Utils.writeFile("接口回调", resParam);
                        //此处可以在添加相关处理业务

                        if (decimal.TryParse(resHandler.getParameter("total_fee").ToString(), out result))
                        {
                            msg     = "支付成功";
                            opstate = "0";
                            status  = 2;
                        }
                    }

                    OrderBankUtils.SuppNotify(SuppId
                                              , resHandler.getParameter("out_trade_no").ToString()
                                              , resHandler.getParameter("transaction_id").ToString()
                                              , status
                                              , opstate
                                              , msg
                                              , result / 100M
                                              , 0M, "success", "failure");
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
            }
        }
예제 #20
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int     SuppId      = int.Parse(this.txtSuppId.Text);
            string  SuppTransNo = "test_sup" + DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            string  SysOrderNo  = txtSysOrderId.Text;
            decimal TranAmt     = decimal.Parse(this.txtTranAmt.Text);

            OrderBankUtils.SuppNotify(SuppId
                                      , SysOrderNo
                                      , SuppTransNo
                                      , 2
                                      , "0"
                                      , "sucess"
                                      , TranAmt
                                      , 0M
                                      , "OK"
                                      , "NO");
        }
예제 #21
0
        /// <summary>
        ///
        /// </summary>
        public void ReturnBank()
        {
            String key = SuppKey;                                                                                 //配置文件密钥
            //返回参数
            String orderid    = HttpContext.Current.Request["orderid"];                                           //返回订单号
            String opstate    = HttpContext.Current.Request["opstate"];                                           //返回处理结果
            String ovalue     = HttpContext.Current.Request["ovalue"];                                            //返回实际充值金额
            String sign       = HttpContext.Current.Request["sign"];                                              //返回签名
            String ekaorderID = HttpContext.Current.Request["ekaorderid"];                                        //录入时产生流水号。
            String ekatime    = HttpContext.Current.Request["ekatime"];                                           //处理时间。
            String attach     = HttpContext.Current.Request["attach"];                                            //上行附加信息
            String msg        = HttpContext.Current.Request["msg"];                                               //返回订单处理消息

            String param = String.Format("orderid={0}&opstate={1}&ovalue={2}{3}", orderid, opstate, ovalue, key); //组织参数

            //比对签名是否有效
            if (sign.Equals(FormsAuthentication.HashPasswordForStoringInConfigFile(param, "MD5").ToLower()))
            {
                string _info    = "支付失败";
                string opstate1 = "-1";
                int    status   = 4;


                if (opstate.Equals("0") || opstate.Equals("-3"))
                {
                    _info    = "支付成功";
                    opstate1 = "0";
                    status   = 2;
                }

                string returnUrl = string.Empty;

                OrderBankUtils.SuppPageReturn(SuppId
                                              , SuppKey
                                              , orderid
                                              , status
                                              , opstate1
                                              , string.Empty
                                              , Convert.ToDecimal(ovalue), 0M);
            }
        }
예제 #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var resHandler = new ResponseHandlerX(Context);

            resHandler.init();
            resHandler.setKey(ZweixinpayUtil.key, string.Empty);

            bool signOk = resHandler.IsTenpaySign();

            log4net.ILog log = log4net.LogManager.GetLogger(typeof(callback));
            log.Info("signOk:" + signOk);
            log.Info("return_code:" + resHandler.getParameter("return_code"));
            if (signOk)
            {
                string return_code = resHandler.getParameter("return_code");
                string return_msg  = resHandler.getParameter("return_msg");
                string result_code = resHandler.getParameter("result_code");

                string total_fee      = resHandler.getParameter("total_fee");
                string transaction_id = resHandler.getParameter("transaction_id");
                string out_trade_no   = resHandler.getParameter("out_trade_no");
                string attach         = resHandler.getParameter("attach");

                string  opstate = "-1";
                int     status  = 4;
                decimal tranAmt = 0M;

                if (return_code == "SUCCESS" &&
                    result_code == "SUCCESS")
                {
                    status  = 2;
                    opstate = "0";
                    tranAmt = decimal.Parse(total_fee) / 100M;
                }

                string retSuccXml = @"<xml>
<return_code><![CDATA[SUCCESS]]></return_code>
<return_msg></return_msg>
</xml>";
                string retFailXml = @"<xml>
<return_code><![CDATA[FAIL]]></return_code>
<return_msg></return_msg>
</xml>";
                OrderBankUtils.SuppNotify((int)SupplierCode.Weixin
                                          , out_trade_no
                                          , transaction_id
                                          , status
                                          , opstate
                                          , return_msg
                                          , tranAmt, tranAmt
                                          , retSuccXml
                                          , retFailXml);


                //BankUtils.SuppNotify(1006
                //                , out_trade_no
                //                , transaction_id
                //                , status
                //                , opstate
                //                , return_msg
                //                , tranAmt
                //                , retXml);
            }
            else
            {
                Response.Write("fail -md5 failed");
                Response.Write(resHandler.getDebugInfo());
            }
        }
예제 #23
0
        /// <summary>
        ///
        /// </summary>
        public void ReturnBank()
        {
            //    返回值示例:http://pay.wengpay.com/return/cared70/weixin.aspx?
            //state=1&
            //    customerid=5774&
            //    sd51no=E115100900000131&
            //    sdcustomno=B4840362426830361619&
            //    ordermoney=1&
            //    cardno=32&
            //    mark=chongzhi&
            //    sign=D17F0F3DF603F31DCB2EAAAAA98848D4&
            //    resign=2A5D80BF516D050EE14B0B364A4580DF&
            //    Des=success
            //http://pay.wengpay.com/return/cared70/weixin.aspx?state=1&customerid=5774&sd51no=E115100900000196&sdcustomno=B4822333598710201852&ordermoney=1&cardno=32&mark=chongzhi&sign=42A7884F911DB783149E6600DCF1E938&resign=B30611FF86954BBD14A87C432642E356&Des=success
            //接收数据
            string state      = HttpContext.Current.Request["state"];
            string customerid = HttpContext.Current.Request["customerid"];
            string sd51no     = HttpContext.Current.Request["sd51no"];
            string sdcustomno = HttpContext.Current.Request["sdcustomno"];
            string ordermoney = HttpContext.Current.Request["ordermoney"];
            string cardno     = HttpContext.Current.Request["cardno"];
            string mark       = HttpContext.Current.Request["mark"];
            string sign       = HttpContext.Current.Request["sign"];
            string resign     = HttpContext.Current.Request["resign"];
            string des        = HttpContext.Current.Request["des"];
            //签名是否正确
            Boolean verify = false;

            string plain = "customerid={0}&sd51no={1}&sdcustomno={2}&mark={3}&key={4}";

            plain = string.Format(plain, customerid, sd51no, sdcustomno, mark, SuppKey);
            string sign1 = Cryptography.MD5(plain).ToUpper().ToString();

            if (sign1 == sign)
            {
                verify = true;
            }
            //判断签名验证是否通过
            if (verify == true)
            {
                string opstate = "-1";
                int    status  = 4;
                //判断交易是否成功
                if (state == "1")
                {
                    opstate = "0";
                    status  = 2;
                }

                OrderBankUtils.SuppPageReturn(SuppId
                                              , sdcustomno
                                              , sd51no
                                              , status
                                              , opstate
                                              , des
                                              , decimal.Parse(ordermoney), decimal.Parse(ordermoney));
            }
            else
            {
                HttpContext.Current.Response.Write("签名验证失败");
            }
        }
예제 #24
0
        public void Notify(HttpContext Context)
        {
            //商户号
            string partner = SuppAccount;
            //密钥
            string key = SuppKey;
            //创建ResponseHandler实例
            ResponseHandler resHandler = new ResponseHandler(Context);

            resHandler.setKey(key);

            //判断签名
            if (resHandler.isTenpaySign())
            {
                ///通知id
                string notify_id = resHandler.getParameter("notify_id");
                //通过通知ID查询,确保通知来至财付通
                //创建查询请求
                RequestHandler queryReq = new RequestHandler(Context);
                queryReq.init();
                queryReq.setKey(key);
                queryReq.setGateUrl("https://gw.tenpay.com/gateway/verifynotifyid.xml");
                queryReq.setParameter("partner", partner);
                queryReq.setParameter("notify_id", notify_id);

                //通信对象
                TenpayHttpClient httpClient = new TenpayHttpClient();
                httpClient.setTimeOut(5);
                //设置请求内容
                httpClient.setReqContent(queryReq.getRequestURL());
                //后台调用
                if (httpClient.call())
                {
                    //设置结果参数
                    ClientResponseHandler queryRes = new ClientResponseHandler();
                    queryRes.setContent(httpClient.getResContent());
                    queryRes.setKey(key);
                    //判断签名及结果
                    //只有签名正确,retcode为0,trade_state为0才是支付成功
                    if (queryRes.isTenpaySign())
                    {
                        //取结果参数做业务处理
                        string out_trade_no = queryRes.getParameter("out_trade_no");
                        //财付通订单号
                        string transaction_id = queryRes.getParameter("transaction_id");
                        //金额,以分为单位
                        string total_fee = queryRes.getParameter("total_fee");
                        //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee
                        string discount = queryRes.getParameter("discount");
                        //支付结果
                        string trade_state = resHandler.getParameter("trade_state");
                        //交易模式,1即时到帐 2中介担保
                        string trade_mode = resHandler.getParameter("trade_mode");
                        #region
                        //判断签名及结果
                        if ("0".Equals(queryRes.getParameter("retcode")))
                        {
                            //Response.Write("id验证成功");


                            if ("1".Equals(trade_mode))
                            {
                                string opstate = "-1";
                                int    status  = 4;

                                //即时到账
                                if ("0".Equals(trade_state))
                                {
                                    status  = 2;
                                    opstate = "0";

                                    //------------------------------
                                    //即时到账处理业务开始
                                    //------------------------------

                                    //处理数据库逻辑
                                    //注意交易单不要重复处理
                                    //注意判断返回金额

                                    //------------------------------
                                    //即时到账处理业务完毕
                                    //------------------------------

                                    //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知
                                    //Context.Response.Write("success");
                                }
                                else
                                {
                                    //Context.Response.Write("即时到账支付失败");
                                }

                                decimal tranAmt = decimal.Parse(total_fee) / 100M;

                                OrderBankUtils.SuppNotify(SuppId
                                                          , out_trade_no
                                                          , transaction_id
                                                          , status
                                                          , opstate
                                                          , string.Empty
                                                          , tranAmt, tranAmt
                                                          , Succflag
                                                          , Failflag);

                                //viviapi.BLL.OrderBank bll = new viviapi.BLL.OrderBank();
                                //bll.DoBankComplete(suppId, out_trade_no, transaction_id, status, opstate, string.Empty, decimal.Parse(total_fee) / 100M, 0M, true, false);
                            }
                            else if ("2".Equals(trade_mode))
                            { //中介担保
                              //------------------------------
                              //中介担保处理业务开始
                              //------------------------------
                              //处理数据库逻辑
                              //注意交易单不要重复处理
                              //注意判断返回金额

                                int iStatus = Convert.ToInt32(trade_state);
                                switch (iStatus)
                                {
                                case 0:                 //付款成功

                                    break;

                                case 1:                 //交易创建

                                    break;

                                case 2:                 //收获地址填写完毕

                                    break;

                                case 4:                 //卖家发货成功

                                    break;

                                case 5:                 //买家收货确认,交易成功

                                    break;

                                case 6:                 //交易关闭,未完成超时关闭

                                    break;

                                case 7:                 //修改交易价格成功

                                    break;

                                case 8:                 //买家发起退款

                                    break;

                                case 9:                 //退款成功

                                    break;

                                case 10:        //退款关闭

                                    break;
                                }


                                //------------------------------
                                //中介担保处理业务开始
                                //------------------------------


                                //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知
                                //Response.Write("success");
                            }
                        }
                        else
                        {
                            //错误时,返回结果可能没有签名,写日志trade_state、retcode、retmsg看失败详情。
                            //通知财付通处理失败,需要重新通知
                            //Response.Write("查询验证签名失败或id验证失败");
                            //Response.Write("retcode:" + queryRes.getParameter("retcode"));
                        }
                        #endregion
                    }
                    else
                    {
                        //Response.Write("通知ID查询签名验证失败");
                    }
                }
                else
                {
                    //通知财付通处理失败,需要重新通知
                    // Response.Write("后台调用通信失败");
                    //写错误日志
                    //Response.Write("call err:" + httpClient.getErrInfo() + "<br>" + httpClient.getResponseCode() + "<br>");
                }
            }
            else
            {
                //Response.Write("签名验证失败");
            }
            //Response.End();
        }
예제 #25
0
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="okxrorderid"></param>
        ///// <param name="amount"></param>
        ///// <param name="Context"></param>
        ///// <returns></returns>
        //public string GetPayUrl(string sysorderid, decimal amount, HttpContext Context)
        //{
        //    string puserid = suppAccount;
        //    string puserkey = suppKey;

        //    string str3 = DateTime.Now.ToString("yyyyMMdd");
        //    string str4 = "" + DateTime.Now.ToString("HHmmss") + tenpay.TenpayUtil.BuildRandomStr(4);

        //    string parameterValue = sysorderid;
        //    string str6 = puserid + str3 + str4;
        //    string str7 = notify_url;
        //    string str8 = ServerVariables.TrueIP;

        //    tenpay.PayRequestHandler handler = new tenpay.PayRequestHandler(Context);
        //    handler.setKey(puserkey);
        //    handler.init();
        //    handler.setParameter("bargainor_id", puserid);
        //    handler.setParameter("sp_billno", parameterValue);
        //    handler.setParameter("transaction_id", str6);
        //    handler.setParameter("return_url", str7);
        //    handler.setParameter("desc", "orderNo:" + str6);
        //    handler.setParameter("total_fee", Convert.ToString((double)(amount * 100.0M)));
        //    handler.setParameter("spbill_create_ip", getRealIp());
        //    string url = postBankUrl;
        //    if (string.IsNullOrEmpty(url))
        //    {
        //        url = "https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi";
        //    }
        //    url = handler.getRequestURL().Replace("http://service.tenpay.com/cgi-bin/v3.0/payservice.cgi", url);
        //    viviLib.Logging.LogHelper.Write(url);
        //    return url;
        //}

        //#region Return
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="Context"></param>
        //public void Return(bool isnotify, HttpContext Context)
        //{
        //    string puserkey = suppKey;
        //    PayResponseHandler handler = new PayResponseHandler(Context);
        //    handler.setKey(puserkey);

        //    if (handler.isTenpaySign())
        //    {
        //        string transaction_id = handler.getParameter("transaction_id");
        //        string total_fee = handler.getParameter("total_fee");
        //        string pay_result = handler.getParameter("pay_result");
        //        string out_trade_no = handler.getParameter("sp_billno");

        //        string opstate = "-1";
        //        int status = 4;
        //        if (pay_result == "0")
        //        {
        //            status = 2;
        //            opstate = "0";
        //        }

        //        string debuginfo = handler.getDebugInfo();
        //        if (!string.IsNullOrEmpty(debuginfo))
        //        {
        //            LogHelper.Write(LogHelper.GetTenPayLogPath(), debuginfo);
        //        }
        //        viviapi.BLL.OrderBank bll = new viviapi.BLL.OrderBank();
        //        bll.DoBankComplete(suppId, out_trade_no, transaction_id, status, opstate, debuginfo, decimal.Parse(total_fee) / 100M, 0M, true,false);
        //    }
        //}
        //#endregion


        public void Return(HttpContext Context)
        {
            //密钥
            string key = SuppKey;

            //创建ResponseHandler实例
            ResponseHandler resHandler = new ResponseHandler(Context);

            resHandler.setKey(key);

            //判断签名
            if (resHandler.isTenpaySign())
            {
                ///通知id
                string notify_id = resHandler.getParameter("notify_id");
                //商户订单号
                string out_trade_no = resHandler.getParameter("out_trade_no");
                //财付通订单号
                string transaction_id = resHandler.getParameter("transaction_id");
                //金额,以分为单位
                string total_fee = resHandler.getParameter("total_fee");
                //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee
                string discount = resHandler.getParameter("discount");
                //支付结果
                string trade_state = resHandler.getParameter("trade_state");
                //交易模式,1即时到账,2中介担保
                string trade_mode = resHandler.getParameter("trade_mode");

                if ("1".Equals(trade_mode))
                {
                    string debuginfo = resHandler.getDebugInfo();
                    string _info     = "支付失败" + debuginfo;
                    string opstate   = "-1";
                    int    status    = 4;

                    //即时到账
                    if ("0".Equals(trade_state))
                    {
                        _info   = "支付成功";
                        status  = 2;
                        opstate = "0";

                        //------------------------------
                        //即时到账处理业务开始
                        //------------------------------

                        //处理数据库逻辑
                        //注意交易单不要重复处理
                        //注意判断返回金额

                        //------------------------------
                        //即时到账处理业务完毕
                        //------------------------------

                        //Response.Write("即时到帐付款成功");
                        //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知
                    }
                    else
                    {
                        //Response.Write("即时到账支付失败");
                    }

                    //viviapi.BLL.OrderBank bll = new viviapi.BLL.OrderBank();
                    //bll.DoBankComplete(suppId, out_trade_no, transaction_id, status, opstate, _info, decimal.Parse(total_fee) / 100M, 0M, false, true);

                    decimal tranAmt = decimal.Parse(total_fee) / 100M;

                    OrderBankUtils.SuppPageReturn(SuppId
                                                  , out_trade_no
                                                  , transaction_id
                                                  , status
                                                  , opstate
                                                  , _info
                                                  , tranAmt, 0M);
                }
                else if ("2".Equals(trade_mode))
                {    //中介担保
                    if ("0".Equals(trade_state))
                    {
                        //------------------------------
                        //中介担保处理业务开始
                        //------------------------------

                        //处理数据库逻辑
                        //注意交易单不要重复处理
                        //注意判断返回金额

                        //------------------------------
                        //中介担保处理业务完毕
                        //------------------------------


                        //Response.Write("中介担保付款成功");
                        //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知
                    }
                    else
                    {
                        //Response.Write("trade_state=" + trade_state);
                    }
                }
            }
            else
            {
                //Response.Write("认证签名失败");
            }

            ////获取debug信息,建议把debug信息写入日志,方便定位问题
            //string debuginfo = resHandler.getDebugInfo();
            //Response.Write("<br/>debuginfo:" + debuginfo + "<br/>");
        }
예제 #26
0
        public void callback()
        {
            // LogWrite("swift pass callback start");

            string logfiles = FormatRequestData(HttpContext.Current.Request.Params);

            // LogWrite("swift pass callback start=>" + logfiles);

            try
            {
                using (StreamReader sr = new StreamReader(HttpContext.Current.Request.InputStream))
                {
                    string contenct = sr.ReadToEnd();
                    this.resHandler.setContent(contenct);
                    this.resHandler.setKey(SuppKey);

                    //  LogWrite("setContent" + contenct);

                    Hashtable resParam = this.resHandler.getAllParameters();
                    if (this.resHandler.isTenpaySign())
                    {
                        string  opstate = "-1";
                        int     status  = 4;
                        string  msg     = "支付失败";
                        decimal result  = 0M;

                        if (int.Parse(resParam["status"].ToString()) == 0 &&
                            int.Parse(resParam["result_code"].ToString()) == 0)
                        {
                            Utils.writeFile("接口回调", resParam);
                            //此处可以在添加相关处理业务

                            if (decimal.TryParse(resParam["total_fee"].ToString(), out result))
                            {
                                msg     = "支付成功";
                                opstate = "0";
                                status  = 2;
                            }
                        }

                        OrderBankUtils.SuppNotify(SuppId
                                                  , resParam["out_trade_no"].ToString()
                                                  , resParam["transaction_id"].ToString()
                                                  , status
                                                  , opstate
                                                  , msg
                                                  , result / 100M
                                                  , 0M, "success", "failure");

                        //context.Response.Write("success");
                    }
                    else
                    {
                        HttpContext.Current.Response.Write("failure");
                    }
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
            }
        }
예제 #27
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            string puserid   = SuppAccount;
            string pusername = SuppUserName;
            string puserkey  = SuppKey;


            this.alipayNotifyURL = this.alipayNotifyURL + "service=notify_verify&partner=" + puserid + "&notify_id=" + HttpContext.Current.Request.Form["notify_id"];
            string str4 = this.Get_Http(this.alipayNotifyURL, 0x1d4c0);

            string[] strArray2 = BubbleSort(HttpContext.Current.Request.Form.AllKeys);
            string   str5      = "";

            for (int i = 0; i < strArray2.Length; i++)
            {
                if (((HttpContext.Current.Request.Form[strArray2[i]] != "") && (strArray2[i] != "sign")) && (strArray2[i] != "sign_type"))
                {
                    if (i == (strArray2.Length - 1))
                    {
                        str5 = str5 + strArray2[i] + "=" + HttpContext.Current.Request.Form[strArray2[i]];
                    }
                    else
                    {
                        str5 = str5 + strArray2[i] + "=" + HttpContext.Current.Request.Form[strArray2[i]] + "&";
                    }
                }
            }
            string str6 = GetMD5(str5 + puserkey, this._input_charset);
            string str7 = HttpContext.Current.Request.Form["sign"];

            if (str6 == str7)
            {
                string opstate = "-1";
                int    status  = 4;
                string msg     = "支付失败";

                string  s          = string.Empty;
                string  outorderid = string.Empty;
                decimal result     = 0M;
                if ((HttpContext.Current.Request.Form["out_trade_no"] != null) && (HttpContext.Current.Request.Form["out_trade_no"].Trim().Length > 1))
                {
                    s = HttpContext.Current.Request.Form["out_trade_no"].Trim();
                }
                if ((HttpContext.Current.Request.Form["trade_no"] != null) && (HttpContext.Current.Request.Form["trade_no"].Trim().Length > 1))
                {
                    outorderid = HttpContext.Current.Request.Form["trade_no"].Trim();
                }
                if (((HttpContext.Current.Request.Form["total_fee"] != null) && (HttpContext.Current.Request.Form["total_fee"].Trim().Length > 0)) && !decimal.TryParse(HttpContext.Current.Request.Form["total_fee"].Trim(), out result))
                {
                    result = 0M;
                }
                if ((HttpContext.Current.Request.Form["trade_status"] == "TRADE_FINISHED") || (HttpContext.Current.Request.Form["trade_status"] == "TRADE_SUCCESS"))
                {
                    msg     = "失败成功";
                    opstate = "0";
                    status  = 2;
                }
                else
                {
                    msg = "支付失败 状态号:" + HttpContext.Current.Request.Form["trade_status"];
                }

                OrderBankUtils.SuppNotify(SuppId
                                          , s
                                          , outorderid
                                          , status
                                          , opstate
                                          , msg
                                          , result, result
                                          , Succflag
                                          , Failflag);
            }
        }
예제 #28
0
        /// <summary>
        ///
        /// </summary>
        public void Return()
        {
            string puserid   = SuppAccount;
            string pusername = SuppUserName;
            string puserkey  = SuppKey;

            this.alipayNotifyURL = this.alipayNotifyURL + "service=notify_verify&partner=" + puserid + "&notify_id=" + HttpContext.Current.Request.QueryString["notify_id"];
            string str4 = this.Get_Http(this.alipayNotifyURL, 0x1d4c0);

            string[] strArray2 = BubbleSort(HttpContext.Current.Request.QueryString.AllKeys);


            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < strArray2.Length; i++)
            {
                if (((HttpContext.Current.Request.Form[strArray2[i]] != "") && (strArray2[i] != "sign")) && (strArray2[i] != "sign_type"))
                {
                    if (i == (strArray2.Length - 1))
                    {
                        builder.Append(strArray2[i] + "=" + HttpContext.Current.Request.QueryString[strArray2[i]]);
                    }
                    else
                    {
                        builder.Append(strArray2[i] + "=" + HttpContext.Current.Request.QueryString[strArray2[i]] + "&");
                    }
                }
            }
            builder.Append(puserkey);
            string  str5       = GetMD5(builder.ToString(), this._input_charset);
            string  str6       = HttpContext.Current.Request.QueryString["sign"];
            string  str7       = HttpContext.Current.Request.QueryString["trade_status"];
            string  s          = string.Empty;
            string  outorderid = string.Empty;
            decimal result     = 0M;

            if (HttpContext.Current.Request.QueryString["out_trade_no"] != null)
            {
                s = HttpContext.Current.Request.QueryString["out_trade_no"].Trim();
            }
            if ((HttpContext.Current.Request.QueryString["trade_no"] != null) && (HttpContext.Current.Request.QueryString["trade_no"].Trim().Length > 1))
            {
                outorderid = HttpContext.Current.Request.QueryString["trade_no"].Trim();
            }
            if (((HttpContext.Current.Request.QueryString["total_fee"] != null) && (HttpContext.Current.Request.QueryString["total_fee"].Trim().Length > 0)) && !decimal.TryParse(HttpContext.Current.Request.QueryString["total_fee"].Trim(), out result))
            {
                result = 0M;
            }

            string opstate = "-1";
            int    status  = 4;
            string msg     = string.Empty;

            if (str5 == str6)
            {
                switch (str7)
                {
                case "TRADE_FINISHED":
                case "TRADE_SUCCESS":
                    opstate = "0";
                    status  = 2;
                    break;

                default:
                    msg = str7;
                    break;
                }

                OrderBankUtils.SuppPageReturn(SuppId
                                              , s
                                              , outorderid
                                              , status
                                              , opstate
                                              , msg
                                              , result, 0M);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('出现异常!请查看充值是否到帐。若未到帐,请与管理员联系。');</script>");
            }
        }
예제 #29
0
        /// <summary>
        ///
        /// </summary>
        public void Show()
        {
            string version            = HttpContext.Current.Request["version"];
            string charset            = HttpContext.Current.Request["charset"];
            string language           = HttpContext.Current.Request["language"];
            string signType           = HttpContext.Current.Request["signType"];
            string tranCode           = HttpContext.Current.Request["tranCode"];
            string merchantID         = HttpContext.Current.Request["merchantID"];
            string merOrderNum        = HttpContext.Current.Request["merOrderNum"];
            string tranAmt            = HttpContext.Current.Request["tranAmt"];
            string feeAmt             = HttpContext.Current.Request["feeAmt"];
            string frontMerUrl        = HttpContext.Current.Request["frontMerUrl"];
            string backgroundMerUrl   = HttpContext.Current.Request["backgroundMerUrl"];
            string tranDateTime       = HttpContext.Current.Request["tranDateTime"];
            string tranIP             = HttpContext.Current.Request["tranIP"];
            string respCode           = HttpContext.Current.Request["respCode"];
            string msgExt             = HttpContext.Current.Request["msgExt"];
            string orderId            = HttpContext.Current.Request["orderId"];
            string gopayOutOrderId    = HttpContext.Current.Request["gopayOutOrderId"];
            string bankCode           = HttpContext.Current.Request["bankCode"];
            string tranFinishTime     = HttpContext.Current.Request["tranFinishTime"];
            string merRemark1         = HttpContext.Current.Request["merRemark1"];
            string merRemark2         = HttpContext.Current.Request["merRemark2"];
            string verficationCode    = SuppKey;
            string signValueFromGopay = HttpContext.Current.Request["signValue"];

            // 组织加密明文
            string plain = "version=[" + version + "]tranCode=[" + tranCode + "]merchantID=[" + merchantID + "]merOrderNum=[" + merOrderNum + "]tranAmt=[" + tranAmt + "]feeAmt=[" + feeAmt + "]tranDateTime=[" + tranDateTime + "]frontMerUrl=[" + frontMerUrl + "]backgroundMerUrl=[" + backgroundMerUrl + "]orderId=[" + orderId + "]gopayOutOrderId=[" + gopayOutOrderId + "]tranIP=[" + tranIP + "]respCode=[" + respCode + "]gopayServerTime=[]VerficationCode=[" + verficationCode + "]";

            AsynsRetLogger("Show plain:" + plain);

            string signValue = viviLib.Security.Cryptography.MD5(plain, "gbk");

            AsynsRetLogger("Show signValue:" + signValue);

            AsynsRetLogger("Show signValueFromGopay:" + signValueFromGopay);

            if (signValue.Equals(signValueFromGopay))
            {
                string  info     = "支付失败" + msgExt;
                string  opstate  = "-1";
                int     status   = 4;
                decimal dtranAmt = 0M;

                if (respCode.Equals("0000"))
                {
                    info    = "支付成功";
                    opstate = "0";
                    status  = 2;

                    dtranAmt = decimal.Parse(tranAmt);
                }

                OrderBankUtils.SuppPageReturn(SuppId
                                              , merOrderNum
                                              , gopayOutOrderId
                                              , status
                                              , opstate
                                              , string.Empty
                                              , dtranAmt, 0M);
            }
            else
            {
                HttpContext.Current.Response.Write("RespCode=9999|JumpURL=" + ShowUrl);
            }
        }
예제 #30
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            //string state = HttpContext.Current.Request["state"];
            //string customerid = HttpContext.Current.Request["customerid"];
            //string sd51no = HttpContext.Current.Request["sd51no"];
            //string sdcustomno = HttpContext.Current.Request["sdcustomno"];
            //string ordermoney = HttpContext.Current.Request["ordermoney"];
            //string cardno = HttpContext.Current.Request["cardno"];
            //string mark = HttpContext.Current.Request["mark"];
            //string sign = HttpContext.Current.Request["sign"];
            //string resign = HttpContext.Current.Request["resign"];
            //string des = HttpContext.Current.Request["des"];
            ////签名是否正确
            //Boolean verify = false;

            //string plain = "customerid={0}&sd51no={1}&sdcustomno={2}&mark={3}&key={4}";
            //plain = string.Format(plain, customerid, sd51no, sdcustomno, mark, SuppKey);
            //string sign1 = Cryptography.MD5(plain).ToUpper().ToString();

            //if (sign1 == sign)
            //{
            //    verify = true;
            //}
            ////判断签名验证是否通过
            //if (verify == true)
            //{
            //    string opstate = "-1";
            //    int status = 4;
            //    //判断交易是否成功
            //    if (state == "1")
            //    {
            //        opstate = "0";
            //        status = 2;
            //    }

            //    OrderBankUtils.SuppNotify(SuppId
            //      , sdcustomno
            //      , sd51no
            //      , status
            //      , opstate
            //      , des
            //      , decimal.Parse(ordermoney), decimal.Parse(ordermoney)
            //      , Succflag
            //      , Failflag);
            //}
            //else
            //{
            //    HttpContext.Current.Response.Write("fail");
            //}
            //{
            //接收数据
            string returncode = HttpContext.Current.Request["returncode"];
            string userid     = HttpContext.Current.Request["userid"];//1:成功 2:失败
            string orderid    = HttpContext.Current.Request["orderid"];
            string money      = HttpContext.Current.Request["money"];
            string sign       = HttpContext.Current.Request["sign"];
            string ext        = HttpContext.Current.Request["ext"];
            //签名是否正确
            Boolean verify = false;

            string plain = "returncode={0}&userid={1}&orderid={2}&keyvalue={3}";

            plain = string.Format(plain, returncode, userid, orderid, SuppKey);
            string signature1 = Cryptography.MD5(plain).ToLower();

            if (signature1 == sign)
            {
                verify = true;
            }

            //判断签名验证是否通过
            if (verify == true)
            {
                string opstate = "-1";
                int    status1 = 4;
                //判断交易是否成功
                if (returncode == "1")
                {
                    opstate = "0";
                    status1 = 2;
                }

                OrderBankUtils.SuppNotify(SuppId
                                          , orderid
                                          , ""
                                          , status1
                                          , opstate
                                          , GetErrMsg(int.Parse(returncode))
                                          , decimal.Parse(money), 0M, Succflag, Failflag);
            }
            else
            {
                HttpContext.Current.Response.Write("false");
            }
        }