protected void Page_Load(object sender, EventArgs e)
    {
        //if (Page.Request.RequestType.ToString() != "POST")
        //{
        //    Response.Redirect("/index.htm");
        //    return;
        //}
        if (Request.QueryString["action"] != null)
        {
            action = Request.QueryString["action"].Trim();
        }
        TransType = Request.Form["TransType"]; //交易类型

        MerId = Request.Form["MerId"];         //商户号

        OrdId = Request.Form["OrdId"];         //订单号

        MerDate = Request.Form["MerDate"];     //商户日期

        TransAmt = Request.Form["TransAmt"];   //交易金额

        MerPriv = Request.Form["MerPriv"];     //商户私有域

        GateId = Request.Form["GateId"];       //网关号

        TransStat = Request.Form["TransStat"]; //交易状态

        SysDate = Request.Form["SysDate"];     //系统日期

        SysSeqId = Request.Form["SysSeqId"];   //系统流水号

        lblPnr.Text   = OrdId;
        lblSys.Text   = SysSeqId;
        lblPoint.Text = TransAmt;                                                        //实际支付金额
        ChkValue      = Request.Form["ChkValue"];                                        //签名值
        PgKeyFile     = System.Configuration.ConfigurationSettings.AppSettings["pnrPK"]; //公钥文件名
        CHINAPNRLib.NetpayClientClass ThisOrder = new CHINAPNRLib.NetpayClientClass();
        ret       = ThisOrder.VeriSignOrder0(MerId, PgKeyFile, OrdId, TransAmt, MerDate, TransType, TransStat, GateId, MerPriv, SysDate, SysSeqId, ChkValue);
        loginname = Page.User.Identity.Name;
        bool cz_success = OnlineStrike.isSuccess(OrdId);//该订单是否充值成功

        if (!Page.IsPostBack)
        {
            if (ret == "0")//本次调用成功
            {
                if (TransStat == "S")
                {
                    if (!cz_success)//订单是否被充值成功
                    {
                        bool b = dal.StrikeSuccess(OrdId, "pnr", SysSeqId, loginname);
                    }
                }
            }
            else
            {
                //Response.Write("验证失败");
            }
        }
    }
Beispiel #2
0
        /// <summary>
        /// 返回签名字符串
        /// </summary>
        /// <param name="merId"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private string GetValue(string merId, string data)
        {
            string chkValue = "";

            CHINAPNRLib.NetpayClientClass netpay = new CHINAPNRLib.NetpayClientClass();

            chkValue = netpay.SignMsg0(merId, _MerKeyUrl, data, data.Length);

            return(chkValue);
        }
Beispiel #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="OrdId"></param>
    /// <param name="TransMoney"></param>
    /// <returns></returns>
    public static string pnrForm(string OrdId, string TransMoney)
    {
        NumberFormatInfo n        = new CultureInfo("en-US", false).NumberFormat;
        string           TransAmt = String.Format("{0:N}", Convert.ToDouble(TransMoney));
        string           Version  = "10";//版本号

        string url       = "https://payment.chinapnr.com/pay/TransGet";
        string MerId     = "880452";                                                            //商户ID
        string MerDate   = DateTime.Now.ToString("yyyyMMdd").Trim();                            //商户时间
        string TransType = "P";                                                                 //交易方式
        string GateId    = "";                                                                  //网关号

        string MerPriv = "";                                                                    //商户私有域

        string BgRetUrl   = DomainName.VipDomain() + "/PayManage/return_back_pnr.aspx";         //后台应答URL
        string PageRetUrl = DomainName.VipDomain() + "/PayManage/return_pnr.aspx";              //页面应答URL
        string MerKeyFile = System.Configuration.ConfigurationSettings.AppSettings["pnrMerPK"]; //私钥文件名

        CHINAPNRLib.NetpayClientClass ThisOrder = new CHINAPNRLib.NetpayClientClass();
        string ChkValue = ThisOrder.SignOrder0(MerId, MerKeyFile, OrdId, TransAmt, MerDate, TransType, GateId, MerPriv, BgRetUrl, PageRetUrl);
        string htmlCode = @"
							<form id=""frmPay""  action="""                             + url + @""" method=""post"">
							<input type=""hidden"" name=Version   value="""                             + Version + @""">
							<input type=""hidden"" name=MerId     value="""                             + MerId + @""">
							<input type=""hidden"" name=MerDate   value="""                             + MerDate + @""">
							<input type=""hidden"" name=OrdId     value="""                             + OrdId + @""">
							<input type=""hidden"" name=TransType value="""                             + TransType + @""">
							<input type=""hidden"" name=TransAmt  value="""                             + TransAmt + @""">
							<input type=""hidden"" name=GateId    value="""                             + GateId + @""">
							<input type=""hidden"" name=MerPriv   value="""                             + MerPriv + @""">
							<input type=""hidden"" name=BgRetUrl  value="""                             + BgRetUrl + @""">
							<input type=""hidden"" name=PageRetUrl value="""                             + PageRetUrl + @""">
							<input type=""hidden"" name=ChkValue value="""                             + ChkValue + @""">	
						    <input type=""submit"" style=""display:none"" id=""submit""/>
							</form>
							<script language=""javascript"">
							document.all.submit.click();
							</script>"                            ;

        return(htmlCode);
    }
