From 6a5d28b55b769b7e85827870a1c9a70cd5214a24 Mon Sep 17 00:00:00 2001 From: Silviana Ghita <> Date: Wed, 20 Dec 2023 13:11:29 +0200 Subject: [PATCH] Added CardInfo to 4 entities --- .../ApiCardPreAuthorizationsTest.cs | 35 ++++ MangoPay.SDK.Tests/ApiDepositsTest.cs | 19 ++ MangoPay.SDK.Tests/ApiPayInsTest.cs | 170 ++++++++++++++++++ MangoPay.SDK/Entities/CardInfo.cs | 24 +++ .../Entities/GET/CardPreAuthorizationDTO.cs | 2 + MangoPay.SDK/Entities/GET/DepositDTO.cs | 2 + .../Entities/GET/PayInCardDirectDTO.cs | 2 + .../Entities/GET/RecurringPayInDTO.cs | 2 + 8 files changed, 256 insertions(+) create mode 100644 MangoPay.SDK/Entities/CardInfo.cs diff --git a/MangoPay.SDK.Tests/ApiCardPreAuthorizationsTest.cs b/MangoPay.SDK.Tests/ApiCardPreAuthorizationsTest.cs index bb674b0..52a8a7f 100644 --- a/MangoPay.SDK.Tests/ApiCardPreAuthorizationsTest.cs +++ b/MangoPay.SDK.Tests/ApiCardPreAuthorizationsTest.cs @@ -69,6 +69,41 @@ public async Task Test_CardPreAuthorization_Create_WithBilling() Assert.Fail(ex.Message); } } + + [Test] + public async Task Test_CardPreAuthorization_Create_WithBilling_CheckCardInfo() + { + try + { + var john = await GetJohn(); + var cardPreAuthorization = await GetPreAuthorization(john.Id); + var billing = new Billing(); + var address = new Address + { + City = "Test city", + AddressLine1 = "Test address line 1", + AddressLine2 = "Test address line 2", + Country = CountryIso.RO, + PostalCode = "65400" + }; + billing.Address = address; + billing.FirstName = "Joe"; + billing.LastName = "Doe"; + cardPreAuthorization.Billing = billing; + + var cardPreAuthorizationWithBilling = await this.Api.CardPreAuthorizations.CreateAsync(cardPreAuthorization); + + Assert.IsNotNull(cardPreAuthorizationWithBilling.CardInfo); + Assert.IsNotNull(cardPreAuthorizationWithBilling.CardInfo.IssuingBank); + Assert.IsNotNull(cardPreAuthorizationWithBilling.CardInfo.Brand); + Assert.IsNotNull(cardPreAuthorizationWithBilling.CardInfo.Type); + Assert.IsNotNull(cardPreAuthorizationWithBilling.CardInfo.IssuerCountryCode); + } + catch (Exception ex) + { + Assert.Fail(ex.Message); + } + } [Test] public async Task Test_CardPreAuthorization_Create_WithRequested3DS() diff --git a/MangoPay.SDK.Tests/ApiDepositsTest.cs b/MangoPay.SDK.Tests/ApiDepositsTest.cs index 3c0e616..fe5ce21 100644 --- a/MangoPay.SDK.Tests/ApiDepositsTest.cs +++ b/MangoPay.SDK.Tests/ApiDepositsTest.cs @@ -24,6 +24,25 @@ public async Task Test_CreateDeposit() Assert.Fail(ex.Message); } } + + [Test] + public async Task Test_CreateDeposit_CheckCardInfo() + { + try + { + DepositDTO deposit = await this.CreateNewDeposit(); + + Assert.IsNotNull(deposit.CardInfo); + Assert.IsNotNull(deposit.CardInfo.IssuingBank); + Assert.IsNotNull(deposit.CardInfo.Brand); + Assert.IsNotNull(deposit.CardInfo.Type); + Assert.IsNotNull(deposit.CardInfo.IssuerCountryCode); + } + catch (Exception ex) + { + Assert.Fail(ex.Message); + } + } [Test] public async Task Test_GetDeposit() diff --git a/MangoPay.SDK.Tests/ApiPayInsTest.cs b/MangoPay.SDK.Tests/ApiPayInsTest.cs index 8d0d8cc..69f91dd 100644 --- a/MangoPay.SDK.Tests/ApiPayInsTest.cs +++ b/MangoPay.SDK.Tests/ApiPayInsTest.cs @@ -250,6 +250,25 @@ public async Task Test_PayIns_Create_CardDirect() } } + [Test] + public async Task Test_PayIns_Create_CardDirect_CheckCardInfo() + { + try + { + var payIn = await this.GetNewPayInCardDirect(); + + Assert.IsNotNull(payIn.CardInfo); + Assert.IsNotNull(payIn.CardInfo.IssuingBank); + Assert.IsNotNull(payIn.CardInfo.Brand); + Assert.IsNotNull(payIn.CardInfo.Type); + Assert.IsNotNull(payIn.CardInfo.IssuerCountryCode); + } + catch (Exception ex) + { + Assert.Fail(ex.Message); + } + } + [Test] public async Task Test_PayIns_Create_MbwayWeb() { @@ -1753,5 +1772,156 @@ public async Task Test_CreateCardPreAuthorizedDepositPayIn() Assert.Fail(ex.Message); } }*/ + + + [Test] + public async Task Test_PayIns_Create_Recurring_MIT_CheckCardInfo() + { + try + { + var data = await GetNewJohnsWalletWithMoneyAndCardId(1000); + var cardId = data.Item1; + var wallet = data.Item2; + var userId = wallet.Owners.FirstOrDefault(); + + var payInPost = new RecurringPayInRegistrationPostDTO + { + AuthorId = userId, + CardId = cardId, + CreditedUserId = userId, + CreditedWalletId = wallet.Id, + FirstTransactionDebitedFunds = new Money + { + Amount = 12, + Currency = CurrencyIso.EUR + }, + FirstTransactionFees = new Money + { + Amount = 1, + Currency = CurrencyIso.EUR + }, + Billing = new Billing + { + FirstName = "Joe", + LastName = "Blogs", + Address = new Address + { + AddressLine1 = "1 MangoPay Street", + AddressLine2 = "The Loop", + City = "Paris", + Region = "Ile de France", + PostalCode = "75001", + Country = CountryIso.FR + } + }, + Shipping = new Shipping + { + FirstName = "Joe", + LastName = "Blogs", + Address = new Address + { + AddressLine1 = "1 MangoPay Street", + AddressLine2 = "The Loop", + City = "Paris", + Region = "Ile de France", + PostalCode = "75001", + Country = CountryIso.FR + } + }, + EndDate = DateTime.Now.AddDays(365), + Migration = true, + NextTransactionDebitedFunds = new Money + { + Amount = 12, + Currency = CurrencyIso.EUR + }, + NextTransactionFees = new Money + { + Amount = 1, + Currency = CurrencyIso.EUR + }, + Frequency = "Daily", + FixedNextAmount = true, + FractionedPayment = false + }; + + var createdPayInRegistration = await this.Api.PayIns.CreateRecurringPayInRegistration(payInPost); + + Assert.NotNull(createdPayInRegistration); + Assert.IsTrue(userId == createdPayInRegistration.CreditedUserId); + Assert.IsTrue(cardId == createdPayInRegistration.CardId); + Assert.IsTrue(wallet.Id == createdPayInRegistration.CreditedWalletId); + Assert.NotNull(createdPayInRegistration.Shipping); + Assert.NotNull(createdPayInRegistration.Billing); + + var cit = new RecurringPayInCITPostDTO + { + RecurringPayinRegistrationId = createdPayInRegistration.Id, + BrowserInfo = new BrowserInfo + { + AcceptHeader = "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8", + JavaEnabled = true, + Language = "FR-FR", + ColorDepth = 4, + ScreenHeight = 1800, + ScreenWidth = 400, + JavascriptEnabled = true, + TimeZoneOffset = "+60", + UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" + }, + IpAddress = "2001:0620:0000:0000:0211:24FF:FE80:C12C", + SecureModeReturnURL = "http://www.my-site.com/returnURL", + StatementDescriptor = "lorem", + Tag = "custom meta", + DebitedFunds = new Money + { + Amount = 12, + Currency = CurrencyIso.EUR + }, + Fees = new Money + { + Amount = 1, + Currency = CurrencyIso.EUR + } + }; + + var createdCit = await this.Api.PayIns.CreateRecurringPayInRegistrationCIT(cit); + + Assert.IsNotNull(createdCit.CardInfo); + Assert.IsNotNull(createdCit.CardInfo.IssuingBank); + Assert.IsNotNull(createdCit.CardInfo.Brand); + Assert.IsNotNull(createdCit.CardInfo.Type); + Assert.IsNotNull(createdCit.CardInfo.IssuerCountryCode); + + var mit = new RecurringPayInMITPostDTO + { + RecurringPayinRegistrationId = createdPayInRegistration.Id, + StatementDescriptor = "lorem", + Tag = "custom meta", + DebitedFunds = new Money + { + Amount = 10, + Currency = CurrencyIso.EUR + }, + Fees = new Money + { + Amount = 1, + Currency = CurrencyIso.EUR + } + }; + + var createdMit = await this.Api.PayIns.CreateRecurringPayInRegistrationMIT(mit); + + Assert.IsNotNull(createdMit.CardInfo); + Assert.IsNotNull(createdMit.CardInfo.IssuingBank); + Assert.IsNotNull(createdMit.CardInfo.Brand); + Assert.IsNotNull(createdMit.CardInfo.Type); + Assert.IsNotNull(createdMit.CardInfo.IssuerCountryCode); + } + catch (Exception ex) + { + Assert.Fail(ex.Message); + } + } } } \ No newline at end of file diff --git a/MangoPay.SDK/Entities/CardInfo.cs b/MangoPay.SDK/Entities/CardInfo.cs new file mode 100644 index 0000000..5ab6e4a --- /dev/null +++ b/MangoPay.SDK/Entities/CardInfo.cs @@ -0,0 +1,24 @@ +namespace MangoPay.SDK.Entities +{ + /// Class represents informations about the cards + public class CardInfo + { + /// The 6-digit bank identification number (BIN) of the card issuer. + public string BIN; + + /// The name of the card issuer. + public string IssuingBank; + + /// The country where the card was issued. + public string IssuerCountryCode; + + /// The type of card product: DEBIT, CREDIT, CHARGE CARD. + public string Type; + + /// The card brand. Examples include: AMERICAN EXPRESS, DISCOVER, JCB, MASTERCARD, VISA, etc. + public string Brand; + + /// The subtype of the card product. Examples include: CLASSIC, GOLD, PLATINUM, PREPAID, etc. + public string SubType; + } +} \ No newline at end of file diff --git a/MangoPay.SDK/Entities/GET/CardPreAuthorizationDTO.cs b/MangoPay.SDK/Entities/GET/CardPreAuthorizationDTO.cs index 39d9b3e..75116c8 100644 --- a/MangoPay.SDK/Entities/GET/CardPreAuthorizationDTO.cs +++ b/MangoPay.SDK/Entities/GET/CardPreAuthorizationDTO.cs @@ -85,5 +85,7 @@ public class CardPreAuthorizationDTO : EntityBase public string Requested3DSVersion { get; set; } public string Applied3DSVersion { get; set; } + + public CardInfo CardInfo { get; set; } } } diff --git a/MangoPay.SDK/Entities/GET/DepositDTO.cs b/MangoPay.SDK/Entities/GET/DepositDTO.cs index 5777e2f..bbebcf5 100644 --- a/MangoPay.SDK/Entities/GET/DepositDTO.cs +++ b/MangoPay.SDK/Entities/GET/DepositDTO.cs @@ -77,5 +77,7 @@ public class DepositDTO : EntityBase public string Requested3DSVersion { get; set; } public string Applied3DSVersion { get; set; } + + public CardInfo CardInfo { get; set; } } } \ No newline at end of file diff --git a/MangoPay.SDK/Entities/GET/PayInCardDirectDTO.cs b/MangoPay.SDK/Entities/GET/PayInCardDirectDTO.cs index 860c0cd..1576c5d 100644 --- a/MangoPay.SDK/Entities/GET/PayInCardDirectDTO.cs +++ b/MangoPay.SDK/Entities/GET/PayInCardDirectDTO.cs @@ -38,5 +38,7 @@ public class PayInCardDirectDTO : PayInDTO /// → Is mandatory when the flag “Use 3DSV2 Scenario” is active for (FORCE/DEFAULT/FRICTIONLESS both 3) /// public string IpAddress { get; set; } + + public CardInfo CardInfo { get; set; } } } diff --git a/MangoPay.SDK/Entities/GET/RecurringPayInDTO.cs b/MangoPay.SDK/Entities/GET/RecurringPayInDTO.cs index 1e65111..fc5a23d 100644 --- a/MangoPay.SDK/Entities/GET/RecurringPayInDTO.cs +++ b/MangoPay.SDK/Entities/GET/RecurringPayInDTO.cs @@ -40,5 +40,7 @@ public class RecurringPayInDTO : PayInDTO public string Applied3DSVersion { get; set; } public string RecurringPayinRegistrationId { get; set; } + + public CardInfo CardInfo { get; set; } } }