### Create Payment Request Source: https://github.com/iyzico/iyzipay-dotnet/blob/master/README.md This example demonstrates how to configure options, create a payment request with buyer, shipping, billing addresses, and basket items, and then initiate the payment. ```csharp Options options = new Options(); options.ApiKey = "your api key"; options.SecretKey = "your secret key"; options.BaseUrl = "https://sandbox-api.iyzipay.com"; 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 = Payment.Create(request, options); ``` -------------------------------- ### Install Iyzipay Package Source: https://github.com/iyzico/iyzipay-dotnet/blob/master/README.md Use this command in the Package Manager Console to install the Iyzipay library. ```powershell Install-Package Iyzipay ``` -------------------------------- ### Retrieve Installment Options Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Use this to get available installment options and pricing for a given card BIN and amount. Ensure you have the correct Iyzipay options configured. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Request; RetrieveInstallmentInfoRequest request = new RetrieveInstallmentInfoRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = "123456789"; request.BinNumber = "554960"; request.Price = "100"; InstallmentInfo installmentInfo = await InstallmentInfo.Retrieve(request, options); if (installmentInfo.Status == Status.SUCCESS.ToString()) { foreach (var detail in installmentInfo.InstallmentDetails) { Console.WriteLine($"Bank: {detail.BankName}"); foreach (var price in detail.InstallmentPrices) { Console.WriteLine($" {price.InstallmentNumber} installments: {price.TotalPrice} ({price.InstallmentPrice}/month)"); } } } ``` -------------------------------- ### InstallmentInfo.Retrieve - Get Installment Options Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Retrieves available installment options and pricing for a specific card BIN and amount. ```APIDOC ## InstallmentInfo.Retrieve - Get Installment Options ### Description Retrieves available installment options and pricing for a specific card BIN and amount. ### Method POST ### Endpoint /installment/plans ### Parameters #### Query Parameters - **locale** (string) - Optional - Sets the locale for the response. - **conversationId** (string) - Optional - Unique identifier for the conversation. #### Request Body - **binNumber** (string) - Required - The BIN number of the card. - **price** (string) - Required - The price for which to retrieve installment options. ### Request Example ```json { "locale": "tr", "conversationId": "123456789", "binNumber": "554960", "price": "100" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation (e.g., SUCCESS). - **installmentDetails** (array) - A list of installment options. - **bankName** (string) - The name of the bank offering the installment. - **installmentPrices** (array) - A list of pricing options for each installment. - **installmenNumber** (integer) - The number of installments. - **totalPrice** (string) - The total price for the given number of installments. - **installmentPrice** (string) - The price per installment. #### Response Example ```json { "status": "success", "installmentDetails": [ { "bankName": "Example Bank", "installmentPrices": [ { "installmenNumber": 2, "totalPrice": "105.00", "installmentPrice": "52.50" }, { "installmenNumber": 3, "totalPrice": "110.00", "installmentPrice": "36.67" } ] } ] } ``` ``` -------------------------------- ### Initialize API Options Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Set up your API credentials and base URL before making any requests. Use the sandbox URL for testing and the production URL for live transactions. ```csharp using Iyzipay; // Initialize API options with your credentials Options options = new Options(); options.ApiKey = "your_api_key"; options.SecretKey = "your_secret_key"; options.BaseUrl = "https://sandbox-api.iyzipay.com"; // Use https://api.iyzipay.com for production ``` -------------------------------- ### Initialize Pay with iyzico Flow Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Use this to initialize the 'Pay with iyzico' flow, allowing customers to use their iyzico wallet for faster checkout. Ensure all required buyer, address, and basket item details are provided. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Request; using System.Collections.Generic; CreatePayWithIyzicoInitializeRequest request = new CreatePayWithIyzicoInitializeRequest(); 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 { 2, 3, 6, 9 }; request.EnabledInstallments = enabledInstallments; // Buyer, addresses, and basket items (same structure as other payments) Buyer buyer = new Buyer(); buyer.Id = "BY789"; buyer.Name = "John"; buyer.Surname = "Doe"; buyer.Email = "email@email.com"; buyer.IdentityNumber = "74300864791"; buyer.Ip = "85.34.78.112"; buyer.City = "Istanbul"; buyer.Country = "Turkey"; buyer.RegistrationAddress = "Address"; request.Buyer = buyer; Address address = new Address(); address.ContactName = "Jane Doe"; address.City = "Istanbul"; address.Country = "Turkey"; address.Description = "Address"; address.ZipCode = "34742"; request.ShippingAddress = address; request.BillingAddress = address; List basketItems = new List(); BasketItem item = new BasketItem(); item.Id = "BI101"; item.Name = "Product"; item.Category1 = "Category"; item.ItemType = BasketItemType.PHYSICAL.ToString(); item.Price = "1"; basketItems.Add(item); request.BasketItems = basketItems; PayWithIyzicoInitialize payWithIyzicoInitialize = await PayWithIyzicoInitialize.Create(request, options); if (payWithIyzicoInitialize.Status == Status.SUCCESS.ToString()) { Console.WriteLine($"Pay with iyzico URL: {payWithIyzicoInitialize.PayWithIyzicoPageUrl}"); // Or embed using: payWithIyzicoInitialize.CheckoutFormContent } ``` -------------------------------- ### Initialize 3D Secure Payment with C# Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Initializes a 3D Secure payment flow. This method requires a callback URL and returns HTML content to redirect the customer to their bank for authentication. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Request; using System.Collections.Generic; 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"; // Required for 3DS 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; // Include buyer, addresses, and basket items (same as direct payment) 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.Ip = "85.34.78.112"; buyer.City = "Istanbul"; buyer.Country = "Turkey"; buyer.RegistrationAddress = "Address"; request.Buyer = buyer; Address address = new Address(); address.ContactName = "Jane Doe"; address.City = "Istanbul"; address.Country = "Turkey"; address.Description = "Address description"; address.ZipCode = "34742"; request.ShippingAddress = address; request.BillingAddress = address; List basketItems = new List(); BasketItem item = new BasketItem(); item.Id = "BI101"; item.Name = "Product"; item.Category1 = "Category"; item.ItemType = BasketItemType.PHYSICAL.ToString(); item.Price = "1"; basketItems.Add(item); request.BasketItems = basketItems; ThreedsInitialize threedsInitialize = await ThreedsInitialize.Create(request, options); if (threedsInitialize.Status == Status.SUCCESS.ToString()) { // Display this HTML content to redirect user to 3DS verification string htmlContent = threedsInitialize.HtmlContent; Console.WriteLine("Redirect user to 3DS page using HtmlContent"); } ``` -------------------------------- ### Create Payment Link (IyziLink) with .NET SDK Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Generates a payment link for customers. Requires product details, price, and currency. Image can be base64 encoded. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Model.V2; using Iyzipay.Model.V2.Iyzilink; using Iyzipay.Request; IyziLinkSaveRequest request = new IyziLinkSaveRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = "123456789"; request.Name = "Product Name"; request.Description = "Product Description"; request.Base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8H8BwGwAF0QIs4BDpAAAAAABJRU5ErkJggg=="; request.Price = "100"; request.Currency = Currency.TRY.ToString(); request.AddressIgnorable = true; request.InstallmentRequested = false; request.StockEnabled = true; request.StockCount = 10; request.SourceType = "API"; ResponseData response = IyziLink.Create(request, options); if (response.Status == Status.SUCCESS.ToString()) { Console.WriteLine($"IyziLink created!"); Console.WriteLine($"Payment URL: {response.Data.Url}"); Console.WriteLine($"Token: {response.Data.Token}"); Console.WriteLine($"Image URL: {response.Data.ImageUrl}"); } ``` -------------------------------- ### Initialize Hosted Checkout Form Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Use this to create a hosted checkout form for payments. iyzico handles the UI. Ensure all required buyer, address, and basket item details are provided. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Request; using System.Collections.Generic; 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"; // Specify allowed installment options List enabledInstallments = new List(); enabledInstallments.Add(2); enabledInstallments.Add(3); enabledInstallments.Add(6); enabledInstallments.Add(9); request.EnabledInstallments = enabledInstallments; // Buyer information 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.Ip = "85.34.78.112"; buyer.City = "Istanbul"; buyer.Country = "Turkey"; buyer.RegistrationAddress = "Address"; request.Buyer = buyer; // Addresses and basket items Address address = new Address(); address.ContactName = "Jane Doe"; address.City = "Istanbul"; address.Country = "Turkey"; address.Description = "Address"; address.ZipCode = "34742"; request.ShippingAddress = address; request.BillingAddress = address; List basketItems = new List(); BasketItem item = new BasketItem(); item.Id = "BI101"; item.Name = "Product"; item.Category1 = "Category"; item.ItemType = BasketItemType.PHYSICAL.ToString(); item.Price = "1"; basketItems.Add(item); request.BasketItems = basketItems; CheckoutFormInitialize checkoutFormInitialize = await CheckoutFormInitialize.Create(request, options); if (checkoutFormInitialize.Status == Status.SUCCESS.ToString()) { // Option 1: Redirect to hosted page string paymentPageUrl = checkoutFormInitialize.PaymentPageUrl; // Option 2: Embed checkout form string checkoutFormContent = checkoutFormInitialize.CheckoutFormContent; Console.WriteLine($"Payment Page URL: {paymentPageUrl}"); } ``` -------------------------------- ### POST /iyzico/checkoutForm/initialize Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Initializes a hosted checkout form for payments. This method returns a URL or embeddable content for the payment form, allowing iyzico to handle the UI. ```APIDOC ## POST /iyzico/checkoutForm/initialize ### Description Creates a hosted checkout form where iyzico handles the payment UI. Returns a URL or embeddable content for the payment form. ### Method POST ### Endpoint /iyzico/checkoutForm/initialize ### Parameters #### Request Body - **locale** (string) - Required - Locale for the payment form (e.g., "TR"). - **conversationId** (string) - Required - Unique identifier for the conversation. - **price** (string) - Required - The total price of the transaction. - **paidPrice** (string) - Required - The price to be paid by the customer. - **currency** (string) - Required - Currency of the transaction (e.g., "TRY"). - **basketId** (string) - Required - Unique identifier for the basket. - **paymentGroup** (string) - Required - Type of payment group (e.g., "PRODUCT"). - **callbackUrl** (string) - Required - The URL to redirect the user to after payment. - **enabledInstallments** (array of integers) - Optional - List of enabled installment options. - **buyer** (object) - Required - Buyer information. - **id** (string) - Required - Buyer's unique identifier. - **name** (string) - Required - Buyer's first name. - **surname** (string) - Required - Buyer's last name. - **gsmNumber** (string) - Required - Buyer's GSM number. - **email** (string) - Required - Buyer's email address. - **identityNumber** (string) - Required - Buyer's identity number. - **ip** (string) - Required - Buyer's IP address. - **city** (string) - Required - Buyer's city. - **country** (string) - Required - Buyer's country. - **registrationAddress** (string) - Required - Buyer's registration address. - **shippingAddress** (object) - Required - Buyer's shipping address. - **contactName** (string) - Required - Contact person's name. - **city** (string) - Required - City. - **country** (string) - Required - Country. - **description** (string) - Optional - Address description. - **zipCode** (string) - Required - Zip code. - **billingAddress** (object) - Required - Buyer's billing address (can be the same as shipping address). - **contactName** (string) - Required - Contact person's name. - **city** (string) - Required - City. - **country** (string) - Required - Country. - **description** (string) - Optional - Address description. - **zipCode** (string) - Required - Zip code. - **basketItems** (array of objects) - Required - List of items in the basket. - **id** (string) - Required - Item's unique identifier. - **name** (string) - Required - Item's name. - **category1** (string) - Required - Primary category. - **itemType** (string) - Required - Type of item (e.g., "PHYSICAL"). - **price** (string) - Required - Item's price. ### Request Example ```json { "locale": "TR", "conversationId": "123456789", "price": "1", "paidPrice": "1.2", "currency": "TRY", "basketId": "B67832", "paymentGroup": "PRODUCT", "callbackUrl": "https://www.merchant.com/callback", "enabledInstallments": [2, 3, 6, 9], "buyer": { "id": "BY789", "name": "John", "surname": "Doe", "gsmNumber": "+905350000000", "email": "email@email.com", "identityNumber": "74300864791", "ip": "85.34.78.112", "city": "Istanbul", "country": "Turkey", "registrationAddress": "Address" }, "shippingAddress": { "contactName": "Jane Doe", "city": "Istanbul", "country": "Turkey", "description": "Address", "zipCode": "34742" }, "billingAddress": { "contactName": "Jane Doe", "city": "Istanbul", "country": "Turkey", "description": "Address", "zipCode": "34742" }, "basketItems": [ { "id": "BI101", "name": "Product", "category1": "Category", "itemType": "PHYSICAL", "price": "1" } ] } ``` ### Response #### Success Response (200) - **status** (string) - Status of the operation (e.g., "SUCCESS"). - **paymentPageUrl** (string) - URL for the hosted payment page. - **checkoutFormContent** (string) - Embeddable HTML content for the checkout form. #### Response Example ```json { "status": "SUCCESS", "paymentId": "12345", "paidPrice": "1.2", "paymentPageUrl": "https://sandbox-checkout.iyzipay.com/form/... } ``` ``` -------------------------------- ### Create Subscription with Direct Card Charge Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Creates a new subscription by directly charging a card. Requires a pre-created pricing plan reference code. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Model.V2; using Iyzipay.Model.V2.Subscription; using Iyzipay.Request.V2.Subscription; string randomString = DateTime.Now.ToString("yyyyMMddHHmmssfff"); SubscriptionInitializeRequest request = new SubscriptionInitializeRequest { Locale = Locale.TR.ToString(), ConversationId = "123456789", PricingPlanReferenceCode = "pricing_plan_reference_code", Customer = new CheckoutFormCustomer { Email = $"customer-{randomString}@email.com", Name = "John", Surname = "Doe", GsmNumber = "+905350000000", IdentityNumber = "55555555555", BillingAddress = new Address { City = "Istanbul", Country = "Turkey", Description = "Billing address", ContactName = "John Doe", ZipCode = "34732" }, ShippingAddress = new Address { City = "Istanbul", Country = "Turkey", Description = "Shipping address", ContactName = "John Doe", ZipCode = "34732" } }, PaymentCard = new CardInfo { CardNumber = "5528790000000008", CardHolderName = "John Doe", ExpireMonth = "12", ExpireYear = "2029", Cvc = "123", RegisterConsumerCard = true } }; ResponseData response = Subscription.Initialize(request, options); if (response.Status == Status.SUCCESS.ToString()) { Console.WriteLine($"Subscription created! Reference: {response.Data.ReferenceCode}"); Console.WriteLine($"Status: {response.Data.SubscriptionStatus}"); Console.WriteLine($"Trial Days: {response.Data.TrialDays}"); Console.WriteLine($"Start Date: {response.Data.StartDate}"); } ``` -------------------------------- ### ThreedsInitialize.Create - Initialize 3D Secure Payment Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Initializes a 3D Secure payment flow. This method redirects the customer to their bank for authentication and returns HTML content to be displayed to the customer. ```APIDOC ## POST /payment/3ds/initialize ### Description Initializes a 3D Secure payment flow that redirects the customer to their bank for authentication. Returns HTML content to be displayed to the customer. ### Method POST ### Endpoint /payment/3ds/initialize ### Parameters #### Request Body - **locale** (string) - Required - Language of the API response. - **conversationId** (string) - Required - Unique identifier for the conversation. - **price** (string) - Required - The total price of the transaction. - **paidPrice** (string) - Required - The amount to be paid. - **currency** (string) - Required - Currency of the transaction (e.g., TRY). - **installment** (integer) - Optional - Number of installments. - **basketId** (string) - Required - Unique identifier for the basket. - **paymentChannel** (string) - Required - Payment channel (e.g., WEB). - **paymentGroup** (string) - Required - Payment group (e.g., PRODUCT). - **callbackUrl** (string) - Required - The URL to redirect the customer to after authentication. - **paymentCard** (object) - Required - Details of the payment card. - **cardHolderName** (string) - Required - Name of the cardholder. - **cardNumber** (string) - Required - The credit card number. - **expireMonth** (string) - Required - Expiration month of the card. - **expireYear** (string) - Required - Expiration year of the card. - **cvc** (string) - Required - The CVC code of the card. - **registerCard** (integer) - Optional - Whether to register the card (0 for no, 1 for yes). - **buyer** (object) - Required - Information about the buyer. - **id** (string) - Required - Unique identifier for the buyer. - **name** (string) - Required - Buyer's first name. - **surname** (string) - Required - Buyer's last name. - **gsmNumber** (string) - Required - Buyer's GSM number. - **email** (string) - Required - Buyer's email address. - **identityNumber** (string) - Required - Buyer's identity number. - **ip** (string) - Required - Buyer's IP address. - **city** (string) - Required - Buyer's city. - **country** (string) - Required - Buyer's country. - **registrationAddress** (string) - Required - Buyer's registration address. - **shippingAddress** (object) - Required - Shipping address details. - **contactName** (string) - Required - Contact person's name. - **city** (string) - Required - City of the shipping address. - **country** (string) - Required - Country of the shipping address. - **description** (string) - Optional - Description of the address. - **zipCode** (string) - Required - Zip code of the shipping address. - **billingAddress** (object) - Required - Billing address details (same as shippingAddress if not specified). - **basketItems** (array) - Required - List of items in the basket. - **id** (string) - Required - Item's unique identifier. - **name** (string) - Required - Item's name. - **category1** (string) - Required - Primary category of the item. - **itemType** (string) - Required - Type of the item (e.g., PHYSICAL). - **price** (string) - Required - Price of the item. ### Request Example ```json { "locale": "tr", "conversationId": "123456789", "price": "1", "paidPrice": "1.2", "currency": "TRY", "installment": 1, "basketId": "B67832", "paymentChannel": "WEB", "paymentGroup": "PRODUCT", "callbackUrl": "https://www.merchant.com/callback", "paymentCard": { "cardHolderName": "John Doe", "cardNumber": "5528790000000008", "expireMonth": "12", "expireYear": "2030", "cvc": "123", "registerCard": 0 }, "buyer": { "id": "BY789", "name": "John", "surname": "Doe", "gsmNumber": "+905350000000", "email": "email@email.com", "identityNumber": "74300864791", "ip": "85.34.78.112", "city": "Istanbul", "country": "Turkey", "registrationAddress": "Address" }, "shippingAddress": { "contactName": "Jane Doe", "city": "Istanbul", "country": "Turkey", "description": "Address description", "zipCode": "34742" }, "billingAddress": { "contactName": "Jane Doe", "city": "Istanbul", "country": "Turkey", "description": "Address description", "zipCode": "34742" }, "basketItems": [ { "id": "BI101", "name": "Product", "category1": "Category", "itemType": "PHYSICAL", "price": "1" } ] } ``` ### Response #### Success Response (200) - **status** (string) - Status of the operation (e.g., SUCCESS). - **htmlContent** (string) - HTML content to redirect the user to the 3DS authentication page. #### Response Example ```json { "status": "SUCCESS", "htmlContent": "..." } ``` ``` -------------------------------- ### Create Payment Link (IyziLink) Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Creates a payment link that can be shared with customers for payment collection. Includes details about the product, price, and stock. ```APIDOC ## POST /v2/iyzilik/payment-links ### Description Creates a payment link (IyziLink) that can be shared with customers for payment collection. ### Method POST ### Endpoint /v2/iyzilik/payment-links ### Parameters #### Request Body - **locale** (string) - Optional - The locale for the request (e.g., TR, EN). - **conversationId** (string) - Optional - A unique identifier for the conversation. - **name** (string) - Required - The name of the product or service. - **description** (string) - Optional - A description of the product or service. - **base64EncodedImage** (string) - Optional - A base64 encoded string of the product image. - **price** (string) - Required - The price of the product or service. - **currency** (string) - Required - The currency of the price (e.g., TRY, EUR). - **addressIgnorable** (boolean) - Optional - Whether the address is ignorable for this payment link. - **installmentRequested** (boolean) - Optional - Whether installments are requested for this payment link. - **stockEnabled** (boolean) - Optional - Whether stock management is enabled for this product. - **stockCount** (integer) - Optional - The number of available stock if stock management is enabled. - **sourceType** (string) - Optional - The source type of the link creation (e.g., API). ### Request Example ```json { "locale": "tr", "conversationId": "123456789", "name": "Product Name", "description": "Product Description", "base64EncodedImage": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8H8BwGwAF0QIs4BDpAAAAAABJRU5ErkJggg==", "price": "100", "currency": "TRY", "addressIgnorable": true, "installmentRequested": false, "stockEnabled": true, "stockCount": 10, "sourceType": "API" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation (e.g., SUCCESS). - **locale** (string) - The locale used for the response. - **systemTime** (long) - The system time when the response was generated. - **conversationId** (string) - The conversation ID associated with the request. - **data** (object) - Contains details about the created payment link. - **token** (string) - The unique token for the payment link. - **url** (string) - The URL of the payment link. - **imageUrl** (string) - The URL of the product image. #### Response Example ```json { "status": "success", "locale": "tr", "systemTime": 1678886400000, "conversationId": "123456789", "data": { "token": "generated_token", "url": "https://iyzipay.com/pay/link/generated_token", "imageUrl": "https://iyzipay.com/images/product.jpg" } } ``` ``` -------------------------------- ### Store Card for Future Use with Card.Create Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Stores a credit card securely for future payments. Requires user details and card information. Returns a card token and user key for subsequent operations. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Request; // Create new user and add card CreateCardRequest request = new CreateCardRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = "123456789"; request.Email = "email@email.com"; request.ExternalId = "external_user_id"; CardInformation cardInformation = new CardInformation(); cardInformation.CardAlias = "My Visa Card"; cardInformation.CardHolderName = "John Doe"; cardInformation.CardNumber = "5528790000000008"; cardInformation.ExpireMonth = "12"; cardInformation.ExpireYear = "2030"; request.Card = cardInformation; Card card = await Card.Create(request, options); if (card.Status == Status.SUCCESS.ToString()) { Console.WriteLine($"Card stored successfully!"); Console.WriteLine($"Card User Key: {card.CardUserKey}"); // Store this for user Console.WriteLine($"Card Token: {card.CardToken}"); // Use this for payments Console.WriteLine($"Card Type: {card.CardType}"); Console.WriteLine($"Card Association: {card.CardAssociation}"); Console.WriteLine($"Bank: {card.CardBankName}"); } ``` -------------------------------- ### Cancel Subscription with .NET SDK Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Use this to cancel an active subscription. Ensure you have the correct subscription reference code. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Model.V2.Subscription; using Iyzipay.Request.V2.Subscription; CancelSubscriptionRequest request = new CancelSubscriptionRequest { Locale = Locale.TR.ToString(), ConversationId = "123456789", SubscriptionReferenceCode = "subscription_reference_code" }; IyzipayResourceV2 response = Subscription.Cancel(request, options); if (response.Status == Status.SUCCESS.ToString()) { Console.WriteLine("Subscription cancelled successfully"); } ``` -------------------------------- ### Decimal Comparison for .NET Framework Source: https://github.com/iyzico/iyzipay-dotnet/blob/master/README.md When using .NET Framework 4.5, decimal values might be deserialized as strings with trailing zeros trimmed. Use string comparison for accurate checks. ```csharp // true for .net 45 bool isEqual = payment.IyziCommissionRateAmount.Equals("0.028875") ``` -------------------------------- ### Card.Create - Store Card for Future Use Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Stores a credit card securely for future payments. Returns a card token that can be used instead of card details. ```APIDOC ## Card.Create - Store Card for Future Use ### Description Stores a credit card securely for future payments. Returns a card token that can be used instead of card details. ### Method POST ### Endpoint /iyzipay/card ### Parameters #### Request Body - **Locale** (string) - Required - The locale for the request. - **ConversationId** (string) - Required - A unique identifier for the conversation. - **Email** (string) - Required - The email address of the cardholder. - **ExternalId** (string) - Required - An external identifier for the user. - **Card** (object) - Required - Card details. - **CardAlias** (string) - Required - An alias for the card. - **CardHolderName** (string) - Required - The name of the cardholder. - **CardNumber** (string) - Required - The credit card number. - **ExpireMonth** (string) - Required - The expiration month of the card (MM). - **ExpireYear** (string) - Required - The expiration year of the card (YYYY). ### Request Example ```json { "locale": "tr", "conversationId": "123456789", "email": "email@email.com", "externalId": "external_user_id", "card": { "cardAlias": "My Visa Card", "cardHolderName": "John Doe", "cardNumber": "5528790000000008", "expireMonth": "12", "expireYear": "2030" } } ``` ### Response #### Success Response (200) - **Status** (string) - The status of the operation (e.g., SUCCESS). - **CardUserKey** (string) - The unique key for the card user. - **CardToken** (string) - The token representing the stored card. - **CardType** (string) - The type of the card (e.g., CREDIT_CARD). - **CardAssociation** (string) - The card association (e.g., VISA). - **CardBankName** (string) - The name of the bank that issued the card. #### Response Example ```json { "status": "success", "cardUserKey": "some_card_user_key", "cardToken": "some_card_token", "cardType": "CREDIT_CARD", "cardAssociation": "VISA", "cardBankName": "Some Bank" } ``` ``` -------------------------------- ### Create Direct Payment Transaction Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Use this method to process an immediate payment using credit card details without 3D Secure verification. Ensure all required fields for payment, buyer, addresses, and basket items are correctly populated. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Request; using System.Collections.Generic; // Create payment request CreatePaymentRequest request = new CreatePaymentRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = "123456789"; request.Price = "1.0"; request.PaidPrice = "1.2"; request.Currency = Currency.TRY.ToString(); request.Installment = 1; request.BasketId = "B67832"; request.PaymentChannel = PaymentChannel.WEB.ToString(); request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); // Payment card details PaymentCard paymentCard = new PaymentCard(); paymentCard.CardHolderName = "John Doe"; paymentCard.CardNumber = "5528790000000008"; paymentCard.ExpireMonth = "12"; paymentCard.ExpireYear = "2030"; paymentCard.Cvc = "123"; paymentCard.RegisterCard = 0; // Set to 1 to save card for future use request.PaymentCard = paymentCard; // Buyer information 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 Goztepe, Merdivenkoy Mah. Bora Sok. No:1"; buyer.Ip = "85.34.78.112"; buyer.City = "Istanbul"; buyer.Country = "Turkey"; buyer.ZipCode = "34732"; request.Buyer = buyer; // Shipping address Address shippingAddress = new Address(); shippingAddress.ContactName = "Jane Doe"; shippingAddress.City = "Istanbul"; shippingAddress.Country = "Turkey"; shippingAddress.Description = "Nidakule Goztepe, Merdivenkoy Mah. Bora Sok. No:1"; shippingAddress.ZipCode = "34742"; request.ShippingAddress = shippingAddress; // Billing address Address billingAddress = new Address(); billingAddress.ContactName = "Jane Doe"; billingAddress.City = "Istanbul"; billingAddress.Country = "Turkey"; billingAddress.Description = "Nidakule Goztepe, Merdivenkoy Mah. Bora Sok. No:1"; billingAddress.ZipCode = "34742"; request.BillingAddress = billingAddress; // Basket items (sum of prices must equal request.Price) 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; // Process payment Payment payment = await Payment.Create(request, options); // Check result if (payment.Status == Status.SUCCESS.ToString()) { Console.WriteLine($"Payment successful! Payment ID: {payment.PaymentId}"); Console.WriteLine($"Paid Price: {payment.PaidPrice}"); } else { Console.WriteLine($"Payment failed: {payment.ErrorMessage}"); } ``` -------------------------------- ### Complete 3D Secure Payment with C# Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Completes a 3D Secure payment after the customer has been authenticated by their bank. This requires the payment ID and conversation data received from the callback. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Request; CreateThreedsPaymentRequest request = new CreateThreedsPaymentRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = "123456789"; request.PaymentId = "1"; // From callback parameters request.ConversationData = "conversation data"; // From callback parameters ThreedsPayment threedsPayment = await ThreedsPayment.Create(request, options); if (threedsPayment.Status == Status.SUCCESS.ToString()) { Console.WriteLine($"3DS Payment completed! Payment ID: {threedsPayment.PaymentId}"); } ``` -------------------------------- ### Lookup Card BIN Information with BinNumber.Retrieve Source: https://context7.com/iyzico/iyzipay-dotnet/llms.txt Retrieves card information based on the first 6 digits (BIN) of a card number. This is useful for displaying card type, association, and bank name to customers before or during payment. ```csharp using Iyzipay; using Iyzipay.Model; using Iyzipay.Request; RetrieveBinNumberRequest request = new RetrieveBinNumberRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = "123456789"; request.BinNumber = "554960"; // First 6 digits of card BinNumber binNumber = await BinNumber.Retrieve(request, options); if (binNumber.Status == Status.SUCCESS.ToString()) { Console.WriteLine($"BIN: {binNumber.Bin}"); Console.WriteLine($"Card Type: {binNumber.CardType}"); // CREDIT_CARD, DEBIT_CARD Console.WriteLine($"Card Association: {binNumber.CardAssociation}"); // VISA, MASTER_CARD Console.WriteLine($"Card Family: {binNumber.CardFamily}"); // Bonus, Maximum, etc. Console.WriteLine($"Bank Name: {binNumber.BankName}"); Console.WriteLine($"Bank Code: {binNumber.BankCode}"); } ```