Beispiel #4
0
    /// <summary>
    /// IsValidation
    /// </summary>
    private void IsValidation()
    {
        try
        {
            //GateId =U2
            //MerPriv =
            //TrxId =2013062589057816
            //OrdId =30201020130625000010
            //RetType =2
            //OrdAmt =1.00
            //Pid =
            //ChkValue =9188B176EE0CEC769E077BC63ACE7ADBDAD0FA273A5C81DF9E14C67789F93FACFBF062F22A9EECCA4208CBCEDC4084505C4565E32BA20C9670FC83C775804520AC8C317A2B59BF1FE173F7AC58A80286A54DBA3A2B6C8CFC8559A8530D6E2A55CDF1286A6EE1169712C90212526EA8A0E954B0D3488A8BEEC025DB4AA702F6BD
            //CmdId =Buy
            //DivDetails =Agent:00000458605930201020:1.00
            //CurCode =RMB
            //RespCode =000000
            //MerId =871997

            String GateId, MerPriv, TrxId, OrdId, RetType, OrdAmt, Pid, ChkValue, CmdId, DivDetails, CurCode, RespCode, MerId;

            GateId     = Request.Form["GateId"];
            MerPriv    = Request.Form["MerPriv"];
            TrxId      = Request.Form["TrxId"];
            OrdId      = Request.Form["OrdId"];
            RetType    = Request.Form["RetType"];
            OrdAmt     = Request.Form["OrdAmt"];
            Pid        = Request.Form["Pid"];
            ChkValue   = Request.Form["ChkValue"];
            CmdId      = Request.Form["CmdId"];
            DivDetails = Request.Form["DivDetails"];
            CurCode    = Request.Form["CurCode"];
            RespCode   = Request.Form["RespCode"];
            MerId      = Request.Form["MerId"];



            string SignData = "";

            #region 验证签名使用

            PbProject.Logic.Pay.ChinaPnr _ChinaPnr = new PbProject.Logic.Pay.ChinaPnr();
            String MsgData;
            MsgData = CmdId + MerId + RespCode + TrxId + OrdAmt + CurCode + Pid + OrdId + MerPriv + RetType + DivDetails + GateId; //参数顺序不能错
            CHINAPNRLib.NetpayClient SignObject = new CHINAPNRLib.NetpayClientClass();
            SignData = SignObject.VeriSignMsg0(_ChinaPnr._PgKeyUrl, MsgData, MsgData.Length, ChkValue);                            //请将此处改成你的私钥文件所在路径

            #endregion


            if (SignData == "0")
            {
                if (RespCode == "000000")
                {
                    #region 交易成功

                    if (CmdId == "Buy")
                    {
                        new PbProject.Logic.Pay.Bill().CreateLogMoneyDetail("", TrxId, OrdAmt, 12, OrdId.Substring(0, 8), "POS充值", "POS充值");
                    }
                    #endregion
                }
                else
                {
                    //交易失败
                    OnErrorNew("交易失败 OrdId=" + OrdId, false);
                }
                Response.Write("RECV_ORD_ID_" + OrdId);
            }
            else
            {
                //验签失败
                OnErrorNew("验签失败", false);
            }
        }
        catch (Exception ex)
        {
        }
    }
