WeiXinMPSDK icon indicating copy to clipboard operation
WeiXinMPSDK copied to clipboard

【异步方法】 用于企业向微信用户个人付款 serviceProvider 参数从哪里获得? 是否有相关demo?

Open redcatH opened this issue 3 years ago • 1 comments

使用最新的TransfersAsync接口 请问serviceProvider 从哪里获取? asp.net core, 有相关demo吗?

public static async Task<TransfersResult> TransfersAsync(
            IServiceProvider serviceProvider,
            TenPayV3TransfersRequestData dataInfo,
#if NET45
            string cert, string certPassword, 
#endif
            int timeOut = Config.TIME_OUT)
        {
}

redcatH avatar Jun 29 '21 09:06 redcatH

这是 .NET Core 中的依赖注入官方的参数,通过依赖注入自动得到。你只需要在调用这个接口的类(通常是Service或者Controller之类,在构造函数中注入即可。

示例:

https://github.com/JeffreySu/WeiXinMPSDK/blob/fa4b15d52af652196d5c988c9990f6bedd78e4c5/Samples/net6-mvc/Senparc.Weixin.Sample.Net6/Controllers/Weixin/TenPay/TenPayV3Controller.cs#L94

JeffreySu avatar Jul 16 '21 16:07 JeffreySu