예제 #1
0
        protected override string GenerateUrl(UseType useType, string body, decimal vMoney, int userID, ref string exchangeID, string returnUrl, string notifyUrl, string name, string orderid = "")
        {
            Random random       = new Random(System.Environment.TickCount);
            string out_trade_no = DateTime.Now.ToString("yyyyMMdd") + random.Next(10, 99);

            exchangeID = out_trade_no;
            string OrdId    = out_trade_no;
            string OrdAmt   = (Convert.ToInt32(Convert.ToDecimal(vMoney) * 100)).ToString(); //订单金额,单位:分,必填
            string OrdDesc  = string.Format(base.GenerateSubject(useType), name);
            string Priv1    = body;                                                          //商户自填信息
            string CustomIp = IPHelper.getRealIPAddress;                                     //用户提交订单的IP地址,选填
            string ChkValue = "";                                                            //签名数据,必填

            ChinaPayUtils.priKeyPath = HttpContext.Current.Server.MapPath("/" + ConfigurationManager.AppSettings["ChinaPayPriKeyPath"].ToString());
            string plainData = Partner
                               + ChinaPayBusiId
                               + OrdId
                               + OrdAmt
                               + ChinaPayCuryId
                               + ChinaPayVersion
                               + NotifyAddress
                               + ReturnAddress
                               + ChinaPayGateId
                               + ChinaPayShareType
                               + ChinaPayShareData + OrdAmt
                               + Priv1
                               + CustomIp;

            ChkValue = ChinaPayUtils.signData(Partner, plainData);

            return(Gateway + "?"
                   + "MerId=" + Partner
                   + "&BusiId=" + ChinaPayBusiId
                   + "&OrdId=" + OrdId
                   + "&OrdAmt=" + OrdAmt
                   + "&CuryId=" + ChinaPayCuryId
                   + "&Version=" + ChinaPayVersion
                   + "&BgRetUrl=" + NotifyAddress
                   + "&PageRetUrl=" + ReturnAddress
                   + "&GateId=" + ChinaPayGateId
                   + "&OrdDesc=" + OrdDesc
                   + "&ShareType=" + ChinaPayShareType
                   + "&ShareData=" + ChinaPayShareData + OrdAmt
                   + "&Priv1=" + Priv1
                   + "&CustomIp=" + CustomIp
                   + "&ChkValue=" + ChkValue);
        }
예제 #2
0
        /// <summary>
        /// 银联Notify回写参数
        /// </summary>
        /// <param name="MerId"></param>
        /// <param name="BusiId"></param>
        /// <param name="OrdId"></param>
        /// <param name="OrdAmt"></param>
        /// <param name="CuryId"></param>
        /// <param name="Versions"></param>
        /// <param name="BgRetUrl"></param>
        /// <param name="PageRetUrl"></param>
        /// <param name="GateId"></param>
        /// <param name="OrdDesc"></param>
        /// <param name="ShareType"></param>
        /// <param name="ShareData"></param>
        /// <param name="Priv1"></param>
        /// <param name="CustomIp"></param>
        /// <param name="PayStat">银联為我們返回的,防治篡改的</param>
        /// <param name="PayTime">银联為我們返回的,防治篡改的</param>
        /// <param name="ChkValue"></param>
        /// <returns></returns>
        public bool ChinaPayRetUrlParam(
            string MerId,
            string BusiId,
            string OrdId,
            string OrdAmt,
            string CuryId,
            string Versions,
            string GateId,
            string OrdDesc,
            string ShareType,
            string ShareData,
            string Priv1,
            string CustomIp,
            string PayStat,
            string PayTime,
            string ChkValue)
        {
            ChinaPayUtils.pubKeyPath = HttpContext.Current.Server.MapPath("/" + ConfigurationManager.AppSettings["ChinaPayPubKeyPath"].ToString());
            string plainData = MerId
                               + BusiId
                               + OrdId
                               + OrdAmt
                               + CuryId
                               + Versions
                               + GateId
                               + ShareType
                               + ShareData
                               + Priv1
                               + CustomIp
                               + PayStat
                               + PayTime;
            string i = ChinaPayUtils.checkData(plainData, ChkValue);

            LoggerFactory.Instance.Logger_Info("plainData:" + plainData);
            LoggerFactory.Instance.Logger_Info("ChkValue:" + ChkValue);
            LoggerFactory.Instance.Logger_Info("plainData&ChkValue:" + i);
            if (PayStat == "1001" && i == "0")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }