示例#1
0
 public WechatScanPayEndpoint(ILogger <WechatScanPayEndpoint> logger, IWeChatPayClient client,
                              IScanPayValidator validator)
 {
     this._logger    = logger;
     this._client    = client;
     this._validator = validator;
 }
示例#2
0
 public WepayService(IWeChatPayClient client,
                     IOptions <WeChatPayOptions> options,
                     IOrderService orderService)
 {
     this.client       = client;
     this.options      = options;
     this.orderService = orderService;
 }
示例#3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="accessor"></param>
 /// <param name="client"></param>
 /// <param name="wechatPayOption"></param>
 public PaymentService(IHttpContextAccessor accessor,
                       IWeChatPayClient client,
                       IOptions <WeChatPayOptions> wechatPayOption)
 {
     _accessor        = accessor;
     _client          = client;
     _wechatPayOption = wechatPayOption.Value;
 }
示例#4
0
 public PaymentService(
     ILogger <PaymentService> logger,
     IWeChatPayClient client,
     IAppSettingService appSettingService)
 {
     _logger            = logger;
     _client            = client;
     _appSettingService = appSettingService;
 }
示例#5
0
        public async Task <WeChatPayPlatformCertificate> GetCertificateAsync(IWeChatPayClient client, WeChatPayOptions options)
        {
            // 如果证书序列号已缓存,则直接使用缓存的
            var platformCert = _certDictionary.Values.Where(cert => cert.EffectiveTime <DateTime.Now && cert.ExpireTime> DateTime.Now).FirstOrDefault();

            if (platformCert != null)
            {
                return(platformCert);
            }

            // 否则重新下载新的平台证书
            var request  = new WeChatPayCertificatesRequest();
            var response = await client.ExecuteAsync(request, options);

            foreach (var certificate in response.Certificates)
            {
                // 若证书序列号未被缓存,解密证书并加入缓存
                if (!_certDictionary.ContainsKey(certificate.SerialNo))
                {
                    switch (certificate.EncryptCertificate.Algorithm)
                    {
                    case nameof(AEAD_AES_256_GCM):
                    {
                        var certStr = AEAD_AES_256_GCM.Decrypt(certificate.EncryptCertificate.Nonce, certificate.EncryptCertificate.Ciphertext, certificate.EncryptCertificate.AssociatedData, options.V3Key);

                        var cert = new WeChatPayPlatformCertificate
                        {
                            SerialNo      = certificate.SerialNo,
                            EffectiveTime = DateTime.Parse(certificate.EffectiveTime),
                            ExpireTime    = DateTime.Parse(certificate.ExpireTime),
                            Certificate   = new X509Certificate2(Encoding.ASCII.GetBytes(certStr))
                        };

                        _certDictionary.TryAdd(certificate.SerialNo, cert);
                    }
                    break;

                    default:
                        throw new WeChatPayException($"Unknown algorithm: {certificate.EncryptCertificate.Algorithm}");
                    }
                }
            }

            // 重新从缓存获取
            platformCert = _certDictionary.Values.Where(cert => cert.EffectiveTime <DateTime.Now && cert.ExpireTime> DateTime.Now).FirstOrDefault();
            if (platformCert != null)
            {
                return(platformCert);
            }
            else
            {
                throw new WeChatPayException("Download certificates failed!");
            }
        }
示例#6
0
 public PaymentService(
     ILogger <PaymentService> logger,
     IWeChatPayClient client,
     IOptionsMonitor <MiniProgramOptions> options,
     IOptionsMonitor <ShopConfig> config)
 {
     _logger  = logger;
     _client  = client;
     _options = options;
     _apiHost = config.CurrentValue.ApiHost;
 }
示例#7
0
        private void init()
        {
            var someOptions = Options.Create(new WeChatPayOptions {
                AppId     = "wxdace645e0bc2c424",
                AppSecret = "4693afc6b2084885ca9fbc2355b97827",
                BaseUrl   = "https://api.mch.weixin.qq.com",
                Key       = "1900009641"
            });

            _client  = new WeChatPayClient(someOptions, wechatpaylogger);
            _subject = new WechatAppletPayEndpoint(logger, _client);
        }
示例#8
0
 public WepayService(ILogger <WepayService> logger,
                     IWeChatPayClient client,
                     IWeChatPayNotifyClient notifyClient,
                     IOptions <WeChatPayOptions> options,
                     IOrderService orderService)
 {
     this.logger       = logger;
     this.client       = client;
     this.notifyClient = notifyClient;
     this.options      = options;
     this.OrderService = orderService;
 }
示例#9
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="client"></param>
 /// <param name="options"></param>
 /// <param name="withdrawalHistoryRepository"></param>
 /// <param name="custoemrRepository"></param>
 /// <param name="customerManager"></param>
 /// <param name="mapper"></param>
 public AdminWithdrawalController(IWeChatPayClient client,
                                  IOptions <WeChatPayOptions> options,
                                  IRepositoryByInt <WithdrawalHistory> withdrawalHistoryRepository,
                                  IRepositoryByInt <Customer> custoemrRepository,
                                  ICustomerManager customerManager,
                                  IMapper mapper)
 {
     _client                      = client;
     _weChatPayOptions            = options.Value;
     _withdrawalHistoryRepository = withdrawalHistoryRepository;
     _custoemrRepository          = custoemrRepository;
     _customerManager             = customerManager;
     _mapper                      = mapper;
 }
示例#10
0
 public QueryResult(IWeChatPayClient client)
 {
     this._client = client;
 }
示例#11
0
 public WechatPublicPayEndpoint(ILogger <WechatPublicPayEndpoint> logger, IWeChatPayClient client)
 {
     this._logger = logger;
     this._client = client;
 }
示例#12
0
 public AppPayResult(IWeChatPayClient client)
 {
     this._client = client;
 }
示例#13
0
 public CloseResult(IWeChatPayClient client)
 {
     this._client = client;
 }
 public WeChatPayController(IWeChatPayClient client)
 {
     _client = client;
 }
示例#15
0
 public WeChatPayController(IWeChatPayClient client, IOptions <WeChatPayOptions> optionsAccessor)
 {
     _client          = client;
     _optionsAccessor = optionsAccessor;
 }
示例#16
0
 public WeChatPayController(ILogger <WeChatPayController> logger, IWeChatPayClient client, IOptions <WeChatPayOptions> optionsAccessor)
 {
     _logger          = logger;
     _client          = client;
     _optionsAccessor = optionsAccessor;
 }
示例#17
0
 public WeChatPayNotifyClient(IWeChatPayClient client, WeChatPayPlatformCertificateManager platformCertificateManager)
 {
     _client = client;
     _platformCertificateManager = platformCertificateManager;
 }