예제 #1
0
        public static string GetJsApiMiniAppPaySign(WeChatPayConfig config, string nancestr, string timestamp, string prepayId, string signType = "MD5")
        {
            string sign = null;
            SortedDictionary <string, string> param = new SortedDictionary <string, string>();

            param.Add("timeStamp", timestamp);
            param.Add("nonceStr", nancestr);
            param.Add("appId", config.MiniAppId);
            param.Add("package", "prepay_id=" + prepayId);
            param.Add("signType", signType);
            sign = HashWrapper.MD5_Hash(param, config.ShopSecret);
            return(sign);
        }
예제 #2
0
        /// <summary>
        /// JSSDK Payment configure signature
        /// </summary>
        /// <param name="config"></param>
        /// <param name="nancestr"></param>
        /// <param name="timestamp"></param>
        /// <param name="url"></param>
        /// <param name="ticket"></param>
        /// <returns></returns>
        public static string GetJsApiPayConfigSign(WeChatPayConfig config, string nancestr, string timestamp, string url, JSAPITicket ticket)
        {
            string sign = null;
            SortedDictionary <string, string> param = new SortedDictionary <string, string>();

            if (ticket == null || string.IsNullOrEmpty(ticket.Ticket))
            {
                throw new Exception("WeChat js ticket is empty.");
            }
            logger.Info("Generate pay config sign");
            logger.Info("jsapi_ticket:" + ticket.Ticket);
            logger.Info("timestamp:" + timestamp);
            logger.Info("noncestr:" + nancestr);
            logger.Info("url:" + url);

            param.Add("jsapi_ticket", ticket.Ticket);
            param.Add("timestamp", timestamp);
            param.Add("noncestr", nancestr);
            param.Add("url", url);
            sign = HashWrapper.SHA1_Hash(param);
            logger.Info("sign:" + sign);
            return(sign);
        }