Exemplo n.º 1
0
        private PaymentFacade(PayGatewayTypes gatewayType, CommonPayConfig payConfig)
        {
            if (payConfig == null)
            {
                throw new ArgumentNullException(nameof(payConfig), "未提供支付平台配置");
            }

            _paymentGateway = gatewayType switch
            {
                PayGatewayTypes.WxJsApiPay => new WxJsApiPayGateway(payConfig),
                _ => _gatewayBuilders?.GetValue(gatewayType)?.Invoke(payConfig)
            };

            if (_paymentGateway == null)
            {
                throw new ArgumentOutOfRangeException("gatewayType", "未知的支付方式");
            }
            _paymentGateway.GatewayType = gatewayType;
        }
Exemplo n.º 2
0
 /// <summary>
 /// 通过支付渠道及配置信息,创建PaymentFacade。
 /// </summary>
 public static PaymentFacade Create(PayGatewayTypes gatewayType, CommonPayConfig payConfig)
 {
     return(new PaymentFacade(gatewayType, payConfig));
 }
Exemplo n.º 3
0
 protected PaymentGatewayBase(CommonPayConfig payConfig)
 {
     PayConfig = payConfig;
 }