public WxPayServiceMiddleware(RequestDelegate next, IWxPayPaymentService paymentService, IOptions <WxPayOptions> options) { this._next = next; this._paymentService = paymentService; this._options = options.Value; _mapPath = _options.MapPath; }
public static void AddWxPayService(this IServiceCollection services, IConfigurationRoot configuration) { var section = configuration.GetSection("WxPay"); WxPayOptions wxPayConfig = new WxPayOptions() { AppID = section["AppID"], AppSecret = section["AppSecret"], EncodingAESKey = section["EncodingAESKey"], MechantID = section["MechantID"], Token = section["Token"], DeviceInfo = section["DeviceInfo"], APIKey = section["APIKey"], MapPath = section["MapPath"], Domain = section["Domain"] }; services.AddScoped <IWxPayPaymentService>(provider => new WxPayPaymentService(wxPayConfig)); }
//private static TimeZoneInfo _ChinaStandardTime = TimeZoneInfo.GetSystemTimeZones().First(x => x.StandardName == "China Standard Time"); public WxPayPaymentService(WxPayOptions configuration) { _configuration = configuration; _httpClient.BaseAddress = new Uri("https://api.mch.weixin.qq.com/pay/"); _secureHttpClient.BaseAddress = new Uri("https://api.mch.weixin.qq.com/secapi/pay/"); }