예제 #1
0
        /// <summary>
        /// 设置支付接口中订单参数的详细信息并反序列化成json字符串
        /// </summary>
        /// <param name="orderLists"></param>
        /// <returns></returns>
        private static string GetOrdersString(List <EBOrder> orderLists)
        {
            string result = string.Empty;

            foreach (var item in orderLists)
            {
                item.body        = BuildSignature.Base64Encode(item.body);
                item.currency    = "CNY";
                item.goodsName   = BuildSignature.Base64Encode(item.goodsName);
                item.orderTime   = DateTime.Now.ToString("yyyyMMddHHmmss");
                item.orderType   = "01";
                item.payTimeout  = "7d";
                item.receiveInfo = BuildSignature.Base64Encode(item.receiveInfo);
            }
            result = JsonConvert.SerializeObject(orderLists);
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 校验接口签名
        /// </summary>
        /// <returns></returns>
        public static string ValidationSignature(EPAPIModel returnData)
        {
            // 排除的参数
            string[] parasmeters = new string[2] {
                "Signature",
                "SignAlgorithm"
            };
            // 私钥字符串
            string privateKey = GetEPSinotexPrivateKey();
            // 签名结果
            var strSignature = BuildSignature.PCBuildMysign(
                returnData, privateKey, string.Empty, returnData.signAlgorithm, "UTF-8", parasmeters);

            if (!returnData.signature.Equals(strSignature))
            {
                return("签名校验失败");
            }
            return(string.Empty);
        }
예제 #3
0
        /// <summary>
        /// 收银台支付接口提交的表单字符串生成方法
        /// </summary>
        /// <param name="param"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string GenerateFormString(BaseSignParam param, string url)
        {
            string result = string.Empty;

            // 签名算法
            param.SignAlgorithm = "RSA";
            // 字符类型
            param.InputCharset = "UTF-8";
            // 公钥索引
            param.PublicKeyIndex = ConfigurationManager.AppSettings["SinotexPublicKeyIndex"];

            // 排除的参数
            string[] parasmeters = new string[2] {
                "Signature",
                "SignAlgorithm"
            };
            // 私钥字符串
            string privateKey = GetEPSinotexPrivateKey();

            // 签名结果
            var strSignature = BuildSignature.PCBuildMysign(
                param, privateKey, string.Empty, param.SignAlgorithm, param.InputCharset, parasmeters);

            // 签名
            param.Signature = strSignature;

            StringBuilder formParamters = new StringBuilder();

            PropertyInfo[] propertyInfos = param.GetType().GetProperties();
            foreach (PropertyInfo propertyInfo in propertyInfos)
            {
                // 将属性的首字母大写改为小写
                string name = propertyInfo.Name.Substring(0, 1).ToLower();
                name = name + propertyInfo.Name.Substring(1, propertyInfo.Name.Length - 1);
                // 判断是否为空
                string paramValue = propertyInfo.GetValue(param, null) == null ? "" : propertyInfo.GetValue(param, null).ToString();
                formParamters.Append(BuildInputHiddenFieldInForm(name, paramValue));
            }
            // 最终提交的form表单
            String formString = BuildForm(url, formParamters.ToString());

            return(formString);
        }