Beispiel #5
0
    /// <summary>
    /// Validation
    /// </summary>
    private string Validation()
    {
        string val = "";

        try
        {
            String CmdId, MerId, RespCode, TrxId, OrdAmt, CurCode, Pid, OrdId, MerPriv, RetType, DivDetails, GateId, ChkValue;

            CmdId      = Request.Form["CmdId"];         //消息类型
            MerId      = Request.Form["MerId"];         //商户号
            RespCode   = Request.Form["RespCode"];      //应答返回码
            TrxId      = Request.Form["TrxId"];         //钱管家交易唯一标识
            OrdAmt     = Request.Form["OrdAmt"];        //金额
            CurCode    = Request.Form["CurCode"];       //币种
            Pid        = Request.Form["Pid"];           //商品编号
            OrdId      = Request.Form["OrdId"];         //订单号
            MerPriv    = Request.Form["MerPriv"];       //商户私有域
            RetType    = Request.Form["RetType"];       //返回类型
            DivDetails = Request.Form["DivDetails"];    //分账明细
            GateId     = Request.Form["GateId"];        //银行ID
            ChkValue   = Request.Form["ChkValue"];      //签名信息

            PbProject.Logic.Pay.ChinaPnr _ChinaPnr = new PbProject.Logic.Pay.ChinaPnr();

            //验证签名
            String MsgData, SignData;
            MsgData = CmdId + MerId + RespCode + TrxId + OrdAmt + CurCode + Pid + OrdId + MerPriv + RetType + DivDetails + GateId;
            CHINAPNRLib.NetpayClient SignObject = new CHINAPNRLib.NetpayClientClass();

            SignData = SignObject.VeriSignMsg0(_ChinaPnr._PgKeyUrl, MsgData, MsgData.Length, ChkValue);       //请将此处改成你的私钥文件所在路径

            if (SignData == "0")
            {
                if (RespCode == "000000")
                {
                    #region 交易成功

                    if (CmdId == "Buy")
                    {
                        #region 支付
                        #endregion
                    }
                    else if (CmdId == "Refund")
                    {
                        #region 退款
                        #endregion
                    }

                    #endregion

                    val = "Sucess.aspx?PayType=3&ReturnType=1&OrderId=" + OrdId + "&Price=" + OrdAmt + "&OnLineNo=" + OrdId;
                }
                else
                {
                    //交易失败
                    OnErrorNew("交易失败", false);
                }
            }
            else
            {
                OnErrorNew("验证失败", false);
            }
        }
        catch (Exception ex)
        {
            OnErrorNew("catch:" + ex, false);
        }

        return(val);
    }
Beispiel #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (Page.Request.RequestType.ToString() != "POST")
        //{
        //    Response.Redirect("/index.htm");
        //    return;
        //}
        if (Request.QueryString["action"] != null)
        {
            action = Request.QueryString["action"].Trim();
        }
        TransType = Request.Form["TransType"]; //交易类型

        MerId = Request.Form["MerId"];         //商户号


        OrdId = Request.Form["OrdId"];//订单号


        MerDate = Request.Form["MerDate"];   //商户日期

        TransAmt = Request.Form["TransAmt"]; //交易金额

        MerPriv = Request.Form["MerPriv"];   //商户私有域


        GateId = Request.Form["GateId"];//网关号


        TransStat = Request.Form["TransStat"];//交易状态


        SysDate = Request.Form["SysDate"];   //系统日期

        SysSeqId = Request.Form["SysSeqId"]; //系统流水号


        //lblPnr.Text = OrdId;
        //lblSys.Text = SysSeqId;
        //lblPayPoint.Text = TransAmt;//实际支付金额
        //lblPoint.Text = tzWeb.pay.comm.getOrderPoint(Convert.ToInt64(OrdId));//需要支付的点数

        ChkValue = Request.Form["ChkValue"];                                         //签名值

        PgKeyFile = System.Configuration.ConfigurationSettings.AppSettings["pnrPK"]; //公钥文件名

        CHINAPNRLib.NetpayClientClass ThisOrder = new CHINAPNRLib.NetpayClientClass();
        ret = ThisOrder.VeriSignOrder0(MerId, PgKeyFile, OrdId, TransAmt, MerDate, TransType, TransStat, GateId, MerPriv, SysDate, SysSeqId, ChkValue);
        //loginname = tzWeb.LoginInfo.GetLoginUserName(0);
        bool cs_success = OnlineStrike.isSuccess(OrdId);//该订单是否充值成功

        if (!Page.IsPostBack)
        {
            if (ret == "0")//本次调用成功
            {
                if (TransStat == "S")
                {
                    if (!cs_success)//
                    {
                        //开始充值

                        //bool b = dal.StrikeSuccess(OrdId, "huanglelou");
                        bool b = dal.StrikeSuccess(OrdId, "pnr", SysSeqId, Page.User.Identity.Name);
                        if (b)
                        {
                            Response.Write("RECV_ORD_ID" + OrdId);
                        }
                        else
                        {
                            Response.Write("充值未成功,请联系我们的客服!");
                        }
                    }
                }
            }
            else
            {
                Response.Write("验证失败");
            }
        }
    }