### Getting Bank Codes Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/configuration.md Illustrates how to retrieve bank codes using the BankService class. ```csharp var bankCode = CP.VPOS.Services.BankService.Akbank; // "0046" var paymentProvider = CP.VPOS.Services.BankService.Iyzico; // "9997" var allBanks = VPOSClient.AllBankList(b => true); ``` -------------------------------- ### Additional Installment Query Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Example of how to query additional installment options for a sale. ```csharp var campaigns = VPOSClient.AdditionalInstallmentQuery(new AdditionalInstallmentQueryRequest { saleInfo = new SaleInfo { cardNameSurname = "JOHN DOE", cardNumber = "4022780520669303", cardExpiryDateMonth = 12, cardExpiryDateYear = 2025, cardCVV = "123", amount = 2000m, currency = CP.VPOS.Enums.Currency.TRY, installment = 1 } }, auth); if (campaigns.confirm) { foreach (var campaign in campaigns.installmentList) { Console.WriteLine($"Campaign: {campaign.campaignName} ({campaign.campaignCode})"); Console.WriteLine($" Description: {campaign.campaignDescription}"); Console.WriteLine($" Installments: {campaign.count}"); Console.WriteLine($" Required: {campaign.required}"); } } ``` -------------------------------- ### BIN Installment Query Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Queries available installment options for a specific card BIN. ```csharp var binQuery = VPOSClient.BINInstallmentQuery(new BINInstallmentQueryRequest { BIN = "402220", amount = 1000m, currency = CP.VPOS.Enums.Currency.TRY }, auth); if (binQuery.confirm) { foreach (var installment in binQuery.installmentList) { Console.WriteLine($"Installment {installment.count}: Commission {installment.customerCostCommissionRate}%"); } } ``` -------------------------------- ### All Installment Query Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Queries all available installment options for a given amount across all supported cards and banks. ```csharp var allInstallments = VPOSClient.AllInstallmentQuery(new AllInstallmentQueryRequest { amount = 5000m, currency = CP.VPOS.Enums.Currency.TRY }, auth); if (allInstallments.confirm) { var byBankCode = allInstallments.installmentList.GroupBy(x => x.bankCode); foreach (var bankGroup in byBankCode) { Console.WriteLine($"Bank {bankGroup.Key}:"); foreach (var option in bankGroup) { Console.WriteLine($" {option.cardProgram}: {option.count} months @ {option.customerCostCommissionRate}%"); } } } ``` -------------------------------- ### Installation Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/README.md Install the CP.VPOS package using the .NET CLI. ```bash dotnet add package CP.VPOS ``` -------------------------------- ### All Credit Card BIN List Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Example of how to retrieve a complete list of all supported credit card BINs. ```csharp var allBins = VPOSClient.AllCreditCardBinList(); var visaCards = allBins.Where(b => b.cardBrand == CP.VPOS.Enums.CreditCardBrand.Visa); var commercialCards = allBins.Where(b => b.commercialCard); ``` -------------------------------- ### InstallmentCommissionPolicy Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/configuration.md Demonstrates how to configure installment commission policies using VirtualPOSAuth. ```csharp var auth = new VirtualPOSAuth { bankCode = CP.VPOS.Services.BankService.Iyzico, merchantID = "...", merchantUser = "...", merchantPassword = "...", testPlatform = true, installmentCommissionPolicy = InstallmentCommissionPolicy.ChargeToCustomer // or AbsorbByMerchant }; ``` -------------------------------- ### AllBankList Examples Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Examples of how to retrieve lists of banks using different filter criteria. ```csharp // Get all banks supporting installment API var installmentBanks = VPOSClient.AllBankList(b => b.InstallmentAPI); foreach (var bank in installmentBanks) { Console.WriteLine($"{bank.BankCode}: {bank.BankName}"); } // Get all collective VPOS platforms var collectivePlatforms = VPOSClient.AllBankList(b => b.CollectiveVPOS); // Get all banks var allBanks = VPOSClient.AllBankList(b => true); ``` -------------------------------- ### Credit Card BIN Query Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Example of how to query credit card BIN information using the VPOS client. ```csharp var binInfo = VPOSClient.CreditCardBinQuery(new CreditCardBinQueryRequest { binNumber = "402220" }); if (binInfo != null) { Console.WriteLine($"Card: {binInfo.cardBrand} {binInfo.cardType}"); Console.WriteLine($"Issued by: {binInfo.bankCode}"); Console.WriteLine($"Program: {binInfo.cardProgram}"); if (binInfo.banksWithInstallments?.Any() == true) { Console.WriteLine($"Installments available at: {string.Join(", ", binInfo.banksWithInstallments)}"); } } ``` -------------------------------- ### ToHtmlForm Usage Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/helpers.md Example of how to use the ToHtmlForm extension method. ```csharp var formFields = new Dictionary { { "MdStatus", "1" }, { "PaReq", "xxxxx" }, { "TermUrl", "https://yoursite.com/callback" } }; var html = formFields.ToHtmlForm("https://bank3d.example.com/api"); Response.Write(html); // Auto-submits form ``` -------------------------------- ### Usage Pattern Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/configuration.md Shows a typical usage pattern for VirtualPOSAuth with VPOSClient operations. ```csharp var auth = new VirtualPOSAuth { bankCode = CP.VPOS.Services.BankService.QNBpay, merchantID = "20158", merchantUser = "07fb70f9d8de575f32baa6518e38c5d6", merchantPassword = "61d97b2cac247069495be4b16f8604db", merchantStorekey = "$2y$10$N9IJkgazXMUwCzpn7NJrZePy3v.dIFOQUyW4yGfT3eWry6m.KxanK", testPlatform = true // Set to false for production }; // All VPOSClient operations accept this auth object var saleResponse = VPOSClient.Sale(saleRequest, auth); var installments = VPOSClient.BINInstallmentQuery(binRequest, auth); var cancelResponse = VPOSClient.Cancel(cancelRequest, auth); ``` -------------------------------- ### String Extensions Usage Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/helpers.md Example demonstrating the usage of string extension methods for sanitization and truncation. ```csharp var saleRequest = new SaleRequest { /* ... */ }; // Automatic truncation in VPOSClient.Sale() request.invoiceInfo.cityName = request.invoiceInfo.cityName.clearString().getMaxLength(25); ``` -------------------------------- ### Get Card Information Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/README.md Shows how to query card details using the BIN number and display the card brand, type, and associated banks for installments. ```csharp var bin = VPOSClient.CreditCardBinQuery(new CreditCardBinQueryRequest { binNumber = "402220" }); if (bin != null) { Console.WriteLine($"Brand: {bin.cardBrand}"); Console.WriteLine($"Type: {bin.cardType}"); Console.WriteLine($"Banks with installments: {string.Join(", ", bin.banksWithInstallments)}"); } ``` -------------------------------- ### Bank Code Format Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/errors.md Example demonstrating the correct format for the bankCode in VirtualPOSAuth. ```csharp var auth = new VirtualPOSAuth { bankCode = "0046", // Must be exactly 4 characters // ... }; ``` -------------------------------- ### Use BIN to Pre-Filter Banks Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/bank-utilities.md Shows how to first get card BIN information and then use the identified banks to pre-filter subsequent installment queries, optimizing the process. ```csharp // Get card info var cardBin = VPOSClient.CreditCardBinQuery(new CreditCardBinQueryRequest { binNumber = "402220" }); // Only query installments for banks supporting this card if (cardBin?.banksWithInstallments?.Any() == true) { foreach (var bankCode in cardBin.banksWithInstallments) { var auth = new VirtualPOSAuth { bankCode = bankCode, /* ... */ }; var installments = VPOSClient.BINInstallmentQuery(new BINInstallmentQueryRequest { BIN = "402220", amount = 1000m }, auth); } } ``` -------------------------------- ### Refund Payment Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Example of how to partially refund a payment. ```csharp var refundResult = VPOSClient.Refund(new RefundRequest { customerIPAddress = "192.168.1.1", orderNumber = "ORD123456", transactionId = "123456789", refundAmount = 50.00m, currency = CP.VPOS.Enums.Currency.TRY }, auth); if (refundResult.statu == CP.VPOS.Enums.ResponseStatu.Success) { Console.WriteLine($"Refund successful: {refundResult.refundAmount}"); } else { Console.WriteLine($"Refund failed: {refundResult.message}"); } ``` -------------------------------- ### Usage Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/bank-utilities.md Example of how to use the BankService constants in VirtualPOSAuth. ```csharp var auth = new VirtualPOSAuth { bankCode = CP.VPOS.Services.BankService.QNBpay, // Use constant instead of "9990" merchantID = "...", merchantUser = "...", merchantPassword = "...", testPlatform = true }; ``` -------------------------------- ### Query Installments Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/README.md Illustrates how to query available installment options for a given amount and currency, then group and display them by bank code. ```csharp var result = VPOSClient.AllInstallmentQuery(new AllInstallmentQueryRequest { amount = 5000m, currency = Currency.TRY }, auth); if (result.confirm) { foreach (var option in result.installmentList.GroupBy(x => x.bankCode)) { Console.WriteLine($"\nBank {option.Key}:"); foreach (var installment in option) Console.WriteLine($" {installment.count} months @ {installment.customerCostCommissionRate}%"); } } ``` -------------------------------- ### Example: 3D Secure Sale - Step 1 Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Initiates a payment transaction with 3D Secure authentication enabled, returning a redirect URL or HTML for user authentication. ```csharp var saleRequest = new SaleRequest { invoiceInfo = customerInfo, shippingInfo = customerInfo, saleInfo = new SaleInfo { cardNameSurname = "JOHN DOE", cardNumber = "4022780520669303", cardExpiryDateMonth = 1, cardExpiryDateYear = 2050, cardCVV = "988", amount = 100.50m, currency = CP.VPOS.Enums.Currency.TRY, installment = 1 }, payment3D = new Payment3D { confirm = true, returnURL = "https://yoursite.com/payment/complete" }, customerIPAddress = "192.168.1.1", orderNumber = "ORD123456" }; var response = VPOSClient.Sale(saleRequest, auth); if (response.statu == CP.VPOS.Enums.SaleResponseStatu.RedirectURL) { // Redirect user to response.message URL for 3D authentication Response.Redirect(response.message); } else if (response.statu == CP.VPOS.Enums.SaleResponseStatu.RedirectHTML) { // Output HTML form that auto-submits to 3D provider Response.Write(response.message); } ``` -------------------------------- ### Get Banks Supporting Card Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/bank-utilities.md Retrieves BIN information and then lists the issuing bank and other banks that support installments for the given card. ```csharp var cardBin = VPOSClient.CreditCardBinQuery(new CreditCardBinQueryRequest { binNumber = "402220" }); if (cardBin?.banksWithInstallments?.Any() == true) { // Issuing bank is first var issuingBank = cardBin.banksWithInstallments[0]; Console.WriteLine($"Issued by: {issuingBank}"); // Other banks that support installments var otherBanks = cardBin.banksWithInstallments.Skip(1); Console.WriteLine($"Also offers installments at: {string.Join(", ", otherBanks)}"); } ``` -------------------------------- ### ToHtmlForm Output Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/helpers.md Example of the generated HTML form for 3D Secure redirection. ```html Sanal Pos
...
``` -------------------------------- ### AllInstallmentQueryRequest Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/types.md Request to query all available installment options across banks/cards. ```csharp public class AllInstallmentQueryRequest : ModelValidation { [Required] [Range(0.0001, 10000000.00)] public decimal amount { get; set; } public Currency? currency { get; set; } } ``` -------------------------------- ### BINInstallmentQueryResponse Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/types.md Response with installment options for a card BIN. ```csharp public class BINInstallmentQueryResponse { public bool confirm { get; set; } public List installmentList { get; set; } } public class installment { public int count { get; set; } public float customerCostCommissionRate { get; set; } } ``` -------------------------------- ### Example: Direct Sale (3D Disabled) Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Demonstrates how to perform a direct payment transaction without 3D Secure authentication using the VPOSClient.Sale method. ```csharp var auth = new VirtualPOSAuth { bankCode = CP.VPOS.Services.BankService.QNBpay, merchantID = "20158", merchantUser = "07fb70f9d8de575f32baa6518e38c5d6", merchantPassword = "61d97b2cac247069495be4b16f8604db", merchantStorekey = "$2y$10$N9IJkgazXMUwCzpn7NJrZePy3v.dIFOQUyW4yGfT3eWry6m.KxanK", testPlatform = true }; var customerInfo = new CustomerInfo { taxNumber = "1111111111", emailAddress = "test@test.com", name = "John", surname = "Doe", phoneNumber = "5555555555", addressDesc = "123 Main St", cityName = "Istanbul", country = CP.VPOS.Enums.Country.TUR, postCode = "34000", taxOffice = "Maltepe", townName = "Maltepe" }; var saleRequest = new SaleRequest { invoiceInfo = customerInfo, shippingInfo = customerInfo, saleInfo = new SaleInfo { cardNameSurname = "JOHN DOE", cardNumber = "4022780520669303", cardExpiryDateMonth = 1, cardExpiryDateYear = 2050, cardCVV = "988", amount = 100.50m, currency = CP.VPOS.Enums.Currency.TRY, installment = 1 }, payment3D = new Payment3D { confirm = false }, customerIPAddress = "192.168.1.1", orderNumber = "ORD123456" }; var response = VPOSClient.Sale(saleRequest, auth); if (response.statu == CP.VPOS.Enums.SaleResponseStatu.Success) { Console.WriteLine($"Payment successful. Transaction ID: {response.transactionId}"); } else { Console.WriteLine($"Payment failed: {response.message}"); } ``` -------------------------------- ### Cancel Payment Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Example of how to cancel a same-day payment transaction. ```csharp var cancelResult = VPOSClient.Cancel(new CancelRequest { customerIPAddress = "192.168.1.1", orderNumber = "ORD123456", transactionId = "123456789", currency = CP.VPOS.Enums.Currency.TRY }, auth); if (cancelResult.statu == CP.VPOS.Enums.ResponseStatu.Success) { Console.WriteLine($"Payment cancelled. Refunded: {cancelResult.refundAmount}"); } else { Console.WriteLine($"Cancellation failed: {cancelResult.message}"); } ``` -------------------------------- ### BINInstallmentQueryRequest Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/types.md Request to query installment options for a specific card BIN. ```csharp public class BINInstallmentQueryRequest : ModelValidation { [Required] [StringLength(8, MinimumLength = 6)] [RegularExpression("[0-9]+")] public string BIN { get; set; } [Required] [Range(0.0001, 10000000.00)] public decimal amount { get; set; } public Currency? currency { get; set; } } ``` -------------------------------- ### ModelValidation Usage Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/helpers.md Example of how to use the Validate() method from the ModelValidation base class. ```csharp request.Validate(); // Throws ValidationException if invalid ``` -------------------------------- ### AdditionalInstallmentQueryRequest Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/types.md Request to query promotional installment campaigns for a card. ```csharp public class AdditionalInstallmentQueryRequest : ModelValidation { [Required] public SaleInfo saleInfo { get; set; } } ``` -------------------------------- ### Basic Payment Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/README.md Example of performing a basic payment transaction using CP.VPOS. ```csharp using CP.VPOS; using CP.VPOS.Models; using CP.VPOS.Enums; var auth = new VirtualPOSAuth { bankCode = CP.VPOS.Services.BankService.QNBpay, merchantID = "your-merchant-id", merchantUser = "your-api-user", merchantPassword = "your-api-password", merchantStorekey = "your-3d-key", testPlatform = true }; var saleRequest = new SaleRequest { orderNumber = "ORDER123", customerIPAddress = "192.168.1.1", saleInfo = new SaleInfo { cardNameSurname = "JOHN DOE", cardNumber = "4022780520669303", cardExpiryDateMonth = 12, cardExpiryDateYear = 2025, cardCVV = "123", amount = 100.50m, currency = Currency.TRY, installment = 1 }, invoiceInfo = new CustomerInfo { name = "John", surname = "Doe", emailAddress = "john@example.com", phoneNumber = "5551234567", taxNumber = "12345678901" }, shippingInfo = new CustomerInfo { name = "John", surname = "Doe", emailAddress = "john@example.com", phoneNumber = "5551234567", taxNumber = "12345678901" }, payment3D = new Payment3D { confirm = false } }; var response = VPOSClient.Sale(saleRequest, auth); if (response.statu == SaleResponseStatu.Success) { Console.WriteLine($"Payment successful: {response.transactionId}"); } else { Console.WriteLine($"Payment failed: {response.message}"); } ``` -------------------------------- ### NuGet Package Manager Source: https://github.com/cempehlivan/cp.vpos/blob/master/README.md Install the CP.VPOS library using the NuGet Package Manager. ```powershell Install-Package CP.VPOS ``` -------------------------------- ### AdditionalInstallmentQueryResponse Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/types.md Response with promotional/campaign installment options. ```csharp public class AdditionalInstallmentQueryResponse { public bool confirm { get; set; } public List installmentList { get; set; } } public class AdditionalInstallment { public int count { get; set; } public string campaignCode { get; set; } public string campaignName { get; set; } public string campaignDescription { get; set; } public bool required { get; set; } } ``` -------------------------------- ### AllInstallmentQueryResponse Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/types.md Response with installment options across all banks and card programs. ```csharp public class AllInstallmentQueryResponse { public bool confirm { get; set; } public List installmentList { get; set; } } public class AllInstallment { public string bankCode { get; set; } public CreditCardProgram cardProgram { get; set; } public int count { get; set; } public float customerCostCommissionRate { get; set; } } ``` -------------------------------- ### 3D Secure Response Handling Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/README.md Example of handling the 3D Secure response callback from the bank. ```csharp var result = VPOSClient.Sale3DResponse(new Sale3DResponseRequest { responseArray = formData // Form/query data from bank }, auth); ``` -------------------------------- ### Check Bank Support Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/README.md Demonstrates how to retrieve a list of banks that support the installment API and print their codes and names. ```csharp var banks = VPOSClient.AllBankList(b => b.InstallmentAPI); foreach (var bank in banks) Console.WriteLine($"{bank.BankCode}: {bank.BankName}"); ``` -------------------------------- ### BIN Database Structure Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/bank-utilities.md Example JSON entry for the BIN database. ```json { "binNumber": "402220", "bankCode": "0111", "cardType": 1, "cardBrand": 0, "commercialCard": false, "cardProgram": 4 } ``` -------------------------------- ### Payment Callback Example Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/vpos-client.md Handles incoming payment callback notifications from the bank, processing the response and updating payment status. ```csharp [HttpPost] public IActionResult PaymentCallback() { // Extract form data from bank Dictionary responseData = new Dictionary(); if (Request.Method == "GET") { foreach (var key in Request.Query.Keys) responseData[key] = (object)Request.Query[key]; } else { foreach (var key in Request.Form.Keys) responseData[key] = (object)Request.Form[key]; } var result = VPOSClient.Sale3DResponse(new Sale3DResponseRequest { responseArray = responseData }, auth); if (result.statu == CP.VPOS.Enums.SaleResponseStatu.Success) { // Payment completed successfully return Ok("Payment successful"); } else { // Payment failed return BadRequest("Payment failed: " + result.message); } } ``` -------------------------------- ### Public API Usage Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/bank-utilities.md Demonstrates how to query single BIN information, retrieve all BINs, and check for installment support from banks. ```csharp // Query single BIN var binInfo = VPOSClient.CreditCardBinQuery(new CreditCardBinQueryRequest { binNumber = "402220" }); // Get all BINs var allBins = VPOSClient.AllCreditCardBinList(); // Query and find installment banks if (binInfo?.banksWithInstallments?.Any() == true) { foreach (var bankCode in binInfo.banksWithInstallments) { Console.WriteLine($"Bank {bankCode} supports installments for this card"); } } ``` -------------------------------- ### Find Card Type and Brand Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/bank-utilities.md Example of querying BIN information to determine the card type (Credit/Debit), brand (Visa, MasterCard), program, issuing bank, and if it's a commercial card. ```csharp var cardBin = VPOSClient.CreditCardBinQuery(new CreditCardBinQueryRequest { binNumber = "402220" }); if (cardBin != null) { Console.WriteLine($"Card Type: {cardBin.cardType}"); // Credit or Debit Console.WriteLine($"Brand: {cardBin.cardBrand}"); // Visa, MasterCard, etc. Console.WriteLine($"Program: {cardBin.cardProgram}"); // Bonus, Axess, etc. Console.WriteLine($"Issuing Bank: {cardBin.bankCode}"); // Bank code Console.WriteLine($"Commercial: {cardBin.commercialCard}"); // Corporate card } ``` -------------------------------- ### Query Card Info Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/INDEX.md Shows how to query card information using the CreditCardBinQuery method. ```csharp var bin = VPOSClient.CreditCardBinQuery(new CreditCardBinQueryRequest { binNumber = "402220" }); ``` -------------------------------- ### 3D Secure Payment Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/INDEX.md Illustrates how to initiate a 3D Secure payment, including handling the redirect URL. ```csharp var response = VPOSClient.Sale(saleRequest with { payment3D = new Payment3D { confirm = true, returnURL = callbackUrl } }, auth); if (response.statu == SaleResponseStatu.RedirectURL) Response.Redirect(response.message); ``` -------------------------------- ### Refund Payment Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/INDEX.md Demonstrates how to process a refund for a previous payment. ```csharp var result = VPOSClient.Refund(new RefundRequest { transactionId = savedTxId, orderNumber = orderId, refundAmount = amount, currency = Currency.TRY, customerIPAddress = ip }, auth); ``` -------------------------------- ### Minimal Payment Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/INDEX.md Demonstrates a basic payment transaction using the VPOSClient.Sale method. ```csharp var response = VPOSClient.Sale(saleRequest, auth); if (response.statu == SaleResponseStatu.Success) Console.WriteLine($"Paid: {response.transactionId}"); ``` -------------------------------- ### InstallmentCommissionPolicy Enum Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/types.md Controls how installment commissions are applied in collective VPOS platforms. ```csharp public enum InstallmentCommissionPolicy { Default = 0, // Preserves backward-compatible behavior ChargeToCustomer = 1, // Commission charged to customer AbsorbByMerchant = 2 // Merchant absorbs commission } ``` -------------------------------- ### ToHtmlForm Method Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/helpers.md Generates an HTML form for 3D Secure redirection. ```csharp internal static string ToHtmlForm(this Dictionary keyValuePairs, string link) ``` -------------------------------- ### 3D Secure Payment Configuration Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/README.md Configuration for enabling 3D Secure authentication in payment requests. ```csharp payment3D = new Payment3D { confirm = true, returnURL = "https://yoursite.com/payment/callback" } ``` -------------------------------- ### CalculateCustomerCommissionRate Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/helpers.md Calculates the customer-facing commission rate from the seller commission rate. ```csharp internal static float CalculateCustomerCommissionRate(float sellerCommissionRate) ``` -------------------------------- ### toXml Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/helpers.md Converts a Dictionary to an XML string for bank requests. ```csharp internal static string toXml(this Dictionary valuePairs, string rootTag = "CC5Request", string charset = "ISO-8859-9") ``` ```csharp var data = new Dictionary { { "OrderId", "12345" }, { "Amount", "100.50" }, { "Card", new Dictionary { { "Number", "4022780520669303" }, { "CVV", "123" } }} }; var xml = data.toXml(); // Result: // // // 12345 // 100.50 // // 4022780520669303 // 123 // // ``` -------------------------------- ### Filter BIN Database Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/bank-utilities.md Demonstrates how to filter the entire BIN database based on various criteria such as card brand, commercial status, card type, bank code, and card program. ```csharp var allBins = VPOSClient.AllCreditCardBinList(); // All Visa cards var visaCards = allBins.Where(b => b.cardBrand == CP.VPOS.Enums.CreditCardBrand.Visa).ToList(); // Commercial cards only var commercialCards = allBins.Where(b => b.commercialCard).ToList(); // All credit cards (not debit) var creditCards = allBins.Where(b => b.cardType == CP.VPOS.Enums.CreditCardType.Credit).ToList(); // Cards from specific bank var akbankCards = allBins.Where(b => b.bankCode == CP.VPOS.Services.BankService.Akbank).ToList(); // Cards with specific program var axessCards = allBins.Where(b => b.cardProgram == CP.VPOS.Enums.CreditCardProgram.Axess).ToList(); ``` -------------------------------- ### CreditCardBinQueryResponse Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/types.md Response with detailed card BIN information. ```csharp public class CreditCardBinQueryResponse { public string binNumber { get; set; } public string bankCode { get; set; } public CreditCardType cardType { get; set; } public CreditCardBrand cardBrand { get; set; } public bool commercialCard { get; set; } public CreditCardProgram cardProgram { get; set; } public List banksWithInstallments { get; set; } } ``` -------------------------------- ### Basic ValidationException Handling Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/errors.md Demonstrates catching a general ValidationException during a sale operation. ```csharp using System.ComponentModel.DataAnnotations; try { var response = VPOSClient.Sale(saleRequest, auth); } catch (ValidationException ex) { Console.WriteLine($"Validation Error: {ex.Message}"); } ``` -------------------------------- ### CustomerInfo Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/types.md Address and contact information for customer. ```csharp public class CustomerInfo : ModelValidation { [Required] public string name { get; set; } [Required] public string surname { get; set; } [Required] public string emailAddress { get; set; } [Required] public string phoneNumber { get; set; } [Required] public string taxNumber { get; set; } public string taxOffice { get; set; } public Country country { get; set; } public string cityName { get; set; } public string townName { get; set; } public string addressDesc { get; set; } public string postCode { get; set; } } ``` -------------------------------- ### time Method Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/helpers.md Returns the current UTC time in milliseconds since the epoch. ```csharp internal static long time() ``` -------------------------------- ### CreditCardBinQueryRequest Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/types.md Request to query card BIN information. ```csharp public class CreditCardBinQueryRequest : ModelValidation { [Required] [StringLength(8, MinimumLength = 6)] [RegularExpression("[0-9]+")] public string binNumber { get; set; } } ``` -------------------------------- ### XmltoDictionary Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/api-reference/helpers.md Converts an XML response string to a Dictionary. ```csharp internal static Dictionary XmltoDictionary(string xml, string xpath = "CC5Response") ``` ```csharp var xml = @" 12345 0 "; var dict = FoundationHelper.XmltoDictionary(xml); // Result: { {"OrderId", "12345"}, {"Status", "0"} } ``` -------------------------------- ### SaleResponseStatu Enum and Checking Status Source: https://github.com/cempehlivan/cp.vpos/blob/master/_autodocs/errors.md Defines the SaleResponseStatu enum for sale operations and demonstrates how to check its values. ```csharp public enum SaleResponseStatu { Error = 0, // Transaction failed Success = 1, // Transaction completed successfully RedirectURL = 2, // User must be redirected to URL for 3D RedirectHTML = 3 // HTML form must be submitted for 3D } // Checking Status: var response = VPOSClient.Sale(saleRequest, auth); if (response.statu == SaleResponseStatu.Success) { Console.WriteLine($"Payment successful. ID: {response.transactionId}"); } else if (response.statu == SaleResponseStatu.Error) { Console.WriteLine($"Payment failed: {response.message}"); } else if (response.statu == SaleResponseStatu.RedirectURL) { // Redirect user to 3D page Response.Redirect(response.message); } else if (response.statu == SaleResponseStatu.RedirectHTML) { // Output HTML form that auto-submits Response.Write(response.message); } ```