Skip to content

Commit

Permalink
handled latest payconiq api url
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Feb 28, 2025
1 parent 0208c3a commit b63f655
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 33 deletions.
72 changes: 49 additions & 23 deletions MangoPay.SDK.Tests/ApiPayInsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,7 @@ public async Task Test_PayIns_Create_Payconiq()
{
try
{
var wallet = await this.GetJohnsWallet();
var user = await this.GetJohn();

var payInPost = new PayInPayconiqPostDTO
{
Tag = "custom meta",
AuthorId = user.Id,
DebitedFunds = new Money
{
Amount = 22,
Currency = CurrencyIso.EUR
},
Fees = new Money
{
Amount = 10,
Currency = CurrencyIso.EUR
},
ReturnURL = "http://www.my-site.com/returnURL",
CreditedWalletId = wallet.Id,
Country = "BE",
CreditedUserId = user.Id
};

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

Assert.IsTrue(payIn.Id.Length > 0);
Expand All @@ -183,6 +161,54 @@ public async Task Test_PayIns_Create_Payconiq()
Assert.Fail(ex.Message);
}
}

[Test]
public async Task Test_PayIns_Create_Payconiq_V2()
{
try
{
var payInPost = await payconiqPostDto();
var payIn = await this.Api.PayIns.CreatePayconiqV2Async(payInPost);

Assert.IsTrue(payIn.Id.Length > 0);
Assert.IsTrue(payIn.PaymentType == PayInPaymentType.PAYCONIQ);
Assert.IsTrue(payIn.ExecutionType == PayInExecutionType.WEB);
Assert.IsNotNull(payIn.DeepLinkURL);
Assert.IsNotNull(payIn.QRCodeURL);
}
catch (Exception ex)
{
Assert.Fail(ex.Message);
}
}

private async Task<PayInPayconiqPostDTO> payconiqPostDto()
{
var wallet = await this.GetJohnsWallet();
var user = await this.GetJohn();

var payInPost = new PayInPayconiqPostDTO
{
Tag = "custom meta",
AuthorId = user.Id,
DebitedFunds = new Money
{
Amount = 22,
Currency = CurrencyIso.EUR
},
Fees = new Money
{
Amount = 10,
Currency = CurrencyIso.EUR
},
ReturnURL = "http://www.my-site.com/returnURL",
CreditedWalletId = wallet.Id,
Country = "BE",
CreditedUserId = user.Id
};

return payInPost;
}

[Test]
public async Task Test_PayIns_Create_PayPal_WithShippingAddress()
Expand Down
1 change: 1 addition & 0 deletions MangoPay.SDK/Core/APIs/ApiBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public abstract class ApiBase
{ MethodKey.PayinsBankwireDirectCreate, new ApiEndPoint("/payins/bankwire/direct", RequestType.POST)},

{ MethodKey.PayinsPayconiqWebCreate, new ApiEndPoint("/payins/payconiq/web", RequestType.POST)},
{ MethodKey.PayinsPayconiqV2WebCreate, new ApiEndPoint("/payins/payment-methods/payconiq", RequestType.POST)},

{ MethodKey.PayinsDirectDebitCreate, new ApiEndPoint("/payins/directdebit/web", RequestType.POST)},
{ MethodKey.PayinsMandateDirectDebitCreate, new ApiEndPoint("/payins/directdebit/direct", RequestType.POST)},
Expand Down
9 changes: 9 additions & 0 deletions MangoPay.SDK/Core/APIs/ApiPayIns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ public async Task<PayInPayconiqDTO> CreatePayconiqAsync(PayInPayconiqPostDTO pay
{
return await this.CreateObjectAsync<PayInPayconiqDTO, PayInPayconiqPostDTO>(MethodKey.PayinsPayconiqWebCreate, payIn, idempotentKey);
}

/// <summary>Creates new payin by Payconiq using the latest API url (/payment-methods/payconiq)</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<PayInPayconiqDTO> CreatePayconiqV2Async(PayInPayconiqPostDTO payIn, string idempotentKey = null)
{
return await this.CreateObjectAsync<PayInPayconiqDTO, PayInPayconiqPostDTO>(MethodKey.PayinsPayconiqV2WebCreate, payIn, idempotentKey);
}

/// <summary>Creates new payin preauthorized direct.</summary>
/// <param name="idempotentKey">Idempotent key for this request.</param>
Expand Down
1 change: 1 addition & 0 deletions MangoPay.SDK/Core/Enumerations/MethodKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public enum MethodKey
PayinsPayPalWebCreate,
PayinsBankwireDirectCreate,
PayinsPayconiqWebCreate,
PayinsPayconiqV2WebCreate,
PayinsCardDirectCreate,
PayinsCardWebCreate,
PayinsCardWebGetCardData,
Expand Down
12 changes: 7 additions & 5 deletions MangoPay.SDK/Entities/GET/PayInPayconiqDTO.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace MangoPay.SDK.Entities.GET
namespace MangoPay.SDK.Entities.GET
{
public class PayInPayconiqDTO : PayInDTO
{
Expand All @@ -13,5 +9,11 @@ public class PayInPayconiqDTO : PayInDTO
public string RedirectURL { get; set; }

public string ExpirationDate { get; set; }

public string StatementDescriptor { get; set; }

public string Country { get; set; }

public string QRCodeURL { get; set; }
}
}
9 changes: 4 additions & 5 deletions MangoPay.SDK/Entities/POST/PayInPayconiqPostDTO.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace MangoPay.SDK.Entities.POST
namespace MangoPay.SDK.Entities.POST
{
/// <summary>
/// Payconiq Post Class
Expand Down Expand Up @@ -50,5 +46,8 @@ public class PayInPayconiqPostDTO : EntityPostBase
/// Required
/// </summary>
public string Country { get; set; }

/// <summary> A custom description to appear </summary>
public string StatementDescriptor { get; set; }
}
}

0 comments on commit b63f655

Please sign in to comment.