Example #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="options">微信服务配置</param>
 /// <param name="version">微信支付接口版本</param>
 /// <param name="notifyType">微信财付通通知类型</param>
 /// <param name="request">请求信息</param>
 public WeChatNotifyData(WeChatGenOptions options, WeChatPayApiVersion version, WeChatNotifyType notifyType, HttpRequest request)
 {
     NotifyType = notifyType;
     Version    = version;
     Options    = options;
     Request    = request;
 }
        /// <summary>
        /// 获取通知Url
        /// </summary>
        /// <param name="configUrl">配置地址</param>
        /// <param name="notifyType">通知类型</param>
        /// <returns></returns>
        string GetNotifyUrl(string configUrl, WeChatNotifyType notifyType)
        {
            if (!string.IsNullOrWhiteSpace(configUrl))
            {
                return(configUrl);
            }

            var middleware = (WeChatNotifyV3Middleware)Options.WeChatDevOptions.ServiceProvider.GetService(typeof(WeChatNotifyV3Middleware));

            if (middleware != null && middleware.UrlDic.ContainsKey(notifyType))
            {
                return(middleware.UrlDic[WeChatNotifyType.Pay]);
            }
            else
            {
                throw new WeChatServiceException($"未配置接收通知的URL, WeChatNotifyType: {notifyType}.");
            }
        }