Skip to content

Commit

Permalink
Merge pull request #199 from Mangopay/feature/ideal-and-giropay-mops
Browse files Browse the repository at this point in the history
Feature/ Ideal and Giropay mops
  • Loading branch information
iulian03 authored Nov 2, 2023
2 parents 78f4005 + f50d1d9 commit bf7bfe5
Show file tree
Hide file tree
Showing 10 changed files with 260 additions and 0 deletions.
58 changes: 58 additions & 0 deletions MangoPay.SDK.Tests/ApiPayInsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,64 @@ public async Task Test_PayIns_Create_KlarnaWeb()
Assert.Fail(ex.Message);
}
}

[Test]
public async Task Test_PayIns_Create_IdealWeb()
{
try
{
var user = await GetJohn();
var payIn = await GetNewPayInIdealWeb();
var fetched = await Api.PayIns.GetIdealAsync(payIn.Id);

Assert.IsTrue(payIn.Id.Length > 0);
Assert.AreEqual(PayInPaymentType.IDEAL, payIn.PaymentType);
Assert.AreEqual(PayInExecutionType.WEB, payIn.ExecutionType);
Assert.IsTrue(payIn.DebitedFunds is Money);
Assert.IsTrue(payIn.CreditedFunds is Money);
Assert.IsTrue(payIn.Fees is Money);
Assert.AreEqual(user.Id, payIn.AuthorId);
Assert.AreEqual(TransactionStatus.CREATED, payIn.Status);
Assert.AreEqual(TransactionType.PAYIN, payIn.Type);
Assert.AreEqual(TransactionNature.REGULAR, payIn.Nature);

Assert.AreEqual(payIn.Id, fetched.Id);
Assert.IsNotNull(fetched.Id);
}
catch (Exception ex)
{
Assert.Fail(ex.Message);
}
}

[Test]
public async Task Test_PayIns_Create_GiropayWeb()
{
try
{
var user = await GetJohn();
var payIn = await GetNewPayInGiropayWeb();
var fetched = await Api.PayIns.GetGiropayAsync(payIn.Id);

Assert.IsTrue(payIn.Id.Length > 0);
Assert.AreEqual(PayInPaymentType.GIROPAY, payIn.PaymentType);
Assert.AreEqual(PayInExecutionType.WEB, payIn.ExecutionType);
Assert.IsTrue(payIn.DebitedFunds is Money);
Assert.IsTrue(payIn.CreditedFunds is Money);
Assert.IsTrue(payIn.Fees is Money);
Assert.AreEqual(user.Id, payIn.AuthorId);
Assert.AreEqual(TransactionStatus.CREATED, payIn.Status);
Assert.AreEqual(TransactionType.PAYIN, payIn.Type);
Assert.AreEqual(TransactionNature.REGULAR, payIn.Nature);

Assert.AreEqual(payIn.Id, fetched.Id);
Assert.IsNotNull(fetched.Id);
}
catch (Exception ex)
{
Assert.Fail(ex.Message);
}
}

[Test]
public async Task Test_Payins_CardDirect_Create_WithBilling()
Expand Down
51 changes: 51 additions & 0 deletions MangoPay.SDK.Tests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,18 @@ protected async Task<PayInKlarnaWebDTO> GetNewPayInKlarnaWeb()
PayInKlarnaWebPostDTO payIn = await GetPayInKlarnaWebPost();
return await this.Api.PayIns.CreateKlarnaWebAsync(payIn);
}

protected async Task<PayInIdealWebDTO> GetNewPayInIdealWeb()
{
PayInIdealWebPostDTO payIn = await GetPayInIdealWebPost();
return await this.Api.PayIns.CreateIdealWebAsync(payIn);
}

protected async Task<PayInGiropayWebDTO> GetNewPayInGiropayWeb()
{
PayInGiropayWebPostDTO payIn = await GetPayInGiropayWebPost();
return await this.Api.PayIns.CreateGiropayWebAsync(payIn);
}

/// <summary>Creates PayIn Card Direct object.</summary>
/// <param name="userId">User identifier.</param>
Expand Down Expand Up @@ -710,6 +722,45 @@ protected async Task<PayInKlarnaWebPostDTO> GetPayInKlarnaWebPost()

return payIn;
}


protected async Task<PayInIdealWebPostDTO> GetPayInIdealWebPost()
{
var wallet = await GetJohnsWalletWithMoney();
var user = await GetJohn();

var payIn = new PayInIdealWebPostDTO(
user.Id,
new Money { Amount = 100, Currency = CurrencyIso.EUR },
new Money { Amount = 20, Currency = CurrencyIso.EUR },
wallet.Id,
"http://www.my-site.com/returnURL?transactionId=wt_71a08458-b0cc-468d-98f7-1302591fc238",
"RBRBNL21",
"Ideal tag",
"Ideal test"
);

return payIn;
}

