Example #1
0
        public bool ProcessPayment(IPayer payer, IReceiver receiver, double value)
        {
            if (!payer.CanPay(value))
            {
                return(false);
            }

            payer.Pay(value);

            receiver.ReceiveMoney(value);

            return(true);
        }
Example #2
0
        public bool ProcessPayment(IPayer payer, IReceiver receiver, double value)
        {
            if (!payer.CanPay(value))
            {
                return(false);
            }

            payer.Pay(value);

            var operationTax = value * 0.001;

            receiver.ReceiveMoney(operationTax);

            var cashBack = value <= 100 ? value * 0.010 : 10;

            payer.CashBack(cashBack);

            return(true);
        }
Example #3
0
        public bool ProcessPayment(IPayer payer, IReceiver receiver, double value)
        {
            var interest = value * 0.021;

            var totalValueToPay = value + interest;

            if (payer.CanPay(totalValueToPay))
            {
                payer.Pay(totalValueToPay);

                receiver.ReceiveMoney(value);

                var operationTax = interest / 4;

                receiver.PayOperationTax(operationTax);

                return(true);
            }

            return(false);
        }