Exemple #1
0
        /// <summary>
        /// 构成URL参数的sign值
        /// </summary>
        /// <param name="dic">参数的字典集合</param>
        /// <param name="key">安全校验码</param>
        /// <returns>返回sign的值</returns>
        /// <remarks>参与加密的参数存入Dictionary,参数的值不允许为空,若该参数为空,不要把这个参数加到Dictionary集合里面</remarks>
        public static string GetSign(Dictionary <string, string> dic, string key)
        {
            //构造数组
            string[] Oristr = new string[dic.Count];
            int      ct     = 0;

            foreach (KeyValuePair <string, string> entry in dic)
            {
                if (!String.IsNullOrEmpty(entry.Value))
                {
                    Oristr[ct] = entry.Key + "=" + entry.Value;
                    ct++;
                }
            }
            //进行排序
            string[] Sortedstr = Alipay.BubbleSort(Oristr);

            //构造待md5摘要字符串
            System.Text.StringBuilder prestr = new System.Text.StringBuilder();

            for (int i = 0; i < Sortedstr.Length; i++)
            {
                if (i == Sortedstr.Length - 1)
                {
                    prestr.Append(Sortedstr[i]);
                }
                else
                {
                    prestr.Append(Sortedstr[i] + "&");
                }
            }
            prestr.Append(key);//追加key
            //生成Md5摘要
            return(Alipay.GetMD5(prestr.ToString(), _Input_Charset));
        }
Exemple #2
0
        /// <summary>
        /// 构造积分兑入接口请求url
        /// </summary>
        /// <param name="logon_id">支付宝会员登陆账号,即需要被兑入集分宝的支付宝登录账号,可以是手机或邮箱</param>
        /// <param name="amount">需要兑入的支付宝积分数</param>
        /// <param name="out_biz_no">外部流水号-即本地系统的订单流水号</param>
        /// <param name="out_user_id">外部会员ID,即为外部系统的会员ID,用以支付宝进行反查询使用</param>
        /// <param name="out_biz_time">外部业务时间</param>
        /// <param name="out_point_amount">外部积分数</param>
        /// <param name="is_need_q">是否需要Q会员</param>
        /// <returns></returns>
        public string CreateDirectPayByUser(string logon_id, string amount, string out_biz_no, string out_user_id, string out_biz_time, string out_point_amount, string is_need_q)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("service", "generalpoint_add_point");//服务名称,这个是识别是何接口实现何功能的标识,请勿修改
            dic.Add("partner", AlipayConfig.Partner);
            dic.Add("_input_charset", Alipay._Input_Charset);
            dic.Add("logon_id", logon_id);
            dic.Add("amount", amount);
            dic.Add("out_biz_no", out_biz_no);
            dic.Add("out_user_id", out_user_id);
            dic.Add("out_biz_time", out_biz_time);
            dic.Add("out_point_amount", out_point_amount);
            dic.Add("is_need_q", is_need_q);
            return(Alipay.AlipayDoGetN(dic, AlipayConfig.Key));
        }
Exemple #3
0
        /// <summary>
        /// 构造md5签名字符串
        /// </summary>
        /// <param name="nvc">NameValues集合</param>
        /// <param name="key">安全校验码</param>
        /// <returns>返回排序后的字符串(自动剔除末尾的sign和sign_type类型)</returns>
        private string BuildSignString(System.Collections.Specialized.NameValueCollection nvc, string key)
        {
            string[]      Sortedstr = Alipay.BubbleSort(nvc.AllKeys); //对参数进行排序
            StringBuilder prestr    = new StringBuilder();            //构造待md5摘要字符串

            for (int i = 0; i < Sortedstr.Length; i++)
            {
                if (nvc.Get(Sortedstr[i]) != "" && Sortedstr[i] != "sign" && Sortedstr[i] != "sign_type")
                {
                    if (i == Sortedstr.Length - 1)
                    {
                        prestr.Append(Sortedstr[i] + "=" + nvc.Get(Sortedstr[i]));
                    }
                    else
                    {
                        prestr.Append(Sortedstr[i] + "=" + nvc.Get(Sortedstr[i]) + "&");
                    }
                }
            }
            prestr.Append(key);//追加key
            return(prestr.ToString());
        }
Exemple #4
0
 /// <summary>
 /// 将返回的URL生成Md5摘要
 /// </summary>
 /// <param name="coll">NameValues集合,通过Request.QueryString或Request.Form方式取得</param>
 /// <returns>返回sign串</returns>
 public string GetMD5Sign(System.Collections.Specialized.NameValueCollection coll)
 {
     return(Alipay.GetMD5(BuildSignString(coll, AlipayConfig.Key), Alipay._Input_Charset));
 }