public static async Task <T> GetWithdrawRspAsync <T>(string url, string customerNo, string sha256SignKey, JdWithdrawBaseReq req) where T : class { var jdReq = BuildJdWithdrawRequest(customerNo, sha256SignKey, req); return(await GetWithdrawRspAsync <T>(url, jdReq)); }
public static JdWithdrawRequest BuildJdWithdrawRequest(string customerNo, string sha256SignKey, JdWithdrawBaseReq req) { var srcSignData = JdHelper.GetSignData(req); var jdReq = new JdWithdrawRequest(customerNo) { SignData = JdHelper.ComputeSha256(srcSignData + sha256SignKey), EncryptData = JdHelper.SignEnvelop(srcSignData) }; return(jdReq); }
/// <summary> /// 获取待签名的内容 /// </summary> /// <param name="req"></param> /// <returns></returns> public static string GetSignData(JdWithdrawBaseReq req) { var dic = new Dictionary <string, string>(); foreach (var prop in req.GetType().GetProperties()) { var attrs = prop.GetCustomAttributes(typeof(JsonPropertyAttribute), false) as JsonPropertyAttribute[]; if (attrs.Any()) { var attr = attrs.First(); var value = Convert.ToString(prop.GetValue(req)); if (!String.IsNullOrEmpty(value) && !IGNORES.Contains(attr.PropertyName)) { dic.Add(attr.PropertyName, value); } } } return(String.Join("&", dic.OrderBy(w => w.Key).Select(w => $"{w.Key}={w.Value}"))); }