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

Issue #74 #75

Open
wants to merge 6 commits 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
16 changes: 16 additions & 0 deletions Iyzipay.Samples/ApiTestSample.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Iyzipay.Model;
using NUnit.Framework;
using System.Threading.Tasks;

namespace Iyzipay.Samples
{
Expand All @@ -19,5 +20,20 @@ public void Should_Test_Api()
Assert.IsNull(iyzipayResource.ErrorMessage);
Assert.IsNull(iyzipayResource.ErrorGroup);
}

[Test]
public async Task Should_Test_ApiAsync()
{
IyzipayResource iyzipayResource = await ApiTest.RetrieveAsync(options);

PrintResponse<IyzipayResource>(iyzipayResource);

Assert.AreEqual(Status.SUCCESS.ToString(), iyzipayResource.Status);
Assert.AreEqual(Locale.TR.ToString(), iyzipayResource.Locale);
Assert.IsNotNull(iyzipayResource.SystemTime);
Assert.IsNull(iyzipayResource.ErrorCode);
Assert.IsNull(iyzipayResource.ErrorMessage);
Assert.IsNull(iyzipayResource.ErrorGroup);
}
}
}
110 changes: 110 additions & 0 deletions Iyzipay.Samples/ApmSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Iyzipay.Request;
using NUnit.Framework;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Iyzipay.Samples
{
Expand Down Expand Up @@ -115,5 +116,114 @@ public void Should_Retrieve_Apm_Result()
Assert.AreEqual(Locale.TR.ToString(), retrieve.Locale);
Assert.AreEqual("123456789", retrieve.ConversationId);
}

[Test]
public async Task Should_Initialize_Apm_PaymentAsync()
{
CreateApmInitializeRequest request = new CreateApmInitializeRequest();
request.Locale = Locale.TR.ToString();
request.ConversationId = "123456789";
request.Price = "1";
request.PaidPrice = "1.2";
request.Currency = Currency.EUR.ToString();
request.CountryCode = "DE";
request.PaymentChannel = PaymentChannel.WEB.ToString();
request.PaymentGroup = PaymentGroup.PRODUCT.ToString();
request.AccountHolderName = "success";
request.MerchantCallbackUrl = "https://www.merchant.com/callback";
request.MerchantErrorUrl = "https://www.merchant.com/error";
request.MerchantNotificationUrl = "https://www.merchant.com/notification";
request.ApmType = ApmType.SOFORT.ToString();

Buyer buyer = new Buyer();
buyer.Id = "BY789";
buyer.Name = "John";
buyer.Surname = "Doe";
buyer.GsmNumber = "+905350000000";
buyer.Email = "[email protected]";
buyer.IdentityNumber = "74300864791";
buyer.LastLoginDate = "2015-10-05 12:43:35";
buyer.RegistrationDate = "2013-04-21 15:12:09";
buyer.RegistrationAddress = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1";
buyer.Ip = "85.34.78.112";
buyer.City = "Istanbul";
buyer.Country = "Turkey";
buyer.ZipCode = "34732";
request.Buyer = buyer;

Address shippingAddress = new Address();
shippingAddress.ContactName = "Jane Doe";
shippingAddress.City = "Istanbul";
shippingAddress.Country = "Turkey";
shippingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1";
shippingAddress.ZipCode = "34742";
request.ShippingAddress = shippingAddress;

Address billingAddress = new Address();
billingAddress.ContactName = "Jane Doe";
billingAddress.City = "Istanbul";
billingAddress.Country = "Turkey";
billingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1";
billingAddress.ZipCode = "34742";
request.BillingAddress = billingAddress;

List<BasketItem> basketItems = new List<BasketItem>();
BasketItem firstBasketItem = new BasketItem();
firstBasketItem.Id = "BI101";
firstBasketItem.Name = "Binocular";
firstBasketItem.Category1 = "Collectibles";
firstBasketItem.Category2 = "Accessories";
firstBasketItem.ItemType = BasketItemType.PHYSICAL.ToString();
firstBasketItem.Price = "0.3";
basketItems.Add(firstBasketItem);

BasketItem secondBasketItem = new BasketItem();
secondBasketItem.Id = "BI102";
secondBasketItem.Name = "Game code";
secondBasketItem.Category1 = "Game";
secondBasketItem.Category2 = "Online Game Items";
secondBasketItem.ItemType = BasketItemType.VIRTUAL.ToString();
secondBasketItem.Price = "0.5";
basketItems.Add(secondBasketItem);

BasketItem thirdBasketItem = new BasketItem();
thirdBasketItem.Id = "BI103";
thirdBasketItem.Name = "Usb";
thirdBasketItem.Category1 = "Electronics";
thirdBasketItem.Category2 = "Usb / Cable";
thirdBasketItem.ItemType = BasketItemType.PHYSICAL.ToString();
thirdBasketItem.Price = "0.2";
basketItems.Add(thirdBasketItem);
request.BasketItems = basketItems;

Apm apmInitialize = await Apm.CreateAsync(request, options);

PrintResponse<Apm>(apmInitialize);

Assert.AreEqual(Status.SUCCESS.ToString(), apmInitialize.Status);
Assert.AreEqual(Locale.TR.ToString(), apmInitialize.Locale);
Assert.AreEqual("123456789", apmInitialize.ConversationId);
Assert.IsNotNull(apmInitialize.SystemTime);
Assert.IsNull(apmInitialize.ErrorCode);
Assert.IsNull(apmInitialize.ErrorMessage);
Assert.IsNull(apmInitialize.ErrorGroup);
}

