Skip to content

Commit

Permalink
Added CardInfo to 4 entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Silviana Ghita committed Dec 20, 2023
1 parent 67ec4da commit 6a5d28b
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 0 deletions.
35 changes: 35 additions & 0 deletions MangoPay.SDK.Tests/ApiCardPreAuthorizationsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 19 additions & 0 deletions MangoPay.SDK.Tests/ApiDepositsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
170 changes: 170 additions & 0 deletions MangoPay.SDK.Tests/ApiPayInsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);
}
}
}
}
24 changes: 24 additions & 0 deletions MangoPay.SDK/Entities/CardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace MangoPay.SDK.Entities
{
/// <summary>Class represents informations about the cards</summary>
public class CardInfo
{
/// <summary>The 6-digit bank identification number (BIN) of the card issuer.</summary>
public string BIN;

/// <summary>The name of the card issuer.</summary>
public string IssuingBank;

/// <summary>The country where the card was issued.</summary>
public string IssuerCountryCode;

/// <summary>The type of card product: DEBIT, CREDIT, CHARGE CARD.</summary>
public string Type;

/// <summary>The card brand. Examples include: AMERICAN EXPRESS, DISCOVER, JCB, MASTERCARD, VISA, etc.</summary>
public string Brand;

/// <summary>The subtype of the card product. Examples include: CLASSIC, GOLD, PLATINUM, PREPAID, etc.</summary>
public string SubType;
}
}
2 changes: 2 additions & 0 deletions MangoPay.SDK/Entities/GET/CardPreAuthorizationDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,7 @@ public class CardPreAuthorizationDTO : EntityBase
public string Requested3DSVersion { get; set; }

public string Applied3DSVersion { get; set; }

public CardInfo CardInfo { get; set; }
}
}
2 changes: 2 additions & 0 deletions MangoPay.SDK/Entities/GET/DepositDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@ public class DepositDTO : EntityBase
public string Requested3DSVersion { get; set; }

public string Applied3DSVersion { get; set; }

public CardInfo CardInfo { get; set; }
}
}
2 changes: 2 additions & 0 deletions MangoPay.SDK/Entities/GET/PayInCardDirectDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ public class PayInCardDirectDTO : PayInDTO
/// → Is mandatory when the flag “Use 3DSV2 Scenario” is active for (FORCE/DEFAULT/FRICTIONLESS both 3)
/// </summary>
public string IpAddress { get; set; }

public CardInfo CardInfo { get; set; }
}
}
2 changes: 2 additions & 0 deletions MangoPay.SDK/Entities/GET/RecurringPayInDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ public class RecurringPayInDTO : PayInDTO
public string Applied3DSVersion { get; set; }

public string RecurringPayinRegistrationId { get; set; }

public CardInfo CardInfo { get; set; }
}
}

0 comments on commit 6a5d28b

Please sign in to comment.