protected async Task<PayInGiropayWebPostDTO> GetPayInGiropayWebPost()
{
var wallet = await GetJohnsWalletWithMoney();
var user = await GetJohn();

var payIn = new PayInGiropayWebPostDTO(
user.Id,
new Money { Amount = 100, Currency = CurrencyIso.EUR },
new Money { Amount = 20, Currency = CurrencyIso.EUR },
wallet.Id,
"http://www.my-site.com/returnURL?transactionId=wt_71a08458-b0cc-468d-98f7-1302591fc238",
"Giropay tag",
"test"

);

return payIn;
}

protected async Task<PayOutBankWireDTO> GetJohnsPayOutBankWire()
{
Expand Down
2 changes: 2 additions & 0 deletions MangoPay.SDK/Core/APIs/ApiBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public abstract class ApiBase
{ MethodKey.PayinsSatispayWebCreate, new ApiEndPoint("/payins/payment-methods/satispay", RequestType.POST)},
{ MethodKey.PayinsBlikWebCreate, new ApiEndPoint("/payins/payment-methods/blik", RequestType.POST)},
{ MethodKey.PayinsKlarnaWebCreate, new ApiEndPoint("/payins/payment-methods/klarna", RequestType.POST)},
{ MethodKey.PayinsIdealWebCreate, new ApiEndPoint("/payins/payment-methods/ideal", RequestType.POST)},
{ MethodKey.PayinsGiropayWebCreate, new ApiEndPoint("/payins/payment-methods/giropay", RequestType.POST)},

{ MethodKey.PayinsRecurringRegistration, new ApiEndPoint("/recurringpayinregistrations", RequestType.POST)},
{ MethodKey.PayinsGetRecurringRegistration, new ApiEndPoint("/recurringpayinregistrations/{0}", RequestType.GET)},
Expand Down
38 changes: 38 additions & 0 deletions MangoPay.SDK/Core/APIs/ApiPayIns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,28 @@ public async Task<PayInKlarnaWebDTO> CreateKlarnaWebAsync(PayInKlarnaWebPostDTO
return await this.CreateObjectAsync<PayInKlarnaWebDTO, PayInKlarnaWebPostDTO>(
MethodKey.PayinsKlarnaWebCreate, payIn, idempotentKey);
}

/// <summary>Creates new payin ideal web.</summary>
/// <param name="idempotentKey">Idempotent key for this request.</param>
/// <param name="payIn">Object instance to be created.</param>
/// <returns>Object instance returned from API.</returns>
public async Task<PayInIdealWebDTO> CreateIdealWebAsync(PayInIdealWebPostDTO payIn,
string idempotentKey = null)
{
return await this.CreateObjectAsync<PayInIdealWebDTO, PayInIdealWebPostDTO>(
MethodKey.PayinsIdealWebCreate, payIn, idempotentKey);
}

/// <summary>Creates new payin giropay web.</summary>
/// <param name="idempotentKey">Idempotent key for this request.</param>
/// <param name="payIn">Object instance to be created.</param>
/// <returns>Object instance returned from API.</returns>
public async Task<PayInGiropayWebDTO> CreateGiropayWebAsync(PayInGiropayWebPostDTO payIn,
string idempotentKey = null)
{
return await this.CreateObjectAsync<PayInGiropayWebDTO, PayInGiropayWebPostDTO>(
MethodKey.PayinsGiropayWebCreate, payIn, idempotentKey);
}

/// <summary>Gets PayIn entity by its identifier.</summary>
/// <param name="payInId">PayIn identifier.</param>
Expand Down Expand Up @@ -288,6 +310,22 @@ public async Task<PayInKlarnaWebDTO> GetKlarnaAsync(string payInId)
{
return await this.GetObjectAsync<PayInKlarnaWebDTO>(MethodKey.PayinsGet, entitiesId: payInId);
}

/// <summary>Gets PayIn Ideal entity by its identifier.</summary>
/// <param name="payInId">PayIn identifier.</param>
/// <returns>PayIn object returned from API.</returns>
public async Task<PayInIdealWebDTO> GetIdealAsync(string payInId)
{
return await this.GetObjectAsync<PayInIdealWebDTO>(MethodKey.PayinsGet, entitiesId: payInId);
}

/// <summary>Gets PayIn Giropay entity by its identifier.</summary>
/// <param name="payInId">PayIn identifier.</param>
/// <returns>PayIn object returned from API.</returns>
public async Task<PayInGiropayWebDTO> GetGiropayAsync(string payInId)
{
return await this.GetObjectAsync<PayInGiropayWebDTO>(MethodKey.PayinsGet, entitiesId: payInId);
}

/// <summary>Creates refund for PayIn object.</summary>
/// <param name="idempotentKey">Idempotent key for this request.</param>
Expand Down
2 changes: 2 additions & 0 deletions MangoPay.SDK/Core/Enumerations/MethodKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public enum MethodKey
PayinsSatispayWebCreate,
PayinsBlikWebCreate,
PayinsKlarnaWebCreate,
PayinsIdealWebCreate,
PayinsGiropayWebCreate,
PayoutsBankwireCreate,
PayoutsBankwireGet,
PayoutsGet,
Expand Down
4 changes: 4 additions & 0 deletions MangoPay.SDK/Core/Enumerations/PayInPaymentType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ public enum PayInPaymentType
BLIK,
/// <summary> Klarna payment type </summary>
KLARNA,
/// <summary> Ideal payment type </summary>
IDEAL,
/// <summary> Giropay payment type </summary>
GIROPAY,
}
}
14 changes: 14 additions & 0 deletions MangoPay.SDK/Entities/GET/PayInGiropayWebDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace MangoPay.SDK.Entities.GET
{
public class PayInGiropayWebDTO: PayInDTO
{
/// <summary>An optional value to be specified on the user's bank statement.</summary>
public string StatementDescriptor { get; set; }

/// <summary> The URL to redirect to after the payment, whether the transaction was successful or not
public string ReturnURL { get; set; }

/// <summary> The URL to which the user is redirected to complete the payment
public string RedirectURL { get; set; }
}
}
17 changes: 17 additions & 0 deletions MangoPay.SDK/Entities/GET/PayInIdealWebDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace MangoPay.SDK.Entities.GET
{
public class PayInIdealWebDTO : PayInDTO
{
/// <summary>An optional value to be specified on the user's bank statement.</summary>
public string StatementDescriptor { get; set; }

/// <summary> The URL to redirect to after the payment, whether the transaction was successful or not
public string ReturnURL { get; set; }

/// <summary> The URL to which the user is redirected to complete the payment
public string RedirectURL { get; set; }

/// <summary> Name of the end-user’s bank </summary>
public string BankName { get; set; }
}
}
35 changes: 35 additions & 0 deletions MangoPay.SDK/Entities/POST/PayInGiropayWebPostDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace MangoPay.SDK.Entities.POST
{
public class PayInGiropayWebPostDTO : EntityPostBase
{
public PayInGiropayWebPostDTO(string authorId, Money debitedFunds, Money fees, string creditedWalletId,
string returnUrl, string tag = null, string statementDescriptor = null)
{
AuthorId = authorId;
DebitedFunds = debitedFunds;
Fees = fees;
CreditedWalletId = creditedWalletId;
ReturnURL = returnUrl;
StatementDescriptor = statementDescriptor;
Tag = tag;
}

/// <summary>Author identifier.</summary>
public string AuthorId { get; set; }

/// <summary>Debited funds.</summary>
public Money DebitedFunds { get; set; }

/// <summary>Fees.</summary>
public Money Fees { get; set; }

/// <summary>Credited wallet identifier.</summary>
public string CreditedWalletId { get; set; }

/// <summary> The URL to redirect to after the payment, whether the transaction was successful or not
public string ReturnURL { get; set; }

/// <summary>An optional value to be specified on the user's bank statement.</summary>
public string StatementDescriptor { get; set; }
}
}
39 changes: 39 additions & 0 deletions MangoPay.SDK/Entities/POST/PayInIdealWebPostDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace MangoPay.SDK.Entities.POST
{
public class PayInIdealWebPostDTO : EntityPostBase
{
public PayInIdealWebPostDTO(string authorId, Money debitedFunds, Money fees, string creditedWalletId,
string returnUrl, string bic, string tag = null, string statementDescriptor = null)
{
AuthorId = authorId;
DebitedFunds = debitedFunds;
Fees = fees;
CreditedWalletId = creditedWalletId;
ReturnURL = returnUrl;
Bic = bic;
StatementDescriptor = statementDescriptor;
Tag = tag;
}

/// <summary>Author identifier.</summary>
public string AuthorId { get; set; }

/// <summary>Debited funds.</summary>
public Money DebitedFunds { get; set; }

/// <summary>Fees.</summary>
public Money Fees { get; set; }

/// <summary>Credited wallet identifier.</summary>
public string CreditedWalletId { get; set; }

/// <summary> The URL to redirect to after the payment, whether the transaction was successful or not
public string ReturnURL { get; set; }

/// <summary> The BIC identifier of the end-user’s bank
public string Bic { get; set; }

/// <summary>An optional value to be specified on the user's bank statement.</summary>
public string StatementDescriptor { get; set; }
}
}

0 comments on commit bf7bfe5

Please sign in to comment.