[Test]
public async Task Should_Retrieve_Apm_ResultAsync()
{
RetrieveApmRequest request = new RetrieveApmRequest();
request.Locale = Locale.TR.ToString();
request.ConversationId = "123456789";
request.PaymentId = "1";

Apm retrieve = await Apm.RetrieveAsync(request, options);

PrintResponse<Apm>(retrieve);

Assert.AreEqual(Status.SUCCESS.ToString(), retrieve.Status);
Assert.AreEqual(Locale.TR.ToString(), retrieve.Locale);
Assert.AreEqual("123456789", retrieve.ConversationId);
}
}
}
28 changes: 28 additions & 0 deletions Iyzipay.Samples/BinNumberSample.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Iyzipay.Request;
using Iyzipay.Model;
using NUnit.Framework;
using System.Threading.Tasks;

namespace Iyzipay.Samples
{
Expand Down Expand Up @@ -32,5 +33,32 @@ public void Should_Retrieve_Bin_Number()
Assert.AreEqual("Garanti Bankası", binNumber.BankName);
Assert.AreEqual(62, binNumber.BankCode);
}

[Test]
public async Task Should_Retrieve_Bin_NumberAsync()
{
RetrieveBinNumberRequest request = new RetrieveBinNumberRequest();
request.Locale = Locale.TR.ToString();
request.ConversationId = "123456789";
request.BinNumber = "554960";

BinNumber binNumber = await BinNumber.RetrieveAsync(request, options);

PrintResponse<BinNumber>(binNumber);

Assert.AreEqual(Status.SUCCESS.ToString(), binNumber.Status);
Assert.AreEqual(Locale.TR.ToString(), binNumber.Locale);
Assert.AreEqual("123456789", binNumber.ConversationId);
Assert.IsNotNull(binNumber.SystemTime);
Assert.IsNull(binNumber.ErrorCode);
Assert.IsNull(binNumber.ErrorMessage);
Assert.IsNull(binNumber.ErrorGroup);
Assert.AreEqual("554960", binNumber.Bin);
Assert.AreEqual("CREDIT_CARD", binNumber.CardType);
Assert.AreEqual("MASTER_CARD", binNumber.CardAssociation);
Assert.AreEqual("Bonus", binNumber.CardFamily);
Assert.AreEqual("Garanti Bankası", binNumber.BankName);
Assert.AreEqual(62, binNumber.BankCode);
}
}
}
108 changes: 108 additions & 0 deletions Iyzipay.Samples/BkmSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Iyzipay.Model;
using System.Collections.Generic;
using NUnit.Framework;
using System.Threading.Tasks;

namespace Iyzipay.Samples
{
Expand Down Expand Up @@ -113,5 +114,112 @@ public void Should_Retrieve_Bkm_Result()
Assert.IsNull(bkm.ErrorMessage);
Assert.IsNull(bkm.ErrorGroup);
}

