From e6fd8a72d41011c90bf78770769ed27b3641534a Mon Sep 17 00:00:00 2001 From: Silviana Ghita Date: Mon, 2 Oct 2023 12:47:55 +0300 Subject: [PATCH 1/2] Integrated Ideal and Giropay mops --- MangoPay.SDK.Tests/ApiPayInsTest.cs | 58 +++++++++++++++++++++ MangoPay.SDK.Tests/BaseTest.cs | 49 +++++++++++++++++ MangoPay.SDK/Core/APIs/ApiPayIns.cs | 22 ++++++++ MangoPay.SDK/Core/Enumerations/MethodKey.cs | 2 + 4 files changed, 131 insertions(+) diff --git a/MangoPay.SDK.Tests/ApiPayInsTest.cs b/MangoPay.SDK.Tests/ApiPayInsTest.cs index d4b12d7..7b490d9 100644 --- a/MangoPay.SDK.Tests/ApiPayInsTest.cs +++ b/MangoPay.SDK.Tests/ApiPayInsTest.cs @@ -393,6 +393,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() diff --git a/MangoPay.SDK.Tests/BaseTest.cs b/MangoPay.SDK.Tests/BaseTest.cs index 9f1caeb..e20470a 100644 --- a/MangoPay.SDK.Tests/BaseTest.cs +++ b/MangoPay.SDK.Tests/BaseTest.cs @@ -423,6 +423,18 @@ protected async Task GetNewPayInKlarnaWeb() PayInKlarnaWebPostDTO payIn = await GetPayInKlarnaWebPost(); return await this.Api.PayIns.CreateKlarnaWebAsync(payIn); } + + protected async Task GetNewPayInIdealWeb() + { + PayInIdealWebPostDTO payIn = await GetPayInIdealWebPost(); + return await this.Api.PayIns.CreateIdealWebAsync(payIn); + } + + protected async Task GetNewPayInGiropayWeb() + { + PayInGiropayWebPostDTO payIn = await GetPayInGiropayWebPost(); + return await this.Api.PayIns.CreateGiropayWebAsync(payIn); + } /// Creates PayIn Card Direct object. /// User identifier. @@ -710,6 +722,43 @@ protected async Task GetPayInKlarnaWebPost() return payIn; } + + + protected async Task 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", + "mango@mangopay.com", + "Ideal test" + ); + + return payIn; + } + + protected async Task 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", + "mango@mangopay.com", + "Giropay test" + ); + + return payIn; + } protected async Task GetJohnsPayOutBankWire() { diff --git a/MangoPay.SDK/Core/APIs/ApiPayIns.cs b/MangoPay.SDK/Core/APIs/ApiPayIns.cs index d4dc573..942c54b 100644 --- a/MangoPay.SDK/Core/APIs/ApiPayIns.cs +++ b/MangoPay.SDK/Core/APIs/ApiPayIns.cs @@ -151,6 +151,28 @@ public async Task CreateKlarnaWebAsync(PayInKlarnaWebPostDTO return await this.CreateObjectAsync( MethodKey.PayinsKlarnaWebCreate, payIn, idempotentKey); } + + /// Creates new payin ideal web. + /// Idempotent key for this request. + /// Object instance to be created. + /// Object instance returned from API. + public async Task CreateIdealWebAsync(PayInIdealWebPostDTO payIn, + string idempotentKey = null) + { + return await this.CreateObjectAsync( + MethodKey.PayinsIdealWebCreate, payIn, idempotentKey); + } + + /// Creates new payin giropay web. + /// Idempotent key for this request. + /// Object instance to be created. + /// Object instance returned from API. + public async Task CreateGiropayWebAsync(PayInGiropayWebPostDTO payIn, + string idempotentKey = null) + { + return await this.CreateObjectAsync( + MethodKey.PayinsGiropayWebCreate, payIn, idempotentKey); + } /// Gets PayIn entity by its identifier. /// PayIn identifier. diff --git a/MangoPay.SDK/Core/Enumerations/MethodKey.cs b/MangoPay.SDK/Core/Enumerations/MethodKey.cs index 4c23c5e..03a8558 100644 --- a/MangoPay.SDK/Core/Enumerations/MethodKey.cs +++ b/MangoPay.SDK/Core/Enumerations/MethodKey.cs @@ -45,6 +45,8 @@ public enum MethodKey PayinsSatispayWebCreate, PayinsBlikWebCreate, PayinsKlarnaWebCreate, + PayinsIdealWebCreate, + PayinsGiropayWebCreate, PayoutsBankwireCreate, PayoutsBankwireGet, PayoutsGet, From f50d1d9e8ff8c73dd631a8af70dbe5289a41970b Mon Sep 17 00:00:00 2001 From: Silviana Ghita Date: Mon, 2 Oct 2023 14:24:27 +0300 Subject: [PATCH 2/2] Integrated Ideal and Giropay mops --- MangoPay.SDK.Tests/BaseTest.cs | 8 ++-- MangoPay.SDK/Core/APIs/ApiBase.cs | 2 + MangoPay.SDK/Core/APIs/ApiPayIns.cs | 16 ++++++++ .../Core/Enumerations/PayInPaymentType.cs | 4 ++ .../Entities/GET/PayInGiropayWebDTO.cs | 14 +++++++ MangoPay.SDK/Entities/GET/PayInIdealWebDTO.cs | 17 ++++++++ .../Entities/POST/PayInGiropayWebPostDTO.cs | 35 +++++++++++++++++ .../Entities/POST/PayInIdealWebPostDTO.cs | 39 +++++++++++++++++++ 8 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 MangoPay.SDK/Entities/GET/PayInGiropayWebDTO.cs create mode 100644 MangoPay.SDK/Entities/GET/PayInIdealWebDTO.cs create mode 100644 MangoPay.SDK/Entities/POST/PayInGiropayWebPostDTO.cs create mode 100644 MangoPay.SDK/Entities/POST/PayInIdealWebPostDTO.cs diff --git a/MangoPay.SDK.Tests/BaseTest.cs b/MangoPay.SDK.Tests/BaseTest.cs index e20470a..15d58e0 100644 --- a/MangoPay.SDK.Tests/BaseTest.cs +++ b/MangoPay.SDK.Tests/BaseTest.cs @@ -735,7 +735,8 @@ protected async Task GetPayInIdealWebPost() new Money { Amount = 20, Currency = CurrencyIso.EUR }, wallet.Id, "http://www.my-site.com/returnURL?transactionId=wt_71a08458-b0cc-468d-98f7-1302591fc238", - "mango@mangopay.com", + "RBRBNL21", + "Ideal tag", "Ideal test" ); @@ -753,8 +754,9 @@ protected async Task GetPayInGiropayWebPost() new Money { Amount = 20, Currency = CurrencyIso.EUR }, wallet.Id, "http://www.my-site.com/returnURL?transactionId=wt_71a08458-b0cc-468d-98f7-1302591fc238", - "mango@mangopay.com", - "Giropay test" + "Giropay tag", + "test" + ); return payIn; diff --git a/MangoPay.SDK/Core/APIs/ApiBase.cs b/MangoPay.SDK/Core/APIs/ApiBase.cs index bff54a8..8a74705 100644 --- a/MangoPay.SDK/Core/APIs/ApiBase.cs +++ b/MangoPay.SDK/Core/APIs/ApiBase.cs @@ -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)}, diff --git a/MangoPay.SDK/Core/APIs/ApiPayIns.cs b/MangoPay.SDK/Core/APIs/ApiPayIns.cs index 942c54b..c77971c 100644 --- a/MangoPay.SDK/Core/APIs/ApiPayIns.cs +++ b/MangoPay.SDK/Core/APIs/ApiPayIns.cs @@ -310,6 +310,22 @@ public async Task GetKlarnaAsync(string payInId) { return await this.GetObjectAsync(MethodKey.PayinsGet, entitiesId: payInId); } + + /// Gets PayIn Ideal entity by its identifier. + /// PayIn identifier. + /// PayIn object returned from API. + public async Task GetIdealAsync(string payInId) + { + return await this.GetObjectAsync(MethodKey.PayinsGet, entitiesId: payInId); + } + + /// Gets PayIn Giropay entity by its identifier. + /// PayIn identifier. + /// PayIn object returned from API. + public async Task GetGiropayAsync(string payInId) + { + return await this.GetObjectAsync(MethodKey.PayinsGet, entitiesId: payInId); + } /// Creates refund for PayIn object. /// Idempotent key for this request. diff --git a/MangoPay.SDK/Core/Enumerations/PayInPaymentType.cs b/MangoPay.SDK/Core/Enumerations/PayInPaymentType.cs index c79a3f2..dd2144b 100644 --- a/MangoPay.SDK/Core/Enumerations/PayInPaymentType.cs +++ b/MangoPay.SDK/Core/Enumerations/PayInPaymentType.cs @@ -46,5 +46,9 @@ public enum PayInPaymentType BLIK, /// Klarna payment type KLARNA, + /// Ideal payment type + IDEAL, + /// Giropay payment type + GIROPAY, } } diff --git a/MangoPay.SDK/Entities/GET/PayInGiropayWebDTO.cs b/MangoPay.SDK/Entities/GET/PayInGiropayWebDTO.cs new file mode 100644 index 0000000..05a607e --- /dev/null +++ b/MangoPay.SDK/Entities/GET/PayInGiropayWebDTO.cs @@ -0,0 +1,14 @@ +namespace MangoPay.SDK.Entities.GET +{ + public class PayInGiropayWebDTO: PayInDTO + { + /// An optional value to be specified on the user's bank statement. + public string StatementDescriptor { get; set; } + + /// The URL to redirect to after the payment, whether the transaction was successful or not + public string ReturnURL { get; set; } + + /// The URL to which the user is redirected to complete the payment + public string RedirectURL { get; set; } + } +} \ No newline at end of file diff --git a/MangoPay.SDK/Entities/GET/PayInIdealWebDTO.cs b/MangoPay.SDK/Entities/GET/PayInIdealWebDTO.cs new file mode 100644 index 0000000..a4bccb3 --- /dev/null +++ b/MangoPay.SDK/Entities/GET/PayInIdealWebDTO.cs @@ -0,0 +1,17 @@ +namespace MangoPay.SDK.Entities.GET +{ + public class PayInIdealWebDTO : PayInDTO + { + /// An optional value to be specified on the user's bank statement. + public string StatementDescriptor { get; set; } + + /// The URL to redirect to after the payment, whether the transaction was successful or not + public string ReturnURL { get; set; } + + /// The URL to which the user is redirected to complete the payment + public string RedirectURL { get; set; } + + /// Name of the end-user’s bank + public string BankName { get; set; } + } +} \ No newline at end of file diff --git a/MangoPay.SDK/Entities/POST/PayInGiropayWebPostDTO.cs b/MangoPay.SDK/Entities/POST/PayInGiropayWebPostDTO.cs new file mode 100644 index 0000000..25161cf --- /dev/null +++ b/MangoPay.SDK/Entities/POST/PayInGiropayWebPostDTO.cs @@ -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; + } + + /// Author identifier. + public string AuthorId { get; set; } + + /// Debited funds. + public Money DebitedFunds { get; set; } + + /// Fees. + public Money Fees { get; set; } + + /// Credited wallet identifier. + public string CreditedWalletId { get; set; } + + /// The URL to redirect to after the payment, whether the transaction was successful or not + public string ReturnURL { get; set; } + + /// An optional value to be specified on the user's bank statement. + public string StatementDescriptor { get; set; } + } +} \ No newline at end of file diff --git a/MangoPay.SDK/Entities/POST/PayInIdealWebPostDTO.cs b/MangoPay.SDK/Entities/POST/PayInIdealWebPostDTO.cs new file mode 100644 index 0000000..a6639e3 --- /dev/null +++ b/MangoPay.SDK/Entities/POST/PayInIdealWebPostDTO.cs @@ -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; + } + + /// Author identifier. + public string AuthorId { get; set; } + + /// Debited funds. + public Money DebitedFunds { get; set; } + + /// Fees. + public Money Fees { get; set; } + + /// Credited wallet identifier. + public string CreditedWalletId { get; set; } + + /// The URL to redirect to after the payment, whether the transaction was successful or not + public string ReturnURL { get; set; } + + /// The BIC identifier of the end-user’s bank + public string Bic { get; set; } + + /// An optional value to be specified on the user's bank statement. + public string StatementDescriptor { get; set; } + } +} \ No newline at end of file