Permalink
Branch: master
Find file Copy path
b710b4e Nov 9, 2016
1 contributor

Users who have contributed to this file

132 lines (116 sloc) 5.62 KB
using Iyzipay.Request;
using Iyzipay.Model;
using System.Collections.Generic;
using NUnit.Framework;
namespace Iyzipay.Samples
{
public class ThreedsSample : Sample
{
[Test]
public void Should_Initialize_Threeds()
{
CreatePaymentRequest request = new CreatePaymentRequest();
request.Locale = Locale.TR.ToString();
request.ConversationId = "123456789";
request.Price = "1";
request.PaidPrice = "1.2";
request.Currency = Currency.TRY.ToString();
request.Installment = 1;
request.BasketId = "B67832";
request.PaymentChannel = PaymentChannel.WEB.ToString();
request.PaymentGroup = PaymentGroup.PRODUCT.ToString();
request.CallbackUrl = "https://www.merchant.com/callback";
PaymentCard paymentCard = new PaymentCard();
paymentCard.CardHolderName = "John Doe";
paymentCard.CardNumber = "5528790000000008";
paymentCard.ExpireMonth = "12";
paymentCard.ExpireYear = "2030";
paymentCard.Cvc = "123";
paymentCard.RegisterCard = 0;
request.PaymentCard = paymentCard;
Buyer buyer = new Buyer();
buyer.Id = "BY789";
buyer.Name = "John";
buyer.Surname = "Doe";
buyer.GsmNumber = "+905350000000";
buyer.Email = "email@email.com";
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;
ThreedsInitialize threedsInitialize = ThreedsInitialize.Create(request, options);
PrintResponse<ThreedsInitialize>(threedsInitialize);
Assert.AreEqual(Status.SUCCESS.ToString(), threedsInitialize.Status);
Assert.AreEqual(Locale.TR.ToString(), threedsInitialize.Locale);
Assert.AreEqual("123456789", threedsInitialize.ConversationId);
Assert.IsNotNull(threedsInitialize.SystemTime);
Assert.IsNull(threedsInitialize.ErrorCode);
Assert.IsNull(threedsInitialize.ErrorMessage);
Assert.IsNull(threedsInitialize.ErrorGroup);
Assert.IsNotNull(threedsInitialize.HtmlContent);
}
[Test]
public void Should_Create_Threeds_Payment()
{
CreateThreedsPaymentRequest request = new CreateThreedsPaymentRequest();
request.Locale = Locale.TR.ToString();
request.ConversationId = "123456789";
request.PaymentId = "1";
request.ConversationData = "conversation data";
ThreedsPayment threedsPayment = ThreedsPayment.Create(request, options);
PrintResponse<ThreedsPayment>(threedsPayment);
Assert.AreEqual(Status.SUCCESS.ToString(), threedsPayment.Status);
Assert.AreEqual(Locale.TR.ToString(), threedsPayment.Locale);
Assert.AreEqual("123456789", threedsPayment.ConversationId);
Assert.IsNotNull(threedsPayment.SystemTime);
Assert.IsNull(threedsPayment.ErrorCode);
Assert.IsNull(threedsPayment.ErrorMessage);
Assert.IsNull(threedsPayment.ErrorGroup);
}
}
}