[Test]
public async Task Should_Initialize_BkmAsync()
{
CreateBkmInitializeRequest request = new CreateBkmInitializeRequest();
request.Locale = Locale.TR.ToString();
request.ConversationId = "123456789";
request.Price = "1";
request.BasketId = "B67832";
request.PaymentGroup = PaymentGroup.PRODUCT.ToString();
request.CallbackUrl = "https://www.merchant.com/callback";

Buyer buyer = new Buyer();
buyer.Id = "BY789";
buyer.Name = "John";
buyer.Surname = "Doe";
buyer.GsmNumber = "+905350000000";
buyer.Email = "[email protected]";
buyer.IdentityNumber = "74300864791";
buyer.LastLoginDate = "2015-10-05 12:43:35";
buyer.RegistrationDate = "2013-04-21 15:12:09";
buyer.RegistrationAddress = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1";
buyer.Ip = "85.34.78.112";
buyer.City = "Istanbul";
buyer.Country = "Turkey";
buyer.ZipCode = "34732";
request.Buyer = buyer;

Address shippingAddress = new Address();
shippingAddress.ContactName = "Jane Doe";
shippingAddress.City = "Istanbul";
shippingAddress.Country = "Turkey";
shippingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1";
shippingAddress.ZipCode = "34742";
request.ShippingAddress = shippingAddress;

Address billingAddress = new Address();
billingAddress.ContactName = "Jane Doe";
billingAddress.City = "Istanbul";
billingAddress.Country = "Turkey";
billingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1";
billingAddress.ZipCode = "34742";
request.BillingAddress = billingAddress;

List<BasketItem> basketItems = new List<BasketItem>();
BasketItem firstBasketItem = new BasketItem();
firstBasketItem.Id = "BI101";
firstBasketItem.Name = "Binocular";
firstBasketItem.Category1 = "Collectibles";
firstBasketItem.Category2 = "Accessories";
firstBasketItem.ItemType = BasketItemType.PHYSICAL.ToString();
firstBasketItem.Price = "0.3";
basketItems.Add(firstBasketItem);

BasketItem secondBasketItem = new BasketItem();
secondBasketItem.Id = "BI102";
secondBasketItem.Name = "Game code";
secondBasketItem.Category1 = "Game";
secondBasketItem.Category2 = "Online Game Items";
secondBasketItem.ItemType = BasketItemType.VIRTUAL.ToString();
secondBasketItem.Price = "0.5";
basketItems.Add(secondBasketItem);

BasketItem thirdBasketItem = new BasketItem();
thirdBasketItem.Id = "BI103";
thirdBasketItem.Name = "Usb";
thirdBasketItem.Category1 = "Electronics";
thirdBasketItem.Category2 = "Usb / Cable";
thirdBasketItem.ItemType = BasketItemType.PHYSICAL.ToString();
thirdBasketItem.Price = "0.2";
basketItems.Add(thirdBasketItem);
request.BasketItems = basketItems;

BkmInitialize bkmInitialize = await BkmInitialize.CreateAsync(request, options);

PrintResponse<BkmInitialize>(bkmInitialize);

Assert.AreEqual(Status.SUCCESS.ToString(), bkmInitialize.Status);
Assert.AreEqual(Locale.TR.ToString(), bkmInitialize.Locale);
Assert.AreEqual("123456789", bkmInitialize.ConversationId);
Assert.IsNotNull(bkmInitialize.SystemTime);
Assert.IsNull(bkmInitialize.ErrorCode);
Assert.IsNull(bkmInitialize.ErrorMessage);
Assert.IsNull(bkmInitialize.ErrorGroup);
Assert.IsNotNull(bkmInitialize.HtmlContent);
}

[Test]
public async Task Should_Retrieve_Bkm_ResultAsync()
{
RetrieveBkmRequest request = new RetrieveBkmRequest();
request.Locale = Locale.TR.ToString();
request.ConversationId = "123456789";
request.Token = "token";

Bkm bkm = await Bkm.RetrieveAsync(request, options);

PrintResponse<Bkm>(bkm);

Assert.AreEqual(Status.SUCCESS.ToString(), bkm.Status);
Assert.AreEqual(Locale.TR.ToString(), bkm.Locale);
Assert.AreEqual("123456789", bkm.ConversationId);
Assert.IsNotNull(bkm.SystemTime);
Assert.IsNull(bkm.ErrorCode);
Assert.IsNull(bkm.ErrorMessage);
Assert.IsNull(bkm.ErrorGroup);
}
}
}
Loading