From 3868f8ed119955981f606107c8d315dad194431d Mon Sep 17 00:00:00 2001 From: eeyuksel Date: Mon, 1 Apr 2024 18:51:05 +0300 Subject: [PATCH] =?UTF-8?q?Exceldeki=20maddeler=20geli=C5=9Ftirildi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Iyzipay.Samples/ApiTestSample.cs | 23 - Iyzipay.Samples/IyziLinkSample.cs | 9 +- Iyzipay.Samples/PaymentSample.cs | 1120 +++++----- Iyzipay.Samples/TransactionReportSample.cs | 25 + Iyzipay.Tests/Functional/ApiTest.cs | 23 - Iyzipay.Tests/Functional/IyziLinkTest.cs | 14 +- .../Functional/SubscriptionCustomer.cs | 543 ++--- Iyzipay.Tests/Functional/SubscriptionTest.cs | 1872 +++++++++-------- Iyzipay/Model/ApiTest.cs | 10 - Iyzipay/Model/BasketItem.cs | 50 +- Iyzipay/Model/SubMerchantC2C.cs | 19 + .../Model/V2/Iyzilink/FastLink/FastLink.cs | 43 + .../V2/Iyzilink/FastLink/IyziFastLinkSave.cs | 9 + Iyzipay/Model/V2/Iyzilink/IyziLink.cs | 132 +- .../V2/Subscription/CheckoutFormResource.cs | 2 +- .../V2/Subscription/CheckoutFormResult.cs | 15 + Iyzipay/Model/V2/Subscription/Customer.cs | 8 +- .../Model/V2/Subscription/CustomerResource.cs | 4 +- Iyzipay/Model/V2/Subscription/Subscription.cs | 233 +- .../Model/V2/Transaction/TransactionReport.cs | 39 +- .../Request/CreateC2CSubMerchantRequest.cs | 30 + Iyzipay/Request/IyziFastLinkSaveRequest.cs | 14 + Iyzipay/Request/IyziLinkSaveRequest.cs | 35 +- .../Request/IyziLinkUpdateStatusRequest.cs | 7 + .../RetrieveScrollTransactionReportRequest.cs | 10 + .../V2/RetrieveTransactionReportRequest.cs | 2 +- .../V2/Subscription/DeleteCustomerRequest.cs | 7 + .../GetCheckoutFormResultRequest.cs | 7 + .../InitializeCheckoutFormRequest.cs | 2 +- ...bscriptionInitializeWithCustomerRequest.cs | 9 + .../V2/Subscription/UpdateCustomerRequest.cs | 4 +- .../Request/VerifyC2CSubMerchantRequest.cs | 19 + Iyzipay/RestHttpClientV2.cs | 154 +- 33 files changed, 2540 insertions(+), 1953 deletions(-) delete mode 100644 Iyzipay.Samples/ApiTestSample.cs delete mode 100644 Iyzipay.Tests/Functional/ApiTest.cs delete mode 100644 Iyzipay/Model/ApiTest.cs create mode 100644 Iyzipay/Model/SubMerchantC2C.cs create mode 100644 Iyzipay/Model/V2/Iyzilink/FastLink/FastLink.cs create mode 100644 Iyzipay/Model/V2/Iyzilink/FastLink/IyziFastLinkSave.cs create mode 100644 Iyzipay/Model/V2/Subscription/CheckoutFormResult.cs create mode 100644 Iyzipay/Request/CreateC2CSubMerchantRequest.cs create mode 100644 Iyzipay/Request/IyziFastLinkSaveRequest.cs create mode 100644 Iyzipay/Request/IyziLinkUpdateStatusRequest.cs create mode 100644 Iyzipay/Request/V2/RetrieveScrollTransactionReportRequest.cs create mode 100644 Iyzipay/Request/V2/Subscription/DeleteCustomerRequest.cs create mode 100644 Iyzipay/Request/V2/Subscription/GetCheckoutFormResultRequest.cs create mode 100644 Iyzipay/Request/V2/Subscription/SubscriptionInitializeWithCustomerRequest.cs create mode 100644 Iyzipay/Request/VerifyC2CSubMerchantRequest.cs diff --git a/Iyzipay.Samples/ApiTestSample.cs b/Iyzipay.Samples/ApiTestSample.cs deleted file mode 100644 index 60ad1f0..0000000 --- a/Iyzipay.Samples/ApiTestSample.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Iyzipay.Model; -using NUnit.Framework; - -namespace Iyzipay.Samples -{ - public class ApiTestSample : Sample - { - [Test] - public void Should_Test_Api() - { - IyzipayResource iyzipayResource = ApiTest.Retrieve(options); - - PrintResponse(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); - } - } -} diff --git a/Iyzipay.Samples/IyziLinkSample.cs b/Iyzipay.Samples/IyziLinkSample.cs index 6a0e5b4..6a8d889 100644 --- a/Iyzipay.Samples/IyziLinkSample.cs +++ b/Iyzipay.Samples/IyziLinkSample.cs @@ -20,8 +20,11 @@ public void Should_Create_IyziLink() request.Price = "1"; request.Currency = Currency.TRY.ToString(); request.AddressIgnorable = false; - request.SoldLimit = 1; request.InstallmentRequested = false; + request.StockEnabled = true; + request.StockCount = 1; + request.InstallmentRequested = false; + request.SourceType = "API"; ResponseData response = IyziLink.Create(request, options); PrintResponse(response); @@ -47,7 +50,9 @@ public void Should_Update_IyziLink() updateRequest.Price = "10"; updateRequest.Currency = Currency.TRY.ToString(); updateRequest.AddressIgnorable = false; - updateRequest.SoldLimit = 1; + updateRequest.StockEnabled = true; + updateRequest.StockCount = 1; + updateRequest.SourceType = "API"; updateRequest.InstallmentRequested = false; ResponseData response = IyziLink.Update("token", updateRequest, options); diff --git a/Iyzipay.Samples/PaymentSample.cs b/Iyzipay.Samples/PaymentSample.cs index 8520fa0..32971da 100644 --- a/Iyzipay.Samples/PaymentSample.cs +++ b/Iyzipay.Samples/PaymentSample.cs @@ -5,513 +5,615 @@ namespace Iyzipay.Samples { - public class PaymentSample : Sample - { - [Test] - public void Should_Create_Payment() - { - CreatePaymentRequest request = new CreatePaymentRequest(); - request.Locale = Locale.TR.ToString(); - request.ConversationId = "123456789"; - request.Price = "1.0"; - 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(); - - 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 basketItems = new List(); - 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; - - Payment payment = Payment.Create(request, options); - - PrintResponse(payment); - - Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); - Assert.AreEqual(Locale.TR.ToString(), payment.Locale); - Assert.AreEqual("123456789", payment.ConversationId); - Assert.IsNotNull(payment.SystemTime); - Assert.IsNull(payment.ErrorCode); - Assert.IsNull(payment.ErrorMessage); - Assert.IsNull(payment.ErrorGroup); - } - - [Test] - public void Should_Create_Marketplace_Payment() - { - 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(); - - PaymentCard paymentCard = new PaymentCard(); - paymentCard.CardHolderName = "John Doe"; - paymentCard.CardNumber = "5528790000000008"; - paymentCard.ExpireMonth = "12"; - paymentCard.ExpireYear = "2020"; - 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 basketItems = new List(); - 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"; - firstBasketItem.SubMerchantKey = "sub merchant key"; - firstBasketItem.SubMerchantPrice = "0.27"; - 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"; - secondBasketItem.SubMerchantKey = "sub merchant key"; - secondBasketItem.SubMerchantPrice = "0.42"; - 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"; - thirdBasketItem.SubMerchantKey = "sub merchant key"; - thirdBasketItem.SubMerchantPrice = "0.18"; - basketItems.Add(thirdBasketItem); - request.BasketItems = basketItems; - - Payment payment = Payment.Create(request, options); - - PrintResponse(payment); - - Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); - Assert.AreEqual(Locale.TR.ToString(), payment.Locale); - Assert.AreEqual("123456789", payment.ConversationId); - Assert.IsNotNull(payment.SystemTime); - Assert.IsNull(payment.ErrorCode); - Assert.IsNull(payment.ErrorMessage); - Assert.IsNull(payment.ErrorGroup); - } - - [Test] - public void Should_Create_Payment_With_Registered_Card() - { - 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(); - - PaymentCard paymentCard = new PaymentCard(); - paymentCard.CardUserKey = "card user key"; - paymentCard.CardToken = "card token"; - 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 basketItems = new List(); - 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; - - Payment payment = Payment.Create(request, options); - - PrintResponse(payment); - - Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); - Assert.AreEqual(Locale.TR.ToString(), payment.Locale); - Assert.AreEqual("123456789", payment.ConversationId); - Assert.IsNotNull(payment.SystemTime); - Assert.IsNull(payment.ErrorCode); - Assert.IsNull(payment.ErrorMessage); - Assert.IsNull(payment.ErrorGroup); - } - - [Test] - public void Should_Create_Ucs_Payment_And_Register_Card() - { - CreatePaymentRequest request = new CreatePaymentRequest(); - request.Locale = Locale.TR.ToString(); - request.ConversationId = "123456789"; - request.Price = "1.0"; - request.PaidPrice = "1.2"; - request.Currency = Currency.TRY.ToString(); - request.GsmNumber = "+905350000000"; - request.Installment = 1; - request.BasketId = "B67832"; - request.PaymentChannel = PaymentChannel.WEB.ToString(); - request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); - - PaymentCard paymentCard = new PaymentCard(); - paymentCard.CardHolderName = "John Doe"; - paymentCard.CardNumber = "5528790000000008"; - paymentCard.ExpireMonth = "12"; - paymentCard.ExpireYear = "2030"; - paymentCard.Cvc = "123"; - paymentCard.RegisterConsumerCard = "false"; - request.PaymentCard = paymentCard; - - Buyer buyer = new Buyer(); - buyer.Id = "BY789"; - buyer.Name = "John"; - buyer.Surname = "Doe"; - buyer.GsmNumber = "+905350000000"; - buyer.Email = "emailbusra@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 basketItems = new List(); - 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; - - Payment payment = Payment.Create(request, options); - - PrintResponse(payment); - - Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); - Assert.AreEqual(Locale.TR.ToString(), payment.Locale); - Assert.AreEqual("123456789", payment.ConversationId); - Assert.IsNotNull(payment.SystemTime); - Assert.IsNull(payment.ErrorCode); - Assert.IsNull(payment.ErrorMessage); - Assert.IsNull(payment.ErrorGroup); - } - - [Test] - public void Should_Create_Ucs_Payment_With_Registered_Card() - { - 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(); - - PaymentCard paymentCard = new PaymentCard(); - paymentCard.CardToken = "card Token"; - paymentCard.ConsumerToken = "consumer Token"; - paymentCard.UcsToken = "ucs Token"; - 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 basketItems = new List(); - 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; - - Payment payment = Payment.Create(request, options); - - PrintResponse(payment); - - Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); - Assert.AreEqual(Locale.TR.ToString(), payment.Locale); - Assert.AreEqual("123456789", payment.ConversationId); - Assert.IsNotNull(payment.SystemTime); - Assert.IsNull(payment.ErrorCode); - Assert.IsNull(payment.ErrorMessage); - Assert.IsNull(payment.ErrorGroup); - } - - [Test] - public void Should_Retrieve_Payment_Result() - { - RetrievePaymentRequest request = new RetrievePaymentRequest(); - request.Locale = Locale.TR.ToString(); - request.ConversationId = "123456789"; - request.PaymentId = "1"; - request.PaymentConversationId = "123456789"; - - Payment payment = Payment.Retrieve(request, options); - - PrintResponse(payment); - - Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); - Assert.AreEqual(Locale.TR.ToString(), payment.Locale); - Assert.AreEqual("123456789", payment.ConversationId); - Assert.IsNotNull(payment.SystemTime); - Assert.IsNull(payment.ErrorCode); - Assert.IsNull(payment.ErrorMessage); - Assert.IsNull(payment.ErrorGroup); - } - } + public class PaymentSample : Sample + { + [Test] + public void Should_Create_Payment() + { + CreatePaymentRequest request = new CreatePaymentRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Price = "1.0"; + 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(); + + 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 basketItems = new List(); + 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; + + Payment payment = Payment.Create(request, options); + + PrintResponse(payment); + + Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); + Assert.AreEqual(Locale.TR.ToString(), payment.Locale); + Assert.AreEqual("123456789", payment.ConversationId); + Assert.IsNotNull(payment.SystemTime); + Assert.IsNull(payment.ErrorCode); + Assert.IsNull(payment.ErrorMessage); + Assert.IsNull(payment.ErrorGroup); + } + + [Test] + public void Should_Create_Payment_Usage_Reward() + { + CreatePaymentRequest request = new CreatePaymentRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Price = "1.0"; + 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(); + + 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 basketItems = new List(); + 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; + + LoyaltyReward loyaltyReward = new LoyaltyReward(); + loyaltyReward.RewardAmount = "0.1"; + loyaltyReward.RewardUsage = 1; + request.Reward = loyaltyReward; + + Payment payment = Payment.Create(request, options); + PrintResponse(payment); + + Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); + Assert.AreEqual(Locale.TR.ToString(), payment.Locale); + Assert.AreEqual("123456789", payment.ConversationId); + Assert.IsNotNull(payment.SystemTime); + Assert.IsNull(payment.ErrorCode); + Assert.IsNull(payment.ErrorMessage); + Assert.IsNull(payment.ErrorGroup); + } + + [Test] + public void Should_Create_Marketplace_Payment() + { + 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(); + + PaymentCard paymentCard = new PaymentCard(); + paymentCard.CardHolderName = "John Doe"; + paymentCard.CardNumber = "5528790000000008"; + paymentCard.ExpireMonth = "12"; + paymentCard.ExpireYear = "2020"; + 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 basketItems = new List(); + 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"; + firstBasketItem.SubMerchantKey = "sub merchant key"; + firstBasketItem.SubMerchantPrice = "0.27"; + 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"; + secondBasketItem.SubMerchantKey = "sub merchant key"; + secondBasketItem.SubMerchantPrice = "0.42"; + 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"; + thirdBasketItem.SubMerchantKey = "sub merchant key"; + thirdBasketItem.SubMerchantPrice = "0.18"; + basketItems.Add(thirdBasketItem); + request.BasketItems = basketItems; + + Payment payment = Payment.Create(request, options); + + PrintResponse(payment); + + Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); + Assert.AreEqual(Locale.TR.ToString(), payment.Locale); + Assert.AreEqual("123456789", payment.ConversationId); + Assert.IsNotNull(payment.SystemTime); + Assert.IsNull(payment.ErrorCode); + Assert.IsNull(payment.ErrorMessage); + Assert.IsNull(payment.ErrorGroup); + } + + [Test] + public void Should_Create_Payment_With_Registered_Card() + { + 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(); + + PaymentCard paymentCard = new PaymentCard(); + paymentCard.CardUserKey = "card user key"; + paymentCard.CardToken = "card token"; + 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 basketItems = new List(); + 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; + + Payment payment = Payment.Create(request, options); + + PrintResponse(payment); + + Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); + Assert.AreEqual(Locale.TR.ToString(), payment.Locale); + Assert.AreEqual("123456789", payment.ConversationId); + Assert.IsNotNull(payment.SystemTime); + Assert.IsNull(payment.ErrorCode); + Assert.IsNull(payment.ErrorMessage); + Assert.IsNull(payment.ErrorGroup); + } + + [Test] + public void Should_Create_Ucs_Payment_And_Register_Card() + { + CreatePaymentRequest request = new CreatePaymentRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Price = "1.0"; + request.PaidPrice = "1.2"; + request.Currency = Currency.TRY.ToString(); + request.GsmNumber = "+905350000000"; + request.Installment = 1; + request.BasketId = "B67832"; + request.PaymentChannel = PaymentChannel.WEB.ToString(); + request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); + + PaymentCard paymentCard = new PaymentCard(); + paymentCard.CardHolderName = "John Doe"; + paymentCard.CardNumber = "5528790000000008"; + paymentCard.ExpireMonth = "12"; + paymentCard.ExpireYear = "2030"; + paymentCard.Cvc = "123"; + paymentCard.RegisterConsumerCard = "false"; + request.PaymentCard = paymentCard; + + Buyer buyer = new Buyer(); + buyer.Id = "BY789"; + buyer.Name = "John"; + buyer.Surname = "Doe"; + buyer.GsmNumber = "+905350000000"; + buyer.Email = "emailbusra@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 basketItems = new List(); + 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; + + Payment payment = Payment.Create(request, options); + + PrintResponse(payment); + + Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); + Assert.AreEqual(Locale.TR.ToString(), payment.Locale); + Assert.AreEqual("123456789", payment.ConversationId); + Assert.IsNotNull(payment.SystemTime); + Assert.IsNull(payment.ErrorCode); + Assert.IsNull(payment.ErrorMessage); + Assert.IsNull(payment.ErrorGroup); + } + + [Test] + public void Should_Create_Ucs_Payment_With_Registered_Card() + { + 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(); + + PaymentCard paymentCard = new PaymentCard(); + paymentCard.CardToken = "card Token"; + paymentCard.ConsumerToken = "consumer Token"; + paymentCard.UcsToken = "ucs Token"; + 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 basketItems = new List(); + 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; + + Payment payment = Payment.Create(request, options); + + PrintResponse(payment); + + Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); + Assert.AreEqual(Locale.TR.ToString(), payment.Locale); + Assert.AreEqual("123456789", payment.ConversationId); + Assert.IsNotNull(payment.SystemTime); + Assert.IsNull(payment.ErrorCode); + Assert.IsNull(payment.ErrorMessage); + Assert.IsNull(payment.ErrorGroup); + } + + [Test] + public void Should_Retrieve_Payment_Result() + { + RetrievePaymentRequest request = new RetrievePaymentRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.PaymentId = "1"; + request.PaymentConversationId = "123456789"; + + Payment payment = Payment.Retrieve(request, options); + + PrintResponse(payment); + + Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); + Assert.AreEqual(Locale.TR.ToString(), payment.Locale); + Assert.AreEqual("123456789", payment.ConversationId); + Assert.IsNotNull(payment.SystemTime); + Assert.IsNull(payment.ErrorCode); + Assert.IsNull(payment.ErrorMessage); + Assert.IsNull(payment.ErrorGroup); + } + + } } diff --git a/Iyzipay.Samples/TransactionReportSample.cs b/Iyzipay.Samples/TransactionReportSample.cs index 43b113f..1d81539 100644 --- a/Iyzipay.Samples/TransactionReportSample.cs +++ b/Iyzipay.Samples/TransactionReportSample.cs @@ -30,5 +30,30 @@ public void Should_Retrieve_TransactionReport() Assert.IsNotNull(transactionReport.SystemTime); Assert.IsNull(transactionReport.ErrorMessage); } + + [Test] + public void Should_Retrieve_ScrollTransactionReport() + { + RetrieveScrollTransactionReportRequest request = new RetrieveScrollTransactionReportRequest() + { + ConversationId = "123", + TransactionDate = "2018-06-28", + Locale = Locale.TR.ToString(), + DocumentScrollVoSortingOrder ="ASC", + LastId = 1689853839161 + }; + + TransactionReport transactionReport = TransactionReport.Retrieve(request, options); + + PrintResponse(transactionReport); + + Assert.AreEqual(Status.SUCCESS.ToString(), transactionReport.Status); + Assert.AreEqual(200, transactionReport.StatusCode); + Assert.AreEqual("123", transactionReport.ConversationId); + Assert.AreEqual(1, transactionReport.CurrentPage); + Assert.IsNotNull(transactionReport.TotalPageCount); + Assert.IsNotNull(transactionReport.SystemTime); + Assert.IsNull(transactionReport.ErrorMessage); + } } } diff --git a/Iyzipay.Tests/Functional/ApiTest.cs b/Iyzipay.Tests/Functional/ApiTest.cs deleted file mode 100644 index 0585582..0000000 --- a/Iyzipay.Tests/Functional/ApiTest.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Iyzipay.Model; -using NUnit.Framework; - -namespace Iyzipay.Tests.Functional -{ - public class ApiTest : BaseTest - { - [Test] - public void Should_Test_Api() - { - IyzipayResource iyzipayResource = Model.ApiTest.Retrieve(_options); - - PrintResponse(iyzipayResource); - - Assert.AreEqual(Status.SUCCESS.ToString(), iyzipayResource.Status); - Assert.AreEqual(Locale.TR.ToString(), iyzipayResource.Locale); - Assert.NotNull(iyzipayResource.SystemTime); - Assert.Null(iyzipayResource.ErrorCode); - Assert.Null(iyzipayResource.ErrorMessage); - Assert.Null(iyzipayResource.ErrorGroup); - } - } -} diff --git a/Iyzipay.Tests/Functional/IyziLinkTest.cs b/Iyzipay.Tests/Functional/IyziLinkTest.cs index d689500..8b8678e 100644 --- a/Iyzipay.Tests/Functional/IyziLinkTest.cs +++ b/Iyzipay.Tests/Functional/IyziLinkTest.cs @@ -9,7 +9,7 @@ namespace Iyzipay.Tests.Functional { public class IyziLinkTest : BaseTest { - + /*[Test] public void Should_Create_IyziLink() { @@ -22,8 +22,10 @@ public void Should_Create_IyziLink() request.Price = "1"; request.Currency = Currency.TRY.ToString(); request.AddressIgnorable = false; - request.SoldLimit = 1; + request.StockEnabled = true; + request.StockCount = 1; request.InstallmentRequested = false; + request.SourceType = "API"; ResponseData response = IyziLink.Create(request, _options); PrintResponse(response); @@ -36,7 +38,7 @@ public void Should_Create_IyziLink() Assert.NotNull(response.Data.ImageUrl); Assert.NotNull(response.Data.Token); }*/ - + /*[Test] public void Should_Update_IyziLink() { @@ -77,7 +79,7 @@ public void Should_Update_IyziLink() Assert.NotNull(response.Data.ImageUrl); Assert.NotNull(response.Data.Token); }*/ - + /*[Test] public void Should_Retrieve_IyziLinks_With_Pagination() { @@ -112,7 +114,7 @@ public void Should_Retrieve_IyziLinks_With_Pagination() Assert.AreEqual(1,response.Data.Items.Count); Assert.AreEqual(1,response.Data.CurrentPage); }*/ - + /*[Test] public void Should_Retrieve_IyziLink_With_Token() { @@ -149,7 +151,7 @@ public void Should_Retrieve_IyziLink_With_Token() Assert.AreEqual(false,response.Data.AddressIgnorable); Assert.NotNull(response.Data.ImageUrl); }*/ - + /*[Test] public void Should_Delete_IyziLink() { diff --git a/Iyzipay.Tests/Functional/SubscriptionCustomer.cs b/Iyzipay.Tests/Functional/SubscriptionCustomer.cs index ef93a44..f8d5be7 100644 --- a/Iyzipay.Tests/Functional/SubscriptionCustomer.cs +++ b/Iyzipay.Tests/Functional/SubscriptionCustomer.cs @@ -7,260 +7,309 @@ namespace Iyzipay.Tests.Functional { - public class SubscriptionCustomer : BaseTest - { - [Test] - public void Should_Create_Customer() - { - string randomString = $"{DateTime.Now:yyyyMMddHHmmssfff}"; - CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest - { - Email = $"iyzico-{randomString}@iyzico.com", - Locale = Locale.TR.ToString(), - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - ConversationId = "123456789", - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }; + public class SubscriptionCustomer : BaseTest + { + [Test] + public void Should_Create_Customer() + { + string randomString = $"{DateTime.Now:yyyyMMddHHmmssfff}"; + CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest + { + Email = $"iyzico-{randomString}@iyzico.com", + Locale = Locale.TR.ToString(), + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + ConversationId = "123456789", + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }; - ResponseData response = Customer.Create(createCustomerRequest, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.AreEqual($"iyzico-{randomString}@iyzico.com",response.Data.Email); - Assert.AreEqual("customer-name",response.Data.Name); - Assert.AreEqual("customer-surname",response.Data.Surname); - Assert.AreEqual("+905350000000",response.Data.GsmNumber); - Assert.AreEqual("55555555555",response.Data.IdentityNumber); - Assert.AreEqual("İstanbul",response.Data.BillingAddress.City); - Assert.AreEqual("Türkiye",response.Data.BillingAddress.Country); - Assert.AreEqual("billing-address-description",response.Data.BillingAddress.Description); - Assert.AreEqual("billing-contact-name",response.Data.BillingAddress.ContactName); - Assert.AreEqual("010101",response.Data.BillingAddress.ZipCode); - Assert.AreEqual("İstanbul",response.Data.ShippingAddress.City); - Assert.AreEqual("Türkiye",response.Data.ShippingAddress.Country); - Assert.AreEqual("shipping-address-description",response.Data.ShippingAddress.Description); - Assert.AreEqual("shipping-contact-name",response.Data.ShippingAddress.ContactName); - Assert.AreEqual("010102",response.Data.ShippingAddress.ZipCode); - Assert.IsNotNull(response.Data.ReferenceCode); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - } - - [Test] - public void Should_Update_Customer() - { - string randomString = $"{DateTime.Now:yyyyMMddHHmmssfff}"; - CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest - { - Email = $"iyzico-{randomString}@iyzico.com", - Locale = Locale.TR.ToString(), - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - ConversationId = "123456789", - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }; + ResponseData response = Customer.Create(createCustomerRequest, _options); + PrintResponse(response); - ResponseData createCustomerResponse = Customer.Create(createCustomerRequest, _options); + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.AreEqual($"iyzico-{randomString}@iyzico.com", response.Data.Email); + Assert.AreEqual("customer-name", response.Data.Name); + Assert.AreEqual("customer-surname", response.Data.Surname); + Assert.AreEqual("+905350000000", response.Data.GsmNumber); + Assert.AreEqual("55555555555", response.Data.IdentityNumber); + Assert.AreEqual("İstanbul", response.Data.BillingAddress.City); + Assert.AreEqual("Türkiye", response.Data.BillingAddress.Country); + Assert.AreEqual("billing-address-description", response.Data.BillingAddress.Description); + Assert.AreEqual("billing-contact-name", response.Data.BillingAddress.ContactName); + Assert.AreEqual("010101", response.Data.BillingAddress.ZipCode); + Assert.AreEqual("İstanbul", response.Data.ShippingAddress.City); + Assert.AreEqual("Türkiye", response.Data.ShippingAddress.Country); + Assert.AreEqual("shipping-address-description", response.Data.ShippingAddress.Description); + Assert.AreEqual("shipping-contact-name", response.Data.ShippingAddress.ContactName); + Assert.AreEqual("010102", response.Data.ShippingAddress.ZipCode); + Assert.IsNotNull(response.Data.ReferenceCode); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + } - UpdateCustomerRequest updateCustomerRequest = new UpdateCustomerRequest - { - Locale = Locale.TR.ToString(), - Name = "upd-customer-name", - Surname = "upd-customer-surname", - BillingAddress = new Address - { - City = "upd-İstanbul", - Country = "upd-Türkiye", - Description = "upd-billing-address-description", - ContactName = "upd-billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "upd-İstanbul", - Country = "upd-Türkiye", - Description = "upd-shipping-address-description", - ContactName = "upd-shipping-contact-name", - ZipCode = "010102" - }, - ConversationId = "123456789", - IdentityNumber = "55555555551", - CustomerReferenceCode = createCustomerResponse.Data.ReferenceCode - }; - - ResponseData response = Customer.Update(updateCustomerRequest, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.AreEqual($"iyzico-{randomString}@iyzico.com",response.Data.Email); - Assert.AreEqual("upd-customer-name",response.Data.Name); - Assert.AreEqual("upd-customer-surname",response.Data.Surname); - Assert.AreEqual("+905350000000",response.Data.GsmNumber); - Assert.AreEqual("55555555551",response.Data.IdentityNumber); - Assert.AreEqual("upd-İstanbul",response.Data.BillingAddress.City); - Assert.AreEqual("upd-Türkiye",response.Data.BillingAddress.Country); - Assert.AreEqual("upd-billing-address-description",response.Data.BillingAddress.Description); - Assert.AreEqual("upd-billing-contact-name",response.Data.BillingAddress.ContactName); - Assert.AreEqual("010101",response.Data.BillingAddress.ZipCode); - Assert.AreEqual("upd-İstanbul",response.Data.ShippingAddress.City); - Assert.AreEqual("upd-Türkiye",response.Data.ShippingAddress.Country); - Assert.AreEqual("upd-shipping-address-description",response.Data.ShippingAddress.Description); - Assert.AreEqual("upd-shipping-contact-name",response.Data.ShippingAddress.ContactName); - Assert.AreEqual("010102",response.Data.ShippingAddress.ZipCode); - Assert.IsNotNull(response.Data.ReferenceCode); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - } - - [Test] - public void Should_Retrieve_Customer() - { - string randomString = $"{DateTime.Now:yyyyMMddHHmmssfff}"; - CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest - { - Email = $"iyzico-{randomString}@iyzico.com", - Locale = Locale.TR.ToString(), - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - ConversationId = "123456789", - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }; + [Test] + public void Should_Update_Customer() + { + string randomString = $"{DateTime.Now:yyyyMMddHHmmssfff}"; + CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest + { + Email = $"iyzico-{randomString}@iyzico.com", + Locale = Locale.TR.ToString(), + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + ConversationId = "123456789", + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }; - ResponseData createCustomerResponse = Customer.Create(createCustomerRequest, _options); + ResponseData createCustomerResponse = Customer.Create(createCustomerRequest, _options); - RetrieveCustomerRequest retrieveCustomerRequest = new RetrieveCustomerRequest - { - Locale = Locale.TR.ToString(), - ConversationId = "123456789", - CustomerReferenceCode = createCustomerResponse.Data.ReferenceCode - }; - - ResponseData response = Customer.Retrieve(retrieveCustomerRequest, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.AreEqual($"iyzico-{randomString}@iyzico.com",response.Data.Email); - Assert.AreEqual("customer-name",response.Data.Name); - Assert.AreEqual("customer-surname",response.Data.Surname); - Assert.AreEqual("+905350000000",response.Data.GsmNumber); - Assert.AreEqual("55555555555",response.Data.IdentityNumber); - Assert.AreEqual("İstanbul",response.Data.BillingAddress.City); - Assert.AreEqual("Türkiye",response.Data.BillingAddress.Country); - Assert.AreEqual("billing-address-description",response.Data.BillingAddress.Description); - Assert.AreEqual("billing-contact-name",response.Data.BillingAddress.ContactName); - Assert.AreEqual("010101",response.Data.BillingAddress.ZipCode); - Assert.AreEqual("İstanbul",response.Data.ShippingAddress.City); - Assert.AreEqual("Türkiye",response.Data.ShippingAddress.Country); - Assert.AreEqual("shipping-address-description",response.Data.ShippingAddress.Description); - Assert.AreEqual("shipping-contact-name",response.Data.ShippingAddress.ContactName); - Assert.AreEqual("010102",response.Data.ShippingAddress.ZipCode); - Assert.IsNotNull(response.Data.ReferenceCode); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - } - - [Test] - public void Should_RetrieveAll_Customer() - { - string randomString = $"{DateTime.Now:yyyyMMddHHmmssfff}"; - CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest - { - Email = $"iyzico-{randomString}@iyzico.com", - Locale = Locale.TR.ToString(), - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - ConversationId = "123456789", - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }; + UpdateCustomerRequest updateCustomerRequest = new UpdateCustomerRequest + { + Locale = Locale.TR.ToString(), + Name = "upd-customer-name", + Surname = "upd-customer-surname", + Enail = "upd-customer-email", + GsmNumber = "upd-customer-gsm-number", + BillingAddress = new Address + { + City = "upd-İstanbul", + Country = "upd-Türkiye", + Description = "upd-billing-address-description", + ContactName = "upd-billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "upd-İstanbul", + Country = "upd-Türkiye", + Description = "upd-shipping-address-description", + ContactName = "upd-shipping-contact-name", + ZipCode = "010102" + }, + ConversationId = "123456789", + IdentityNumber = "55555555551", + CustomerReferenceCode = createCustomerResponse.Data.ReferenceCode + }; - Customer.Create(createCustomerRequest, _options); + ResponseData response = Customer.Update(updateCustomerRequest, _options); + PrintResponse(response); - PagingRequest pagingRequest = new PagingRequest - { - Locale = Locale.TR.ToString(), - ConversationId = "123456789", - Page = 1, - Count = 1 - }; + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.AreEqual($"iyzico-{randomString}@iyzico.com", response.Data.Email); + Assert.AreEqual("upd-customer-name", response.Data.Name); + Assert.AreEqual("upd-customer-surname", response.Data.Surname); + Assert.AreEqual("+905350000000", response.Data.GsmNumber); + Assert.AreEqual("55555555551", response.Data.IdentityNumber); + Assert.AreEqual("upd-İstanbul", response.Data.BillingAddress.City); + Assert.AreEqual("upd-Türkiye", response.Data.BillingAddress.Country); + Assert.AreEqual("upd-billing-address-description", response.Data.BillingAddress.Description); + Assert.AreEqual("upd-billing-contact-name", response.Data.BillingAddress.ContactName); + Assert.AreEqual("010101", response.Data.BillingAddress.ZipCode); + Assert.AreEqual("upd-İstanbul", response.Data.ShippingAddress.City); + Assert.AreEqual("upd-Türkiye", response.Data.ShippingAddress.Country); + Assert.AreEqual("upd-shipping-address-description", response.Data.ShippingAddress.Description); + Assert.AreEqual("upd-shipping-contact-name", response.Data.ShippingAddress.ContactName); + Assert.AreEqual("010102", response.Data.ShippingAddress.ZipCode); + Assert.IsNotNull(response.Data.ReferenceCode); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + } - ResponsePagingData response = Customer.RetrieveAll(pagingRequest, _options); - PrintResponse(response); - - Assert.AreEqual(response.Status,Status.SUCCESS.ToString()); - Assert.AreEqual(1,response.Data.Items.Count); - Assert.AreEqual(1, response.Data.CurrentPage); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - } + [Test] + public void Should_Delete_Customer() + { + string randomString = $"{DateTime.Now:yyyyMMddHHmmssfff}"; + CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest + { + Email = $"iyzico-{randomString}@iyzico.com", + Locale = Locale.TR.ToString(), + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + ConversationId = "123456789", + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }; - } + ResponseData createCustomerResponse = Customer.Create(createCustomerRequest, _options); + DeleteCustomerRequest deleteCustomerRequest = new DeleteCustomerRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + CustomerReferenceCode = createCustomerResponse.Data.ReferenceCode + }; + + IyzipayResourceV2 response = Customer.Delete(deleteCustomerRequest, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + } + + [Test] + public void Should_Retrieve_Customer() + { + string randomString = $"{DateTime.Now:yyyyMMddHHmmssfff}"; + CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest + { + Email = $"iyzico-{randomString}@iyzico.com", + Locale = Locale.TR.ToString(), + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + ConversationId = "123456789", + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }; + + ResponseData createCustomerResponse = Customer.Create(createCustomerRequest, _options); + + RetrieveCustomerRequest retrieveCustomerRequest = new RetrieveCustomerRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + CustomerReferenceCode = createCustomerResponse.Data.ReferenceCode + }; + + ResponseData response = Customer.Retrieve(retrieveCustomerRequest, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.AreEqual($"iyzico-{randomString}@iyzico.com", response.Data.Email); + Assert.AreEqual("customer-name", response.Data.Name); + Assert.AreEqual("customer-surname", response.Data.Surname); + Assert.AreEqual("+905350000000", response.Data.GsmNumber); + Assert.AreEqual("55555555555", response.Data.IdentityNumber); + Assert.AreEqual("İstanbul", response.Data.BillingAddress.City); + Assert.AreEqual("Türkiye", response.Data.BillingAddress.Country); + Assert.AreEqual("billing-address-description", response.Data.BillingAddress.Description); + Assert.AreEqual("billing-contact-name", response.Data.BillingAddress.ContactName); + Assert.AreEqual("010101", response.Data.BillingAddress.ZipCode); + Assert.AreEqual("İstanbul", response.Data.ShippingAddress.City); + Assert.AreEqual("Türkiye", response.Data.ShippingAddress.Country); + Assert.AreEqual("shipping-address-description", response.Data.ShippingAddress.Description); + Assert.AreEqual("shipping-contact-name", response.Data.ShippingAddress.ContactName); + Assert.AreEqual("010102", response.Data.ShippingAddress.ZipCode); + Assert.IsNotNull(response.Data.ReferenceCode); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + } + + [Test] + public void Should_RetrieveAll_Customer() + { + string randomString = $"{DateTime.Now:yyyyMMddHHmmssfff}"; + CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest + { + Email = $"iyzico-{randomString}@iyzico.com", + Locale = Locale.TR.ToString(), + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + ConversationId = "123456789", + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }; + + Customer.Create(createCustomerRequest, _options); + + PagingRequest pagingRequest = new PagingRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + Page = 1, + Count = 1 + }; + + ResponsePagingData response = Customer.RetrieveAll(pagingRequest, _options); + PrintResponse(response); + + Assert.AreEqual(response.Status, Status.SUCCESS.ToString()); + Assert.AreEqual(1, response.Data.Items.Count); + Assert.AreEqual(1, response.Data.CurrentPage); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + } + + } } \ No newline at end of file diff --git a/Iyzipay.Tests/Functional/SubscriptionTest.cs b/Iyzipay.Tests/Functional/SubscriptionTest.cs index cc9f203..357038a 100644 --- a/Iyzipay.Tests/Functional/SubscriptionTest.cs +++ b/Iyzipay.Tests/Functional/SubscriptionTest.cs @@ -9,856 +9,1024 @@ namespace Iyzipay.Tests.Functional { - public class SubscriptionTest : BaseTest - { - - [Test] - public void Should_Initialize_CheckoutForm() - { - string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); - CreateProductRequest createProductRequest = new CreateProductRequest - { - Description = "product-description", - Locale = Locale.TR.ToString(), - Name = $"product-name-{randomString}", - ConversationId = "123456789" - }; - - ResponseData createProductResponse = Product.Create(createProductRequest, _options); - - CreatePlanRequest createPlanRequest = new CreatePlanRequest() - { - Locale = Locale.TR.ToString(), - Name = $"plan-name-{randomString}", - ConversationId = "123456789", - TrialPeriodDays = 3, - Price = "5.23", - CurrencyCode = Currency.TRY.ToString(), - PaymentInterval = PaymentInterval.WEEKLY.ToString(), - RecurrenceCount = 12, - PaymentIntervalCount = 1, - PlanPaymentType = PlanPaymentType.RECURRING.ToString(), - ProductReferenceCode = createProductResponse.Data.ReferenceCode - }; - - PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; - - InitializeCheckoutFormRequest request = new InitializeCheckoutFormRequest - { - Locale = Locale.TR.ToString(), - Customer = new CheckoutFormCustomer - { - Email = $"iyzico-{randomString}@iyzico.com", - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - GsmNumber = "+905350000000", - IdentityNumber = "55555555555", - }, - CallbackUrl = "https://www.google.com", - ConversationId = "123456789", - PricingPlanReferenceCode = planResource.ReferenceCode, - SubscriptionInitialStatus = SubscriptionStatus.PENDING.ToString() - }; - - CheckoutFormResource response = Subscription.InitializeCheckoutForm(request, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.IsNotNull(response.SystemTime); - Assert.IsNotNull(response.CheckoutFormContent); - Assert.IsNotNull(response.Token); - Assert.IsNotNull(response.TokenExpireTime); - Assert.Null(response.ErrorMessage); - } - - [Test] - public void Should_Initialize_Subscription() - { - string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); - CreateProductRequest createProductRequest = new CreateProductRequest - { - Description = "product-description", - Locale = Locale.TR.ToString(), - Name = $"product-name-{randomString}", - ConversationId = "123456789" - }; - - ResponseData createProductResponse = Product.Create(createProductRequest, _options); - - CreatePlanRequest createPlanRequest = new CreatePlanRequest() - { - Locale = Locale.TR.ToString(), - Name = $"plan-name-{randomString}", - ConversationId = "123456789", - TrialPeriodDays = 3, - Price = "5.23", - CurrencyCode = Currency.TRY.ToString(), - PaymentInterval = PaymentInterval.WEEKLY.ToString(), - RecurrenceCount = 12, - PaymentIntervalCount = 1, - PlanPaymentType = PlanPaymentType.RECURRING.ToString(), - ProductReferenceCode = createProductResponse.Data.ReferenceCode - }; - - PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; - - SubscriptionInitializeRequest request = new SubscriptionInitializeRequest - { - Locale = Locale.TR.ToString(), - Customer = new CheckoutFormCustomer - { - Email = $"iyzico-{randomString}@iyzico.com", - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }, - PaymentCard = new CardInfo - { - CardNumber = "5528790000000008", - CardHolderName = "iyzico", - ExpireMonth = "12", - ExpireYear = "2029", - Cvc = "123", - RegisterConsumerCard = true - }, - ConversationId = "123456789", - PricingPlanReferenceCode = planResource.ReferenceCode - }; - - ResponseData response = Subscription.Initialize(request, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - Assert.NotNull(response.Data.ReferenceCode); - Assert.NotNull(response.Data.ParentReferenceCode); - Assert.AreEqual(planResource.ReferenceCode,response.Data.PricingPlanReferenceCode); - Assert.AreEqual(SubscriptionStatus.ACTIVE.ToString(),response.Data.SubscriptionStatus); - Assert.AreEqual(3,response.Data.TrialDays); - Assert.NotNull(response.Data.TrialStartDate); - Assert.NotNull(response.Data.TrialEndDate); - Assert.NotNull(response.Data.StartDate); - - } - - [Test] - public void Should_Activate_Subscription() - { - string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); - CreateProductRequest createProductRequest = new CreateProductRequest - { - Description = "product-description", - Locale = Locale.TR.ToString(), - Name = $"product-name-{randomString}", - ConversationId = "123456789" - }; - - ResponseData createProductResponse = Product.Create(createProductRequest, _options); - - CreatePlanRequest createPlanRequest = new CreatePlanRequest() - { - Locale = Locale.TR.ToString(), - Name = $"plan-name-{randomString}", - ConversationId = "123456789", - TrialPeriodDays = 3, - Price = "5.23", - CurrencyCode = Currency.TRY.ToString(), - PaymentInterval = PaymentInterval.WEEKLY.ToString(), - RecurrenceCount = 12, - PaymentIntervalCount = 1, - PlanPaymentType = PlanPaymentType.RECURRING.ToString(), - ProductReferenceCode = createProductResponse.Data.ReferenceCode - }; - - PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; - - SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest - { - Locale = Locale.TR.ToString(), - Customer = new CheckoutFormCustomer - { - Email = $"iyzico-{randomString}@iyzico.com", - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }, - PaymentCard = new CardInfo - { - CardNumber = "5528790000000008", - CardHolderName = "iyzico", - ExpireMonth = "12", - ExpireYear = "2029", - Cvc = "123", - RegisterConsumerCard = true - }, - ConversationId = "123456789", - PricingPlanReferenceCode = planResource.ReferenceCode, - SubscriptionInitialStatus = SubscriptionStatus.PENDING.ToString() - }; - - ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); - - ActivateSubscriptionRequest request = new ActivateSubscriptionRequest - { - Locale = Locale.TR.ToString(), - ConversationId = "123456789", - SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode - }; - - IyzipayResourceV2 response = Subscription.Activate(request, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - } - - [Ignore("Test needs failed payment (OrderStatus=Failed,SubscriptionStatus=Unpaid), but we can not supply this condition in test now.")] - public void Should_Retry_Subscription() - { - string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); - CreateProductRequest createProductRequest = new CreateProductRequest - { - Description = "product-description", - Locale = Locale.TR.ToString(), - Name = $"product-name-{randomString}", - ConversationId = "123456789" - }; - - ResponseData createProductResponse = Product.Create(createProductRequest, _options); - - CreatePlanRequest createPlanRequest = new CreatePlanRequest - { - Locale = Locale.TR.ToString(), - Name = $"plan-name-{randomString}", - ConversationId = "123456789", - Price = "5.23", - CurrencyCode = Currency.TRY.ToString(), - PaymentInterval = PaymentInterval.WEEKLY.ToString(), - RecurrenceCount = 12, - PaymentIntervalCount = 1, - PlanPaymentType = PlanPaymentType.RECURRING.ToString(), - ProductReferenceCode = createProductResponse.Data.ReferenceCode - }; - - PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; - - SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest - { - Locale = Locale.TR.ToString(), - Customer = new CheckoutFormCustomer - { - Email = $"iyzico-{randomString}@iyzico.com", - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }, - PaymentCard = new CardInfo - { - CardNumber = "5528790000000008", - CardHolderName = "iyzico", - ExpireMonth = "12", - ExpireYear = "2029", - Cvc = "123" - }, - ConversationId = "123456789", - PricingPlanReferenceCode = planResource.ReferenceCode, - SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() - }; - - ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); - - RetrieveSubscriptionRequest retrieveSubscriptionRequest = new RetrieveSubscriptionRequest - { - Locale = Locale.TR.ToString(), - ConversationId = "123456789", - SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode - }; - ResponseData subscriptionResponse = Subscription.Retrieve(retrieveSubscriptionRequest, _options); - - RetrySubscriptionRequest request = new RetrySubscriptionRequest() - { - Locale = Locale.TR.ToString(), - ConversationId = "123456789", - SubscriptionOrderReferenceCode = subscriptionResponse.Data.SubscriptionOrders.FirstOrDefault()?.ReferenceCode - }; - - IyzipayResourceV2 response = Subscription.Retry(request, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - } - - [Test] - public void Should_Upgrade_Subscription() - { - string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); - CreateProductRequest createProductRequest = new CreateProductRequest - { - Description = "product-description", - Locale = Locale.TR.ToString(), - Name = $"product-name-{randomString}", - ConversationId = "123456789" - }; - - ResponseData createProductResponse = Product.Create(createProductRequest, _options); - - CreatePlanRequest createPlanRequest = new CreatePlanRequest() - { - Locale = Locale.TR.ToString(), - Name = $"plan-name-{randomString}", - ConversationId = "123456789", - TrialPeriodDays = 3, - Price = "5.23", - CurrencyCode = Currency.TRY.ToString(), - PaymentInterval = PaymentInterval.WEEKLY.ToString(), - RecurrenceCount = 12, - PaymentIntervalCount = 1, - PlanPaymentType = PlanPaymentType.RECURRING.ToString(), - ProductReferenceCode = createProductResponse.Data.ReferenceCode - }; - - PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; - - SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest - { - Locale = Locale.TR.ToString(), - Customer = new CheckoutFormCustomer - { - Email = $"iyzico-{randomString}@iyzico.com", - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }, - PaymentCard = new CardInfo - { - CardNumber = "5528790000000008", - CardHolderName = "iyzico", - ExpireMonth = "12", - ExpireYear = "2029", - Cvc = "123", - RegisterConsumerCard = true - }, - ConversationId = "123456789", - PricingPlanReferenceCode = planResource.ReferenceCode, - SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() - }; - - ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); - - CreatePlanRequest newPlanRequest = new CreatePlanRequest() - { - Locale = Locale.TR.ToString(), - Name = $"new-plan-name-{randomString}", - ConversationId = "123456789", - TrialPeriodDays = 2, - Price = "3.23", - CurrencyCode = Currency.TRY.ToString(), - PaymentInterval = PaymentInterval.WEEKLY.ToString(), - RecurrenceCount = 2, - PaymentIntervalCount = 1, - PlanPaymentType = PlanPaymentType.RECURRING.ToString(), - ProductReferenceCode = createProductResponse.Data.ReferenceCode - }; - - PlanResource newPlanResource = Plan.Create(newPlanRequest, _options).Data; - - UpgradeSubscriptionRequest request = new UpgradeSubscriptionRequest - { - Locale = Locale.TR.ToString(), - ConversationId = "123456789", - SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode, - NewPricingPlanReferenceCode = newPlanResource.ReferenceCode, - UseTrial = true, - ResetRecurrenceCount = true, - UpgradePeriod = SubscriptionUpgradePeriod.NOW.ToString() - }; - - IyzipayResourceV2 response = Subscription.Upgrade(request, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - } - - [Test] - public void Should_Cancel_Subscription() - { - string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); - CreateProductRequest createProductRequest = new CreateProductRequest - { - Description = "product-description", - Locale = Locale.TR.ToString(), - Name = $"product-name-{randomString}", - ConversationId = "123456789" - }; - - ResponseData createProductResponse = Product.Create(createProductRequest, _options); - - CreatePlanRequest createPlanRequest = new CreatePlanRequest() - { - Locale = Locale.TR.ToString(), - Name = $"plan-name-{randomString}", - ConversationId = "123456789", - TrialPeriodDays = 3, - Price = "5.23", - CurrencyCode = Currency.TRY.ToString(), - PaymentInterval = PaymentInterval.WEEKLY.ToString(), - RecurrenceCount = 12, - PaymentIntervalCount = 1, - PlanPaymentType = PlanPaymentType.RECURRING.ToString(), - ProductReferenceCode = createProductResponse.Data.ReferenceCode - }; - - PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; - - SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest - { - Locale = Locale.TR.ToString(), - Customer = new CheckoutFormCustomer - { - Email = $"iyzico-{randomString}@iyzico.com", - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }, - PaymentCard = new CardInfo - { - CardNumber = "5528790000000008", - CardHolderName = "iyzico", - ExpireMonth = "12", - ExpireYear = "2029", - Cvc = "123", - RegisterConsumerCard = true - }, - ConversationId = "123456789", - PricingPlanReferenceCode = planResource.ReferenceCode, - SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() - }; - - ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); - - CancelSubscriptionRequest request = new CancelSubscriptionRequest - { - Locale = Locale.TR.ToString(), - ConversationId = "123456789", - SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode - }; - - IyzipayResourceV2 response = Subscription.Cancel(request, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - } - - [Test] - public void Should_Retrieve_Subscription() - { - string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); - CreateProductRequest createProductRequest = new CreateProductRequest - { - Description = "product-description", - Locale = Locale.TR.ToString(), - Name = $"product-name-{randomString}", - ConversationId = "123456789" - }; - - ResponseData createProductResponse = Product.Create(createProductRequest, _options); - - CreatePlanRequest createPlanRequest = new CreatePlanRequest() - { - Locale = Locale.TR.ToString(), - Name = $"plan-name-{randomString}", - ConversationId = "123456789", - TrialPeriodDays = 3, - Price = "5.23", - CurrencyCode = Currency.TRY.ToString(), - PaymentInterval = PaymentInterval.WEEKLY.ToString(), - RecurrenceCount = 12, - PaymentIntervalCount = 1, - PlanPaymentType = PlanPaymentType.RECURRING.ToString(), - ProductReferenceCode = createProductResponse.Data.ReferenceCode - }; - - PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; - - SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest - { - Locale = Locale.TR.ToString(), - Customer = new CheckoutFormCustomer - { - Email = $"iyzico-{randomString}@iyzico.com", - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }, - PaymentCard = new CardInfo - { - CardNumber = "5528790000000008", - CardHolderName = "iyzico", - ExpireMonth = "12", - ExpireYear = "2029", - Cvc = "123", - RegisterConsumerCard = true - }, - ConversationId = "123456789", - PricingPlanReferenceCode = planResource.ReferenceCode, - SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() - }; - - ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); - - RetrieveSubscriptionRequest request = new RetrieveSubscriptionRequest - { - Locale = Locale.TR.ToString(), - ConversationId = "123456789", - SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode - }; - - ResponseData response = Subscription.Retrieve(request, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - Assert.NotNull(response.Data.ReferenceCode); - Assert.NotNull(response.Data.ParentReferenceCode); - Assert.AreEqual(planResource.ReferenceCode,response.Data.PricingPlanReferenceCode); - Assert.AreEqual(SubscriptionStatus.ACTIVE.ToString(),response.Data.SubscriptionStatus); - Assert.AreEqual($"iyzico-{randomString}@iyzico.com",response.Data.CustomerEmail); - Assert.AreEqual(3,response.Data.TrialDays); - Assert.NotNull(response.Data.TrialStartDate); - Assert.NotNull(response.Data.TrialEndDate); - Assert.NotNull(response.Data.StartDate); - } - - [Test] - public void Should_Search_Subscription() - { - string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); - CreateProductRequest createProductRequest = new CreateProductRequest - { - Description = "product-description", - Locale = Locale.TR.ToString(), - Name = $"product-name-{randomString}", - ConversationId = "123456789" - }; - - ResponseData createProductResponse = Product.Create(createProductRequest, _options); - - CreatePlanRequest createPlanRequest = new CreatePlanRequest() - { - Locale = Locale.TR.ToString(), - Name = $"plan-name-{randomString}", - ConversationId = "123456789", - TrialPeriodDays = 3, - Price = "5.23", - CurrencyCode = Currency.TRY.ToString(), - PaymentInterval = PaymentInterval.WEEKLY.ToString(), - RecurrenceCount = 12, - PaymentIntervalCount = 1, - PlanPaymentType = PlanPaymentType.RECURRING.ToString(), - ProductReferenceCode = createProductResponse.Data.ReferenceCode - }; - - PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; - - SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest - { - Locale = Locale.TR.ToString(), - Customer = new CheckoutFormCustomer - { - Email = $"iyzico-{randomString}@iyzico.com", - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }, - PaymentCard = new CardInfo - { - CardNumber = "5528790000000008", - CardHolderName = "iyzico", - ExpireMonth = "12", - ExpireYear = "2029", - Cvc = "123", - RegisterConsumerCard = true - }, - ConversationId = "123456789", - PricingPlanReferenceCode = planResource.ReferenceCode, - SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() - }; - - ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); - - SearchSubscriptionRequest request = new SearchSubscriptionRequest - { - Locale = Locale.TR.ToString(), - ConversationId = "123456789", - SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode, - Page = 1, - Count = 1, - SubscriptionStatus = SubscriptionStatus.ACTIVE.ToString(), - PricingPlanReferenceCode = planResource.ReferenceCode - }; - - ResponsePagingData response = Subscription.Search(request, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.AreEqual(1,response.Data.Items.Count); - Assert.AreEqual(1, response.Data.CurrentPage); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - Assert.NotNull(response.Data.Items.First().ReferenceCode); - Assert.NotNull(response.Data.Items.First().ParentReferenceCode); - Assert.AreEqual(planResource.ReferenceCode,response.Data.Items.First().PricingPlanReferenceCode); - Assert.AreEqual(SubscriptionStatus.ACTIVE.ToString(),response.Data.Items.First().SubscriptionStatus); - Assert.AreEqual($"iyzico-{randomString}@iyzico.com",response.Data.Items.First().CustomerEmail); - Assert.AreEqual(3,response.Data.Items.First().TrialDays); - Assert.NotNull(response.Data.Items.First().TrialStartDate); - Assert.NotNull(response.Data.Items.First().TrialEndDate); - Assert.NotNull(response.Data.Items.First().StartDate); - } - - [Test] - public void Should_Update_Subscription_Card() - { - string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); - CreateProductRequest createProductRequest = new CreateProductRequest - { - Description = "product-description", - Locale = Locale.TR.ToString(), - Name = $"product-name-{randomString}", - ConversationId = "123456789" - }; - - ResponseData createProductResponse = Product.Create(createProductRequest, _options); - - CreatePlanRequest createPlanRequest = new CreatePlanRequest() - { - Locale = Locale.TR.ToString(), - Name = $"plan-name-{randomString}", - ConversationId = "123456789", - TrialPeriodDays = 3, - Price = "5.23", - CurrencyCode = Currency.TRY.ToString(), - PaymentInterval = PaymentInterval.WEEKLY.ToString(), - RecurrenceCount = 12, - PaymentIntervalCount = 1, - PlanPaymentType = PlanPaymentType.RECURRING.ToString(), - ProductReferenceCode = createProductResponse.Data.ReferenceCode - }; - - PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; - - SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest - { - Locale = Locale.TR.ToString(), - Customer = new CheckoutFormCustomer - { - Email = $"iyzico-{randomString}@iyzico.com", - Name = "customer-name", - Surname = "customer-surname", - BillingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "billing-address-description", - ContactName = "billing-contact-name", - ZipCode = "010101" - }, - ShippingAddress = new Address - { - City = "İstanbul", - Country = "Türkiye", - Description = "shipping-address-description", - ContactName = "shipping-contact-name", - ZipCode = "010102" - }, - - GsmNumber = "+905350000000", - IdentityNumber = "55555555555" - }, - PaymentCard = new CardInfo - { - CardNumber = "5528790000000008", - CardHolderName = "iyzico", - ExpireMonth = "12", - ExpireYear = "2029", - Cvc = "123", - RegisterConsumerCard = true - }, - ConversationId = "123456789", - PricingPlanReferenceCode = planResource.ReferenceCode, - SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() - }; - - ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); - - UpdateCardRequest request = new UpdateCardRequest - { - Locale = Locale.TR.ToString(), - ConversationId = "123456789", - CustomerReferenceCode = initializeResponse.Data.CustomerReferenceCode, - CallbackUrl = "https://www.google.com" - }; - - UpdateCardFormResource response = Subscription.UpdateCard(request, _options); - PrintResponse(response); - - Assert.AreEqual(Status.SUCCESS.ToString(),response.Status); - Assert.IsNotNull(response.SystemTime); - Assert.Null(response.ErrorMessage); - Assert.NotNull(response.CheckoutFormContent); - Assert.NotNull(response.Token); - Assert.NotNull(response.TokenExpireTime); - } - } + public class SubscriptionTest : BaseTest + { + + [Test] + public void Should_Initialize_CheckoutForm() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 3, + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + InitializeCheckoutFormRequest request = new InitializeCheckoutFormRequest + { + Locale = Locale.TR.ToString(), + Customer = new CheckoutFormCustomer + { + Email = $"iyzico-{randomString}@iyzico.com", + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + GsmNumber = "+905350000000", + IdentityNumber = "55555555555", + }, + CallbackUrl = "https://www.google.com", + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode, + SubscriptionInitialStatus = SubscriptionStatus.PENDING.ToString() + }; + + CheckoutFormResource response = Subscription.InitializeCheckoutForm(request, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.IsNotNull(response.SystemTime); + Assert.IsNotNull(response.CheckoutFormContent); + Assert.IsNotNull(response.Token); + Assert.IsNotNull(response.TokenExpireTime); + Assert.Null(response.ErrorMessage); + } + [Test] + public void Should_Initialize_CheckoutForm_Result() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 3, + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + InitializeCheckoutFormRequest request = new InitializeCheckoutFormRequest + { + Locale = Locale.TR.ToString(), + Customer = new CheckoutFormCustomer + { + Email = $"iyzico-{randomString}@iyzico.com", + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + GsmNumber = "+905350000000", + IdentityNumber = "55555555555", + }, + CallbackUrl = "https://www.google.com", + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode, + SubscriptionInitialStatus = SubscriptionStatus.PENDING.ToString() + }; + + CheckoutFormResource response = Subscription.InitializeCheckoutForm(request, _options); + + + GetCheckoutFormResultRequest getCheckoutFormResultRequest = new GetCheckoutFormResultRequest() + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + Token = response.Token + }; + + ResponseData resultResponse = Subscription.GetCheckoutFormResult(getCheckoutFormResultRequest, _options); + + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), resultResponse.Status); + Assert.IsNotNull(resultResponse.SystemTime); + Assert.Null(resultResponse.ErrorMessage); + } + + [Test] + public void Should_Initialize_Subscription() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 3, + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + SubscriptionInitializeRequest request = new SubscriptionInitializeRequest + { + Locale = Locale.TR.ToString(), + Customer = new CheckoutFormCustomer + { + Email = $"iyzico-{randomString}@iyzico.com", + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }, + PaymentCard = new CardInfo + { + CardNumber = "5528790000000008", + CardHolderName = "iyzico", + ExpireMonth = "12", + ExpireYear = "2029", + Cvc = "123", + RegisterConsumerCard = true + }, + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode + }; + + ResponseData response = Subscription.Initialize(request, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + Assert.NotNull(response.Data.ReferenceCode); + Assert.NotNull(response.Data.ParentReferenceCode); + Assert.AreEqual(planResource.ReferenceCode, response.Data.PricingPlanReferenceCode); + Assert.AreEqual(SubscriptionStatus.ACTIVE.ToString(), response.Data.SubscriptionStatus); + Assert.AreEqual(3, response.Data.TrialDays); + Assert.NotNull(response.Data.TrialStartDate); + Assert.NotNull(response.Data.TrialEndDate); + Assert.NotNull(response.Data.StartDate); + + } + + [Test] + public void Should_Initialize_Subscription_With_Customer() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 3, + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + CreateCustomerRequest createCustomerRequest = new CreateCustomerRequest + { + Email = $"iyzico-{randomString}@iyzico.com", + Locale = Locale.TR.ToString(), + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + ConversationId = "123456789", + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }; + + ResponseData customerResponse = Customer.Create(createCustomerRequest, _options); + + SubscriptionInitializeWithCustomerRequest request = new SubscriptionInitializeWithCustomerRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode, + CustomerReferenceCode = customerResponse.Data.ReferenceCode, + SubscriptionInitialStatus = "ACTIVE" + }; + + ResponseData response = Subscription.InitializeWithCustomer(request, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + Assert.NotNull(response.Data.ReferenceCode); + Assert.NotNull(response.Data.ParentReferenceCode); + Assert.AreEqual(planResource.ReferenceCode, response.Data.PricingPlanReferenceCode); + Assert.AreEqual(SubscriptionStatus.ACTIVE.ToString(), response.Data.SubscriptionStatus); + Assert.AreEqual(3, response.Data.TrialDays); + Assert.NotNull(response.Data.TrialStartDate); + Assert.NotNull(response.Data.TrialEndDate); + Assert.NotNull(response.Data.StartDate); + + } + + [Test] + public void Should_Activate_Subscription() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 3, + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest + { + Locale = Locale.TR.ToString(), + Customer = new CheckoutFormCustomer + { + Email = $"iyzico-{randomString}@iyzico.com", + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }, + PaymentCard = new CardInfo + { + CardNumber = "5528790000000008", + CardHolderName = "iyzico", + ExpireMonth = "12", + ExpireYear = "2029", + Cvc = "123", + RegisterConsumerCard = true + }, + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode, + SubscriptionInitialStatus = SubscriptionStatus.PENDING.ToString() + }; + + ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); + + ActivateSubscriptionRequest request = new ActivateSubscriptionRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode + }; + + IyzipayResourceV2 response = Subscription.Activate(request, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + } + + [Ignore("Test needs failed payment (OrderStatus=Failed,SubscriptionStatus=Unpaid), but we can not supply this condition in test now.")] + public void Should_Retry_Subscription() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest + { + Locale = Locale.TR.ToString(), + Customer = new CheckoutFormCustomer + { + Email = $"iyzico-{randomString}@iyzico.com", + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }, + PaymentCard = new CardInfo + { + CardNumber = "5528790000000008", + CardHolderName = "iyzico", + ExpireMonth = "12", + ExpireYear = "2029", + Cvc = "123" + }, + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode, + SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() + }; + + ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); + + RetrieveSubscriptionRequest retrieveSubscriptionRequest = new RetrieveSubscriptionRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode + }; + ResponseData subscriptionResponse = Subscription.Retrieve(retrieveSubscriptionRequest, _options); + + RetrySubscriptionRequest request = new RetrySubscriptionRequest() + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + SubscriptionOrderReferenceCode = subscriptionResponse.Data.SubscriptionOrders.FirstOrDefault()?.ReferenceCode + }; + + IyzipayResourceV2 response = Subscription.Retry(request, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + } + + [Test] + public void Should_Upgrade_Subscription() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 3, + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest + { + Locale = Locale.TR.ToString(), + Customer = new CheckoutFormCustomer + { + Email = $"iyzico-{randomString}@iyzico.com", + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }, + PaymentCard = new CardInfo + { + CardNumber = "5528790000000008", + CardHolderName = "iyzico", + ExpireMonth = "12", + ExpireYear = "2029", + Cvc = "123", + RegisterConsumerCard = true + }, + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode, + SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() + }; + + ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); + + CreatePlanRequest newPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"new-plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 2, + Price = "3.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 2, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource newPlanResource = Plan.Create(newPlanRequest, _options).Data; + + UpgradeSubscriptionRequest request = new UpgradeSubscriptionRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode, + NewPricingPlanReferenceCode = newPlanResource.ReferenceCode, + UseTrial = true, + ResetRecurrenceCount = true, + UpgradePeriod = SubscriptionUpgradePeriod.NOW.ToString() + }; + + IyzipayResourceV2 response = Subscription.Upgrade(request, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + } + + [Test] + public void Should_Cancel_Subscription() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 3, + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest + { + Locale = Locale.TR.ToString(), + Customer = new CheckoutFormCustomer + { + Email = $"iyzico-{randomString}@iyzico.com", + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }, + PaymentCard = new CardInfo + { + CardNumber = "5528790000000008", + CardHolderName = "iyzico", + ExpireMonth = "12", + ExpireYear = "2029", + Cvc = "123", + RegisterConsumerCard = true + }, + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode, + SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() + }; + + ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); + + CancelSubscriptionRequest request = new CancelSubscriptionRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode + }; + + IyzipayResourceV2 response = Subscription.Cancel(request, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + } + + [Test] + public void Should_Retrieve_Subscription() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 3, + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest + { + Locale = Locale.TR.ToString(), + Customer = new CheckoutFormCustomer + { + Email = $"iyzico-{randomString}@iyzico.com", + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }, + PaymentCard = new CardInfo + { + CardNumber = "5528790000000008", + CardHolderName = "iyzico", + ExpireMonth = "12", + ExpireYear = "2029", + Cvc = "123", + RegisterConsumerCard = true + }, + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode, + SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() + }; + + ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); + + RetrieveSubscriptionRequest request = new RetrieveSubscriptionRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode + }; + + ResponseData response = Subscription.Retrieve(request, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + Assert.NotNull(response.Data.ReferenceCode); + Assert.NotNull(response.Data.ParentReferenceCode); + Assert.AreEqual(planResource.ReferenceCode, response.Data.PricingPlanReferenceCode); + Assert.AreEqual(SubscriptionStatus.ACTIVE.ToString(), response.Data.SubscriptionStatus); + Assert.AreEqual($"iyzico-{randomString}@iyzico.com", response.Data.CustomerEmail); + Assert.AreEqual(3, response.Data.TrialDays); + Assert.NotNull(response.Data.TrialStartDate); + Assert.NotNull(response.Data.TrialEndDate); + Assert.NotNull(response.Data.StartDate); + } + + [Test] + public void Should_Search_Subscription() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 3, + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest + { + Locale = Locale.TR.ToString(), + Customer = new CheckoutFormCustomer + { + Email = $"iyzico-{randomString}@iyzico.com", + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }, + PaymentCard = new CardInfo + { + CardNumber = "5528790000000008", + CardHolderName = "iyzico", + ExpireMonth = "12", + ExpireYear = "2029", + Cvc = "123", + RegisterConsumerCard = true + }, + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode, + SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() + }; + + ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); + + SearchSubscriptionRequest request = new SearchSubscriptionRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + SubscriptionReferenceCode = initializeResponse.Data.ReferenceCode, + Page = 1, + Count = 1, + SubscriptionStatus = SubscriptionStatus.ACTIVE.ToString(), + PricingPlanReferenceCode = planResource.ReferenceCode + }; + + ResponsePagingData response = Subscription.Search(request, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.AreEqual(1, response.Data.Items.Count); + Assert.AreEqual(1, response.Data.CurrentPage); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + Assert.NotNull(response.Data.Items.First().ReferenceCode); + Assert.NotNull(response.Data.Items.First().ParentReferenceCode); + Assert.AreEqual(planResource.ReferenceCode, response.Data.Items.First().PricingPlanReferenceCode); + Assert.AreEqual(SubscriptionStatus.ACTIVE.ToString(), response.Data.Items.First().SubscriptionStatus); + Assert.AreEqual($"iyzico-{randomString}@iyzico.com", response.Data.Items.First().CustomerEmail); + Assert.AreEqual(3, response.Data.Items.First().TrialDays); + Assert.NotNull(response.Data.Items.First().TrialStartDate); + Assert.NotNull(response.Data.Items.First().TrialEndDate); + Assert.NotNull(response.Data.Items.First().StartDate); + } + + [Test] + public void Should_Update_Subscription_Card() + { + string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + CreateProductRequest createProductRequest = new CreateProductRequest + { + Description = "product-description", + Locale = Locale.TR.ToString(), + Name = $"product-name-{randomString}", + ConversationId = "123456789" + }; + + ResponseData createProductResponse = Product.Create(createProductRequest, _options); + + CreatePlanRequest createPlanRequest = new CreatePlanRequest() + { + Locale = Locale.TR.ToString(), + Name = $"plan-name-{randomString}", + ConversationId = "123456789", + TrialPeriodDays = 3, + Price = "5.23", + CurrencyCode = Currency.TRY.ToString(), + PaymentInterval = PaymentInterval.WEEKLY.ToString(), + RecurrenceCount = 12, + PaymentIntervalCount = 1, + PlanPaymentType = PlanPaymentType.RECURRING.ToString(), + ProductReferenceCode = createProductResponse.Data.ReferenceCode + }; + + PlanResource planResource = Plan.Create(createPlanRequest, _options).Data; + + SubscriptionInitializeRequest subscriptionInitializeRequest = new SubscriptionInitializeRequest + { + Locale = Locale.TR.ToString(), + Customer = new CheckoutFormCustomer + { + Email = $"iyzico-{randomString}@iyzico.com", + Name = "customer-name", + Surname = "customer-surname", + BillingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "billing-address-description", + ContactName = "billing-contact-name", + ZipCode = "010101" + }, + ShippingAddress = new Address + { + City = "İstanbul", + Country = "Türkiye", + Description = "shipping-address-description", + ContactName = "shipping-contact-name", + ZipCode = "010102" + }, + + GsmNumber = "+905350000000", + IdentityNumber = "55555555555" + }, + PaymentCard = new CardInfo + { + CardNumber = "5528790000000008", + CardHolderName = "iyzico", + ExpireMonth = "12", + ExpireYear = "2029", + Cvc = "123", + RegisterConsumerCard = true + }, + ConversationId = "123456789", + PricingPlanReferenceCode = planResource.ReferenceCode, + SubscriptionInitialStatus = SubscriptionStatus.ACTIVE.ToString() + }; + + ResponseData initializeResponse = Subscription.Initialize(subscriptionInitializeRequest, _options); + + UpdateCardRequest request = new UpdateCardRequest + { + Locale = Locale.TR.ToString(), + ConversationId = "123456789", + CustomerReferenceCode = initializeResponse.Data.CustomerReferenceCode, + CallbackUrl = "https://www.google.com" + }; + + UpdateCardFormResource response = Subscription.UpdateCard(request, _options); + PrintResponse(response); + + Assert.AreEqual(Status.SUCCESS.ToString(), response.Status); + Assert.IsNotNull(response.SystemTime); + Assert.Null(response.ErrorMessage); + Assert.NotNull(response.CheckoutFormContent); + Assert.NotNull(response.Token); + Assert.NotNull(response.TokenExpireTime); + } + } } \ No newline at end of file diff --git a/Iyzipay/Model/ApiTest.cs b/Iyzipay/Model/ApiTest.cs deleted file mode 100644 index d692443..0000000 --- a/Iyzipay/Model/ApiTest.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Iyzipay.Model -{ - public class ApiTest : IyzipayResource - { - public static IyzipayResource Retrieve(Options options) - { - return RestHttpClient.Create().Get(options.BaseUrl + "/payment/test"); - } - } -} diff --git a/Iyzipay/Model/BasketItem.cs b/Iyzipay/Model/BasketItem.cs index 0ee3fa5..1cbee4e 100644 --- a/Iyzipay/Model/BasketItem.cs +++ b/Iyzipay/Model/BasketItem.cs @@ -2,29 +2,31 @@ namespace Iyzipay.Model { - public class BasketItem : RequestStringConvertible - { - public String Id { get; set; } - public String Price { get; set; } - public String Name { get; set; } - public String Category1 { get; set; } - public String Category2 { get; set; } - public String ItemType { get; set; } - public String SubMerchantKey { get; set; } - public String SubMerchantPrice { get; set; } + public class BasketItem : RequestStringConvertible + { + public String Id { get; set; } + public String Price { get; set; } + public String Name { get; set; } + public String Category1 { get; set; } + public String Category2 { get; set; } + public String ItemType { get; set; } + public String SubMerchantKey { get; set; } + public String SubMerchantPrice { get; set; } + public bool ChargedFromMerchant { get; set; } - public String ToPKIRequestString() - { - return ToStringRequestBuilder.NewInstance() - .Append("id", Id) - .AppendPrice("price", Price) - .Append("name", Name) - .Append("category1", Category1) - .Append("category2", Category2) - .Append("itemType", ItemType) - .Append("subMerchantKey", SubMerchantKey) - .AppendPrice("subMerchantPrice", SubMerchantPrice) - .GetRequestString(); - } - } + public String ToPKIRequestString() + { + return ToStringRequestBuilder.NewInstance() + .Append("id", Id) + .AppendPrice("price", Price) + .Append("name", Name) + .Append("category1", Category1) + .Append("category2", Category2) + .Append("itemType", ItemType) + .Append("subMerchantKey", SubMerchantKey) + .AppendPrice("subMerchantPrice", SubMerchantPrice) + .Append("chargedFromMerchant", ChargedFromMerchant) + .GetRequestString(); + } + } } diff --git a/Iyzipay/Model/SubMerchantC2C.cs b/Iyzipay/Model/SubMerchantC2C.cs new file mode 100644 index 0000000..f561b1b --- /dev/null +++ b/Iyzipay/Model/SubMerchantC2C.cs @@ -0,0 +1,19 @@ +using Iyzipay.Request; +using System; + +namespace Iyzipay.Model +{ + public class SubMerchantC2C : IyzipayResource + { + public String TxId { get; set; } + + public static SubMerchantC2C Create(CreateC2CSubMerchantRequest request, Options options) + { + return RestHttpClient.Create().Post(options.BaseUrl + "/onboarding/settlement-to-balance/submerchant", GetHttpHeaders(request, options), request); + } + public static SubMerchantC2C Verify(VerifyC2CSubMerchantRequest request, Options options) + { + return RestHttpClient.Create().Post(options.BaseUrl + "/onboarding/settlement-to-balance/submerchant", GetHttpHeaders(request, options), request); + } + } +} diff --git a/Iyzipay/Model/V2/Iyzilink/FastLink/FastLink.cs b/Iyzipay/Model/V2/Iyzilink/FastLink/FastLink.cs new file mode 100644 index 0000000..9d91bec --- /dev/null +++ b/Iyzipay/Model/V2/Iyzilink/FastLink/FastLink.cs @@ -0,0 +1,43 @@ +using System; +using Iyzipay.Request; + +namespace Iyzipay.Model.V2.Iyzilink.FastLink +{ + public class FastLink : IyzipayResourceV2 + { + private static string V2_IYZILINK_FASTLINK_PRODUCTS = "/v2/iyzilink/fast-link/products"; + public static ResponseData Create(IyziFastLinkSaveRequest request, Options options) + { + string uri = options.BaseUrl + V2_IYZILINK_FASTLINK_PRODUCTS + GetQueryParams(request); + return RestHttpClientV2.Create().Post>(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + + private static string GetQueryParams(BaseRequestV2 request) + { + if (request == null) + { + return ""; + } + + string queryParams = "?conversationId=" + request.ConversationId; + + if (!String.IsNullOrEmpty(request.Locale)) + { + queryParams += "&locale=" + request.Locale; + } + + if (!(request is PagingRequest pagingRequest)) return queryParams; + + if (pagingRequest.Page != null) + { + queryParams += "&page=" + pagingRequest.Page; + } + + if (pagingRequest.Count != null) + { + queryParams += "&count=" + pagingRequest.Count; + } + return queryParams; + } + } +} diff --git a/Iyzipay/Model/V2/Iyzilink/FastLink/IyziFastLinkSave.cs b/Iyzipay/Model/V2/Iyzilink/FastLink/IyziFastLinkSave.cs new file mode 100644 index 0000000..479bff7 --- /dev/null +++ b/Iyzipay/Model/V2/Iyzilink/FastLink/IyziFastLinkSave.cs @@ -0,0 +1,9 @@ +namespace Iyzipay.Model.V2.Iyzilink.FastLink +{ + public class IyziFastLinkSave + { + public string Token { get; set; } + public string Url { get; set; } + public string ImageUrl { get; set; } + } +} diff --git a/Iyzipay/Model/V2/Iyzilink/IyziLink.cs b/Iyzipay/Model/V2/Iyzilink/IyziLink.cs index 927f3de..576863b 100644 --- a/Iyzipay/Model/V2/Iyzilink/IyziLink.cs +++ b/Iyzipay/Model/V2/Iyzilink/IyziLink.cs @@ -3,68 +3,80 @@ namespace Iyzipay.Model.V2.Iyzilink { - public class IyziLink : IyzipayResourceV2 - { - private static string V2_IYZILINK_PRODUCTS = "/v2/iyzilink/products"; - - public static ResponseData Create(IyziLinkSaveRequest request, Options options) - { - string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + GetQueryParams(request); - return RestHttpClientV2.Create().Post>(uri, GetHttpHeadersWithRequestBody(request, uri ,options), request); - } - - public static ResponseData Update(string token, IyziLinkSaveRequest request, Options options) - { - string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + "/" + token + GetQueryParams(request); - return RestHttpClientV2.Create().Put>(uri, GetHttpHeadersWithRequestBody(request, uri ,options), request); - } - - public static ResponsePagingData RetrieveAll(PagingRequest request, Options options) - { - string queryParams = GetQueryParams(request); - string iyzilinkQueryParam = "productType=IYZILINK"; - - queryParams = String.IsNullOrEmpty(queryParams) - ? "?" + iyzilinkQueryParam - : queryParams + "&" + iyzilinkQueryParam; - - string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + queryParams; - return RestHttpClientV2.Create().Get>(uri, GetHttpHeadersWithUrlParams(request,uri ,options)); - } - - public static ResponseData Retrieve(string token, BaseRequestV2 request, Options options) - { - string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + "/" + token + GetQueryParams(request); - return RestHttpClientV2.Create().Get>(uri, GetHttpHeadersWithUrlParams(request, uri ,options)); - } - - public static IyzipayResourceV2 Delete(string token, BaseRequestV2 request, Options options) - { - string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + "/" + token + GetQueryParams(request); - return RestHttpClientV2.Create().Delete(uri, GetHttpHeadersWithRequestBody(request, uri ,options),request); - } - - private static string GetQueryParams(BaseRequestV2 request) { - if (request == null) { - return ""; - } + public class IyziLink : IyzipayResourceV2 + { + private static string V2_IYZILINK_PRODUCTS = "/v2/iyzilink/products"; - string queryParams = "?conversationId=" + request.ConversationId; + public static ResponseData Create(IyziLinkSaveRequest request, Options options) + { + string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + GetQueryParams(request); + return RestHttpClientV2.Create().Post>(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } - if (!String.IsNullOrEmpty(request.Locale)) { - queryParams += "&locale=" + request.Locale; - } + public static ResponseData Update(string token, IyziLinkSaveRequest request, Options options) + { + string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + "/" + token + GetQueryParams(request); + return RestHttpClientV2.Create().Put>(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } - if (!(request is PagingRequest pagingRequest)) return queryParams; - - if (pagingRequest.Page != null) { - queryParams += "&page=" + pagingRequest.Page; - } + public static ResponseData UpdateStatus(string token, IyziLinkUpdateStatusRequest request, Options options) + { + var statusValue = request.Status ? "ACTIVE" : "PASSIVE"; + string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + "/" + token + $"/status/{statusValue}" + GetQueryParams(request); + return RestHttpClientV2.Create().Patch>(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } - if (pagingRequest.Count != null) { - queryParams += "&count=" + pagingRequest.Count; - } - return queryParams; - } - } + public static ResponsePagingData RetrieveAll(PagingRequest request, Options options) + { + string queryParams = GetQueryParams(request); + string iyzilinkQueryParam = "productType=IYZILINK"; + + queryParams = String.IsNullOrEmpty(queryParams) + ? "?" + iyzilinkQueryParam + : queryParams + "&" + iyzilinkQueryParam; + + string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + queryParams; + return RestHttpClientV2.Create().Get>(uri, GetHttpHeadersWithUrlParams(request, uri, options)); + } + + public static ResponseData Retrieve(string token, BaseRequestV2 request, Options options) + { + string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + "/" + token + GetQueryParams(request); + return RestHttpClientV2.Create().Get>(uri, GetHttpHeadersWithUrlParams(request, uri, options)); + } + + public static IyzipayResourceV2 Delete(string token, BaseRequestV2 request, Options options) + { + string uri = options.BaseUrl + V2_IYZILINK_PRODUCTS + "/" + token + GetQueryParams(request); + return RestHttpClientV2.Create().Delete(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + + private static string GetQueryParams(BaseRequestV2 request) + { + if (request == null) + { + return ""; + } + + string queryParams = "?conversationId=" + request.ConversationId; + + if (!String.IsNullOrEmpty(request.Locale)) + { + queryParams += "&locale=" + request.Locale; + } + + if (!(request is PagingRequest pagingRequest)) return queryParams; + + if (pagingRequest.Page != null) + { + queryParams += "&page=" + pagingRequest.Page; + } + + if (pagingRequest.Count != null) + { + queryParams += "&count=" + pagingRequest.Count; + } + return queryParams; + } + } } \ No newline at end of file diff --git a/Iyzipay/Model/V2/Subscription/CheckoutFormResource.cs b/Iyzipay/Model/V2/Subscription/CheckoutFormResource.cs index 8e13215..13bdff4 100644 --- a/Iyzipay/Model/V2/Subscription/CheckoutFormResource.cs +++ b/Iyzipay/Model/V2/Subscription/CheckoutFormResource.cs @@ -1,6 +1,6 @@ namespace Iyzipay.Model.V2.Subscription { - public class CheckoutFormResource : IyzipayResourceV2 + public class CheckoutFormResource : IyzipayResourceV2 { public string CheckoutFormContent { get; set; } public string Token { get; set; } diff --git a/Iyzipay/Model/V2/Subscription/CheckoutFormResult.cs b/Iyzipay/Model/V2/Subscription/CheckoutFormResult.cs new file mode 100644 index 0000000..7047279 --- /dev/null +++ b/Iyzipay/Model/V2/Subscription/CheckoutFormResult.cs @@ -0,0 +1,15 @@ +namespace Iyzipay.Model.V2.Subscription +{ + public class CheckoutFormResult : IyzipayResourceV2 + { + public string ReferenceCode { get; set; } + public string ParentReferenceCode { get; set; } + public string PricingPlanReferenceCode { get; set; } + public string CustomerReferenceCode { get; set; } + public string SubscriptionStatus { get; set; } + public int TrialDays { get; set; } + public long CreatedDate { get; set; } + public long StartDate { get; set; } + public long EndDate { get; set; } + } +} \ No newline at end of file diff --git a/Iyzipay/Model/V2/Subscription/Customer.cs b/Iyzipay/Model/V2/Subscription/Customer.cs index 511c1aa..616527b 100644 --- a/Iyzipay/Model/V2/Subscription/Customer.cs +++ b/Iyzipay/Model/V2/Subscription/Customer.cs @@ -16,7 +16,13 @@ public static ResponseData Update(UpdateCustomerRequest reques string uri = $"{options.BaseUrl}/v2/subscription/customers/{request.CustomerReferenceCode}"; return RestHttpClientV2.Create().Post>( uri, GetHttpHeadersWithRequestBody(request, uri ,options), request); } - + + public static IyzipayResourceV2 Delete(DeleteCustomerRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/customers/delete/{request.CustomerReferenceCode}"; + return RestHttpClientV2.Create().Post(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + public static ResponseData Retrieve(RetrieveCustomerRequest request, Options options) { string uri = $"{options.BaseUrl}/v2/subscription/customers/{request.CustomerReferenceCode}"; diff --git a/Iyzipay/Model/V2/Subscription/CustomerResource.cs b/Iyzipay/Model/V2/Subscription/CustomerResource.cs index a411ca6..2c50d9e 100644 --- a/Iyzipay/Model/V2/Subscription/CustomerResource.cs +++ b/Iyzipay/Model/V2/Subscription/CustomerResource.cs @@ -10,7 +10,9 @@ public class CustomerResource public string IdentityNumber { get; set; } public string Email { get; set; } public string GsmNumber { get; set; } - public Address BillingAddress { get; set; } + public string ContactEmail { get; set; } + public string ContactGsmNumber { get; set; } + public Address BillingAddress { get; set; } public Address ShippingAddress { get; set; } } } \ No newline at end of file diff --git a/Iyzipay/Model/V2/Subscription/Subscription.cs b/Iyzipay/Model/V2/Subscription/Subscription.cs index 7f2c417..c7371c4 100644 --- a/Iyzipay/Model/V2/Subscription/Subscription.cs +++ b/Iyzipay/Model/V2/Subscription/Subscription.cs @@ -3,109 +3,132 @@ namespace Iyzipay.Model.V2.Subscription { - public class Subscription : IyzipayResourceV2 - { - public static CheckoutFormResource InitializeCheckoutForm(InitializeCheckoutFormRequest request, Options options) - { - string uri = $"{options.BaseUrl}/v2/subscription/checkoutform/initialize"; - return RestHttpClientV2.Create().Post( uri, GetHttpHeadersWithRequestBody(request, uri ,options), request); - } - - public static UpdateCardFormResource UpdateCard(UpdateCardRequest request, Options options) - { - string uri = $"{options.BaseUrl}/v2/subscription/card-update/checkoutform/initialize"; - return RestHttpClientV2.Create().Post( uri, GetHttpHeadersWithRequestBody(request, uri ,options), request); - } - - public static ResponseData Initialize(SubscriptionInitializeRequest request, Options options) - { - string uri = $"{options.BaseUrl}/v2/subscription/initialize"; - return RestHttpClientV2.Create().Post>( uri, GetHttpHeadersWithRequestBody(request, uri ,options), request); - } - - public static IyzipayResourceV2 Activate(ActivateSubscriptionRequest request, Options options) - { - string uri = $"{options.BaseUrl}/v2/subscription/subscriptions/{request.SubscriptionReferenceCode}/activate"; - return RestHttpClientV2.Create().Post( uri, GetHttpHeadersWithRequestBody(request, uri ,options), request); - } - - public static IyzipayResourceV2 Retry(RetrySubscriptionRequest request, Options options) - { - string uri = $"{options.BaseUrl}/v2/subscription/operation/retry"; - return RestHttpClientV2.Create().Post( uri, GetHttpHeadersWithRequestBody(request, uri ,options), request); - } - - public static IyzipayResourceV2 Upgrade(UpgradeSubscriptionRequest request, Options options) - { - string uri = $"{options.BaseUrl}/v2/subscription/subscriptions/{request.SubscriptionReferenceCode}/upgrade"; - return RestHttpClientV2.Create().Post( uri, GetHttpHeadersWithRequestBody(request, uri ,options), request); - } - - public static IyzipayResourceV2 Cancel(CancelSubscriptionRequest request, Options options) - { - string uri = $"{options.BaseUrl}/v2/subscription/subscriptions/{request.SubscriptionReferenceCode}/cancel"; - return RestHttpClientV2.Create().Post( uri, GetHttpHeadersWithRequestBody(request, uri ,options), request); - } - - public static ResponseData Retrieve(RetrieveSubscriptionRequest request, Options options) - { - string uri = $"{options.BaseUrl}/v2/subscription/subscriptions/{request.SubscriptionReferenceCode}"; - return RestHttpClientV2.Create().Get>( uri, GetHttpHeadersWithUrlParams(request, uri ,options)); - } - - public static ResponsePagingData Search(SearchSubscriptionRequest request, Options options) - { - string uri = $"{options.BaseUrl}/v2/subscription/subscriptions{GetQueryParams(request)}"; - return RestHttpClientV2.Create().Get>( uri, GetHttpHeadersWithUrlParams(request, uri ,options)); - } - - private static string GetQueryParams(SearchSubscriptionRequest request) { - if (request == null) { - return ""; - } - - string queryParams = "?conversationId=" + request.ConversationId; - - if (!String.IsNullOrEmpty(request.Locale)) { - queryParams += "&locale=" + request.Locale; - } - - if (!String.IsNullOrEmpty(request.PricingPlanReferenceCode)) { - queryParams += "&pricingPlanReferenceCode=" + request.PricingPlanReferenceCode; - } - - if (!String.IsNullOrEmpty(request.SubscriptionReferenceCode)) { - queryParams += "&subscriptionReferenceCode=" + request.SubscriptionReferenceCode; - } - - if (!String.IsNullOrEmpty(request.ParentReferenceCode)) { - queryParams += "&parentReferenceCode=" + request.ParentReferenceCode; - } - - if (!String.IsNullOrEmpty(request.CustomerReferenceCode)) { - queryParams += "&customerReferenceCode=" + request.CustomerReferenceCode; - } - - if (!String.IsNullOrEmpty(request.SubscriptionStatus)) { - queryParams += "&subscriptionStatus=" + request.SubscriptionStatus; - } - - if (!String.IsNullOrEmpty(request.StartDate)) { - queryParams += "&startDate=" + request.StartDate; - } - - if (!String.IsNullOrEmpty(request.EndDate)) { - queryParams += "&endDate=" + request.EndDate; - } - - if (request.Page != null) { - queryParams += "&page=" + request.Page; - } - - if (request.Count != null) { - queryParams += "&count=" + request.Count; - } - return queryParams; - } - } + public class Subscription : IyzipayResourceV2 + { + public static CheckoutFormResource InitializeCheckoutForm(InitializeCheckoutFormRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/checkoutform/initialize"; + return RestHttpClientV2.Create().Post(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + + public static ResponseData GetCheckoutFormResult(GetCheckoutFormResultRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/checkoutform/{request.Token}"; + return RestHttpClientV2.Create().Get>(uri, GetHttpHeadersWithUrlParams(request, uri, options)); + } + + public static UpdateCardFormResource UpdateCard(UpdateCardRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/card-update/checkoutform/initialize"; + return RestHttpClientV2.Create().Post(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + + public static ResponseData Initialize(SubscriptionInitializeRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/initialize"; + return RestHttpClientV2.Create().Post>(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + public static ResponseData InitializeWithCustomer(SubscriptionInitializeWithCustomerRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/with-customer"; + return RestHttpClientV2.Create().Post>(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + + public static IyzipayResourceV2 Activate(ActivateSubscriptionRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/subscriptions/{request.SubscriptionReferenceCode}/activate"; + return RestHttpClientV2.Create().Post(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + + public static IyzipayResourceV2 Retry(RetrySubscriptionRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/operation/retry"; + return RestHttpClientV2.Create().Post(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + + public static IyzipayResourceV2 Upgrade(UpgradeSubscriptionRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/subscriptions/{request.SubscriptionReferenceCode}/upgrade"; + return RestHttpClientV2.Create().Post(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + + public static IyzipayResourceV2 Cancel(CancelSubscriptionRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/subscriptions/{request.SubscriptionReferenceCode}/cancel"; + return RestHttpClientV2.Create().Post(uri, GetHttpHeadersWithRequestBody(request, uri, options), request); + } + + public static ResponseData Retrieve(RetrieveSubscriptionRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/subscriptions/{request.SubscriptionReferenceCode}"; + return RestHttpClientV2.Create().Get>(uri, GetHttpHeadersWithUrlParams(request, uri, options)); + } + + public static ResponsePagingData Search(SearchSubscriptionRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/subscription/subscriptions{GetQueryParams(request)}"; + return RestHttpClientV2.Create().Get>(uri, GetHttpHeadersWithUrlParams(request, uri, options)); + } + + private static string GetQueryParams(SearchSubscriptionRequest request) + { + if (request == null) + { + return ""; + } + + string queryParams = "?conversationId=" + request.ConversationId; + + if (!String.IsNullOrEmpty(request.Locale)) + { + queryParams += "&locale=" + request.Locale; + } + + if (!String.IsNullOrEmpty(request.PricingPlanReferenceCode)) + { + queryParams += "&pricingPlanReferenceCode=" + request.PricingPlanReferenceCode; + } + + if (!String.IsNullOrEmpty(request.SubscriptionReferenceCode)) + { + queryParams += "&subscriptionReferenceCode=" + request.SubscriptionReferenceCode; + } + + if (!String.IsNullOrEmpty(request.ParentReferenceCode)) + { + queryParams += "&parentReferenceCode=" + request.ParentReferenceCode; + } + + if (!String.IsNullOrEmpty(request.CustomerReferenceCode)) + { + queryParams += "&customerReferenceCode=" + request.CustomerReferenceCode; + } + + if (!String.IsNullOrEmpty(request.SubscriptionStatus)) + { + queryParams += "&subscriptionStatus=" + request.SubscriptionStatus; + } + + if (!String.IsNullOrEmpty(request.StartDate)) + { + queryParams += "&startDate=" + request.StartDate; + } + + if (!String.IsNullOrEmpty(request.EndDate)) + { + queryParams += "&endDate=" + request.EndDate; + } + + if (request.Page != null) + { + queryParams += "&page=" + request.Page; + } + + if (request.Count != null) + { + queryParams += "&count=" + request.Count; + } + return queryParams; + } + } } \ No newline at end of file diff --git a/Iyzipay/Model/V2/Transaction/TransactionReport.cs b/Iyzipay/Model/V2/Transaction/TransactionReport.cs index 564c6ef..b941acf 100644 --- a/Iyzipay/Model/V2/Transaction/TransactionReport.cs +++ b/Iyzipay/Model/V2/Transaction/TransactionReport.cs @@ -14,5 +14,42 @@ public static TransactionReport Retrieve(RetrieveTransactionReportRequest reques + request.Page; return RestHttpClientV2.Create().Get(url, GetHttpHeadersWithUrlParams(request, url, options)); } - } + + public static TransactionReport Retrieve(RetrieveScrollTransactionReportRequest request, Options options) + { + string uri = $"{options.BaseUrl}/v2/reporting/payment/scroll-transactions{GetQueryParams(request)}"; + return RestHttpClientV2.Create().Get(uri, GetHttpHeadersWithUrlParams(request, uri, options)); + } + private static string GetQueryParams(RetrieveScrollTransactionReportRequest request) + { + if (request == null) + { + return ""; + } + + string queryParams = "?conversationId=" + request.ConversationId; + + if (!String.IsNullOrEmpty(request.Locale)) + { + queryParams += "&locale=" + request.Locale; + } + + if (!String.IsNullOrEmpty(request.DocumentScrollVoSortingOrder)) + { + queryParams += "&documentScrollVoSortingOrder=" + request.DocumentScrollVoSortingOrder; + } + + if (!String.IsNullOrEmpty(request.TransactionDate)) + { + queryParams += "&transactionDate=" + request.TransactionDate; + } + + if (request.LastId.HasValue) + { + queryParams += "&lastId=" + request.LastId; + } + + return queryParams; + } + } } diff --git a/Iyzipay/Request/CreateC2CSubMerchantRequest.cs b/Iyzipay/Request/CreateC2CSubMerchantRequest.cs new file mode 100644 index 0000000..992bbf2 --- /dev/null +++ b/Iyzipay/Request/CreateC2CSubMerchantRequest.cs @@ -0,0 +1,30 @@ +using System; + +namespace Iyzipay.Request +{ + public class CreateC2CSubMerchantRequest : BaseRequest + { + public String Name { get; set; } + public String Surname { get; set; } + public String Email { get; set; } + public String GsmNumber { get; set; } + public String TckNo { get; set; } + public String BirthDate { get; set; } + public String Address { get; set; } + public String ExternalId { get; set; } + + public override String ToPKIRequestString() + { + return ToStringRequestBuilder.NewInstance() + .AppendSuper(base.ToPKIRequestString()) + .Append("name", Name) + .Append("surname", Surname) + .Append("gsmNumber", GsmNumber) + .Append("tckNo", TckNo) + .Append("birthDate", BirthDate) + .Append("address", Address) + .Append("externalId", ExternalId) + .GetRequestString(); + } + } +} diff --git a/Iyzipay/Request/IyziFastLinkSaveRequest.cs b/Iyzipay/Request/IyziFastLinkSaveRequest.cs new file mode 100644 index 0000000..d7d92c2 --- /dev/null +++ b/Iyzipay/Request/IyziFastLinkSaveRequest.cs @@ -0,0 +1,14 @@ +using System; +using Newtonsoft.Json; + +namespace Iyzipay.Request +{ + public class IyziFastLinkSaveRequest : BaseRequestV2 + { + public string Description { get; set; } + public string Price { get; set; } + [JsonProperty(PropertyName = "currencyCode")] + public string Currency { get; set; } + public string SourceType { get; set; } + } +} \ No newline at end of file diff --git a/Iyzipay/Request/IyziLinkSaveRequest.cs b/Iyzipay/Request/IyziLinkSaveRequest.cs index 554ef20..b097a9f 100644 --- a/Iyzipay/Request/IyziLinkSaveRequest.cs +++ b/Iyzipay/Request/IyziLinkSaveRequest.cs @@ -3,22 +3,21 @@ namespace Iyzipay.Request { - public class IyziLinkSaveRequest : BaseRequestV2 - { - public string Name { get; set; } - public string Description { get; set; } - - [JsonProperty(PropertyName = "encodedImageFile")] - public string Base64EncodedImage { get; set; } - - public string Price { get; set; } - - [JsonProperty(PropertyName = "currencyCode")] - public string Currency { get; set; } - - public bool? AddressIgnorable { get; set; } - public int? SoldLimit { get; set; } - public bool? InstallmentRequested { get; set; } - - } + public class IyziLinkSaveRequest : BaseRequestV2 + { + public string Name { get; set; } + public string Description { get; set; } + [JsonProperty(PropertyName = "encodedImageFile")] + public string Base64EncodedImage { get; set; } + public string Price { get; set; } + [JsonProperty(PropertyName = "currencyCode")] + public string Currency { get; set; } + public bool? AddressIgnorable { get; set; } + + public bool StockEnabled { get; set; } + public int StockCount { get; set; } + public string SourceType { get; set; } + public bool? InstallmentRequested { get; set; } + + } } \ No newline at end of file diff --git a/Iyzipay/Request/IyziLinkUpdateStatusRequest.cs b/Iyzipay/Request/IyziLinkUpdateStatusRequest.cs new file mode 100644 index 0000000..e3d71eb --- /dev/null +++ b/Iyzipay/Request/IyziLinkUpdateStatusRequest.cs @@ -0,0 +1,7 @@ +namespace Iyzipay.Request +{ + public class IyziLinkUpdateStatusRequest : BaseRequestV2 + { + public bool Status { get; set; } + } +} \ No newline at end of file diff --git a/Iyzipay/Request/V2/RetrieveScrollTransactionReportRequest.cs b/Iyzipay/Request/V2/RetrieveScrollTransactionReportRequest.cs new file mode 100644 index 0000000..13ecf42 --- /dev/null +++ b/Iyzipay/Request/V2/RetrieveScrollTransactionReportRequest.cs @@ -0,0 +1,10 @@ +namespace Iyzipay.Request.V2 +{ + public class RetrieveScrollTransactionReportRequest : BaseRequestV2 + { + public string DocumentScrollVoSortingOrder { get; set; } + public string TransactionDate { get; set; } + public long? LastId { get; set; } + public string ConversationId { get; set; } + } +} \ No newline at end of file diff --git a/Iyzipay/Request/V2/RetrieveTransactionReportRequest.cs b/Iyzipay/Request/V2/RetrieveTransactionReportRequest.cs index cc8eb52..ef293cd 100644 --- a/Iyzipay/Request/V2/RetrieveTransactionReportRequest.cs +++ b/Iyzipay/Request/V2/RetrieveTransactionReportRequest.cs @@ -2,7 +2,7 @@ namespace Iyzipay.Request.V2 { - public class RetrieveTransactionReportRequest : BaseRequestV2 + public class RetrieveTransactionReportRequest : BaseRequestV2 { public String TransactionDate { get; set; } public int Page { get; set; } diff --git a/Iyzipay/Request/V2/Subscription/DeleteCustomerRequest.cs b/Iyzipay/Request/V2/Subscription/DeleteCustomerRequest.cs new file mode 100644 index 0000000..fcbb9ae --- /dev/null +++ b/Iyzipay/Request/V2/Subscription/DeleteCustomerRequest.cs @@ -0,0 +1,7 @@ +namespace Iyzipay.Request.V2.Subscription +{ + public class DeleteCustomerRequest : BaseRequestV2 + { + public string CustomerReferenceCode { get; set; } + } +} \ No newline at end of file diff --git a/Iyzipay/Request/V2/Subscription/GetCheckoutFormResultRequest.cs b/Iyzipay/Request/V2/Subscription/GetCheckoutFormResultRequest.cs new file mode 100644 index 0000000..39d04b6 --- /dev/null +++ b/Iyzipay/Request/V2/Subscription/GetCheckoutFormResultRequest.cs @@ -0,0 +1,7 @@ +namespace Iyzipay.Request.V2.Subscription +{ + public class GetCheckoutFormResultRequest : BaseRequestV2 + { + public string Token { get; set; } + } +} \ No newline at end of file diff --git a/Iyzipay/Request/V2/Subscription/InitializeCheckoutFormRequest.cs b/Iyzipay/Request/V2/Subscription/InitializeCheckoutFormRequest.cs index a09e79e..7d75e56 100644 --- a/Iyzipay/Request/V2/Subscription/InitializeCheckoutFormRequest.cs +++ b/Iyzipay/Request/V2/Subscription/InitializeCheckoutFormRequest.cs @@ -2,7 +2,7 @@ namespace Iyzipay.Request.V2.Subscription { - public class InitializeCheckoutFormRequest : BaseRequestV2 + public class InitializeCheckoutFormRequest : BaseRequestV2 { public string CallbackUrl { get; set; } public string PricingPlanReferenceCode { get; set; } diff --git a/Iyzipay/Request/V2/Subscription/SubscriptionInitializeWithCustomerRequest.cs b/Iyzipay/Request/V2/Subscription/SubscriptionInitializeWithCustomerRequest.cs new file mode 100644 index 0000000..fe00c76 --- /dev/null +++ b/Iyzipay/Request/V2/Subscription/SubscriptionInitializeWithCustomerRequest.cs @@ -0,0 +1,9 @@ +namespace Iyzipay.Request.V2.Subscription +{ + public class SubscriptionInitializeWithCustomerRequest : BaseRequestV2 + { + public string SubscriptionInitialStatus { get; set; } + public string PricingPlanReferenceCode { get; set; } + public string CustomerReferenceCode { get; set; } + } +} \ No newline at end of file diff --git a/Iyzipay/Request/V2/Subscription/UpdateCustomerRequest.cs b/Iyzipay/Request/V2/Subscription/UpdateCustomerRequest.cs index e82032a..666260b 100644 --- a/Iyzipay/Request/V2/Subscription/UpdateCustomerRequest.cs +++ b/Iyzipay/Request/V2/Subscription/UpdateCustomerRequest.cs @@ -2,11 +2,13 @@ namespace Iyzipay.Request.V2.Subscription { - public class UpdateCustomerRequest : BaseRequestV2 + public class UpdateCustomerRequest : BaseRequestV2 { public string CustomerReferenceCode { get; set; } public string Name { get; set; } public string Surname { get; set; } + public string Enail { get; set; } + public string GsmNumber { get; set; } public string IdentityNumber { get; set; } public Address BillingAddress { get; set; } public Address ShippingAddress { get; set; } diff --git a/Iyzipay/Request/VerifyC2CSubMerchantRequest.cs b/Iyzipay/Request/VerifyC2CSubMerchantRequest.cs new file mode 100644 index 0000000..02548c8 --- /dev/null +++ b/Iyzipay/Request/VerifyC2CSubMerchantRequest.cs @@ -0,0 +1,19 @@ +using System; + +namespace Iyzipay.Request +{ + public class VerifyC2CSubMerchantRequest : BaseRequest + { + public String TxId { get; set; } + public String SmsVerificationCode { get; set; } + + public override String ToPKIRequestString() + { + return ToStringRequestBuilder.NewInstance() + .AppendSuper(base.ToPKIRequestString()) + .Append("txId", TxId) + .Append("smsVerificationCode", SmsVerificationCode) + .GetRequestString(); + } + } +} diff --git a/Iyzipay/RestHttpClientV2.cs b/Iyzipay/RestHttpClientV2.cs index 87a3104..21c04d2 100644 --- a/Iyzipay/RestHttpClientV2.cs +++ b/Iyzipay/RestHttpClientV2.cs @@ -8,85 +8,85 @@ namespace Iyzipay { - class RestHttpClientV2 - { - private static readonly HttpClient HttpClient; - static RestHttpClientV2() - { - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - HttpClient = new HttpClient(); - } + class RestHttpClientV2 + { + private static readonly HttpClient HttpClient; + static RestHttpClientV2() + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + HttpClient = new HttpClient(); + } - public static RestHttpClientV2 Create() - { - return new RestHttpClientV2(); - } + public static RestHttpClientV2 Create() + { + return new RestHttpClientV2(); + } - public T Get(String url, Dictionary headers) where T : IyzipayResourceV2 - { - HttpRequestMessage requestMessage = new HttpRequestMessage - { - Method = HttpMethod.Get, - RequestUri = new Uri(url) + public T Get(String url, Dictionary headers) where T : IyzipayResourceV2 + { + HttpRequestMessage requestMessage = new HttpRequestMessage + { + Method = HttpMethod.Get, + RequestUri = new Uri(url) - }; + }; - foreach (var header in headers) - { - requestMessage.Headers.Add(header.Key, header.Value); - } + foreach (var header in headers) + { + requestMessage.Headers.Add(header.Key, header.Value); + } - HttpResponseMessage httpResponseMessage = HttpClient.SendAsync(requestMessage).Result; - var response = JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); - response.AppendWithHttpResponseHeaders(httpResponseMessage); - return response; - } + HttpResponseMessage httpResponseMessage = HttpClient.SendAsync(requestMessage).Result; + var response = JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); + response.AppendWithHttpResponseHeaders(httpResponseMessage); + return response; + } - public T Post(String url, Dictionary headers, BaseRequestV2 request) where T : IyzipayResourceV2 - { - HttpRequestMessage requestMessage = new HttpRequestMessage - { - Method = HttpMethod.Post, - RequestUri = new Uri(url), - Content = JsonBuilder.ToJsonString(request) - }; + public T Post(String url, Dictionary headers, BaseRequestV2 request) where T : IyzipayResourceV2 + { + HttpRequestMessage requestMessage = new HttpRequestMessage + { + Method = HttpMethod.Post, + RequestUri = new Uri(url), + Content = JsonBuilder.ToJsonString(request) + }; - foreach (var header in headers) - { - requestMessage.Headers.Add(header.Key, header.Value); - } + foreach (var header in headers) + { + requestMessage.Headers.Add(header.Key, header.Value); + } - HttpResponseMessage httpResponseMessage = HttpClient.SendAsync(requestMessage).Result; - var response = JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); - response.AppendWithHttpResponseHeaders(httpResponseMessage); - return response; - } - - public T Put(String url, Dictionary headers, BaseRequestV2 request) where T : IyzipayResourceV2 - { - HttpRequestMessage requestMessage = new HttpRequestMessage - { - Method = HttpMethod.Put, - RequestUri = new Uri(url), - Content = JsonBuilder.ToJsonString(request) - }; + HttpResponseMessage httpResponseMessage = HttpClient.SendAsync(requestMessage).Result; + var response = JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); + response.AppendWithHttpResponseHeaders(httpResponseMessage); + return response; + } - foreach (var header in headers) - { - requestMessage.Headers.Add(header.Key, header.Value); - } + public T Put(String url, Dictionary headers, BaseRequestV2 request) where T : IyzipayResourceV2 + { + HttpRequestMessage requestMessage = new HttpRequestMessage + { + Method = HttpMethod.Put, + RequestUri = new Uri(url), + Content = JsonBuilder.ToJsonString(request) + }; - HttpResponseMessage httpResponseMessage = HttpClient.SendAsync(requestMessage).Result; - var response = JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); - response.AppendWithHttpResponseHeaders(httpResponseMessage); - return response; - } - - public T Delete(String url, Dictionary headers, BaseRequestV2 request) where T : IyzipayResourceV2 + foreach (var header in headers) + { + requestMessage.Headers.Add(header.Key, header.Value); + } + + HttpResponseMessage httpResponseMessage = HttpClient.SendAsync(requestMessage).Result; + var response = JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); + response.AppendWithHttpResponseHeaders(httpResponseMessage); + return response; + } + + public T Patch(String url, Dictionary headers, BaseRequestV2 request) where T : IyzipayResourceV2 { HttpRequestMessage requestMessage = new HttpRequestMessage { - Method = HttpMethod.Delete, + Method = HttpMethod.Put,//todo: [EY] Patch olarak değiştirilmeli fakat kütüphane güncellenmesi gerekiyor. RequestUri = new Uri(url), Content = JsonBuilder.ToJsonString(request) }; @@ -101,5 +101,25 @@ public T Delete(String url, Dictionary headers, BaseRequestV2 response.AppendWithHttpResponseHeaders(httpResponseMessage); return response; } - } + + public T Delete(String url, Dictionary headers, BaseRequestV2 request) where T : IyzipayResourceV2 + { + HttpRequestMessage requestMessage = new HttpRequestMessage + { + Method = HttpMethod.Delete, + RequestUri = new Uri(url), + Content = JsonBuilder.ToJsonString(request) + }; + + foreach (var header in headers) + { + requestMessage.Headers.Add(header.Key, header.Value); + } + + HttpResponseMessage httpResponseMessage = HttpClient.SendAsync(requestMessage).Result; + var response = JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); + response.AppendWithHttpResponseHeaders(httpResponseMessage); + return response; + } + } }