Пример #1
0
        public IPaymentGateWay GetPaymentGateWay(PaymentMethod paymentMethod, Product product)
        {
            switch (paymentMethod)
            {
            case PaymentMethod.AxisBank:
                paymentGateWay = new AxisBank();
                break;

            case PaymentMethod.HDFCBank:
                paymentGateWay = new HDFCBank();
                break;

            case PaymentMethod.BestOne:
                if (product.Price > 50)
                {
                    paymentGateWay = new AxisBank();
                }
                else
                {
                    paymentGateWay = new HDFCBank();
                }
                break;

            default:
                paymentGateWay = new AxisBank();
                break;
            }
            return(paymentGateWay);
        }
        /// <summary>
        /// Create instance of Gateway
        /// </summary>
        /// <param name="gatewayType">gateways type</param>
        /// <returns>IPaymentGateWay</returns>
        public IPaymentGateWay Create(Gateways gatewayType)
        {
            IPaymentGateWay result = null;

            switch (gatewayType)
            {
            case Gateways.ProtocolBase:
                result = new ProtocolBasePaymentGateway();
                break;

            case Gateways.Swift:
                result = new SwiftPaymentGateway();
                break;

            case Gateways.WellsFargo:
                result = new WellsFargoGateway();
                break;

            default:
                result = NullPaymentGateway.Empty;
                break;
            }

            return(result);
        }
        public static void Perform()
        {
            var             factory = new DefaultPaymentGatewayFactory();
            IPaymentGateWay gateway = factory.Create(Gateways.Swift);

            gateway.Invoke();
            gateway = factory.Create(Gateways.WellsFargo);
            gateway.Invoke();
            gateway = factory.Create(Gateways.ProtocolBase);
            gateway.Invoke();
            Console.WriteLine("");
        }
Пример #4
0
        public static void Perform()
        {
            var             container = CompositionRoot.Configure();
            var             factory   = container.Resolve <IPaymentGatewayFactory>();
            IPaymentGateWay gateway   = factory.Create(Gateways.Swift);

            gateway.Invoke();
            gateway = factory.Create(Gateways.WellsFargo);
            gateway.Invoke();
            gateway = factory.Create(Gateways.ProtocolBase);
            gateway.Invoke();
            Console.WriteLine("");
        }