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