From 8c21cfdae6f86cfd3bd8394bb1ece90469a0b1cf Mon Sep 17 00:00:00 2001 From: "thiago.moises" Date: Mon, 24 Jun 2019 17:21:01 -0300 Subject: [PATCH] Payment authorization suport --- .../JsonMaps/PaymentRequestMap.cs | 4 +++- .../MercadoPago.NetCore.csproj | 2 +- .../CardsHubClientTests.cs | 22 ++++++++----------- .../MercadoPago.NetCore.Tests.csproj | 6 ++--- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/MercadoPago.NetCore/JsonMaps/PaymentRequestMap.cs b/src/MercadoPago.NetCore/JsonMaps/PaymentRequestMap.cs index 9b12b5e..725e5ef 100644 --- a/src/MercadoPago.NetCore/JsonMaps/PaymentRequestMap.cs +++ b/src/MercadoPago.NetCore/JsonMaps/PaymentRequestMap.cs @@ -25,7 +25,9 @@ public void Configure(JsonTypeBuilder jsonTypeBuilder) jsonTypeBuilder.Property(x => x.TransactionAmount).HasFieldName("transaction_amount"); jsonTypeBuilder.Property(x => x.CouponAmount).HasFieldName("coupon_amount"); jsonTypeBuilder.Property(x => x.DifferentialPricingId).HasFieldName("differential_pricing_id"); - jsonTypeBuilder.Property(x => x.Capture).HasFieldName("capture"); + jsonTypeBuilder.Property(x => x.Capture) + .HasFieldName("capture") + .AddDefaultValueHandling(Newtonsoft.Json.DefaultValueHandling.Include); jsonTypeBuilder.Property(x => x.BinaryMode).HasFieldName("binary_mode"); jsonTypeBuilder.Property(x => x.StatementDescriptor).HasFieldName("statement_descriptor"); jsonTypeBuilder.Property(x => x.NotificationUrl).HasFieldName("notification_url"); diff --git a/src/MercadoPago.NetCore/MercadoPago.NetCore.csproj b/src/MercadoPago.NetCore/MercadoPago.NetCore.csproj index 2820f23..8e42514 100644 --- a/src/MercadoPago.NetCore/MercadoPago.NetCore.csproj +++ b/src/MercadoPago.NetCore/MercadoPago.NetCore.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/MercadoPago.NetCore.Tests/CardsHubClientTests.cs b/test/MercadoPago.NetCore.Tests/CardsHubClientTests.cs index 8878366..705d948 100644 --- a/test/MercadoPago.NetCore.Tests/CardsHubClientTests.cs +++ b/test/MercadoPago.NetCore.Tests/CardsHubClientTests.cs @@ -1,4 +1,5 @@ -using MercadoPago.NetCore.Model.Resources.Dataclassures.Auth; +using MercadoPago.NetCore.Model.Resources; +using MercadoPago.NetCore.Model.Resources.Dataclassures.Auth; using Moises.Toolkit.MercadoPago.NetCore.HubClients; using Moises.Toolkit.MercadoPago.NetCore.HubClients.Abstracts; using Moises.Toolkit.MercadoPago.NetCore.Tests.Helpers; @@ -28,7 +29,7 @@ public void Setup() var customerHub = new CustomerHubClientTests(); customerHub.Setup(); - if (customerHub.CustomerHubClient.SearchAsync(null).TryExecute(out var customers)) + if (customerHub.CustomerHubClient.SearchAsync(null).TryExecute(out var customers, 10000)) CustomerId = customers.Results.Select(x => x.Id).FirstOrDefault(); tokenHubClient.Setup(x => x.GetTicketAsync()) @@ -45,20 +46,15 @@ public void Cleanup() [Test] public async Task SaveAsync_Test() { - var Card = new Card() + Card card = new Card() { - CustomerId = CustomerId, - ExpirationMonth = 9, - ExpirationYear = 2022, - FirstSixDigits = "123456", - LastFourDigits = "7890", - SecurityCode = new SecurityCode() { CardLocation = "back", Length = 3 }, - CardHolder = new CardHolder { Name = "Thiago Moises" }, - DateCreated = DateTime.Now + Token = "9b2d63e00d66a8c721607214cedaecda", + CustomerId = this.CustomerId }; - var result = await _CardHubClient.SaveAsync(Card); - bool firstCondition = (!string.IsNullOrEmpty(result?.Id) && Card.FirstSixDigits.Equals(result?.FirstSixDigits) && _CardHubClient.IsValid()); + var result = await _CardHubClient.SaveAsync(card); + + bool firstCondition = (!string.IsNullOrEmpty(result?.Id) && card.FirstSixDigits.Equals(result?.FirstSixDigits) && _CardHubClient.IsValid()); bool secondCondition = _CardHubClient.Notifications.Any(x => x.Message.Equals("the card already exist")); Assert.IsTrue(firstCondition || secondCondition); diff --git a/test/MercadoPago.NetCore.Tests/MercadoPago.NetCore.Tests.csproj b/test/MercadoPago.NetCore.Tests/MercadoPago.NetCore.Tests.csproj index 4ca9a5a..90d3b22 100644 --- a/test/MercadoPago.NetCore.Tests/MercadoPago.NetCore.Tests.csproj +++ b/test/MercadoPago.NetCore.Tests/MercadoPago.NetCore.Tests.csproj @@ -8,9 +8,9 @@ - - - + + +