예제 #1
0
        static void Main(string[] args)
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            Decimal amount          = 1000.00m;
            String  creditCardBrand = "visa";

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

                Installments result = InstallmentService.GetInstallments(credentials, amount, creditCardBrand);

                Console.WriteLine("Começando listagem de parcelas - \n");
                foreach (Installment installment in result.Get())
                {
                    Console.WriteLine(installment.ToString());
                }
                Console.WriteLine(" - Terminando listagem de parcelas ");

                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                Console.WriteLine(exception.Message + "\n");

                foreach (ServiceError element in exception.Errors)
                {
                    Console.WriteLine(element + "\n");
                }
                Console.ReadKey();
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter contract data");
            Console.Write("Number: ");
            int number = int.Parse(Console.ReadLine());

            Console.Write("Date (dd/MM/yyyy): ");
            DateTime date = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy", CultureInfo.InvariantCulture);

            Console.Write("Contract value: ");
            double value = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            Console.Write("Enter number of installments: ");
            int months = int.Parse(Console.ReadLine());

            Contract contract = new Contract(number, date, value);

            InstallmentService installmentService = new InstallmentService(new PaypalServiceTax());

            installmentService.ProcessContract(contract, months);

            Console.WriteLine("Installments: ");

            foreach (Installment x in contract.Installments)
            {
                Console.WriteLine(x);
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            Decimal amount                   = 1000.00m;
            String  creditCardBrand          = "visa";
            Int32   maxInstallmentNoInterest = 5;

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox);

                Installments result = InstallmentService.GetInstallments(credentials, amount, creditCardBrand, maxInstallmentNoInterest);


                foreach (Installment installment in result.Get())
                {
                }
            }
            catch (PagSeguroServiceException exception)
            {
                foreach (ServiceError element in exception.Errors)
                {
                }
            }
        }
예제 #4
0
        public Installments GetInstallmentsPagSeguro(Decimal amount, string creditCardBrand, int maxInstallmentNoInterest)
        {
            PagSeguroConfiguration.UrlXmlConfiguration = this.configuration;

            bool isSandbox = true;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

                Installments result = InstallmentService.GetInstallments(credentials, amount, creditCardBrand, maxInstallmentNoInterest);

                return(result);
            }
            catch (PagSeguroServiceException exception)
            {
                return(new Installments());
                //foreach (ServiceError element in exception.Errors)
                //{

                //}
            }
            catch (Exception ex)
            {
                return(new Installments());
            }
        }
예제 #5
0
        public async Task Get_Installment()
        {
            //Arrange
            decimal  purchasePrice = 100;
            DateTime purchaseDate  = System.DateTime.Now;

            _planRepositoryMock.Setup(pr => pr.GetPlansByPriceAsync(It.IsAny <decimal>())).ReturnsAsync(GetPlans());

            //Act
            var installmentService = new InstallmentService(_planRepositoryMock.Object);
            var result             = await installmentService.GetInstallmentsAsync(purchasePrice, purchaseDate);

            //Assert
            _planRepositoryMock.Verify(pr => pr.GetPlansByPriceAsync(It.IsAny <decimal>()), Times.Once);
            Assert.Equal(2, result.Count);
        }
예제 #6
0
        public void CalculateInstalment()
        {
            double baseValue = 0.0;

            baseValue = Value / Quantity;

            for (int i = 1; i <= Quantity; i++)
            {
                InstallmentService installmentService = new InstallmentService(Date, baseValue, i);
                DateTime           dateDue            = installmentService.CalculateDue();
                double             amountInstallment  = installmentService.CalculateAmount();

                Installment parcel = new Installment(dateDue, amountInstallment);

                AddInstallment(parcel);
            }
        }
        public void GetInstallmentPlan_ReturnCorrectInstallments(decimal purchasePrice, DateTime purchaseDate,
                                                                 List <InstallmentsDto> expectedInstallments)
        {
            // arrange
            var installmentPlans = new List <IInstallmentPlan>
            {
                new LessThan100InstallmentPlan(),
                new LessThan1000InstallmentPlan(),
                new LessThan10000InstallmentPlan(),
                new LargerThan10000InstallmentPlan()
            };
            var installmentService = new InstallmentService(installmentPlans);

            // act
            var actualInstallments = installmentService.GetInstallmentPlan(purchasePrice, purchaseDate);

            // assert
            actualInstallments.Should().BeEquivalentTo(expectedInstallments);
        }
예제 #8
0
 public InstallmentsController(InstallmentService installmentService)
 {
     _installmentService = installmentService;
 }