Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature / Added CardInfo to 4 entities #208

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -65,9 +65,9 @@
var wallet = await this.GetJohnsWallet();
var user = await this.GetJohn();

var payInPost = new PayInPayPalPostDTO(user.Id, new Money { Amount = 1000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, "http://test/test");

Check warning on line 68 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'PayInPayPalPostDTO' is obsolete: 'PayInPayPalPostDTO is deprecated, please use PayInPayPalWebPostDTO instead.'

Check warning on line 68 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'PayInPayPalPostDTO' is obsolete: 'PayInPayPalPostDTO is deprecated, please use PayInPayPalWebPostDTO instead.'

var payIn = await this.Api.PayIns.CreatePayPalAsync(payInPost);

Check warning on line 70 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.CreatePayPalAsync(PayInPayPalPostDTO, string)' is obsolete: 'CreatePayPalAsync is deprecated, please use CreatePayPalWebAsync instead.'

Check warning on line 70 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.CreatePayPalAsync(PayInPayPalPostDTO, string)' is obsolete: 'CreatePayPalAsync is deprecated, please use CreatePayPalWebAsync instead.'

Assert.IsTrue(payIn.Id.Length > 0);
Assert.IsTrue(payIn.PaymentType == PayInPaymentType.PAYPAL);
Expand Down Expand Up @@ -197,12 +197,12 @@
PostalCode = "11222",
Region = "Region"
};
var payInPost = new PayInPayPalPostDTO(user.Id, new Money { Amount = 1000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, "http://test/test")

Check warning on line 200 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'PayInPayPalPostDTO' is obsolete: 'PayInPayPalPostDTO is deprecated, please use PayInPayPalWebPostDTO instead.'

Check warning on line 200 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'PayInPayPalPostDTO' is obsolete: 'PayInPayPalPostDTO is deprecated, please use PayInPayPalWebPostDTO instead.'
{
ShippingAddress = new ShippingAddress("recipient name", AddressForShippingAddress)
};

var payIn = await this.Api.PayIns.CreatePayPalAsync(payInPost);

Check warning on line 205 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.CreatePayPalAsync(PayInPayPalPostDTO, string)' is obsolete: 'CreatePayPalAsync is deprecated, please use CreatePayPalWebAsync instead.'

Check warning on line 205 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.CreatePayPalAsync(PayInPayPalPostDTO, string)' is obsolete: 'CreatePayPalAsync is deprecated, please use CreatePayPalWebAsync instead.'

Assert.IsNotNull(payIn.ShippingAddress);
Assert.AreEqual("recipient name", payIn.ShippingAddress.RecipientName);
Expand Down Expand Up @@ -250,6 +250,25 @@
}
}

[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 @@ -902,15 +921,15 @@
var wallet = await this.GetJohnsWallet();
var user = await this.GetJohn();

var payInPost = new PayInPayPalPostDTO(user.Id, new Money { Amount = 1000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, "http://test/test");

Check warning on line 924 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'PayInPayPalPostDTO' is obsolete: 'PayInPayPalPostDTO is deprecated, please use PayInPayPalWebPostDTO instead.'

Check warning on line 924 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'PayInPayPalPostDTO' is obsolete: 'PayInPayPalPostDTO is deprecated, please use PayInPayPalWebPostDTO instead.'

payIn = await this.Api.PayIns.CreatePayPalAsync(payInPost);

Check warning on line 926 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.CreatePayPalAsync(PayInPayPalPostDTO, string)' is obsolete: 'CreatePayPalAsync is deprecated, please use CreatePayPalWebAsync instead.'

Check warning on line 926 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.CreatePayPalAsync(PayInPayPalPostDTO, string)' is obsolete: 'CreatePayPalAsync is deprecated, please use CreatePayPalWebAsync instead.'

Assert.IsTrue(payIn.Id.Length > 0);
Assert.IsTrue(payIn.PaymentType == PayInPaymentType.PAYPAL);
Assert.IsTrue(payIn.ExecutionType == PayInExecutionType.WEB);

var getPayIn = await this.Api.PayIns.GetPayPalAsync(payIn.Id);

Check warning on line 932 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.GetPayPalAsync(string)' is obsolete: 'GetPayPalAsync is deprecated, please use GetPayPalWebAsync instead.'

Check warning on line 932 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.GetPayPalAsync(string)' is obsolete: 'GetPayPalAsync is deprecated, please use GetPayPalWebAsync instead.'

Assert.IsNotNull(getPayIn);
Assert.IsTrue(getPayIn.Id == payIn.Id);
Expand Down Expand Up @@ -939,14 +958,14 @@
Region = "Region"
};

var payInPost = new PayInPayPalPostDTO(user.Id, new Money { Amount = 1000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, "http://test/test")

Check warning on line 961 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'PayInPayPalPostDTO' is obsolete: 'PayInPayPalPostDTO is deprecated, please use PayInPayPalWebPostDTO instead.'

Check warning on line 961 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'PayInPayPalPostDTO' is obsolete: 'PayInPayPalPostDTO is deprecated, please use PayInPayPalWebPostDTO instead.'
{
ShippingAddress = new ShippingAddress("recipient name", addressForShippingAddress)
};

payIn = await this.Api.PayIns.CreatePayPalAsync(payInPost);

Check warning on line 966 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.CreatePayPalAsync(PayInPayPalPostDTO, string)' is obsolete: 'CreatePayPalAsync is deprecated, please use CreatePayPalWebAsync instead.'

Check warning on line 966 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.CreatePayPalAsync(PayInPayPalPostDTO, string)' is obsolete: 'CreatePayPalAsync is deprecated, please use CreatePayPalWebAsync instead.'

var getPayIn = await this.Api.PayIns.GetPayPalAsync(payIn.Id);

Check warning on line 968 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.GetPayPalAsync(string)' is obsolete: 'GetPayPalAsync is deprecated, please use GetPayPalWebAsync instead.'

Check warning on line 968 in MangoPay.SDK.Tests/ApiPayInsTest.cs

View workflow job for this annotation

GitHub Actions / dotnet 6.0.x

'ApiPayIns.GetPayPalAsync(string)' is obsolete: 'GetPayPalAsync is deprecated, please use GetPayPalWebAsync instead.'

Assert.IsNotNull(getPayIn.ShippingAddress);
Assert.AreEqual("recipient name", getPayIn.ShippingAddress.RecipientName);
Expand Down Expand Up @@ -1753,5 +1772,156 @@
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);
}
}
}
}
9 changes: 9 additions & 0 deletions MangoPay.SDK/Core/Enumerations/CardInfoType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MangoPay.SDK.Core.Enumerations
{
public enum CardInfoType
{
DEBIT,
CREDIT,
CHARGE_CARD
}
}
26 changes: 26 additions & 0 deletions MangoPay.SDK/Entities/CardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using MangoPay.SDK.Core.Enumerations;

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 CountryIso IssuerCountryCode;

/// <summary>The type of card product: DEBIT, CREDIT, CHARGE CARD.</summary>
public CardInfoType 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; }
}
}
Loading