public CreditCardController(IUnityContainer container, ICheapPaymentGateway cheapPayment, IExpensivePaymentGateway expensivePayment, IPremiumPaymentGateway premiumPayment) { this.container = container; this.cheapPaymentGateway = cheapPayment; this.expensivePaymentGateway = expensivePayment; this.premiumPaymentGateway = premiumPayment; }
public PaymentService(ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentGateway premiumPaymentGateway, IUnitOfWork unitOfWork) { _cheapPaymentGateway = cheapPaymentGateway; _expensivePaymentGateway = expensivePaymentGateway; _premiumPaymentGateway = premiumPaymentGateway; _unitOfWork = unitOfWork; }
public ProcessPayment(ProcessPaymentsContext context, ICheapPaymentGateway iCheapPaymentGeteway, IExpensivePaymentGateway iExpensivePaymentGateway, IPremiumPaymentGateway iPremiumPaymentGeteway) { _context = context; _iCheapPaymentGeteway = iCheapPaymentGeteway; _iExpensivePaymentGateway = iExpensivePaymentGateway; _iPremiumPaymentGeteway = iPremiumPaymentGeteway; }
public PaymentService(IUnitOfWork unitOfWork) { this.unitOfWork = unitOfWork; this.expensivePaymentGateway = new ExpensivePaymentGateway(); this.cheapPaymentGateway = new CheapPaymentGateway(); this.premiumPaymentGateway = new PremiumPaymentGateway(); }
public PaymentGatewayTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlServer("Data Source=(local)\\SQLEXPRESS;Initial Catalog=PaymentGateway;Integrated Security=True;").Options; _context = new ApplicationDbContext(options); _context.Database.EnsureDeleted(); _context.Database.EnsureCreated(); if (_mapper == null) { var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new AutoMapperProfile()); }); IMapper mapper = mappingConfig.CreateMapper(); _mapper = mapper; } _cheapPaymentGateway = new CheapPaymentGateway(); _expensivePaymentGateway = new ExpensivePaymentGateway(_cheapPaymentGateway); _premiumPaymentGateway = new PremiumPaymentGateway(); _paymentRepo = new PaymentRepository(_context); _paymentStateRepo = new PaymentStateRepository(_context); _paymentGateway = new PaymentGateway(_cheapPaymentGateway, _expensivePaymentGateway, _premiumPaymentGateway, _paymentRepo, _paymentStateRepo, _mapper); }
public PaymentController(ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentGateway premiumPaymentGateway) { _cheapPaymentGateway = cheapPaymentGateway; _expensivePaymentGateway = expensivePaymentGateway; _premiumPaymentGateway = premiumPaymentGateway; }
public PaymentService(ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentGateway premiumPaymentGateway) { _cheapPaymentGateway = cheapPaymentGateway; _expensivePaymentGateway = expensivePaymentGateway; _premiumPaymentGateway = premiumPaymentGateway; }
public PaymentDetailService(IPaymentLogRepository paymentLogRepository, IPaymentDetailRepository detailRepository, IExpensivePaymentGateway expensivePaymentGateway, ICheapPaymentGateway cheapPaymentGateway, IPremiumPaymentGateway premiumPaymentGateway) { this.paymentLogRepository = paymentLogRepository; this.detailRepository = detailRepository; this.expensivePaymentGateway = expensivePaymentGateway; this.cheapPaymentGateway = cheapPaymentGateway; this.premiumPaymentGateway = premiumPaymentGateway; }
//dependency injection of interfaces into the PaymentProcessor constructor public PaymentProcessor(ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentGateway premiumPaymentGateway, IStatusRepository statusRepository) { _cheapPaymentGateway = cheapPaymentGateway; _expensivePaymentGateway = expensivePaymentGateway; _premiumPaymentGateway = premiumPaymentGateway; _statusRepo = statusRepository; }
public PaymentHandler(IRepository <PayDetails> payRepository, IRepository <PaymentStatus> payStatusRepository , ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentGateway premiumPaymentGateway) { _payRepository = payRepository; _payStatusRepository = payStatusRepository; _cheapPaymentGateway = cheapPaymentGateway; _expensivePaymentGateway = expensivePaymentGateway; _premiumPaymentGateway = premiumPaymentGateway; }
public PaymentController(IPaymentEngine paymentEngine, IMapper mapper, ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentGateway premiumPaymentGateway) { _paymentEngine = paymentEngine ?? throw new ArgumentNullException(nameof(paymentEngine)); _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); _cheapPaymentGateway = cheapPaymentGateway ?? throw new ArgumentNullException(nameof(cheapPaymentGateway)); _expensePaymentGateway = expensivePaymentGateway ?? throw new ArgumentNullException(nameof(expensivePaymentGateway)); _premiumPaymentGateway = premiumPaymentGateway ?? throw new ArgumentNullException(nameof(premiumPaymentGateway)); }
public UnitOfWork(IPaymentDbContext iPaymentDbContext, IPaymentRepository iPaymentRepository, ICheapPaymentGateway cheapPaymentGateways, IExpensivePaymentGateway expensivePaymentGateways, IPremiumPaymentGateway premiumPaymentGateways) { _context = iPaymentDbContext; Payments = iPaymentRepository; CheapPaymentGateways = cheapPaymentGateways; ExpensivePaymentGateways = expensivePaymentGateways; PremiumPaymentGateways = premiumPaymentGateways; }
public PaymentGateway(ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentGateway premiumPaymentGateway, IPaymentRepository paymentRepo, IPaymentStateRepository paymentStateRepo, IMapper mapper) { _cheapPaymentGateway = cheapPaymentGateway; _expensivePaymentGateway = expensivePaymentGateway; _premiumPaymentGateway = premiumPaymentGateway; _paymentRepo = paymentRepo; _paymentStateRepo = paymentStateRepo; _mapper = mapper; }
public PaymentController(ILogger <PaymentController> logger, IServiceProvider provider, IMapper mapper) { _logger = logger; _mapper = mapper; _cheapPayment = provider.GetRequiredService <ICheapPaymentGateway>(); _expensivePayment = provider.GetRequiredService <IExpensivePaymentGateway>(); _premiumPayment = provider.GetRequiredService <IPremiumPaymentGateway>(); _transactionRepository = provider.GetRequiredService <ITransactionRepository>(); }
public void TestInitialize() { unityContainer = new UnityContainer(); premiumPaymentGateway = MockRepository.GenerateStub <IPremiumPaymentGateway>(); cheapPaymentGateway = MockRepository.GenerateStub <ICheapPaymentGateway>(); expensivePaymentGateway = MockRepository.GenerateStub <IExpensivePaymentGateway>(); controller = new CreditCardController(unityContainer, cheapPaymentGateway, expensivePaymentGateway, premiumPaymentGateway); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); }
public ProcessPayment(IPaymentService paymentService, IPaymentStatusService paymentStatusService, ILogWriter logWriter, IMapper mapper, ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentGateway premiumPaymentGateway, IConfiguration config) { _paymentService = paymentService; _paymentStatusService = paymentStatusService; _logWriter = logWriter; _mapper = mapper; _cheapPayment = cheapPaymentGateway; _expensivePayment = expensivePaymentGateway; _premium = premiumPaymentGateway; _config = config; }
public BankingSystem(ICheapPaymentGateway cheapGateway, IExpensivePaymentGateway expensiveGateway, IPremiumPaymentGateway premiumGateway ) { _cheapGateway = cheapGateway; _expensiveGateway = expensiveGateway; _premiumGateway = premiumGateway; _cheapGateway.SetNext(_expensiveGateway); _expensiveGateway.SetNext(_premiumGateway); }
public Handler( ICurrentUserService currentUserService, IDataContext dataContext, ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentGateway premiumPaymentGateway) { _currentUserService = currentUserService; _dataContext = dataContext; _cheapPaymentGateway = cheapPaymentGateway; _expensivePaymentGateway = expensivePaymentGateway; _premiumPaymentGateway = premiumPaymentGateway; }
public PaymentBusinessTest() { _logger = Substitute.For <ILoggerManager>(); _unitOfWork = Substitute.For <IUnitOfWork>(); _mapper = Substitute.For <IMapper>(); _cheapPaymentGateway = Substitute.For <ICheapPaymentGateway>(); _expensivePaymentGateway = Substitute.For <IExpensivePaymentGateway>(); _premiumPaymentGateway = Substitute.For <IPremiumPaymentGateway>(); _serviceAccessor = Substitute.For <Register.ServiceResolver>(); _serviceAccessor.Invoke(Constants.CHEAP).Returns(_cheapPaymentGateway); _serviceAccessor.Invoke(Constants.EXPENSIVE).Returns(_expensivePaymentGateway); _serviceAccessor.Invoke(Constants.PREMIUM).Returns(_premiumPaymentGateway); _mapper.Map <PaymentEntities.Entities.Payment>(Arg.Any <PaymentRequestModel>()).Returns(GetPayment()); _paymentBusiness = new PaymentBusiness.Payment.PaymentBusiness(_logger, _unitOfWork, _mapper, _serviceAccessor); }
public PaymentResponse ProcessPayment(Payment payment) { PaymentResponse response = null; IPaymentGateway gateway; if (payment.Amount < 20) { gateway = new ICheapPaymentGateway(); response = gateway.ProcessPayment(payment); } else if (payment.Amount > 20 && payment.Amount <= 500) { gateway = new IExpensivePaymentGateway(); response = gateway.ProcessPayment(payment); if (!response.Success) { gateway = new ICheapPaymentGateway(); response = gateway.ProcessPayment(payment); } } else { gateway = new IPremiumPaymentGateway(); var retries = 3; while (retries > 0) { response = gateway.ProcessPayment(payment); if (response.Success) { return(response); } retries--; } response.ErrorMessage += " Retried: 3 times."; } return(response); }
public PremiumPaymentGatewayCommand(double amount, IPremiumPaymentGateway premiumPaymentGateway) { _amount = amount; _gateway = premiumPaymentGateway; }
public PaymentProcessor() { _cheapPaymentGateWay = new CheapPaymentGateway(); _expensicePaymentGateWay = new ExpensicePaymentGateWay(); _premiumPaymentGateway = new PremiumPaymentGateway(); }
public Invoker(ICheapPaymentGateway cheapPaymentGateway, IExpensivePaymentGateway expensivePaymentGateway, IPremiumPaymentGateway premiumPaymentGateway) { _expensiveGateWay = expensivePaymentGateway; _cheapGateway = cheapPaymentGateway; _premiumGateway = premiumPaymentGateway; }
public PremiumPaymentGatewayProvider(IPremiumPaymentGateway premiumPaymentGateway) { _premiumPaymentGateway = premiumPaymentGateway; }