初始提交
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Hncore.Pass.PaymentCenter.WxPay.WechatJsPay
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信小程序、公众号支付 数据签名校验
|
||||
/// </summary>
|
||||
public class WxJsPayDataBase
|
||||
{
|
||||
public string GenerateNonceStr()
|
||||
{
|
||||
return Guid.NewGuid().ToString("N");
|
||||
}
|
||||
public WxPayChecker ToPayData()
|
||||
{
|
||||
var type = GetType();
|
||||
var properties = type.GetProperties();
|
||||
|
||||
var data = new WxPayChecker();
|
||||
foreach (var property in properties)
|
||||
{
|
||||
var xmlAttr = property.GetCustomAttributes(typeof(XmlElementAttribute), false);
|
||||
|
||||
if (!xmlAttr.Any())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string name = ((XmlElementAttribute)xmlAttr[0]).ElementName;
|
||||
|
||||
object valueObj = property.GetValue(this, null);
|
||||
|
||||
if (valueObj == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string value = valueObj.ToString();
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
data[name] = value;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user