You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.9 KiB
C#

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