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 support for Blik with code #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions MangoPay.SDK.Tests/ApiPayInsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,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 71 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 73 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 @@ -415,6 +415,34 @@
}
}

[Test]
public async Task Test_PayIns_Create_BlikWeb_WithCode()
{
try
{
var user = await GetJohn();
var payIn = await GetNewPayInBlikWebWithCode();
var fetched = await Api.PayIns.GetBlikAsync(payIn.Id);

Assert.IsTrue(payIn.Id.Length > 0);
Assert.AreEqual(PayInPaymentType.BLIK, payIn.PaymentType);
Assert.AreEqual(PayInExecutionType.WEB, payIn.ExecutionType);
Assert.AreEqual(TransactionStatus.CREATED, payIn.Status);
Assert.AreEqual(TransactionType.PAYIN, payIn.Type);
Assert.AreEqual(TransactionNature.REGULAR, payIn.Nature);
Assert.IsNotNull(payIn.Code);
Assert.IsNotNull(payIn.IpAddress);
Assert.IsNotNull(payIn.BrowserInfo);

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

[Test]
public async Task Test_PayIns_Create_KlarnaWeb()
{
Expand Down
9 changes: 9 additions & 0 deletions MangoPay.SDK.Tests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,15 @@ protected async Task<PayInBlikWebDTO> GetNewPayInBlikWeb()
return await this.Api.PayIns.CreateBlikWebAsync(payIn);
}

protected async Task<PayInBlikWebDTO> GetNewPayInBlikWebWithCode()
{
PayInBlikWebPostDTO payIn = await GetPayInBlikWebPost();
payIn.Code = "777365";
payIn.IpAddress = "159.180.248.187";
payIn.BrowserInfo = getBrowserInfo();
return await this.Api.PayIns.CreateBlikWebAsync(payIn);
}

protected async Task<PayInKlarnaWebDTO> GetNewPayInKlarnaWeb()
{
PayInKlarnaWebPostDTO payIn = await GetPayInKlarnaWebPost();
Expand Down
18 changes: 18 additions & 0 deletions MangoPay.SDK/Entities/GET/PayInBlikWebDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,23 @@ public class PayInBlikWebDTO: PayInDTO

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

/// <summary>
/// The 6-digit code from the user’s banking application.
/// Required when creating a Blik PayIn with code.
/// </summary>
public string Code { get; set; }

/// <summary>
/// The IP address of the end user initiating the transaction, in IPV4 or IPV6 format.
/// Required when creating a Blik PayIn with code.
/// </summary>
public string IpAddress { get; set; }

/// <summary>
/// Information about the browser used by the end user (author) to perform the payment.
/// Required when creating a Blik PayIn with code.
/// </summary>
public BrowserInfo BrowserInfo { get; set; }
}
}
37 changes: 36 additions & 1 deletion MangoPay.SDK/Entities/POST/PayInBlikWebPostDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ namespace MangoPay.SDK.Entities.POST
{
public class PayInBlikWebPostDTO: EntityPostBase
{
public PayInBlikWebPostDTO(string authorId, Money debitedFunds, Money fees, string creditedWalletId, string returnUrl, string tag = null, string statementDescriptor = null)
public PayInBlikWebPostDTO(string authorId, Money debitedFunds, Money fees, string creditedWalletId,
string returnUrl, string tag = null, string statementDescriptor = null)
{
AuthorId = authorId;
DebitedFunds = debitedFunds;
Expand All @@ -12,6 +13,22 @@ public PayInBlikWebPostDTO(string authorId, Money debitedFunds, Money fees, stri
StatementDescriptor = statementDescriptor;
Tag = tag;
}

public PayInBlikWebPostDTO(string authorId, Money debitedFunds, Money fees, string creditedWalletId,
string returnUrl, string code, string ipAddress, BrowserInfo browserInfo, string tag = null,
string statementDescriptor = null)
{
AuthorId = authorId;
DebitedFunds = debitedFunds;
Fees = fees;
CreditedWalletId = creditedWalletId;
ReturnURL = returnUrl;
StatementDescriptor = statementDescriptor;
Tag = tag;
Code = code;
IpAddress = ipAddress;
BrowserInfo = browserInfo;
}

/// <summary>Author identifier.</summary>
public string AuthorId { get; set; }
Expand All @@ -30,5 +47,23 @@ public PayInBlikWebPostDTO(string authorId, Money debitedFunds, Money fees, stri

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

/// <summary>
/// The 6-digit code from the user’s banking application.
/// Required when creating a Blik PayIn with code.
/// </summary>
public string Code { get; set; }

/// <summary>
/// The IP address of the end user initiating the transaction, in IPV4 or IPV6 format.
/// Required when creating a Blik PayIn with code.
/// </summary>
public string IpAddress { get; set; }

/// <summary>
/// Information about the browser used by the end user (author) to perform the payment.
/// Required when creating a Blik PayIn with code.
/// </summary>
public BrowserInfo BrowserInfo { get; set; }
}
}
Loading