Using the three-party payment provided by .NET,
Payment
provides basic payment capabilities. Due to the needs of the project, based onPayment
, support for Fuyou (Payment.Fuiou
) and Yinshengbao (Payment.Unspay
) is expanded. Of course, users can also Expand other payment channels based on Payment;
I don’t know if students who have done payment feel the same as me. I think the aspects related to payment are as follows:
In short, reasonable division will help us work in the next step. How to reduce the coupling between modules and how to increase scalability is our principle; the modules are divided, and the principles of doing things are clear. I think we have already figured out what to do. .
This is the way of doing things, and we try our best to make it happen. After all, the effect is unexpected; let’s talk about this project below.
The so-called agile means first satisfying the current situation and the past, and sorting it out in a timely manner without leaving any technical debt.
Students who read the source code will find that the log is commented out. This is because this program is a cut version and has a strong dependence on the platform log. This is very simple and we can add it ourselves; of course, if our communication method is not http , at this time we can mention another layer of ICommunicate;
原则是一样的,但是富有很强的灵活性,使我们所需掌握的
!
Take the variable parameters as an example:
/// <summary>
/// 支付基础参数
/// </summary>
public abstract class BaseParemetor : AbsAccount
{
#region Abstract Method
/// <summary>
/// 获取格式数据
/// </summary>
/// <returns></returns>
public abstract IDictionary < string , string > GetFormatData ( ) ;
/// <summary>
/// 获取访问的路径
/// </summary>
/// <returns></returns>
public abstract string GetRequestUrl ( ) ;
#endregion
}
public class FuiouParemetor : BaseParemetor
{
.. . .. .
/// <summary>
/// 获取签名数据
/// </summary>
/// <returns></returns>
public virtual string GetSignature ( )
{
.. . .. .
}
/// <summary>
/// 获取富有格式数据
/// </summary>
/// <returns></returns>
public override IDictionary < string , string > GetFormatData ( )
{
.. . .. .
}
public override string GetRequestUrl ( )
{
.. . .. .
}
.. . .. .
}
/// <summary>
/// 参数:42 商户P2P网站免登录用户更换银行卡接口
/// </summary>
public class ChangeCardParemetor : FuiouParemetor
{
/// <summary>
/// 个人用户
/// </summary>
[ Paremetor ( "login_id" ) ]
public string User { get ; set ; }
/// <summary>
/// 商户返回地址
/// </summary>
[ Paremetor ( "page_notify_url" ) ]
public string NotifyUrl { get ; set ; }
/// <summary>
/// 字段
/// </summary>
/// <returns></returns>
protected override string [ ] GetDataFields ( )
{
return new string [ ] { "login_id" , "mchnt_cd" , "mchnt_txn_ssn" , "page_notify_url" , "signature" } ;
}
/// <summary>
/// 获取访问的路径
/// </summary>
/// <returns></returns>
public override string GetRequestUrl ( )
{
return FuiouConfig . ApiAddress [ "Fuyou.ChangeCard.Action" ] ;
}
/// <summary>
/// 设置验证字段
/// </summary>
/// <returns></returns>
protected override IEnumerable < VALIDATE > SetValiDateFields ( )
{
yield return VALIDATE . NOTNULLANDLIMITLENGTH ( this . User , 11 , "用户登录ID" ) ;
yield return VALIDATE . NOTNULLANDLIMITLENGTH ( this . NotifyUrl , 200 , "商户前端接收交易结果地址" ) ;
}
}
/// <summary>
/// 银生宝基础接口
/// </summary>
public class UnspayParemetor : BaseParemetor
{
.. . .. .
/// <summary>
/// 获取签名数据
/// </summary>
/// <returns></returns>
public virtual string GetSignature ( )
{
.. . .. .
}
public override IDictionary < string , string > GetFormatData ( )
{
.. . .. .
}
.. . .. .
}
var response = new Provider ( ) . Process ( new Payment . Fuiou . Paremetors . ChangeCardParemetor ( ) ) ;
Is it simple and convenient? But...? What should I do if I change this account to Yinshengbao? Or what should I do if I change to another payment method?
If you find this problem, we can communicate. After all, this problem is not difficult, because the parameter is of
AbsAccount
type after all, what do you think?