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)); }
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); }
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)); }
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"] })); }
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); } }