using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; namespace POSV.Payment.AllinPay.Models { /// /// 基础请求参数 /// public abstract class BaseParamInfo { protected BaseParamInfo() { appId = AllinpayLib.AppId; key = AllinpayLib.AppKey; //format = "JSON"; charset = "utf-8"; signType = "MD5"; version = "1.0"; //sign_v = AllinpayLib.AppSignV ?? "1"; timestamp = DateTime.Now.ToString("yyyyMMddHHmmss"); } /// /// 请求接口时传输方法 /// internal string HttpMethod { get; set; } /// /// 通商云分配给开发者的应用ID /// public string appId { get; set; } /// /// API接口名称 /// public abstract string method { get; } /// /// 可选,指定响应格式。默认xml,目前支持格式为xml,json /// //public string format { get; set; } public string charset { get; set; } /// /// AOP分配给应用的AppKey /// public string key { get; set; } /// /// 商户生成签名字符串所使用的签名算法类型,目前支持MD5 /// public string signType { get; set; } /// /// API输入参数签名结果,使用dsa加密(签名后一定要对该参数赋值,后续验证返回结果会用到) /// internal string sign { get; set; } /// /// 时间戳,格式为yyyyMMddHHmmss,例如:20110125010101。API服务端允许客户端请求时间误差为30分钟。 /// public string timestamp { get; set; } /// /// 调用的接口版本。 /// public string version { get; set; } ///// ///// 签名版本号 1 ,2,3,4,5每次更新后+1递增 ///// //public string sign_v { get; set; } //public abstract string bizContent { get; } public string bizContent { get; set; } public virtual Dictionary GetParamDict() { var props = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(p => p.CanRead); var dict = new Dictionary(); foreach (PropertyInfo prop in props) { var val = prop.GetValue(this, null).ToStringEx(); if (string.IsNullOrEmpty(val)) { continue; } dict.Add(prop.Name, val); } return dict; } } }