Example #1
0
 /// <summary>
 /// 对一段字符进行签名 signData
 /// </summary>
 /// <param name="MerId">商户号,长度为15个字节的数字串,由ChinaPay分配</param>
 /// <param name="SignMsg">用于要签名的字符串</param>
 /// <returns>String CheckValue[256]即NetPayClient根据上述输入参数生成的商户数字签名,长度为256字节的字符串</returns>
 public string signData(string MerId, string SignMsg)
 {
     NetPayClientClass npc = new NetPayClientClass(); //实例NetPay签名
     //npc.setMerKeyFile("Bin/MerPrK.key");          //设置商户密钥文件地址 d:\\MerPrK.key
     npc.setMerKeyFile("C:/Users/kunlun/Desktop/chinapay/chinapay/MerPrK_808080580004253_20110111100236.key");
     string strChkValueData = "";
     strChkValueData = npc.signData(MerId, SignMsg);
     return strChkValueData.Trim();
 }
Example #2
0
        //string strUrl = HttpContext.Current.Request.PhysicalApplicationPath; //获取网站根目录物理路径
        /// <summary>
        /// 订单签名函数sign
        /// </summary>
        /// <param name="MerId">商户号,长度为15个字节的数字串,由ChinaPay或清算银行分配</param>
        /// <param name="OrdId">订单号,长度为16个字节的数字串,由用户系统/网站生成,失败的订单号允许重复支付</param>
        /// <param name="TransAmt">交易金额,长度为12个字节的数字串,例如:数字串"000000001234"表示12.34元</param>
        /// <param name="CuryId">货币代码, 长度为3个字节的数字串,目前只支持人民币,取值为"156"</param>
        /// <param name="TransDate">交易日期,长度为8个字节的数字串,表示格式为:YYYYMMDD</param>
        /// <param name="TransType">交易类型,长度为4个字节的数字串,取值范围为:"0001"和"0002", 其中"0001"表示消费交易,"0002"表示退货交易</param>
        /// <returns>string CheckValue[256]  即NetPayClient根据上述输入参数生成的商户数字签名,长度为256字节的字符串</returns>
        public string getSign(string MerId, string OrdId, string TransAmt, string CuryId, string TransDate, string TransType)
        {
            NetPayClientClass npc = new NetPayClientClass(); //实例NetPay签名

            //npc.setMerKeyFile("Bin/MerPrK.key");          //设置商户密钥文件地址 d:\\MerPrK.key
            npc.setMerKeyFile("C:/Users/kunlun/Desktop/chinapay/chinapay/MerPrK_808080580004253_20110111100236.key");
            string strChkValue = "";                         //chinapay返回的商户数字签名
            strChkValue = npc.sign(MerId, OrdId, TransAmt, CuryId, TransDate, TransType);
            return strChkValue.Trim();
        }