Sign() public static method

public static Sign ( string prestr, string _input_charset ) : string
prestr string
_input_charset string
return string
コード例 #1
0
        private string BuildRequest(string orderNo, string productName, int totalFee, string customerIP, EnumWePayTradeType tradeType)
        {
            SortedDictionary <string, string> dicParam = CreateParam(orderNo, productName, totalFee, customerIP, tradeType);

            string signString = CreateURLParamString(dicParam);
            string key        = tradeType == EnumWePayTradeType.APP ? WepayConfig.WEPAY_APP_KEY : WepayConfig.WEPAY_WEB_KEY;
            string preString  = signString + "&key=" + key;
            string sign       = MD5Helper.Sign(preString, WepayConfig.WEPAY_CHARTSET).ToUpper();

            dicParam.Add("sign", sign);

            return(BuildForm(dicParam));
        }
コード例 #2
0
        private string BuildRequestsign(string urlParam, EnumSignType signType)
        {
            string mysign = "";

            if (signType == EnumSignType.MD5)
            {
                string preString = urlParam + AlipayConfig.ALI_KEY;
                mysign = MD5Helper.Sign(preString, AlipayConfig.CHARTSET);
            }
            else if (signType == EnumSignType.RSA)
            {
                mysign = RSASign(urlParam, AlipayConfig.ALIPay_RSA_PRIVATEKEY, AlipayConfig.CHARTSET);
            }

            return(mysign);
        }
コード例 #3
0
        public static string BuildQueryRequest(string transactionId, SortedDictionary <string, string> dic)
        {
            string tradeType = GetValueFromDic <string>(dic, "trade_type");
            bool   isApp     = tradeType == EnumWePayTradeType.APP.ToString();

            SortedDictionary <string, string> dicParam = CreateQueryParam(transactionId, isApp);
            string signString = CreateURLParamString(dicParam);

            string key       = isApp ? WepayConfig.WEPAY_APP_KEY : WepayConfig.WEPAY_WEB_KEY;
            string preString = signString + "&key=" + key;

            string sign = MD5Helper.Sign(preString, "utf-8").ToUpper();

            dicParam.Add("sign", sign);

            return(BuildForm(dicParam));
        }
コード例 #4
0
        private static string BuildAppPay(string prepayid)
        {
            var    dicParam   = CreateWapAndAppPayParam(prepayid);
            string signString = CreateURLParamString(dicParam);
            string preString  = signString + "&key=" + WepayConfig.WEPAY_APP_KEY;

            string sign = MD5Helper.Sign(preString, WepayConfig.WEPAY_CHARTSET).ToUpper();

            dicParam.Add("sign", sign);

            return(JsonConvert.SerializeObject(
                       new
            {
                appid = dicParam["appid"],
                partnerid = dicParam["partnerid"],
                prepayid = dicParam["prepayid"],
                package = dicParam["package"],
                noncestr = dicParam["noncestr"],
                timestamp = dicParam["timestamp"],
                sign = dicParam["sign"]
            }));
        }
コード例 #5
0
        public static bool WePayNotifyValidation(SortedDictionary <string, string> dic)
        {
            string sign = GetValueFromDic <string>(dic, "sign");

            if (dic.ContainsKey("sign"))
            {
                dic.Remove("sign");
            }

            string tradeType = GetValueFromDic <string>(dic, "trade_type");
            string preString = CreateURLParamString(dic);

            if (string.IsNullOrEmpty(tradeType))
            {
                string key           = tradeType == EnumWePayTradeType.APP.ToString() ? WepayConfig.WEPAY_APP_KEY : WepayConfig.WEPAY_WEB_KEY;
                string preSignString = preString + "&key=" + key;
                string signString    = MD5Helper.Sign(preSignString, WepayConfig.WEPAY_CHARTSET).ToUpper();
                return(signString == sign);
            }
            else
            {
                return(false);
            }
        }