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(); } }
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); } }
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) { } } }
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()); } }
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); }
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); }
public InstallmentsController(InstallmentService installmentService) { _installmentService = installmentService; }