From cf5e87d28cbe9ce01e9a89e551db011a0deab7f1 Mon Sep 17 00:00:00 2001 From: Sinan Taviloglu Date: Thu, 8 Feb 2018 05:22:37 +0300 Subject: [PATCH 1/5] =?UTF-8?q?string=20interpolation=20operator=20($)=20k?= =?UTF-8?q?ullanacak=20=C5=9Fekilde=20refactor=20edildi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Iyzipay/ToStringRequestBuilder.cs | 71 ++++++++----------------------- 1 file changed, 18 insertions(+), 53 deletions(-) diff --git a/Iyzipay/ToStringRequestBuilder.cs b/Iyzipay/ToStringRequestBuilder.cs index 921c7e4..05d1e9d 100644 --- a/Iyzipay/ToStringRequestBuilder.cs +++ b/Iyzipay/ToStringRequestBuilder.cs @@ -5,11 +5,14 @@ namespace Iyzipay { public class ToStringRequestBuilder { - private String _requestString; + private List parameters = new List(); private ToStringRequestBuilder(String requestString) { - this._requestString = requestString; + if (!string.IsNullOrWhiteSpace(requestString)) + { + parameters.Add(requestString); + } } public static ToStringRequestBuilder NewInstance() @@ -31,7 +34,7 @@ public ToStringRequestBuilder AppendSuper(String superRequestString) if (superRequestString.Length > 0) { - this._requestString = this._requestString + superRequestString + ","; + parameters.Add(superRequestString); } } return this; @@ -43,11 +46,12 @@ public ToStringRequestBuilder Append(String key, Object value = null) { if (value is RequestStringConvertible) { - AppendKeyValue(key, ((RequestStringConvertible)value).ToPKIRequestString()); + parameters.Add($"{key}={((RequestStringConvertible)value).ToPKIRequestString()}"); + } else { - AppendKeyValue(key, value.ToString()); + parameters.Add($"{key}={value}"); } } return this; @@ -57,7 +61,7 @@ public ToStringRequestBuilder AppendPrice(String key, String value) { if (value != null) { - AppendKeyValue(key, RequestFormatter.FormatPrice(value)); + parameters.Add($"{key}={RequestFormatter.FormatPrice(value)}"); } return this; } @@ -66,69 +70,30 @@ public ToStringRequestBuilder AppendList(String key, List list = null) whe { if (list != null) { - String appendedValue = ""; - foreach (RequestStringConvertible value in list) + List valueList = new List(); + foreach (RequestStringConvertible val in list) { - appendedValue = appendedValue + value.ToPKIRequestString() + ", "; + valueList.Add(val.ToPKIRequestString()); } - AppendKeyValueArray(key, appendedValue); + parameters.Add($"{key}=[{string.Join(", ", valueList)}]"); } return this; } - public ToStringRequestBuilder AppendList (String key, List list = null) + public ToStringRequestBuilder AppendList(String key, List list = null) { if (list != null) { - String appendedValue = ""; - foreach (int value in list) - { - appendedValue = appendedValue + value + ", "; - } - AppendKeyValueArray(key, appendedValue); + parameters.Add($"{key}=[{string.Join(", ", list)}]"); } return this; } - private ToStringRequestBuilder AppendKeyValue(String key, String value) - { - if (value != null) - { - this._requestString = this._requestString + key + "=" + value + ","; - } - return this; - } - - private ToStringRequestBuilder AppendKeyValueArray(String key, String value) - { - if (value != null) - { - value = value.Substring(0, value.Length - 2); - this._requestString = this._requestString + key + "=[" + value + "],"; - } - return this; - } - - private ToStringRequestBuilder AppendPrefix() - { - this._requestString = "[" + this._requestString + "]"; - return this; - } - - private ToStringRequestBuilder RemoveTrailingComma() - { - if (!string.IsNullOrEmpty(this._requestString)) - { - this._requestString = this._requestString.Substring(0, this._requestString.Length - 1); - } - return this; - } public String GetRequestString() { - RemoveTrailingComma(); - AppendPrefix(); - return _requestString; + return $"[{string.Join(",", parameters)}]"; } } } + From 1c50add6c59971158051718da0594c164a5fd22c Mon Sep 17 00:00:00 2001 From: Sinan Taviloglu Date: Thu, 8 Feb 2018 05:28:41 +0300 Subject: [PATCH 2/5] =?UTF-8?q?Her=20requestte=20yeni=20bir=20HttpClient?= =?UTF-8?q?=20yarat=C4=B1lmas=C4=B1n=C4=B1n=20=C3=B6n=C3=BCne=20ge=C3=A7il?= =?UTF-8?q?di.=20Sabit=20olan=20req.=20headerlar=C4=B1=20ta=C5=9F=C4=B1nd?= =?UTF-8?q?=C4=B1.=20Mevcut=20fonksyionlar=C4=B1n=20Async=20versiyonlar?= =?UTF-8?q?=C4=B1=20eklendi.=20Async=20fonksiyonlar=C4=B1n=20testleri=20ek?= =?UTF-8?q?lendi.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Iyzipay.Samples/ApiTestSample.cs | 16 + Iyzipay.Samples/ApmSample.cs | 110 ++++++ Iyzipay.Samples/BinNumberSample.cs | 28 ++ Iyzipay.Samples/BkmSample.cs | 108 ++++++ Iyzipay.Samples/CheckoutFormSample.cs | 117 +++++++ Iyzipay.Samples/InstallmentSample.cs | 25 ++ Iyzipay.Samples/PaymentSample.cs | 318 ++++++++++++++++++ Iyzipay.Samples/PeccoSample.cs | 110 ++++++ .../RetrievePayoutTransactionsSample.cs | 44 +++ Iyzipay.Samples/Sample.cs | 4 +- Iyzipay.Samples/ThreedsSample.cs | 122 +++++++ Iyzipay.sln | 7 +- Iyzipay/IyzipayResource.cs | 5 +- Iyzipay/Model/ApiTest.cs | 13 +- Iyzipay/Model/Apm.cs | 17 +- Iyzipay/Model/Approval.cs | 9 +- Iyzipay/Model/BasicBkm.cs | 9 +- Iyzipay/Model/BasicBkmInitialize.cs | 17 +- Iyzipay/Model/BasicPayment.cs | 9 +- Iyzipay/Model/BasicPaymentPostAuth.cs | 11 +- Iyzipay/Model/BasicPaymentPreAuth.cs | 8 +- Iyzipay/Model/BasicThreedsInitialize.cs | 14 +- .../Model/BasicThreedsInitializePreAuth.cs | 14 +- Iyzipay/Model/BasicThreedsPayment.cs | 8 +- Iyzipay/Model/BinNumber.cs | 9 +- Iyzipay/Model/Bkm.cs | 8 +- Iyzipay/Model/BkmInitialize.cs | 14 +- Iyzipay/Model/BouncedBankTransferList.cs | 8 +- Iyzipay/Model/Cancel.cs | 8 +- Iyzipay/Model/Card.cs | 15 +- Iyzipay/Model/CardList.cs | 8 +- Iyzipay/Model/CheckoutForm.cs | 10 +- Iyzipay/Model/CheckoutFormInitialize.cs | 8 +- .../Model/CheckoutFormInitializePreAuth.cs | 8 +- Iyzipay/Model/CrossBookingFromSubMerchant.cs | 8 +- Iyzipay/Model/CrossBookingToSubMerchant.cs | 8 +- Iyzipay/Model/Disapproval.cs | 8 +- Iyzipay/Model/InstallmentInfo.cs | 9 +- Iyzipay/Model/Payment.cs | 16 +- Iyzipay/Model/PaymentPostAuth.cs | 8 +- Iyzipay/Model/PaymentPreAuth.cs | 20 +- .../Model/PayoutCompletedTransactionList.cs | 8 +- Iyzipay/Model/PeccoInitialize.cs | 8 +- Iyzipay/Model/PeccoPayment.cs | 8 +- Iyzipay/Model/Refund.cs | 8 +- Iyzipay/Model/RefundChargedFromMerchant.cs | 8 +- Iyzipay/Model/SubMerchant.cs | 23 +- Iyzipay/Model/ThreedsInitialize.cs | 14 +- Iyzipay/Model/ThreedsInitializePreAuth.cs | 16 +- Iyzipay/Model/ThreedsPayment.cs | 19 +- Iyzipay/RestHttpClient.cs | 120 ++++++- 51 files changed, 1474 insertions(+), 74 deletions(-) diff --git a/Iyzipay.Samples/ApiTestSample.cs b/Iyzipay.Samples/ApiTestSample.cs index 60ad1f0..55758ce 100644 --- a/Iyzipay.Samples/ApiTestSample.cs +++ b/Iyzipay.Samples/ApiTestSample.cs @@ -1,5 +1,6 @@ using Iyzipay.Model; using NUnit.Framework; +using System.Threading.Tasks; namespace Iyzipay.Samples { @@ -19,5 +20,20 @@ public void Should_Test_Api() Assert.IsNull(iyzipayResource.ErrorMessage); Assert.IsNull(iyzipayResource.ErrorGroup); } + + [Test] + public async Task Should_Test_ApiAsync() + { + IyzipayResource iyzipayResource = await ApiTest.RetrieveAsync(options); + + PrintResponse(iyzipayResource); + + 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/ApmSample.cs b/Iyzipay.Samples/ApmSample.cs index 2d93132..a834367 100644 --- a/Iyzipay.Samples/ApmSample.cs +++ b/Iyzipay.Samples/ApmSample.cs @@ -2,6 +2,7 @@ using Iyzipay.Request; using NUnit.Framework; using System.Collections.Generic; +using System.Threading.Tasks; namespace Iyzipay.Samples { @@ -115,5 +116,114 @@ public void Should_Retrieve_Apm_Result() Assert.AreEqual(Locale.TR.ToString(), retrieve.Locale); Assert.AreEqual("123456789", retrieve.ConversationId); } + + [Test] + public async Task Should_Initialize_Apm_PaymentAsync() + { + CreateApmInitializeRequest request = new CreateApmInitializeRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Price = "1"; + request.PaidPrice = "1.2"; + request.Currency = Currency.EUR.ToString(); + request.CountryCode = "DE"; + request.PaymentChannel = PaymentChannel.WEB.ToString(); + request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); + request.AccountHolderName = "success"; + request.MerchantCallbackUrl = "https://www.merchant.com/callback"; + request.MerchantErrorUrl = "https://www.merchant.com/error"; + request.MerchantNotificationUrl = "https://www.merchant.com/notification"; + request.ApmType = ApmType.SOFORT.ToString(); + + Buyer buyer = new Buyer(); + buyer.Id = "BY789"; + buyer.Name = "John"; + buyer.Surname = "Doe"; + buyer.GsmNumber = "+905350000000"; + buyer.Email = "email@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; + + Apm apmInitialize = await Apm.CreateAsync(request, options); + + PrintResponse(apmInitialize); + + Assert.AreEqual(Status.SUCCESS.ToString(), apmInitialize.Status); + Assert.AreEqual(Locale.TR.ToString(), apmInitialize.Locale); + Assert.AreEqual("123456789", apmInitialize.ConversationId); + Assert.IsNotNull(apmInitialize.SystemTime); + Assert.IsNull(apmInitialize.ErrorCode); + Assert.IsNull(apmInitialize.ErrorMessage); + Assert.IsNull(apmInitialize.ErrorGroup); + } + + [Test] + public async Task Should_Retrieve_Apm_ResultAsync() + { + RetrieveApmRequest request = new RetrieveApmRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.PaymentId = "1"; + + Apm retrieve = await Apm.RetrieveAsync(request, options); + + PrintResponse(retrieve); + + Assert.AreEqual(Status.SUCCESS.ToString(), retrieve.Status); + Assert.AreEqual(Locale.TR.ToString(), retrieve.Locale); + Assert.AreEqual("123456789", retrieve.ConversationId); + } } } diff --git a/Iyzipay.Samples/BinNumberSample.cs b/Iyzipay.Samples/BinNumberSample.cs index e6cdb6c..38dad5d 100644 --- a/Iyzipay.Samples/BinNumberSample.cs +++ b/Iyzipay.Samples/BinNumberSample.cs @@ -1,6 +1,7 @@ using Iyzipay.Request; using Iyzipay.Model; using NUnit.Framework; +using System.Threading.Tasks; namespace Iyzipay.Samples { @@ -32,5 +33,32 @@ public void Should_Retrieve_Bin_Number() Assert.AreEqual("Garanti Bankası", binNumber.BankName); Assert.AreEqual(62, binNumber.BankCode); } + + [Test] + public async Task Should_Retrieve_Bin_NumberAsync() + { + RetrieveBinNumberRequest request = new RetrieveBinNumberRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.BinNumber = "554960"; + + BinNumber binNumber = await BinNumber.RetrieveAsync(request, options); + + PrintResponse(binNumber); + + Assert.AreEqual(Status.SUCCESS.ToString(), binNumber.Status); + Assert.AreEqual(Locale.TR.ToString(), binNumber.Locale); + Assert.AreEqual("123456789", binNumber.ConversationId); + Assert.IsNotNull(binNumber.SystemTime); + Assert.IsNull(binNumber.ErrorCode); + Assert.IsNull(binNumber.ErrorMessage); + Assert.IsNull(binNumber.ErrorGroup); + Assert.AreEqual("554960", binNumber.Bin); + Assert.AreEqual("CREDIT_CARD", binNumber.CardType); + Assert.AreEqual("MASTER_CARD", binNumber.CardAssociation); + Assert.AreEqual("Bonus", binNumber.CardFamily); + Assert.AreEqual("Garanti Bankası", binNumber.BankName); + Assert.AreEqual(62, binNumber.BankCode); + } } } \ No newline at end of file diff --git a/Iyzipay.Samples/BkmSample.cs b/Iyzipay.Samples/BkmSample.cs index 85ecad3..b195c5d 100644 --- a/Iyzipay.Samples/BkmSample.cs +++ b/Iyzipay.Samples/BkmSample.cs @@ -2,6 +2,7 @@ using Iyzipay.Model; using System.Collections.Generic; using NUnit.Framework; +using System.Threading.Tasks; namespace Iyzipay.Samples { @@ -113,5 +114,112 @@ public void Should_Retrieve_Bkm_Result() Assert.IsNull(bkm.ErrorMessage); Assert.IsNull(bkm.ErrorGroup); } + + [Test] + public async Task Should_Initialize_BkmAsync() + { + CreateBkmInitializeRequest request = new CreateBkmInitializeRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Price = "1"; + request.BasketId = "B67832"; + request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); + request.CallbackUrl = "https://www.merchant.com/callback"; + + Buyer buyer = new Buyer(); + buyer.Id = "BY789"; + buyer.Name = "John"; + buyer.Surname = "Doe"; + buyer.GsmNumber = "+905350000000"; + buyer.Email = "email@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; + + BkmInitialize bkmInitialize = await BkmInitialize.CreateAsync(request, options); + + PrintResponse(bkmInitialize); + + Assert.AreEqual(Status.SUCCESS.ToString(), bkmInitialize.Status); + Assert.AreEqual(Locale.TR.ToString(), bkmInitialize.Locale); + Assert.AreEqual("123456789", bkmInitialize.ConversationId); + Assert.IsNotNull(bkmInitialize.SystemTime); + Assert.IsNull(bkmInitialize.ErrorCode); + Assert.IsNull(bkmInitialize.ErrorMessage); + Assert.IsNull(bkmInitialize.ErrorGroup); + Assert.IsNotNull(bkmInitialize.HtmlContent); + } + + [Test] + public async Task Should_Retrieve_Bkm_ResultAsync() + { + RetrieveBkmRequest request = new RetrieveBkmRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Token = "token"; + + Bkm bkm = await Bkm.RetrieveAsync(request, options); + + PrintResponse(bkm); + + Assert.AreEqual(Status.SUCCESS.ToString(), bkm.Status); + Assert.AreEqual(Locale.TR.ToString(), bkm.Locale); + Assert.AreEqual("123456789", bkm.ConversationId); + Assert.IsNotNull(bkm.SystemTime); + Assert.IsNull(bkm.ErrorCode); + Assert.IsNull(bkm.ErrorMessage); + Assert.IsNull(bkm.ErrorGroup); + } } } diff --git a/Iyzipay.Samples/CheckoutFormSample.cs b/Iyzipay.Samples/CheckoutFormSample.cs index 571858e..4cbd7dc 100644 --- a/Iyzipay.Samples/CheckoutFormSample.cs +++ b/Iyzipay.Samples/CheckoutFormSample.cs @@ -2,6 +2,7 @@ using Iyzipay.Request; using NUnit.Framework; using System.Collections.Generic; +using System.Threading.Tasks; namespace Iyzipay.Samples { @@ -122,5 +123,121 @@ public void Should_Retrieve_Checkout_Form_Result() Assert.IsNull(checkoutForm.ErrorMessage); Assert.IsNull(checkoutForm.ErrorGroup); } + + [Test] + public async Task Should_Initialize_Checkout_FormAsync() + { + CreateCheckoutFormInitializeRequest request = new CreateCheckoutFormInitializeRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Price = "1"; + request.PaidPrice = "1.2"; + request.Currency = Currency.TRY.ToString(); + request.BasketId = "B67832"; + request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); + request.CallbackUrl = "https://www.merchant.com/callback"; + + List enabledInstallments = new List(); + enabledInstallments.Add(2); + enabledInstallments.Add(3); + enabledInstallments.Add(6); + enabledInstallments.Add(9); + request.EnabledInstallments = enabledInstallments; + + 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; + + CheckoutFormInitialize checkoutFormInitialize = await CheckoutFormInitialize.CreateAsync(request, options); + + PrintResponse(checkoutFormInitialize); + + Assert.AreEqual(Status.SUCCESS.ToString(), checkoutFormInitialize.Status); + Assert.AreEqual(Locale.TR.ToString(), checkoutFormInitialize.Locale); + Assert.AreEqual("123456789", checkoutFormInitialize.ConversationId); + Assert.IsNotNull(checkoutFormInitialize.SystemTime); + Assert.IsNull(checkoutFormInitialize.ErrorCode); + Assert.IsNull(checkoutFormInitialize.ErrorMessage); + Assert.IsNull(checkoutFormInitialize.ErrorGroup); + Assert.IsNotNull(checkoutFormInitialize.CheckoutFormContent); + Assert.IsNotNull(checkoutFormInitialize.PaymentPageUrl); + } + + [Test] + public async Task Should_Retrieve_Checkout_Form_ResultAsync() + { + RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest(); + request.ConversationId = "123456789"; + request.Token = "token"; + + CheckoutForm checkoutForm = await CheckoutForm.RetrieveAsync(request, options); + + PrintResponse(checkoutForm); + + Assert.AreEqual(Status.SUCCESS.ToString(), checkoutForm.Status); + Assert.AreEqual(Locale.TR.ToString(), checkoutForm.Locale); + Assert.AreEqual("123456789", checkoutForm.ConversationId); + Assert.IsNotNull(checkoutForm.SystemTime); + Assert.IsNull(checkoutForm.ErrorCode); + Assert.IsNull(checkoutForm.ErrorMessage); + Assert.IsNull(checkoutForm.ErrorGroup); + } } } diff --git a/Iyzipay.Samples/InstallmentSample.cs b/Iyzipay.Samples/InstallmentSample.cs index 17a2c67..4f56060 100644 --- a/Iyzipay.Samples/InstallmentSample.cs +++ b/Iyzipay.Samples/InstallmentSample.cs @@ -1,6 +1,7 @@ using Iyzipay.Request; using Iyzipay.Model; using NUnit.Framework; +using System.Threading.Tasks; namespace Iyzipay.Samples { @@ -29,5 +30,29 @@ public void Should_Retrieve_Installments() Assert.IsNotNull(installmentInfo.InstallmentDetails); Assert.IsNotEmpty(installmentInfo.InstallmentDetails); } + + [Test] + public async Task Should_Retrieve_InstallmentsAsync() + { + RetrieveInstallmentInfoRequest request = new RetrieveInstallmentInfoRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.BinNumber = "554960"; + request.Price = "100"; + + InstallmentInfo installmentInfo =await InstallmentInfo.RetrieveAsync(request, options); + + PrintResponse(installmentInfo); + + Assert.AreEqual(Status.SUCCESS.ToString(), installmentInfo.Status); + Assert.AreEqual(Locale.TR.ToString(), installmentInfo.Locale); + Assert.AreEqual("123456789", installmentInfo.ConversationId); + Assert.IsNotNull(installmentInfo.SystemTime); + Assert.IsNull(installmentInfo.ErrorCode); + Assert.IsNull(installmentInfo.ErrorMessage); + Assert.IsNull(installmentInfo.ErrorGroup); + Assert.IsNotNull(installmentInfo.InstallmentDetails); + Assert.IsNotEmpty(installmentInfo.InstallmentDetails); + } } } diff --git a/Iyzipay.Samples/PaymentSample.cs b/Iyzipay.Samples/PaymentSample.cs index 9a865f8..9b5c4d9 100644 --- a/Iyzipay.Samples/PaymentSample.cs +++ b/Iyzipay.Samples/PaymentSample.cs @@ -2,6 +2,7 @@ using Iyzipay.Request; using NUnit.Framework; using System.Collections.Generic; +using System.Threading.Tasks; namespace Iyzipay.Samples { @@ -321,5 +322,322 @@ public void Should_Retrieve_Payment_Result() Assert.IsNull(payment.ErrorMessage); Assert.IsNull(payment.ErrorGroup); } + + + + [Test] + public async Task Should_Create_PaymentAsync() + { + 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 = "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 =await Payment.CreateAsync(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 async Task Should_Create_Marketplace_PaymentAsync() + { + 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 = await Payment.CreateAsync(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 async Task Should_Create_Payment_With_Registered_CardAsync() + { + 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 = await Payment.CreateAsync(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 async Task Should_Retrieve_Payment_ResultAsync() + { + RetrievePaymentRequest request = new RetrievePaymentRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.PaymentId = "1"; + request.PaymentConversationId = "123456789"; + + Payment payment = await Payment.RetrieveAsync(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/PeccoSample.cs b/Iyzipay.Samples/PeccoSample.cs index 73fa5d7..124bccf 100644 --- a/Iyzipay.Samples/PeccoSample.cs +++ b/Iyzipay.Samples/PeccoSample.cs @@ -2,6 +2,7 @@ using Iyzipay.Model; using System.Collections.Generic; using NUnit.Framework; +using System.Threading.Tasks; namespace Iyzipay.Samples { @@ -115,5 +116,114 @@ public void Should_Create_Pecco_Payment() Assert.IsNull(peccoPayment.ErrorMessage); Assert.IsNull(peccoPayment.ErrorGroup); } + + [Test] + public async Task Should_Initialize_PeccoAsync() + { + CreatePeccoInitializeRequest request = new CreatePeccoInitializeRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Price = "100000"; + request.PaidPrice = "120000"; + request.Currency = Currency.IRR.ToString(); + request.BasketId = "B67832"; + request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); + request.CallbackUrl = "https://www.merchant.com/callback"; + + Buyer buyer = new Buyer(); + buyer.Id = "BY789"; + buyer.Name = "John"; + buyer.Surname = "Doe"; + buyer.GsmNumber = "+905350000000"; + buyer.Email = "email@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 = "30000"; + 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 = "50000"; + 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 = "20000"; + basketItems.Add(thirdBasketItem); + request.BasketItems = basketItems; + + PeccoInitialize peccoInitialize = await PeccoInitialize.CreateAsync(request, options); + + PrintResponse(peccoInitialize); + + Assert.AreEqual(Status.SUCCESS.ToString(), peccoInitialize.Status); + Assert.AreEqual(Locale.TR.ToString(), peccoInitialize.Locale); + Assert.AreEqual("123456789", peccoInitialize.ConversationId); + Assert.IsNotNull(peccoInitialize.SystemTime); + Assert.IsNull(peccoInitialize.ErrorCode); + Assert.IsNull(peccoInitialize.ErrorMessage); + Assert.IsNull(peccoInitialize.ErrorGroup); + Assert.IsNotNull(peccoInitialize.HtmlContent); + } + + [Test] + public async Task Should_Create_Pecco_PaymentAsync() + { + CreatePeccoPaymentRequest request = new CreatePeccoPaymentRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Token = "token"; + + PeccoPayment peccoPayment = await PeccoPayment.CreateAsync(request, options); + + PrintResponse(peccoPayment); + + Assert.AreEqual(Status.SUCCESS.ToString(), peccoPayment.Status); + Assert.AreEqual(Locale.TR.ToString(), peccoPayment.Locale); + Assert.AreEqual("123456789", peccoPayment.ConversationId); + Assert.IsNotNull(peccoPayment.SystemTime); + Assert.IsNull(peccoPayment.ErrorCode); + Assert.IsNull(peccoPayment.ErrorMessage); + Assert.IsNull(peccoPayment.ErrorGroup); + } } } diff --git a/Iyzipay.Samples/RetrievePayoutTransactionsSample.cs b/Iyzipay.Samples/RetrievePayoutTransactionsSample.cs index 82bc68b..b4f5a9a 100644 --- a/Iyzipay.Samples/RetrievePayoutTransactionsSample.cs +++ b/Iyzipay.Samples/RetrievePayoutTransactionsSample.cs @@ -1,6 +1,7 @@ using Iyzipay.Request; using Iyzipay.Model; using NUnit.Framework; +using System.Threading.Tasks; namespace Iyzipay.Samples { @@ -47,5 +48,48 @@ public void Should_Retrieve_Bounced_Bank_Transfers() Assert.IsNull(bouncedBankTransferList.ErrorMessage); Assert.IsNull(bouncedBankTransferList.ErrorGroup); } + + [Test] + public async Task Should_Retrieve_Payout_Completed_TransactionsAsync() + { + RetrieveTransactionsRequest request = new RetrieveTransactionsRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Date = "2015-01-22 19:13:00"; + + PayoutCompletedTransactionList payoutCompletedTransactionList = await PayoutCompletedTransactionList.RetrieveAsync(request, options); + + PrintResponse(payoutCompletedTransactionList); + + Assert.AreEqual(Status.SUCCESS.ToString(), payoutCompletedTransactionList.Status); + Assert.AreEqual(Locale.TR.ToString(), payoutCompletedTransactionList.Locale); + Assert.AreEqual("123456789", payoutCompletedTransactionList.ConversationId); + Assert.IsNotNull(payoutCompletedTransactionList.SystemTime); + Assert.IsNull(payoutCompletedTransactionList.ErrorCode); + Assert.IsNull(payoutCompletedTransactionList.ErrorMessage); + Assert.IsNull(payoutCompletedTransactionList.ErrorGroup); + } + + [Test] + public async Task Should_Retrieve_Bounced_Bank_TransfersAsync() + { + RetrieveTransactionsRequest request = new RetrieveTransactionsRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Date = "2015-06-02 19:13:00"; + + BouncedBankTransferList bouncedBankTransferList = await BouncedBankTransferList.RetrieveAsync(request, options); + + PrintResponse(bouncedBankTransferList); + + Assert.AreEqual(Status.SUCCESS.ToString(), bouncedBankTransferList.Status); + Assert.AreEqual(Locale.TR.ToString(), bouncedBankTransferList.Locale); + Assert.AreEqual("123456789", bouncedBankTransferList.ConversationId); + Assert.IsNotNull(bouncedBankTransferList.SystemTime); + Assert.IsNull(bouncedBankTransferList.ErrorCode); + Assert.IsNull(bouncedBankTransferList.ErrorMessage); + Assert.IsNull(bouncedBankTransferList.ErrorGroup); + } + } } diff --git a/Iyzipay.Samples/Sample.cs b/Iyzipay.Samples/Sample.cs index 99a6949..8cc0e44 100644 --- a/Iyzipay.Samples/Sample.cs +++ b/Iyzipay.Samples/Sample.cs @@ -13,8 +13,8 @@ public class Sample public void Initialize() { options = new Options(); - options.ApiKey = "api key"; - options.SecretKey = "secret key"; + options.ApiKey = "sandbox-etvOpp5dmDk7VH2HMmmtUoZLCemBiaXE"; + options.SecretKey = "sandbox-tfkpngBqftBTIsQvtaXWubbxRQbchv2r"; options.BaseUrl = "https://sandbox-api.iyzipay.com"; } diff --git a/Iyzipay.Samples/ThreedsSample.cs b/Iyzipay.Samples/ThreedsSample.cs index 8946523..8c2e45b 100644 --- a/Iyzipay.Samples/ThreedsSample.cs +++ b/Iyzipay.Samples/ThreedsSample.cs @@ -2,6 +2,7 @@ using Iyzipay.Model; using System.Collections.Generic; using NUnit.Framework; +using System.Threading.Tasks; namespace Iyzipay.Samples { @@ -127,5 +128,126 @@ public void Should_Create_Threeds_Payment() Assert.IsNull(threedsPayment.ErrorMessage); Assert.IsNull(threedsPayment.ErrorGroup); } + + [Test] + public async Task Should_Initialize_ThreedsAsync() + { + CreatePaymentRequest request = new CreatePaymentRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.Price = "1"; + request.PaidPrice = "1.2"; + request.Currency = Currency.TRY.ToString(); + request.Installment = 1; + request.BasketId = "B67832"; + request.PaymentChannel = PaymentChannel.WEB.ToString(); + request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); + request.CallbackUrl = "https://www.merchant.com/callback"; + + PaymentCard paymentCard = new PaymentCard(); + paymentCard.CardHolderName = "John Doe"; + paymentCard.CardNumber = "5528790000000008"; + paymentCard.ExpireMonth = "12"; + paymentCard.ExpireYear = "2030"; + paymentCard.Cvc = "123"; + paymentCard.RegisterCard = 0; + request.PaymentCard = paymentCard; + + Buyer buyer = new Buyer(); + buyer.Id = "BY789"; + buyer.Name = "John"; + buyer.Surname = "Doe"; + buyer.GsmNumber = "+905350000000"; + buyer.Email = "email@email.com"; + buyer.IdentityNumber = "74300864791"; + buyer.LastLoginDate = "2015-10-05 12:43:35"; + buyer.RegistrationDate = "2013-04-21 15:12:09"; + buyer.RegistrationAddress = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; + buyer.Ip = "85.34.78.112"; + buyer.City = "Istanbul"; + buyer.Country = "Turkey"; + buyer.ZipCode = "34732"; + request.Buyer = buyer; + + Address shippingAddress = new Address(); + shippingAddress.ContactName = "Jane Doe"; + shippingAddress.City = "Istanbul"; + shippingAddress.Country = "Turkey"; + shippingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; + shippingAddress.ZipCode = "34742"; + request.ShippingAddress = shippingAddress; + + Address billingAddress = new Address(); + billingAddress.ContactName = "Jane Doe"; + billingAddress.City = "Istanbul"; + billingAddress.Country = "Turkey"; + billingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; + billingAddress.ZipCode = "34742"; + request.BillingAddress = billingAddress; + + List 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; + + ThreedsInitialize threedsInitialize = await ThreedsInitialize.CreateAsync(request, options); + + PrintResponse(threedsInitialize); + + Assert.AreEqual(Status.SUCCESS.ToString(), threedsInitialize.Status); + Assert.AreEqual(Locale.TR.ToString(), threedsInitialize.Locale); + Assert.AreEqual("123456789", threedsInitialize.ConversationId); + Assert.IsNotNull(threedsInitialize.SystemTime); + Assert.IsNull(threedsInitialize.ErrorCode); + Assert.IsNull(threedsInitialize.ErrorMessage); + Assert.IsNull(threedsInitialize.ErrorGroup); + Assert.IsNotNull(threedsInitialize.HtmlContent); + } + + [Test] + public async Task Should_Create_Threeds_PaymentAsync() + { + CreateThreedsPaymentRequest request = new CreateThreedsPaymentRequest(); + request.Locale = Locale.TR.ToString(); + request.ConversationId = "123456789"; + request.PaymentId = "1"; + request.ConversationData = "conversation data"; + + ThreedsPayment threedsPayment = await ThreedsPayment.CreateAsync(request, options); + + PrintResponse(threedsPayment); + + Assert.AreEqual(Status.SUCCESS.ToString(), threedsPayment.Status); + Assert.AreEqual(Locale.TR.ToString(), threedsPayment.Locale); + Assert.AreEqual("123456789", threedsPayment.ConversationId); + Assert.IsNotNull(threedsPayment.SystemTime); + Assert.IsNull(threedsPayment.ErrorCode); + Assert.IsNull(threedsPayment.ErrorMessage); + Assert.IsNull(threedsPayment.ErrorGroup); + } } } diff --git a/Iyzipay.sln b/Iyzipay.sln index 5620a8a..90d166e 100644 --- a/Iyzipay.sln +++ b/Iyzipay.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iyzipay", "Iyzipay\Iyzipay.csproj", "{5011814A-01E4-4E5F-82FA-5282FF01DA5D}" EndProject @@ -25,4 +25,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DE6E0A79-1328-40D3-A5A4-8E221BE1BBC9} + EndGlobalSection EndGlobal diff --git a/Iyzipay/IyzipayResource.cs b/Iyzipay/IyzipayResource.cs index ad9dc0c..521dbb1 100644 --- a/Iyzipay/IyzipayResource.cs +++ b/Iyzipay/IyzipayResource.cs @@ -7,7 +7,6 @@ public class IyzipayResource { private static readonly String AUTHORIZATION = "Authorization"; private static readonly String RANDOM_HEADER_NAME = "x-iyzi-rnd"; - private static readonly String CLIENT_VERSION = "x-iyzi-client-version"; private static readonly String IYZIWS_HEADER_NAME = "IYZWS "; private static readonly String COLON = ":"; @@ -27,9 +26,7 @@ protected static WebHeaderCollection GetHttpHeaders(BaseRequest request, Options { string randomString = DateTime.Now.ToString("ddMMyyyyhhmmssffff"); WebHeaderCollection headers = new WebHeaderCollection(); - headers.Add("Accept", "application/json"); - headers.Add(RANDOM_HEADER_NAME, randomString); - headers.Add(CLIENT_VERSION, "iyzipay-dotnet-2.1.13"); + headers.Add(RANDOM_HEADER_NAME, randomString); headers.Add(AUTHORIZATION, PrepareAuthorizationString(request, randomString, options)); return headers; } diff --git a/Iyzipay/Model/ApiTest.cs b/Iyzipay/Model/ApiTest.cs index d692443..b74f605 100644 --- a/Iyzipay/Model/ApiTest.cs +++ b/Iyzipay/Model/ApiTest.cs @@ -1,10 +1,19 @@ -namespace Iyzipay.Model +using System.Threading.Tasks; + +namespace Iyzipay.Model { public class ApiTest : IyzipayResource { + private const string RetrieveUrl = "payment/test"; + + public async static Task RetrieveAsync(Options options) + { + return await RestHttpClient.Create(options.BaseUrl).GetAsync(RetrieveUrl); + } + public static IyzipayResource Retrieve(Options options) { - return RestHttpClient.Create().Get(options.BaseUrl + "/payment/test"); + return RestHttpClient.Create(options.BaseUrl).Get(RetrieveUrl); } } } diff --git a/Iyzipay/Model/Apm.cs b/Iyzipay/Model/Apm.cs index f810329..44ef81a 100644 --- a/Iyzipay/Model/Apm.cs +++ b/Iyzipay/Model/Apm.cs @@ -1,17 +1,30 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class Apm : ApmResource { + private const string CreateUrl = "payment/apm/initialize"; + private const string RetrieveUrl = "payment/apm/retrieve"; + public async static Task CreateAsync(CreateApmInitializeRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); + } + + public async static Task RetrieveAsync(RetrieveApmRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request); + } + public static Apm Create(CreateApmInitializeRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/apm/initialize", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } public static Apm Retrieve(RetrieveApmRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/apm/retrieve", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Approval.cs b/Iyzipay/Model/Approval.cs index b4525fe..46dd1d1 100644 --- a/Iyzipay/Model/Approval.cs +++ b/Iyzipay/Model/Approval.cs @@ -1,15 +1,22 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { public class Approval : IyzipayResource { + private const string CreateUrl = "payment/iyzipos/item/approve"; public String PaymentTransactionId { get; set; } public static Approval Create(CreateApprovalRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/iyzipos/item/approve", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); + } + + public async static Task CreateAsync(CreateApprovalRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/BasicBkm.cs b/Iyzipay/Model/BasicBkm.cs index fd24fc1..541db15 100644 --- a/Iyzipay/Model/BasicBkm.cs +++ b/Iyzipay/Model/BasicBkm.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -9,9 +10,15 @@ public class BasicBkm : BasicPaymentResource public String CallbackUrl { get; set; } public String PaymentStatus { get; set; } + private const string RetrieveUrl = "payment/bkm/auth/detail/basic"; + public async static Task RetrieveAsync(RetrieveBkmRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request); + } + public static BasicBkm Retrieve(RetrieveBkmRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/bkm/auth/detail/basic", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/BasicBkmInitialize.cs b/Iyzipay/Model/BasicBkmInitialize.cs index d74eff5..4a7ec82 100644 --- a/Iyzipay/Model/BasicBkmInitialize.cs +++ b/Iyzipay/Model/BasicBkmInitialize.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -7,10 +8,22 @@ public class BasicBkmInitialize : IyzipayResource { public String HtmlContent { get; set; } public String Token { get; set; } - + + private const string CreateUrl = "payment/bkm/initialize/basic"; + public async static Task CreateAsync(CreateBasicBkmInitializeRequest request, Options options) + { + BasicBkmInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); + + if (response != null) + { + response.HtmlContent = DigestHelper.DecodeString(response.HtmlContent); + } + return response; + } + public static BasicBkmInitialize Create(CreateBasicBkmInitializeRequest request, Options options) { - BasicBkmInitialize response = RestHttpClient.Create().Post(options.BaseUrl + "/payment/bkm/initialize/basic", GetHttpHeaders(request, options), request); + BasicBkmInitialize response = RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); if (response != null) { diff --git a/Iyzipay/Model/BasicPayment.cs b/Iyzipay/Model/BasicPayment.cs index e8f27c2..bed3e75 100644 --- a/Iyzipay/Model/BasicPayment.cs +++ b/Iyzipay/Model/BasicPayment.cs @@ -1,12 +1,19 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class BasicPayment : BasicPaymentResource { + private const string CerateUrl = "payment/auth/basic"; + public async static Task CreateAsync(CreateBasicPaymentRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CerateUrl, GetHttpHeaders(request, options), request); + } + public static BasicPayment Create(CreateBasicPaymentRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/auth/basic", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CerateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/BasicPaymentPostAuth.cs b/Iyzipay/Model/BasicPaymentPostAuth.cs index 7fae26b..649d8d3 100644 --- a/Iyzipay/Model/BasicPaymentPostAuth.cs +++ b/Iyzipay/Model/BasicPaymentPostAuth.cs @@ -1,12 +1,19 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class BasicPaymentPostAuth : BasicPaymentResource - { + { + private const string CreateUrl = "payment/postauth/basic"; + public async static Task CreateAsync(CreatePaymentPostAuthRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); + } + public static BasicPaymentPostAuth Create(CreatePaymentPostAuthRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/postauth/basic", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/BasicPaymentPreAuth.cs b/Iyzipay/Model/BasicPaymentPreAuth.cs index 8680f61..d391d82 100644 --- a/Iyzipay/Model/BasicPaymentPreAuth.cs +++ b/Iyzipay/Model/BasicPaymentPreAuth.cs @@ -1,12 +1,18 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class BasicPaymentPreAuth : BasicPaymentResource { + public async static Task CreateAsync(CreateBasicPaymentRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/preauth/basic", GetHttpHeaders(request, options), request); + } + public static BasicPaymentPreAuth Create(CreateBasicPaymentRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/preauth/basic", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/preauth/basic", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/BasicThreedsInitialize.cs b/Iyzipay/Model/BasicThreedsInitialize.cs index c0d759d..03a0a68 100644 --- a/Iyzipay/Model/BasicThreedsInitialize.cs +++ b/Iyzipay/Model/BasicThreedsInitialize.cs @@ -1,6 +1,7 @@ using Iyzipay.Request; using System; using Newtonsoft.Json; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -9,9 +10,20 @@ public class BasicThreedsInitialize : IyzipayResource [JsonProperty(PropertyName = "threeDSHtmlContent")] public String HtmlContent { get; set; } + public async static Task CreateAsync(CreateBasicPaymentRequest request, Options options) + { + BasicThreedsInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/3dsecure/initialize/basic", GetHttpHeaders(request, options), request); + + if (response != null) + { + response.HtmlContent = DigestHelper.DecodeString(response.HtmlContent); + } + return response; + } + public static BasicThreedsInitialize Create(CreateBasicPaymentRequest request, Options options) { - BasicThreedsInitialize response = RestHttpClient.Create().Post(options.BaseUrl + "/payment/3dsecure/initialize/basic", GetHttpHeaders(request, options), request); + BasicThreedsInitialize response = RestHttpClient.Create(options.BaseUrl).Post("payment/3dsecure/initialize/basic", GetHttpHeaders(request, options), request); if (response != null) { diff --git a/Iyzipay/Model/BasicThreedsInitializePreAuth.cs b/Iyzipay/Model/BasicThreedsInitializePreAuth.cs index 981cb71..fc06660 100644 --- a/Iyzipay/Model/BasicThreedsInitializePreAuth.cs +++ b/Iyzipay/Model/BasicThreedsInitializePreAuth.cs @@ -1,6 +1,7 @@ using Iyzipay.Request; using System; using Newtonsoft.Json; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -9,9 +10,20 @@ public class BasicThreedsInitializePreAuth : IyzipayResource [JsonProperty(PropertyName = "threeDSHtmlContent")] public String HtmlContent { get; set; } + public async static Task CreateAsync(CreateBasicPaymentRequest request, Options options) + { + BasicThreedsInitializePreAuth response = await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/3dsecure/initialize/preauth/basic", GetHttpHeaders(request, options), request); + + if (response != null) + { + response.HtmlContent = DigestHelper.DecodeString(response.HtmlContent); + } + return response; + } + public static BasicThreedsInitializePreAuth Create(CreateBasicPaymentRequest request, Options options) { - BasicThreedsInitializePreAuth response = RestHttpClient.Create().Post(options.BaseUrl + "/payment/3dsecure/initialize/preauth/basic", GetHttpHeaders(request, options), request); + BasicThreedsInitializePreAuth response = RestHttpClient.Create(options.BaseUrl).Post("payment/3dsecure/initialize/preauth/basic", GetHttpHeaders(request, options), request); if (response != null) { diff --git a/Iyzipay/Model/BasicThreedsPayment.cs b/Iyzipay/Model/BasicThreedsPayment.cs index 4a621c7..8ad6bf5 100644 --- a/Iyzipay/Model/BasicThreedsPayment.cs +++ b/Iyzipay/Model/BasicThreedsPayment.cs @@ -1,12 +1,18 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class BasicThreedsPayment : BasicPaymentResource { + public async static Task CreateAsync(CreateThreedsPaymentRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/3dsecure/auth/basic", GetHttpHeaders(request, options), request); + } + public static BasicThreedsPayment Create(CreateThreedsPaymentRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/3dsecure/auth/basic", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/3dsecure/auth/basic", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/BinNumber.cs b/Iyzipay/Model/BinNumber.cs index 5643535..4600b09 100644 --- a/Iyzipay/Model/BinNumber.cs +++ b/Iyzipay/Model/BinNumber.cs @@ -1,6 +1,7 @@ using Iyzipay.Request; using Newtonsoft.Json; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -14,9 +15,15 @@ public class BinNumber : IyzipayResource public String BankName { get; set; } public long BankCode { get; set; } + private const string RetrieveUrl = "payment/bin/check"; + public async static Task RetrieveAsync(RetrieveBinNumberRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request); + } + public static BinNumber Retrieve(RetrieveBinNumberRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/bin/check", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Bkm.cs b/Iyzipay/Model/Bkm.cs index 4f47e36..15a1b1f 100644 --- a/Iyzipay/Model/Bkm.cs +++ b/Iyzipay/Model/Bkm.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -8,9 +9,14 @@ public class Bkm : PaymentResource public String Token { get; set; } public String CallbackUrl { get; set; } + public async static Task RetrieveAsync(RetrieveBkmRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/bkm/auth/detail", GetHttpHeaders(request, options), request); + } + public static Bkm Retrieve(RetrieveBkmRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/bkm/auth/detail", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/bkm/auth/detail", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/BkmInitialize.cs b/Iyzipay/Model/BkmInitialize.cs index 4d28da3..6edc092 100644 --- a/Iyzipay/Model/BkmInitialize.cs +++ b/Iyzipay/Model/BkmInitialize.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -8,9 +9,20 @@ public class BkmInitialize : IyzipayResource public String HtmlContent { get; set; } public String Token { get; set; } + public async static Task CreateAsync(CreateBkmInitializeRequest request, Options options) + { + BkmInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/bkm/initialize", GetHttpHeaders(request, options), request); + + if (response != null) + { + response.HtmlContent = DigestHelper.DecodeString(response.HtmlContent); + } + return response; + } + public static BkmInitialize Create(CreateBkmInitializeRequest request, Options options) { - BkmInitialize response = RestHttpClient.Create().Post(options.BaseUrl + "/payment/bkm/initialize", GetHttpHeaders(request, options), request); + BkmInitialize response = RestHttpClient.Create(options.BaseUrl).Post("payment/bkm/initialize", GetHttpHeaders(request, options), request); if (response != null) { diff --git a/Iyzipay/Model/BouncedBankTransferList.cs b/Iyzipay/Model/BouncedBankTransferList.cs index adbe4f5..9c82c21 100644 --- a/Iyzipay/Model/BouncedBankTransferList.cs +++ b/Iyzipay/Model/BouncedBankTransferList.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -9,9 +10,14 @@ public class BouncedBankTransferList : IyzipayResource [JsonProperty(PropertyName = "bouncedRows")] public List BankTransfers { get; set; } + public async static Task RetrieveAsync(RetrieveTransactionsRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("reporting/settlement/bounced", GetHttpHeaders(request, options), request); + } + public static BouncedBankTransferList Retrieve(RetrieveTransactionsRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/reporting/settlement/bounced", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("reporting/settlement/bounced", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Cancel.cs b/Iyzipay/Model/Cancel.cs index d589ff7..b491f74 100644 --- a/Iyzipay/Model/Cancel.cs +++ b/Iyzipay/Model/Cancel.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -10,9 +11,14 @@ public class Cancel : IyzipayResource public String Currency { get; set; } public String ConnectorName { get; set; } + public async static Task CreateAsync(CreateCancelRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/cancel", GetHttpHeaders(request, options), request); + } + public static Cancel Create(CreateCancelRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/cancel", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/cancel", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Card.cs b/Iyzipay/Model/Card.cs index f8cf911..ddd183c 100644 --- a/Iyzipay/Model/Card.cs +++ b/Iyzipay/Model/Card.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -17,14 +18,24 @@ public class Card : IyzipayResource public long? CardBankCode { get; set; } public String CardBankName { get; set; } + public async static Task CreateAsync(CreateCardRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("cardstorage/card", GetHttpHeaders(request, options), request); + } + + public async static Task DeleteAsync(DeleteCardRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).DeleteAsync("cardstorage/card", GetHttpHeaders(request, options), request); + } + public static Card Create(CreateCardRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/cardstorage/card", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("cardstorage/card", GetHttpHeaders(request, options), request); } public static Card Delete(DeleteCardRequest request, Options options) { - return RestHttpClient.Create().Delete(options.BaseUrl + "/cardstorage/card", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Delete("cardstorage/card", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CardList.cs b/Iyzipay/Model/CardList.cs index 929d70f..a507362 100644 --- a/Iyzipay/Model/CardList.cs +++ b/Iyzipay/Model/CardList.cs @@ -1,6 +1,7 @@ using Iyzipay.Request; using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -9,9 +10,14 @@ public class CardList : IyzipayResource public String CardUserKey { get; set; } public List CardDetails { get; set; } + public async static Task RetrieveAsync(RetrieveCardListRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("cardstorage/cards", GetHttpHeaders(request, options), request); + } + public static CardList Retrieve(RetrieveCardListRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/cardstorage/cards", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("cardstorage/cards", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CheckoutForm.cs b/Iyzipay/Model/CheckoutForm.cs index 4fa5ac6..2487182 100644 --- a/Iyzipay/Model/CheckoutForm.cs +++ b/Iyzipay/Model/CheckoutForm.cs @@ -1,16 +1,22 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { public class CheckoutForm : PaymentResource { public String Token { get; set; } - public String CallbackUrl { get; set; } + public String CallbackUrl { get; set; } public static CheckoutForm Retrieve(RetrieveCheckoutFormRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/iyzipos/checkoutform/auth/ecom/detail", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/iyzipos/checkoutform/auth/ecom/detail", GetHttpHeaders(request, options), request); + } + + public async static Task RetrieveAsync(RetrieveCheckoutFormRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/iyzipos/checkoutform/auth/ecom/detail", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CheckoutFormInitialize.cs b/Iyzipay/Model/CheckoutFormInitialize.cs index 90318f9..c699334 100644 --- a/Iyzipay/Model/CheckoutFormInitialize.cs +++ b/Iyzipay/Model/CheckoutFormInitialize.cs @@ -1,12 +1,18 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class CheckoutFormInitialize : CheckoutFormInitializeResource { + public async static Task CreateAsync(CreateCheckoutFormInitializeRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/iyzipos/checkoutform/initialize/auth/ecom", GetHttpHeaders(request, options), request); + } + public static CheckoutFormInitialize Create(CreateCheckoutFormInitializeRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/iyzipos/checkoutform/initialize/auth/ecom", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/iyzipos/checkoutform/initialize/auth/ecom", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CheckoutFormInitializePreAuth.cs b/Iyzipay/Model/CheckoutFormInitializePreAuth.cs index 3701c0a..51aad16 100644 --- a/Iyzipay/Model/CheckoutFormInitializePreAuth.cs +++ b/Iyzipay/Model/CheckoutFormInitializePreAuth.cs @@ -1,12 +1,18 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class CheckoutFormInitializePreAuth : CheckoutFormInitializeResource { + public async static Task CreateAsync(CreateCheckoutFormInitializeRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/iyzipos/checkoutform/initialize/preauth/ecom", GetHttpHeaders(request, options), request); + } + public static CheckoutFormInitializePreAuth Create(CreateCheckoutFormInitializeRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/iyzipos/checkoutform/initialize/preauth/ecom", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/iyzipos/checkoutform/initialize/preauth/ecom", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CrossBookingFromSubMerchant.cs b/Iyzipay/Model/CrossBookingFromSubMerchant.cs index a02dd0c..03b6165 100644 --- a/Iyzipay/Model/CrossBookingFromSubMerchant.cs +++ b/Iyzipay/Model/CrossBookingFromSubMerchant.cs @@ -1,12 +1,18 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class CrossBookingFromSubMerchant : IyzipayResource { + public async static Task CreateAsync(CreateCrossBookingRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("crossbooking/receive", GetHttpHeaders(request, options), request); + } + public static CrossBookingFromSubMerchant Create(CreateCrossBookingRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/crossbooking/receive", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("crossbooking/receive", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CrossBookingToSubMerchant.cs b/Iyzipay/Model/CrossBookingToSubMerchant.cs index e8fe29d..ed6eadc 100644 --- a/Iyzipay/Model/CrossBookingToSubMerchant.cs +++ b/Iyzipay/Model/CrossBookingToSubMerchant.cs @@ -1,12 +1,18 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class CrossBookingToSubMerchant : IyzipayResource { + public async static Task CreateAsync(CreateCrossBookingRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("crossbooking/send", GetHttpHeaders(request, options), request); + } + public static CrossBookingToSubMerchant Create(CreateCrossBookingRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/crossbooking/send", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("crossbooking/send", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Disapproval.cs b/Iyzipay/Model/Disapproval.cs index 9492e58..a98b71e 100644 --- a/Iyzipay/Model/Disapproval.cs +++ b/Iyzipay/Model/Disapproval.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -7,9 +8,14 @@ public class Disapproval : IyzipayResource { public String PaymentTransactionId { get; set; } + public async static Task CreateAsync(CreateApprovalRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/iyzipos/item/disapprove", GetHttpHeaders(request, options), request); + } + public static Disapproval Create(CreateApprovalRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/iyzipos/item/disapprove", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/iyzipos/item/disapprove", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/InstallmentInfo.cs b/Iyzipay/Model/InstallmentInfo.cs index abab833..292a38e 100644 --- a/Iyzipay/Model/InstallmentInfo.cs +++ b/Iyzipay/Model/InstallmentInfo.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System.Collections.Generic; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -7,9 +8,15 @@ public class InstallmentInfo : IyzipayResource { public List InstallmentDetails { get; set; } + private const string RetrieveUrl = "payment/iyzipos/installment"; + public async static Task RetrieveAsync(RetrieveInstallmentInfoRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request); + } + public static InstallmentInfo Retrieve(RetrieveInstallmentInfoRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/iyzipos/installment", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Payment.cs b/Iyzipay/Model/Payment.cs index a42c7b5..c5ea597 100644 --- a/Iyzipay/Model/Payment.cs +++ b/Iyzipay/Model/Payment.cs @@ -1,17 +1,29 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class Payment : PaymentResource { + public async static Task CreateAsync(CreatePaymentRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/auth", GetHttpHeaders(request, options), request); + } + + public async static Task RetrieveAsync(RetrievePaymentRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/detail", GetHttpHeaders(request, options), request); + } + + public static Payment Create(CreatePaymentRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/auth", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/auth", GetHttpHeaders(request, options), request); } public static Payment Retrieve(RetrievePaymentRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/detail", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/detail", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/PaymentPostAuth.cs b/Iyzipay/Model/PaymentPostAuth.cs index ff9202a..8d343e5 100644 --- a/Iyzipay/Model/PaymentPostAuth.cs +++ b/Iyzipay/Model/PaymentPostAuth.cs @@ -1,12 +1,18 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class PaymentPostAuth : PaymentResource { + public async static Task CreateAsync(CreatePaymentPostAuthRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/postauth", GetHttpHeaders(request, options), request); + } + public static PaymentPostAuth Create(CreatePaymentPostAuthRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/postauth", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/postauth", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/PaymentPreAuth.cs b/Iyzipay/Model/PaymentPreAuth.cs index cd326ef..a0ccb76 100644 --- a/Iyzipay/Model/PaymentPreAuth.cs +++ b/Iyzipay/Model/PaymentPreAuth.cs @@ -1,17 +1,29 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class PaymentPreAuth : PaymentResource { - public static PaymentPreAuth Create(CreatePaymentRequest request, Options options) + public async static Task CreateAsync(CreatePaymentRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/preauth", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/preauth", GetHttpHeaders(request, options), request); } - public static PaymentPreAuth Retrieve(RetrievePaymentRequest request, Options options) + public async static Task RetrieveAsync(RetrievePaymentRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/detail", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/detail", GetHttpHeaders(request, options), request); + } + + + public static PaymentPreAuth Create(CreatePaymentRequest request, Options options) + { + return RestHttpClient.Create(options.BaseUrl).Post("payment/preauth", GetHttpHeaders(request, options), request); + } + + public static PaymentPreAuth Retrieve(RetrievePaymentRequest request, Options options) + { + return RestHttpClient.Create(options.BaseUrl).Post("payment/detail", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/PayoutCompletedTransactionList.cs b/Iyzipay/Model/PayoutCompletedTransactionList.cs index 7913835..3bdefa6 100644 --- a/Iyzipay/Model/PayoutCompletedTransactionList.cs +++ b/Iyzipay/Model/PayoutCompletedTransactionList.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System.Collections.Generic; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -7,9 +8,14 @@ public class PayoutCompletedTransactionList : IyzipayResource { public List PayoutCompletedTransactions { get; set; } + public async static Task RetrieveAsync(RetrieveTransactionsRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("reporting/settlement/payoutcompleted", GetHttpHeaders(request, options), request); + } + public static PayoutCompletedTransactionList Retrieve(RetrieveTransactionsRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/reporting/settlement/payoutcompleted", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("reporting/settlement/payoutcompleted", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/PeccoInitialize.cs b/Iyzipay/Model/PeccoInitialize.cs index 7b25ca6..29df1a8 100644 --- a/Iyzipay/Model/PeccoInitialize.cs +++ b/Iyzipay/Model/PeccoInitialize.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -10,9 +11,14 @@ public class PeccoInitialize : IyzipayResource public String Token { get; set; } public long? TokenExpireTime { get; set; } + public async static Task CreateAsync(CreatePeccoInitializeRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/pecco/initialize", GetHttpHeaders(request, options), request); + } + public static PeccoInitialize Create(CreatePeccoInitializeRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/pecco/initialize", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/pecco/initialize", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/PeccoPayment.cs b/Iyzipay/Model/PeccoPayment.cs index cb1c52e..7d8d0aa 100644 --- a/Iyzipay/Model/PeccoPayment.cs +++ b/Iyzipay/Model/PeccoPayment.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -7,9 +8,14 @@ public class PeccoPayment : PaymentResource { public String Token { get; set; } + public async static Task CreateAsync(CreatePeccoPaymentRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/pecco/auth", GetHttpHeaders(request, options), request); + } + public static PeccoPayment Create(CreatePeccoPaymentRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/pecco/auth", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/pecco/auth", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Refund.cs b/Iyzipay/Model/Refund.cs index 625f567..78c6068 100644 --- a/Iyzipay/Model/Refund.cs +++ b/Iyzipay/Model/Refund.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -13,7 +14,12 @@ public class Refund : IyzipayResource public static Refund Create(CreateRefundRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/refund", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/refund", GetHttpHeaders(request, options), request); + } + + public async static Task CreateAsync(CreateRefundRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/refund", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/RefundChargedFromMerchant.cs b/Iyzipay/Model/RefundChargedFromMerchant.cs index 9f7298d..cfdf25c 100644 --- a/Iyzipay/Model/RefundChargedFromMerchant.cs +++ b/Iyzipay/Model/RefundChargedFromMerchant.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -11,7 +12,12 @@ public class RefundChargedFromMerchant : IyzipayResource public static RefundChargedFromMerchant Create(CreateRefundRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/iyzipos/refund/merchant/charge", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("payment/iyzipos/refund/merchant/charge", GetHttpHeaders(request, options), request); + } + + public async static Task CreateAsync(CreateRefundRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/iyzipos/refund/merchant/charge", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/SubMerchant.cs b/Iyzipay/Model/SubMerchant.cs index d111ba4..21d7344 100644 --- a/Iyzipay/Model/SubMerchant.cs +++ b/Iyzipay/Model/SubMerchant.cs @@ -1,5 +1,6 @@ using Iyzipay.Request; using System; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -25,17 +26,33 @@ public class SubMerchant : IyzipayResource public static SubMerchant Create(CreateSubMerchantRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/onboarding/submerchant", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("onboarding/submerchant", GetHttpHeaders(request, options), request); } public static SubMerchant Update(UpdateSubMerchantRequest request, Options options) { - return RestHttpClient.Create().Put(options.BaseUrl + "/onboarding/submerchant", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Put("onboarding/submerchant", GetHttpHeaders(request, options), request); } public static SubMerchant Retrieve(RetrieveSubMerchantRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/onboarding/submerchant/detail", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post("onboarding/submerchant/detail", GetHttpHeaders(request, options), request); + } + + + public async static Task CreateAsync(CreateSubMerchantRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("onboarding/submerchant", GetHttpHeaders(request, options), request); + } + + public async static Task UpdateAsync(UpdateSubMerchantRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PutAsync("onboarding/submerchant", GetHttpHeaders(request, options), request); + } + + public async static Task RetrieveAsync(RetrieveSubMerchantRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync("onboarding/submerchant/detail", GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/ThreedsInitialize.cs b/Iyzipay/Model/ThreedsInitialize.cs index a840b73..c9ecf8d 100644 --- a/Iyzipay/Model/ThreedsInitialize.cs +++ b/Iyzipay/Model/ThreedsInitialize.cs @@ -1,6 +1,7 @@ using Iyzipay.Request; using System; using Newtonsoft.Json; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -11,7 +12,18 @@ public class ThreedsInitialize : IyzipayResource public static ThreedsInitialize Create(CreatePaymentRequest request, Options options) { - ThreedsInitialize response = RestHttpClient.Create().Post(options.BaseUrl + "/payment/3dsecure/initialize", GetHttpHeaders(request, options), request); + ThreedsInitialize response = RestHttpClient.Create(options.BaseUrl).Post("payment/3dsecure/initialize", GetHttpHeaders(request, options), request); + + if (response != null) + { + response.HtmlContent = DigestHelper.DecodeString(response.HtmlContent); + } + return response; + } + + public async static Task CreateAsync(CreatePaymentRequest request, Options options) + { + ThreedsInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/3dsecure/initialize", GetHttpHeaders(request, options), request); if (response != null) { diff --git a/Iyzipay/Model/ThreedsInitializePreAuth.cs b/Iyzipay/Model/ThreedsInitializePreAuth.cs index bf28694..004b723 100644 --- a/Iyzipay/Model/ThreedsInitializePreAuth.cs +++ b/Iyzipay/Model/ThreedsInitializePreAuth.cs @@ -1,6 +1,7 @@ using Iyzipay.Request; using System; using Newtonsoft.Json; +using System.Threading.Tasks; namespace Iyzipay.Model { @@ -9,9 +10,22 @@ public class ThreedsInitializePreAuth : IyzipayResource [JsonProperty(PropertyName = "threeDSHtmlContent")] public String HtmlContent { get; set; } + private const string CreateUrl = "payment/3dsecure/initialize/preauth"; + public static ThreedsInitializePreAuth Create(CreatePaymentRequest request, Options options) { - ThreedsInitializePreAuth response = RestHttpClient.Create().Post(options.BaseUrl + "/payment/3dsecure/initialize/preauth", GetHttpHeaders(request, options), request); + ThreedsInitializePreAuth response = RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); + + if (response != null) + { + response.HtmlContent = DigestHelper.DecodeString(response.HtmlContent); + } + return response; + } + + public async static Task CreateAsync(CreatePaymentRequest request, Options options) + { + ThreedsInitializePreAuth response = await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); if (response != null) { diff --git a/Iyzipay/Model/ThreedsPayment.cs b/Iyzipay/Model/ThreedsPayment.cs index 4d42a22..6eb5fcd 100644 --- a/Iyzipay/Model/ThreedsPayment.cs +++ b/Iyzipay/Model/ThreedsPayment.cs @@ -1,17 +1,32 @@ using Iyzipay.Request; +using System.Threading.Tasks; namespace Iyzipay.Model { public class ThreedsPayment : PaymentResource { + private const string CreateUrl = "payment/3dsecure/auth"; + private const string RetrieveUrl = "payment/detail"; public static ThreedsPayment Create(CreateThreedsPaymentRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/3dsecure/auth", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } public static ThreedsPayment Retrieve(RetrievePaymentRequest request, Options options) { - return RestHttpClient.Create().Post(options.BaseUrl + "/payment/detail", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); + } + + + + public async static Task CreateAsync(CreateThreedsPaymentRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); + } + + public async static Task RetrieveAsync(RetrievePaymentRequest request, Options options) + { + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/RestHttpClient.cs b/Iyzipay/RestHttpClient.cs index a83efd7..7f8e2e9 100644 --- a/Iyzipay/RestHttpClient.cs +++ b/Iyzipay/RestHttpClient.cs @@ -2,66 +2,154 @@ using System; using System.Net; using System.Net.Http; +using System.Text; +using System.Threading.Tasks; namespace Iyzipay { public class RestHttpClient { + private static readonly HttpClient _httpClient; + static RestHttpClient() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + _httpClient = new HttpClient(); + _httpClient.DefaultRequestHeaders.Clear(); + _httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); + _httpClient.DefaultRequestHeaders.Add("x-iyzi-client-version", "iyzipay-dotnet-2.1.13"); } + private RestHttpClient(string baseUrl) + { + if (_httpClient.BaseAddress == null) + { + _httpClient.BaseAddress = new Uri(baseUrl); + } + + } + public static RestHttpClient Create(string baseUrl) + { + + return new RestHttpClient(baseUrl); + + } - public static RestHttpClient Create() + public async Task GetAsync(String url) { - return new RestHttpClient(); + var httpMessage = new HttpRequestMessage(HttpMethod.Get, url); + + HttpResponseMessage httpResponseMessage = await _httpClient.GetAsync(url).ConfigureAwait(false); + + return JsonConvert.DeserializeObject(await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false)); } public T Get(String url) { - HttpClient httpClient = new HttpClient(); - HttpResponseMessage httpResponseMessage = httpClient.GetAsync(url).Result; + var httpMessage = new HttpRequestMessage(HttpMethod.Get, url); + + HttpResponseMessage httpResponseMessage = _httpClient.GetAsync(url).Result; return JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); } + public async Task PostAsync(String url, WebHeaderCollection headers, BaseRequest request) + { + HttpRequestMessage requestMessage = new HttpRequestMessage + { + Content = JsonBuilder.ToJsonString(request), + Method = HttpMethod.Post, + RequestUri = new Uri(url, UriKind.Relative) + }; + foreach (String key in headers.Keys) + { + requestMessage.Headers.Add(key, headers.Get(key)); + } + HttpResponseMessage httpResponseMessage = await _httpClient.SendAsync(requestMessage).ConfigureAwait(false); + return JsonConvert.DeserializeObject(await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false)); + } + public T Post(String url, WebHeaderCollection headers, BaseRequest request) { - HttpClient httpClient = new HttpClient(); + HttpRequestMessage requestMessage = new HttpRequestMessage + { + Content = JsonBuilder.ToJsonString(request), + Method = HttpMethod.Post, + RequestUri = new Uri(url, UriKind.Relative) + }; foreach (String key in headers.Keys) { - httpClient.DefaultRequestHeaders.Add(key, headers.Get(key)); + requestMessage.Headers.Add(key, headers.Get(key)); } - HttpResponseMessage httpResponseMessage = httpClient.PostAsync(url, JsonBuilder.ToJsonString(request)).Result; + + HttpResponseMessage httpResponseMessage = _httpClient.SendAsync(requestMessage).Result; return JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); } - public T Delete(String url, WebHeaderCollection headers, BaseRequest request) + public async Task DeleteAsync(String url, WebHeaderCollection headers, BaseRequest request) { - HttpClient httpClient = new HttpClient(); + HttpRequestMessage requestMessage = new HttpRequestMessage + { + Content = JsonBuilder.ToJsonString(request), + Method = HttpMethod.Delete, + RequestUri = new Uri(url, UriKind.Relative) + }; foreach (String key in headers.Keys) { - httpClient.DefaultRequestHeaders.Add(key, headers.Get(key)); + requestMessage.Headers.Add(key, headers.Get(key)); } + + HttpResponseMessage httpResponseMessage = await _httpClient.SendAsync(requestMessage).ConfigureAwait(false); + return JsonConvert.DeserializeObject(await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false)); + } + + public T Delete(String url, WebHeaderCollection headers, BaseRequest request) + { HttpRequestMessage requestMessage = new HttpRequestMessage { Content = JsonBuilder.ToJsonString(request), Method = HttpMethod.Delete, - RequestUri = new Uri(url) - + RequestUri = new Uri(url, UriKind.Relative) }; - HttpResponseMessage httpResponseMessage = httpClient.SendAsync(requestMessage).Result; + foreach (String key in headers.Keys) + { + requestMessage.Headers.Add(key, headers.Get(key)); + } + + HttpResponseMessage httpResponseMessage = _httpClient.SendAsync(requestMessage).Result; return JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); } + public async Task PutAsync(String url, WebHeaderCollection headers, BaseRequest request) + { + HttpRequestMessage requestMessage = new HttpRequestMessage + { + Content = JsonBuilder.ToJsonString(request), + Method = HttpMethod.Put, + RequestUri = new Uri(url, UriKind.Relative) + }; + foreach (String key in headers.Keys) + { + requestMessage.Headers.Add(key, headers.Get(key)); + } + + HttpResponseMessage httpResponseMessage = await _httpClient.SendAsync(requestMessage).ConfigureAwait(false); + return JsonConvert.DeserializeObject(await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false)); + } + public T Put(String url, WebHeaderCollection headers, BaseRequest request) { - HttpClient httpClient = new HttpClient(); + HttpRequestMessage requestMessage = new HttpRequestMessage + { + Content = JsonBuilder.ToJsonString(request), + Method = HttpMethod.Put, + RequestUri = new Uri(url, UriKind.Relative) + }; foreach (String key in headers.Keys) { - httpClient.DefaultRequestHeaders.Add(key, headers.Get(key)); + requestMessage.Headers.Add(key, headers.Get(key)); } - HttpResponseMessage httpResponseMessage = httpClient.PutAsync(url, JsonBuilder.ToJsonString(request)).Result; + + HttpResponseMessage httpResponseMessage = _httpClient.SendAsync(requestMessage).Result; return JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); } } From 90eaef6d11e4b2f5ea8628426dbb354974b00aa6 Mon Sep 17 00:00:00 2001 From: SINAN TAVILOGLU Date: Thu, 8 Feb 2018 09:25:52 +0300 Subject: [PATCH 3/5] Update Sample.cs --- Iyzipay.Samples/Sample.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Iyzipay.Samples/Sample.cs b/Iyzipay.Samples/Sample.cs index 8cc0e44..99a6949 100644 --- a/Iyzipay.Samples/Sample.cs +++ b/Iyzipay.Samples/Sample.cs @@ -13,8 +13,8 @@ public class Sample public void Initialize() { options = new Options(); - options.ApiKey = "sandbox-etvOpp5dmDk7VH2HMmmtUoZLCemBiaXE"; - options.SecretKey = "sandbox-tfkpngBqftBTIsQvtaXWubbxRQbchv2r"; + options.ApiKey = "api key"; + options.SecretKey = "secret key"; options.BaseUrl = "https://sandbox-api.iyzipay.com"; } From 7f53ef6f088609080944f7101244faa94c6d3c23 Mon Sep 17 00:00:00 2001 From: Sinan Taviloglu Date: Thu, 8 Feb 2018 10:57:42 +0300 Subject: [PATCH 4/5] =?UTF-8?q?httpmetodlar=C4=B1=20refactor=20edildi.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Iyzipay/RestHttpClient.cs | 81 +++++++-------------------------------- 1 file changed, 13 insertions(+), 68 deletions(-) diff --git a/Iyzipay/RestHttpClient.cs b/Iyzipay/RestHttpClient.cs index 7f8e2e9..1cdbf26 100644 --- a/Iyzipay/RestHttpClient.cs +++ b/Iyzipay/RestHttpClient.cs @@ -54,103 +54,48 @@ public T Get(String url) public async Task PostAsync(String url, WebHeaderCollection headers, BaseRequest request) { - HttpRequestMessage requestMessage = new HttpRequestMessage - { - Content = JsonBuilder.ToJsonString(request), - Method = HttpMethod.Post, - RequestUri = new Uri(url, UriKind.Relative) - }; - foreach (String key in headers.Keys) - { - requestMessage.Headers.Add(key, headers.Get(key)); - } - HttpResponseMessage httpResponseMessage = await _httpClient.SendAsync(requestMessage).ConfigureAwait(false); - return JsonConvert.DeserializeObject(await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false)); + return await SendHttpRequestAsync(url, HttpMethod.Post, headers, request); } public T Post(String url, WebHeaderCollection headers, BaseRequest request) { - HttpRequestMessage requestMessage = new HttpRequestMessage - { - Content = JsonBuilder.ToJsonString(request), - Method = HttpMethod.Post, - RequestUri = new Uri(url, UriKind.Relative) - }; - foreach (String key in headers.Keys) - { - requestMessage.Headers.Add(key, headers.Get(key)); - } - - HttpResponseMessage httpResponseMessage = _httpClient.SendAsync(requestMessage).Result; - return JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); + return SendHttpRequestAsync(url, HttpMethod.Post, headers, request).Result; } public async Task DeleteAsync(String url, WebHeaderCollection headers, BaseRequest request) { - HttpRequestMessage requestMessage = new HttpRequestMessage - { - Content = JsonBuilder.ToJsonString(request), - Method = HttpMethod.Delete, - RequestUri = new Uri(url, UriKind.Relative) - }; - foreach (String key in headers.Keys) - { - requestMessage.Headers.Add(key, headers.Get(key)); - } - - HttpResponseMessage httpResponseMessage = await _httpClient.SendAsync(requestMessage).ConfigureAwait(false); - return JsonConvert.DeserializeObject(await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false)); + return await SendHttpRequestAsync(url, HttpMethod.Delete, headers, request); } public T Delete(String url, WebHeaderCollection headers, BaseRequest request) { - HttpRequestMessage requestMessage = new HttpRequestMessage - { - Content = JsonBuilder.ToJsonString(request), - Method = HttpMethod.Delete, - RequestUri = new Uri(url, UriKind.Relative) - }; - foreach (String key in headers.Keys) - { - requestMessage.Headers.Add(key, headers.Get(key)); - } - - HttpResponseMessage httpResponseMessage = _httpClient.SendAsync(requestMessage).Result; - return JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); + return SendHttpRequestAsync(url, HttpMethod.Delete, headers, request).Result; } public async Task PutAsync(String url, WebHeaderCollection headers, BaseRequest request) { - HttpRequestMessage requestMessage = new HttpRequestMessage - { - Content = JsonBuilder.ToJsonString(request), - Method = HttpMethod.Put, - RequestUri = new Uri(url, UriKind.Relative) - }; - foreach (String key in headers.Keys) - { - requestMessage.Headers.Add(key, headers.Get(key)); - } - - HttpResponseMessage httpResponseMessage = await _httpClient.SendAsync(requestMessage).ConfigureAwait(false); - return JsonConvert.DeserializeObject(await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false)); + return await SendHttpRequestAsync(url, HttpMethod.Put, headers, request); } public T Put(String url, WebHeaderCollection headers, BaseRequest request) + { + return SendHttpRequestAsync(url, HttpMethod.Put, headers, request).Result; + } + + public async Task SendHttpRequestAsync(string url, HttpMethod method, WebHeaderCollection headers, BaseRequest request) { HttpRequestMessage requestMessage = new HttpRequestMessage { Content = JsonBuilder.ToJsonString(request), - Method = HttpMethod.Put, + Method = method, RequestUri = new Uri(url, UriKind.Relative) }; foreach (String key in headers.Keys) { requestMessage.Headers.Add(key, headers.Get(key)); } - - HttpResponseMessage httpResponseMessage = _httpClient.SendAsync(requestMessage).Result; - return JsonConvert.DeserializeObject(httpResponseMessage.Content.ReadAsStringAsync().Result); + HttpResponseMessage httpResponseMessage = await _httpClient.SendAsync(requestMessage).ConfigureAwait(false); + return JsonConvert.DeserializeObject(await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false)); } } } From 1063982e7e554569454b4a35499d1d1e2b663690 Mon Sep 17 00:00:00 2001 From: Sinan Taviloglu Date: Thu, 8 Feb 2018 11:24:34 +0300 Subject: [PATCH 5/5] - refactoring - Async metodlara ConfigureAwait(false) eklendi. --- Iyzipay/Model/ApiTest.cs | 2 +- Iyzipay/Model/Apm.cs | 4 ++-- Iyzipay/Model/Approval.cs | 2 +- Iyzipay/Model/BasicBkm.cs | 2 +- Iyzipay/Model/BasicBkmInitialize.cs | 2 +- Iyzipay/Model/BasicPayment.cs | 2 +- Iyzipay/Model/BasicPaymentPostAuth.cs | 2 +- Iyzipay/Model/BasicPaymentPreAuth.cs | 2 +- Iyzipay/Model/BasicThreedsInitialize.cs | 2 +- Iyzipay/Model/BasicThreedsInitializePreAuth.cs | 5 +++-- Iyzipay/Model/BasicThreedsPayment.cs | 5 +++-- Iyzipay/Model/BinNumber.cs | 2 +- Iyzipay/Model/Bkm.cs | 7 ++++--- Iyzipay/Model/BkmInitialize.cs | 7 ++++--- Iyzipay/Model/BouncedBankTransferList.cs | 5 +++-- Iyzipay/Model/Cancel.cs | 5 +++-- Iyzipay/Model/Card.cs | 10 ++++++---- Iyzipay/Model/CardList.cs | 5 +++-- Iyzipay/Model/CheckoutForm.cs | 5 +++-- Iyzipay/Model/CheckoutFormInitialize.cs | 5 +++-- Iyzipay/Model/CheckoutFormInitializePreAuth.cs | 5 +++-- Iyzipay/Model/CrossBookingFromSubMerchant.cs | 5 +++-- Iyzipay/Model/CrossBookingToSubMerchant.cs | 5 +++-- Iyzipay/Model/Disapproval.cs | 5 +++-- Iyzipay/Model/InstallmentInfo.cs | 2 +- Iyzipay/Model/Payment.cs | 10 ++++++---- Iyzipay/Model/PaymentPostAuth.cs | 7 ++++--- Iyzipay/Model/PaymentPreAuth.cs | 14 ++++++++------ Iyzipay/Model/PayoutCompletedTransactionList.cs | 6 +++--- Iyzipay/Model/PeccoInitialize.cs | 5 +++-- Iyzipay/Model/PeccoPayment.cs | 5 +++-- Iyzipay/Model/Refund.cs | 5 +++-- Iyzipay/Model/RefundChargedFromMerchant.cs | 5 +++-- Iyzipay/Model/SubMerchant.cs | 15 +++++++++------ Iyzipay/Model/ThreedsInitialize.cs | 5 +++-- Iyzipay/Model/ThreedsInitializePreAuth.cs | 2 +- Iyzipay/Model/ThreedsPayment.cs | 4 ++-- 37 files changed, 107 insertions(+), 79 deletions(-) diff --git a/Iyzipay/Model/ApiTest.cs b/Iyzipay/Model/ApiTest.cs index b74f605..adcc9be 100644 --- a/Iyzipay/Model/ApiTest.cs +++ b/Iyzipay/Model/ApiTest.cs @@ -8,7 +8,7 @@ public class ApiTest : IyzipayResource public async static Task RetrieveAsync(Options options) { - return await RestHttpClient.Create(options.BaseUrl).GetAsync(RetrieveUrl); + return await RestHttpClient.Create(options.BaseUrl).GetAsync(RetrieveUrl).ConfigureAwait(false); } public static IyzipayResource Retrieve(Options options) diff --git a/Iyzipay/Model/Apm.cs b/Iyzipay/Model/Apm.cs index 44ef81a..347704c 100644 --- a/Iyzipay/Model/Apm.cs +++ b/Iyzipay/Model/Apm.cs @@ -9,12 +9,12 @@ public class Apm : ApmResource private const string RetrieveUrl = "payment/apm/retrieve"; public async static Task CreateAsync(CreateApmInitializeRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public async static Task RetrieveAsync(RetrieveApmRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static Apm Create(CreateApmInitializeRequest request, Options options) diff --git a/Iyzipay/Model/Approval.cs b/Iyzipay/Model/Approval.cs index 46dd1d1..3531c5a 100644 --- a/Iyzipay/Model/Approval.cs +++ b/Iyzipay/Model/Approval.cs @@ -16,7 +16,7 @@ public static Approval Create(CreateApprovalRequest request, Options options) public async static Task CreateAsync(CreateApprovalRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } } } diff --git a/Iyzipay/Model/BasicBkm.cs b/Iyzipay/Model/BasicBkm.cs index 541db15..696b791 100644 --- a/Iyzipay/Model/BasicBkm.cs +++ b/Iyzipay/Model/BasicBkm.cs @@ -13,7 +13,7 @@ public class BasicBkm : BasicPaymentResource private const string RetrieveUrl = "payment/bkm/auth/detail/basic"; public async static Task RetrieveAsync(RetrieveBkmRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static BasicBkm Retrieve(RetrieveBkmRequest request, Options options) diff --git a/Iyzipay/Model/BasicBkmInitialize.cs b/Iyzipay/Model/BasicBkmInitialize.cs index 4a7ec82..4b4637a 100644 --- a/Iyzipay/Model/BasicBkmInitialize.cs +++ b/Iyzipay/Model/BasicBkmInitialize.cs @@ -12,7 +12,7 @@ public class BasicBkmInitialize : IyzipayResource private const string CreateUrl = "payment/bkm/initialize/basic"; public async static Task CreateAsync(CreateBasicBkmInitializeRequest request, Options options) { - BasicBkmInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); + BasicBkmInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); if (response != null) { diff --git a/Iyzipay/Model/BasicPayment.cs b/Iyzipay/Model/BasicPayment.cs index bed3e75..d555968 100644 --- a/Iyzipay/Model/BasicPayment.cs +++ b/Iyzipay/Model/BasicPayment.cs @@ -8,7 +8,7 @@ public class BasicPayment : BasicPaymentResource private const string CerateUrl = "payment/auth/basic"; public async static Task CreateAsync(CreateBasicPaymentRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync(CerateUrl, GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CerateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static BasicPayment Create(CreateBasicPaymentRequest request, Options options) diff --git a/Iyzipay/Model/BasicPaymentPostAuth.cs b/Iyzipay/Model/BasicPaymentPostAuth.cs index 649d8d3..0e91a89 100644 --- a/Iyzipay/Model/BasicPaymentPostAuth.cs +++ b/Iyzipay/Model/BasicPaymentPostAuth.cs @@ -8,7 +8,7 @@ public class BasicPaymentPostAuth : BasicPaymentResource private const string CreateUrl = "payment/postauth/basic"; public async static Task CreateAsync(CreatePaymentPostAuthRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static BasicPaymentPostAuth Create(CreatePaymentPostAuthRequest request, Options options) diff --git a/Iyzipay/Model/BasicPaymentPreAuth.cs b/Iyzipay/Model/BasicPaymentPreAuth.cs index d391d82..c7a70d9 100644 --- a/Iyzipay/Model/BasicPaymentPreAuth.cs +++ b/Iyzipay/Model/BasicPaymentPreAuth.cs @@ -7,7 +7,7 @@ public class BasicPaymentPreAuth : BasicPaymentResource { public async static Task CreateAsync(CreateBasicPaymentRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/preauth/basic", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/preauth/basic", GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static BasicPaymentPreAuth Create(CreateBasicPaymentRequest request, Options options) diff --git a/Iyzipay/Model/BasicThreedsInitialize.cs b/Iyzipay/Model/BasicThreedsInitialize.cs index 03a0a68..4f6303f 100644 --- a/Iyzipay/Model/BasicThreedsInitialize.cs +++ b/Iyzipay/Model/BasicThreedsInitialize.cs @@ -12,7 +12,7 @@ public class BasicThreedsInitialize : IyzipayResource public async static Task CreateAsync(CreateBasicPaymentRequest request, Options options) { - BasicThreedsInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/3dsecure/initialize/basic", GetHttpHeaders(request, options), request); + BasicThreedsInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/3dsecure/initialize/basic", GetHttpHeaders(request, options), request).ConfigureAwait(false); if (response != null) { diff --git a/Iyzipay/Model/BasicThreedsInitializePreAuth.cs b/Iyzipay/Model/BasicThreedsInitializePreAuth.cs index fc06660..5b7bbb0 100644 --- a/Iyzipay/Model/BasicThreedsInitializePreAuth.cs +++ b/Iyzipay/Model/BasicThreedsInitializePreAuth.cs @@ -10,9 +10,10 @@ public class BasicThreedsInitializePreAuth : IyzipayResource [JsonProperty(PropertyName = "threeDSHtmlContent")] public String HtmlContent { get; set; } + private const string CreateUrl = "payment/3dsecure/initialize/preauth/basic"; public async static Task CreateAsync(CreateBasicPaymentRequest request, Options options) { - BasicThreedsInitializePreAuth response = await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/3dsecure/initialize/preauth/basic", GetHttpHeaders(request, options), request); + BasicThreedsInitializePreAuth response = await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); if (response != null) { @@ -23,7 +24,7 @@ public async static Task CreateAsync(CreateBasicP public static BasicThreedsInitializePreAuth Create(CreateBasicPaymentRequest request, Options options) { - BasicThreedsInitializePreAuth response = RestHttpClient.Create(options.BaseUrl).Post("payment/3dsecure/initialize/preauth/basic", GetHttpHeaders(request, options), request); + BasicThreedsInitializePreAuth response = RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); if (response != null) { diff --git a/Iyzipay/Model/BasicThreedsPayment.cs b/Iyzipay/Model/BasicThreedsPayment.cs index 8ad6bf5..5d7c000 100644 --- a/Iyzipay/Model/BasicThreedsPayment.cs +++ b/Iyzipay/Model/BasicThreedsPayment.cs @@ -5,14 +5,15 @@ namespace Iyzipay.Model { public class BasicThreedsPayment : BasicPaymentResource { + private const string CreateUrl = "payment/3dsecure/auth/basic"; public async static Task CreateAsync(CreateThreedsPaymentRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/3dsecure/auth/basic", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static BasicThreedsPayment Create(CreateThreedsPaymentRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/3dsecure/auth/basic", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/BinNumber.cs b/Iyzipay/Model/BinNumber.cs index 4600b09..c53239c 100644 --- a/Iyzipay/Model/BinNumber.cs +++ b/Iyzipay/Model/BinNumber.cs @@ -18,7 +18,7 @@ public class BinNumber : IyzipayResource private const string RetrieveUrl = "payment/bin/check"; public async static Task RetrieveAsync(RetrieveBinNumberRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static BinNumber Retrieve(RetrieveBinNumberRequest request, Options options) diff --git a/Iyzipay/Model/Bkm.cs b/Iyzipay/Model/Bkm.cs index 15a1b1f..87caf2f 100644 --- a/Iyzipay/Model/Bkm.cs +++ b/Iyzipay/Model/Bkm.cs @@ -7,16 +7,17 @@ namespace Iyzipay.Model public class Bkm : PaymentResource { public String Token { get; set; } - public String CallbackUrl { get; set; } + public String CallbackUrl { get; set; } + private const string RetrieveUrl = "payment/bkm/auth/detail"; public async static Task RetrieveAsync(RetrieveBkmRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/bkm/auth/detail", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static Bkm Retrieve(RetrieveBkmRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/bkm/auth/detail", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/BkmInitialize.cs b/Iyzipay/Model/BkmInitialize.cs index 6edc092..6841696 100644 --- a/Iyzipay/Model/BkmInitialize.cs +++ b/Iyzipay/Model/BkmInitialize.cs @@ -8,10 +8,11 @@ public class BkmInitialize : IyzipayResource { public String HtmlContent { get; set; } public String Token { get; set; } - + + private const string CreateUrl = "payment/bkm/initialize"; public async static Task CreateAsync(CreateBkmInitializeRequest request, Options options) { - BkmInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/bkm/initialize", GetHttpHeaders(request, options), request); + BkmInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); if (response != null) { @@ -22,7 +23,7 @@ public async static Task CreateAsync(CreateBkmInitializeRequest r public static BkmInitialize Create(CreateBkmInitializeRequest request, Options options) { - BkmInitialize response = RestHttpClient.Create(options.BaseUrl).Post("payment/bkm/initialize", GetHttpHeaders(request, options), request); + BkmInitialize response = RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); if (response != null) { diff --git a/Iyzipay/Model/BouncedBankTransferList.cs b/Iyzipay/Model/BouncedBankTransferList.cs index 9c82c21..c0607e2 100644 --- a/Iyzipay/Model/BouncedBankTransferList.cs +++ b/Iyzipay/Model/BouncedBankTransferList.cs @@ -10,14 +10,15 @@ public class BouncedBankTransferList : IyzipayResource [JsonProperty(PropertyName = "bouncedRows")] public List BankTransfers { get; set; } + private const string RetrieveUrl = "reporting/settlement/bounced"; public async static Task RetrieveAsync(RetrieveTransactionsRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("reporting/settlement/bounced", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static BouncedBankTransferList Retrieve(RetrieveTransactionsRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("reporting/settlement/bounced", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Cancel.cs b/Iyzipay/Model/Cancel.cs index b491f74..f7b83f6 100644 --- a/Iyzipay/Model/Cancel.cs +++ b/Iyzipay/Model/Cancel.cs @@ -11,14 +11,15 @@ public class Cancel : IyzipayResource public String Currency { get; set; } public String ConnectorName { get; set; } + private const string CreateUrl = "payment/cancel"; public async static Task CreateAsync(CreateCancelRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/cancel", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static Cancel Create(CreateCancelRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/cancel", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Card.cs b/Iyzipay/Model/Card.cs index ddd183c..1ef3e34 100644 --- a/Iyzipay/Model/Card.cs +++ b/Iyzipay/Model/Card.cs @@ -18,24 +18,26 @@ public class Card : IyzipayResource public long? CardBankCode { get; set; } public String CardBankName { get; set; } + private const string CreateUrl = "cardstorage/card"; + private const string DeleteUrl = "cardstorage/card"; public async static Task CreateAsync(CreateCardRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("cardstorage/card", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public async static Task DeleteAsync(DeleteCardRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).DeleteAsync("cardstorage/card", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).DeleteAsync(DeleteUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static Card Create(CreateCardRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("cardstorage/card", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(DeleteUrl, GetHttpHeaders(request, options), request); } public static Card Delete(DeleteCardRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Delete("cardstorage/card", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Delete(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CardList.cs b/Iyzipay/Model/CardList.cs index a507362..a9e06c2 100644 --- a/Iyzipay/Model/CardList.cs +++ b/Iyzipay/Model/CardList.cs @@ -10,14 +10,15 @@ public class CardList : IyzipayResource public String CardUserKey { get; set; } public List CardDetails { get; set; } + private const string RetrieveUrl = "cardstorage/cards"; public async static Task RetrieveAsync(RetrieveCardListRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("cardstorage/cards", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static CardList Retrieve(RetrieveCardListRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("cardstorage/cards", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CheckoutForm.cs b/Iyzipay/Model/CheckoutForm.cs index 2487182..c92b6b3 100644 --- a/Iyzipay/Model/CheckoutForm.cs +++ b/Iyzipay/Model/CheckoutForm.cs @@ -9,14 +9,15 @@ public class CheckoutForm : PaymentResource public String Token { get; set; } public String CallbackUrl { get; set; } + private const string RetrieveUrl = "payment/iyzipos/checkoutform/auth/ecom/detail"; public static CheckoutForm Retrieve(RetrieveCheckoutFormRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/iyzipos/checkoutform/auth/ecom/detail", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } public async static Task RetrieveAsync(RetrieveCheckoutFormRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/iyzipos/checkoutform/auth/ecom/detail", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } } } diff --git a/Iyzipay/Model/CheckoutFormInitialize.cs b/Iyzipay/Model/CheckoutFormInitialize.cs index c699334..9aeb3a7 100644 --- a/Iyzipay/Model/CheckoutFormInitialize.cs +++ b/Iyzipay/Model/CheckoutFormInitialize.cs @@ -5,14 +5,15 @@ namespace Iyzipay.Model { public class CheckoutFormInitialize : CheckoutFormInitializeResource { + private const string CreateUrl = "payment/iyzipos/checkoutform/initialize/auth/ecom"; public async static Task CreateAsync(CreateCheckoutFormInitializeRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/iyzipos/checkoutform/initialize/auth/ecom", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static CheckoutFormInitialize Create(CreateCheckoutFormInitializeRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/iyzipos/checkoutform/initialize/auth/ecom", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CheckoutFormInitializePreAuth.cs b/Iyzipay/Model/CheckoutFormInitializePreAuth.cs index 51aad16..7088a35 100644 --- a/Iyzipay/Model/CheckoutFormInitializePreAuth.cs +++ b/Iyzipay/Model/CheckoutFormInitializePreAuth.cs @@ -5,14 +5,15 @@ namespace Iyzipay.Model { public class CheckoutFormInitializePreAuth : CheckoutFormInitializeResource { + private const string CreateUrl = "payment/iyzipos/checkoutform/initialize/preauth/ecom"; public async static Task CreateAsync(CreateCheckoutFormInitializeRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/iyzipos/checkoutform/initialize/preauth/ecom", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static CheckoutFormInitializePreAuth Create(CreateCheckoutFormInitializeRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/iyzipos/checkoutform/initialize/preauth/ecom", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CrossBookingFromSubMerchant.cs b/Iyzipay/Model/CrossBookingFromSubMerchant.cs index 03b6165..df1634f 100644 --- a/Iyzipay/Model/CrossBookingFromSubMerchant.cs +++ b/Iyzipay/Model/CrossBookingFromSubMerchant.cs @@ -5,14 +5,15 @@ namespace Iyzipay.Model { public class CrossBookingFromSubMerchant : IyzipayResource { + private const string CreateUrl = "crossbooking/receive"; public async static Task CreateAsync(CreateCrossBookingRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("crossbooking/receive", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static CrossBookingFromSubMerchant Create(CreateCrossBookingRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("crossbooking/receive", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/CrossBookingToSubMerchant.cs b/Iyzipay/Model/CrossBookingToSubMerchant.cs index ed6eadc..c375fb0 100644 --- a/Iyzipay/Model/CrossBookingToSubMerchant.cs +++ b/Iyzipay/Model/CrossBookingToSubMerchant.cs @@ -5,14 +5,15 @@ namespace Iyzipay.Model { public class CrossBookingToSubMerchant : IyzipayResource { + private const string CreateUrl = "crossbooking/send"; public async static Task CreateAsync(CreateCrossBookingRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("crossbooking/send", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static CrossBookingToSubMerchant Create(CreateCrossBookingRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("crossbooking/send", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Disapproval.cs b/Iyzipay/Model/Disapproval.cs index a98b71e..4629e22 100644 --- a/Iyzipay/Model/Disapproval.cs +++ b/Iyzipay/Model/Disapproval.cs @@ -8,14 +8,15 @@ public class Disapproval : IyzipayResource { public String PaymentTransactionId { get; set; } + private const string CreateUrl = "payment/iyzipos/item/disapprove"; public async static Task CreateAsync(CreateApprovalRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/iyzipos/item/disapprove", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static Disapproval Create(CreateApprovalRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/iyzipos/item/disapprove", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/InstallmentInfo.cs b/Iyzipay/Model/InstallmentInfo.cs index 292a38e..8662e0a 100644 --- a/Iyzipay/Model/InstallmentInfo.cs +++ b/Iyzipay/Model/InstallmentInfo.cs @@ -11,7 +11,7 @@ public class InstallmentInfo : IyzipayResource private const string RetrieveUrl = "payment/iyzipos/installment"; public async static Task RetrieveAsync(RetrieveInstallmentInfoRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static InstallmentInfo Retrieve(RetrieveInstallmentInfoRequest request, Options options) diff --git a/Iyzipay/Model/Payment.cs b/Iyzipay/Model/Payment.cs index c5ea597..b1efce7 100644 --- a/Iyzipay/Model/Payment.cs +++ b/Iyzipay/Model/Payment.cs @@ -5,25 +5,27 @@ namespace Iyzipay.Model { public class Payment : PaymentResource { + private const string CreateUrl = "payment/auth"; + private const string RetrieveUrl = "payment/detail"; public async static Task CreateAsync(CreatePaymentRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/auth", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public async static Task RetrieveAsync(RetrievePaymentRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/detail", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static Payment Create(CreatePaymentRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/auth", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } public static Payment Retrieve(RetrievePaymentRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/detail", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/PaymentPostAuth.cs b/Iyzipay/Model/PaymentPostAuth.cs index 8d343e5..0c8794c 100644 --- a/Iyzipay/Model/PaymentPostAuth.cs +++ b/Iyzipay/Model/PaymentPostAuth.cs @@ -4,15 +4,16 @@ namespace Iyzipay.Model { public class PaymentPostAuth : PaymentResource - { + { + private const string CreateUrl = "payment/postauth"; public async static Task CreateAsync(CreatePaymentPostAuthRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/postauth", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static PaymentPostAuth Create(CreatePaymentPostAuthRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/postauth", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/PaymentPreAuth.cs b/Iyzipay/Model/PaymentPreAuth.cs index a0ccb76..a093817 100644 --- a/Iyzipay/Model/PaymentPreAuth.cs +++ b/Iyzipay/Model/PaymentPreAuth.cs @@ -5,25 +5,27 @@ namespace Iyzipay.Model { public class PaymentPreAuth : PaymentResource { + private const string CreateUrl = "payment/preauth"; + private const string RetrieveUrl = "payment/detail"; public async static Task CreateAsync(CreatePaymentRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/preauth", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public async static Task RetrieveAsync(RetrievePaymentRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/detail", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } - public static PaymentPreAuth Create(CreatePaymentRequest request, Options options) + public static PaymentPreAuth Create(CreatePaymentRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/preauth", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } - public static PaymentPreAuth Retrieve(RetrievePaymentRequest request, Options options) + public static PaymentPreAuth Retrieve(RetrievePaymentRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/detail", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/PayoutCompletedTransactionList.cs b/Iyzipay/Model/PayoutCompletedTransactionList.cs index 3bdefa6..e4af0b3 100644 --- a/Iyzipay/Model/PayoutCompletedTransactionList.cs +++ b/Iyzipay/Model/PayoutCompletedTransactionList.cs @@ -7,15 +7,15 @@ namespace Iyzipay.Model public class PayoutCompletedTransactionList : IyzipayResource { public List PayoutCompletedTransactions { get; set; } - + private const string RetrieveUrl = "reporting/settlement/payoutcompleted"; public async static Task RetrieveAsync(RetrieveTransactionsRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("reporting/settlement/payoutcompleted", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static PayoutCompletedTransactionList Retrieve(RetrieveTransactionsRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("reporting/settlement/payoutcompleted", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetrieveUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/PeccoInitialize.cs b/Iyzipay/Model/PeccoInitialize.cs index 29df1a8..30b6059 100644 --- a/Iyzipay/Model/PeccoInitialize.cs +++ b/Iyzipay/Model/PeccoInitialize.cs @@ -11,14 +11,15 @@ public class PeccoInitialize : IyzipayResource public String Token { get; set; } public long? TokenExpireTime { get; set; } + private const string CreateUrl = "payment/pecco/initialize"; public async static Task CreateAsync(CreatePeccoInitializeRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/pecco/initialize", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static PeccoInitialize Create(CreatePeccoInitializeRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/pecco/initialize", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/PeccoPayment.cs b/Iyzipay/Model/PeccoPayment.cs index 7d8d0aa..50206ed 100644 --- a/Iyzipay/Model/PeccoPayment.cs +++ b/Iyzipay/Model/PeccoPayment.cs @@ -8,14 +8,15 @@ public class PeccoPayment : PaymentResource { public String Token { get; set; } + private const string CreateUrl = "payment/pecco/auth"; public async static Task CreateAsync(CreatePeccoPaymentRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/pecco/auth", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public static PeccoPayment Create(CreatePeccoPaymentRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/pecco/auth", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } } } diff --git a/Iyzipay/Model/Refund.cs b/Iyzipay/Model/Refund.cs index 78c6068..bbb0e94 100644 --- a/Iyzipay/Model/Refund.cs +++ b/Iyzipay/Model/Refund.cs @@ -12,14 +12,15 @@ public class Refund : IyzipayResource public String Currency { get; set; } public String ConnectorName { get; set; } + private const string CreateUrl = "payment/refund"; public static Refund Create(CreateRefundRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/refund", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } public async static Task CreateAsync(CreateRefundRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/refund", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } } } diff --git a/Iyzipay/Model/RefundChargedFromMerchant.cs b/Iyzipay/Model/RefundChargedFromMerchant.cs index cfdf25c..d0f0db5 100644 --- a/Iyzipay/Model/RefundChargedFromMerchant.cs +++ b/Iyzipay/Model/RefundChargedFromMerchant.cs @@ -10,14 +10,15 @@ public class RefundChargedFromMerchant : IyzipayResource public String PaymentTransactionId { get; set; } public String Price { get; set; } + private const string CreateUrl = "payment/iyzipos/refund/merchant/charge"; public static RefundChargedFromMerchant Create(CreateRefundRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("payment/iyzipos/refund/merchant/charge", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } public async static Task CreateAsync(CreateRefundRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/iyzipos/refund/merchant/charge", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } } } diff --git a/Iyzipay/Model/SubMerchant.cs b/Iyzipay/Model/SubMerchant.cs index 21d7344..ce86067 100644 --- a/Iyzipay/Model/SubMerchant.cs +++ b/Iyzipay/Model/SubMerchant.cs @@ -24,35 +24,38 @@ public class SubMerchant : IyzipayResource public String SubMerchantKey { get; set; } public String SettlementDescriptionTemplate { get; set; } + private const string CreateUrl = "onboarding/submerchant"; + private const string UpdateUrl = "onboarding/submerchant"; + private const string RetreiveUrl = "onboarding/submerchant/detail"; public static SubMerchant Create(CreateSubMerchantRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("onboarding/submerchant", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); } public static SubMerchant Update(UpdateSubMerchantRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Put("onboarding/submerchant", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Put(UpdateUrl, GetHttpHeaders(request, options), request); } public static SubMerchant Retrieve(RetrieveSubMerchantRequest request, Options options) { - return RestHttpClient.Create(options.BaseUrl).Post("onboarding/submerchant/detail", GetHttpHeaders(request, options), request); + return RestHttpClient.Create(options.BaseUrl).Post(RetreiveUrl, GetHttpHeaders(request, options), request); } public async static Task CreateAsync(CreateSubMerchantRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("onboarding/submerchant", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public async static Task UpdateAsync(UpdateSubMerchantRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PutAsync("onboarding/submerchant", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PutAsync(UpdateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public async static Task RetrieveAsync(RetrieveSubMerchantRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync("onboarding/submerchant/detail", GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetreiveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } } } diff --git a/Iyzipay/Model/ThreedsInitialize.cs b/Iyzipay/Model/ThreedsInitialize.cs index c9ecf8d..f845842 100644 --- a/Iyzipay/Model/ThreedsInitialize.cs +++ b/Iyzipay/Model/ThreedsInitialize.cs @@ -10,9 +10,10 @@ public class ThreedsInitialize : IyzipayResource [JsonProperty(PropertyName = "threeDSHtmlContent")] public String HtmlContent { get; set; } + private const string CreateUrl = "payment/3dsecure/initialize"; public static ThreedsInitialize Create(CreatePaymentRequest request, Options options) { - ThreedsInitialize response = RestHttpClient.Create(options.BaseUrl).Post("payment/3dsecure/initialize", GetHttpHeaders(request, options), request); + ThreedsInitialize response = RestHttpClient.Create(options.BaseUrl).Post(CreateUrl, GetHttpHeaders(request, options), request); if (response != null) { @@ -23,7 +24,7 @@ public static ThreedsInitialize Create(CreatePaymentRequest request, Options opt public async static Task CreateAsync(CreatePaymentRequest request, Options options) { - ThreedsInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync("payment/3dsecure/initialize", GetHttpHeaders(request, options), request); + ThreedsInitialize response = await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); if (response != null) { diff --git a/Iyzipay/Model/ThreedsInitializePreAuth.cs b/Iyzipay/Model/ThreedsInitializePreAuth.cs index 004b723..82628b7 100644 --- a/Iyzipay/Model/ThreedsInitializePreAuth.cs +++ b/Iyzipay/Model/ThreedsInitializePreAuth.cs @@ -25,7 +25,7 @@ public static ThreedsInitializePreAuth Create(CreatePaymentRequest request, Opti public async static Task CreateAsync(CreatePaymentRequest request, Options options) { - ThreedsInitializePreAuth response = await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); + ThreedsInitializePreAuth response = await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); if (response != null) { diff --git a/Iyzipay/Model/ThreedsPayment.cs b/Iyzipay/Model/ThreedsPayment.cs index 6eb5fcd..99286f6 100644 --- a/Iyzipay/Model/ThreedsPayment.cs +++ b/Iyzipay/Model/ThreedsPayment.cs @@ -21,12 +21,12 @@ public static ThreedsPayment Retrieve(RetrievePaymentRequest request, Options op public async static Task CreateAsync(CreateThreedsPaymentRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(CreateUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } public async static Task RetrieveAsync(RetrievePaymentRequest request, Options options) { - return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request); + return await RestHttpClient.Create(options.BaseUrl).PostAsync(RetrieveUrl, GetHttpHeaders(request, options), request).ConfigureAwait(false); } } }