From 700f172da1d1d1dcf352a8259e121f93745d79c2 Mon Sep 17 00:00:00 2001 From: Damiaan Date: Wed, 15 Oct 2025 18:56:26 +0200 Subject: [PATCH 1/6] Namespace refactor --- PAYNLSDK.sln | 8 +- .../Alliance/AddInvoice/AddInvoiceResult.cs | 42 +- PAYNLSDK/API/Alliance/AddInvoice/Request.cs | 266 ++-- .../Alliance/AddMerchant/AddMerchantResult.cs | 111 +- PAYNLSDK/API/Alliance/AddMerchant/Request.cs | 509 ++++---- .../Alliance/AddService/AddServiceResult.cs | 21 +- PAYNLSDK/API/Alliance/AddService/Request.cs | 157 ++- .../Alliance/GetMerchant/GetMerchantResult.cs | 242 ++-- PAYNLSDK/API/Alliance/GetMerchant/Request.cs | 64 +- PAYNLSDK/API/Banktransfer/Add/Request.cs | 365 +++--- PAYNLSDK/API/Banktransfer/Add/Response.cs | 11 +- PAYNLSDK/API/Document/Add/Request.cs | 114 +- PAYNLSDK/API/Document/Add/Response.cs | 41 +- PAYNLSDK/API/Language/GetAllRequest.cs | 42 +- PAYNLSDK/API/Language/GetAllResult.cs | 37 +- PAYNLSDK/API/Merchant/Add/Request.cs | 343 +++-- PAYNLSDK/API/Merchant/Add/Response.cs | 81 +- PAYNLSDK/API/Merchant/Clearing/Request.cs | 87 +- PAYNLSDK/API/Merchant/Clearing/Response.cs | 32 +- PAYNLSDK/API/Merchant/Info/Request.cs | 68 +- PAYNLSDK/API/Merchant/Info/Response.cs | 270 ++-- PAYNLSDK/API/PaymentMethod/Get/Request.cs | 75 +- PAYNLSDK/API/PaymentMethod/Get/Response.cs | 10 +- PAYNLSDK/API/PaymentMethod/GetAll/Request.cs | 65 +- PAYNLSDK/API/PaymentMethod/GetAll/Response.cs | 17 +- PAYNLSDK/API/PaymentProfile/Get/Request.cs | 67 +- PAYNLSDK/API/PaymentProfile/Get/Response.cs | 10 +- PAYNLSDK/API/PaymentProfile/GetAll/Request.cs | 53 +- .../API/PaymentProfile/GetAll/Response.cs | 11 +- .../PaymentProfile/GetAvailable/Request.cs | 142 ++- .../PaymentProfile/GetAvailable/Response.cs | 17 +- PAYNLSDK/API/Refund/Add/Request.cs | 399 +++--- PAYNLSDK/API/Refund/Add/Response.cs | 20 +- PAYNLSDK/API/Refund/Info/Request.cs | 107 +- PAYNLSDK/API/Refund/Info/Response.cs | 22 +- PAYNLSDK/API/Refund/Transaction/Request.cs | 275 ++-- PAYNLSDK/API/Refund/Transaction/Response.cs | 20 +- PAYNLSDK/API/RequestBase.cs | 147 ++- PAYNLSDK/API/ResponseBase.cs | 37 +- PAYNLSDK/API/SMS/BulkMessage/Request.cs | 77 +- PAYNLSDK/API/SMS/BulkMessage/Response.cs | 18 +- PAYNLSDK/API/SMS/PremiumMessage/Request.cs | 71 +- PAYNLSDK/API/SMS/PremiumMessage/Response.cs | 14 +- PAYNLSDK/API/Service/GetCategories/Request.cs | 80 +- .../API/Service/GetCategories/Response.cs | 13 +- .../GetManagement/GetStatsMultiLevel.cs | 35 +- .../GetManagement/GetStatsResult.cs | 27 +- .../GetManagement/GetStatsResultBase.cs | 1101 ++++++++--------- .../API/Statistics/GetManagement/Request.cs | 428 ++++--- PAYNLSDK/API/Transaction/Approve/Request.cs | 95 +- PAYNLSDK/API/Transaction/Approve/Response.cs | 16 +- PAYNLSDK/API/Transaction/Decline/Request.cs | 102 +- PAYNLSDK/API/Transaction/Decline/Response.cs | 14 +- .../GetLastTransactions/Request.cs | 106 +- .../GetLastTransactions/Response.cs | 16 +- .../API/Transaction/GetService/Request.cs | 60 +- .../API/Transaction/GetService/Response.cs | 25 +- PAYNLSDK/API/Transaction/Info/Request.cs | 81 +- PAYNLSDK/API/Transaction/Info/Response.cs | 48 +- PAYNLSDK/API/Transaction/Refund/Request.cs | 179 ++- PAYNLSDK/API/Transaction/Refund/Response.cs | 12 +- PAYNLSDK/API/Transaction/Start/Request.cs | 677 +++++----- PAYNLSDK/API/Transaction/Start/Response.cs | 54 +- .../API/Validate/BankAccountNumber/Request.cs | 75 +- .../Validate/BankAccountNumber/Response.cs | 27 +- .../BankAccountNumberInternational/Request.cs | 77 +- .../Response.cs | 28 +- PAYNLSDK/API/Validate/GetServerIps/Request.cs | 75 +- .../API/Validate/GetServerIps/Response.cs | 28 +- PAYNLSDK/API/Validate/IBAN/Request.cs | 87 +- PAYNLSDK/API/Validate/IBAN/Response.cs | 30 +- .../API/Validate/IsPayServerIp/Request.cs | 85 +- .../API/Validate/IsPayServerIp/Response.cs | 30 +- PAYNLSDK/API/Validate/KVK/Request.cs | 87 +- PAYNLSDK/API/Validate/KVK/Response.cs | 30 +- PAYNLSDK/API/Validate/SOFI/Request.cs | 69 +- PAYNLSDK/API/Validate/SOFI/Response.cs | 14 +- PAYNLSDK/API/Validate/SWIFT/Request.cs | 87 +- PAYNLSDK/API/Validate/SWIFT/Response.cs | 30 +- PAYNLSDK/API/Validate/Util.cs | 160 ++- PAYNLSDK/API/Validate/VAT/Request.cs | 89 +- PAYNLSDK/API/Validate/VAT/Response.cs | 29 +- PAYNLSDK/Alliance.cs | 86 +- PAYNLSDK/Api/IPayNlConfiguration.cs | 27 +- PAYNLSDK/Api/PayNlConfiguration.cs | 45 +- PAYNLSDK/Api/Transaction/Enduser.cs | 254 ++-- .../Transaction/Info/ResponseExtentions.cs | 83 +- .../Api/Transaction/Info/StornoDetails.cs | 102 +- .../Api/Transaction/Start/TransactionData.cs | 113 +- PAYNLSDK/Api/Transaction/StatsDetails.cs | 99 +- PAYNLSDK/Api/Validate/Util.cs.orig | 171 +++ PAYNLSDK/Banktransfer.cs | 81 +- PAYNLSDK/Converters/BooleanConverter.cs | 49 +- PAYNLSDK/Converters/CountryOptionConverter.cs | 40 +- PAYNLSDK/Converters/DMYConverter.cs | 79 +- PAYNLSDK/Converters/EnumConversionBase.cs | 25 +- PAYNLSDK/Converters/ErrorIdConverter.cs | 65 +- PAYNLSDK/Converters/GenderConverter.cs | 19 +- PAYNLSDK/Converters/ProductTypeConverter.cs | 15 +- PAYNLSDK/Converters/TaxClassConverter.cs | 19 +- PAYNLSDK/Converters/YMDConverter.cs | 121 +- PAYNLSDK/Converters/YMDHISConverter.cs | 169 ++- PAYNLSDK/DateTime.cs | 37 +- PAYNLSDK/Enums/enums.cs | 578 +++++---- PAYNLSDK/Exceptions/PayNlException.cs | 105 +- .../ExtentionMethods/DateTimeExtension.cs | 111 +- PAYNLSDK/IAlliance.cs | 67 +- PAYNLSDK/IMerchant.cs | 16 +- PAYNLSDK/IService.cs | 19 +- PAYNLSDK/ITransaction.cs | 65 +- PAYNLSDK/Language.cs | 59 +- PAYNLSDK/Merchant.cs | 164 ++- PAYNLSDK/Net/ApiTokenClient.cs | 66 +- PAYNLSDK/Net/Client.cs | 459 ++++--- PAYNLSDK/Net/HttpStatusCodes.cs | 163 ++- PAYNLSDK/Net/IClient.cs | 39 +- .../IProxyConfigurationInjector.cs | 11 +- .../InjectCredentialsForProxiedUris.cs | 33 +- .../InjectDefaultCredentialsForProxiedUris.cs | 9 +- .../InjectWebProxy.cs | 43 +- PAYNLSDK/Objects/Address.cs | 109 +- PAYNLSDK/Objects/Company.cs | 49 +- PAYNLSDK/Objects/Connection.cs | 144 ++- PAYNLSDK/Objects/CountryOption.cs | 97 +- PAYNLSDK/Objects/Error.cs | 44 +- PAYNLSDK/Objects/Merchant.cs | 56 +- PAYNLSDK/Objects/OrderData.cs | 488 ++++---- PAYNLSDK/Objects/PaymentDetails.cs | 456 ++++--- PAYNLSDK/Objects/PaymentMethod.cs | 42 +- PAYNLSDK/Objects/PaymentOption.cs | 133 +- PAYNLSDK/Objects/PaymentProfile.cs | 113 +- PAYNLSDK/Objects/RefundInfo.cs | 103 +- PAYNLSDK/Objects/SalesData.cs | 48 +- PAYNLSDK/Objects/Service.cs | 115 +- PAYNLSDK/Objects/ServiceCategory.cs | 32 +- PAYNLSDK/Objects/TransactionStartEnduser.cs | 24 +- PAYNLSDK/Objects/TransactionStartInfo.cs | 61 +- PAYNLSDK/Objects/TransactionStats.cs | 147 ++- PAYNLSDK/PayNLSdk.csproj | 2 +- PAYNLSDK/PaymentMethod.cs | 80 +- PAYNLSDK/PaymentProfile.cs | 124 +- PAYNLSDK/Service.cs | 55 +- PAYNLSDK/Statistics.cs | 129 +- PAYNLSDK/Transaction.cs | 455 +++---- PAYNLSDK/Utilities/Reflection.cs | 21 +- PAYNLSDK/Utilities/Validators.cs | 49 +- .../Api/Alliance/AddInvoiceRequestTests.cs | 175 ++- .../Api/Statistics/GetStatsTests.cs | 245 ++-- .../Api/Transaction/TransactionRefundTests.cs | 73 +- .../ExtentionMethods/DateTimeTests.cs | 287 +++-- PayNLSdk.Tests/PayNLSdk.Tests.csproj | 4 +- PayNLSdk.Tests/ServiceTests.cs | 89 +- PayNLSdk.Tests/Utilities/ValidationTests.cs | 105 +- 153 files changed, 8296 insertions(+), 8455 deletions(-) create mode 100644 PAYNLSDK/Api/Validate/Util.cs.orig diff --git a/PAYNLSDK.sln b/PAYNLSDK.sln index c78d678..1e90c9c 100644 --- a/PAYNLSDK.sln +++ b/PAYNLSDK.sln @@ -1,11 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30204.135 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36301.6 d17.14 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PayNLSdk", "PAYNLSDK\PayNLSdk.csproj", "{C8AB15F6-3F29-490B-8424-F3A337177543}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PayNlSdk", "PAYNLSDK\PayNlSdk.csproj", "{C8AB15F6-3F29-490B-8424-F3A337177543}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PayNLSdk.Tests", "PayNLSdk.Tests\PayNLSdk.Tests.csproj", "{4C691697-D689-4A00-9E3B-45C05D9F7817}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PayNlSdk.Tests", "PayNLSdk.Tests\PayNlSdk.Tests.csproj", "{4C691697-D689-4A00-9E3B-45C05D9F7817}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DACFE405-2E22-4BEB-8B31-60A285F03EA0}" ProjectSection(SolutionItems) = preProject diff --git a/PAYNLSDK/API/Alliance/AddInvoice/AddInvoiceResult.cs b/PAYNLSDK/API/Alliance/AddInvoice/AddInvoiceResult.cs index aa27153..1009180 100644 --- a/PAYNLSDK/API/Alliance/AddInvoice/AddInvoiceResult.cs +++ b/PAYNLSDK/API/Alliance/AddInvoice/AddInvoiceResult.cs @@ -1,29 +1,27 @@ using Newtonsoft.Json; -using PAYNLSDK.API; -namespace PAYNLSDK.API.Alliance.AddInvoice +namespace PayNLSdk.Api.Alliance.AddInvoice; + +/// +/// The result of the Alliance/GetMerchant call +/// Implements the +/// +/// +public class AddInvoiceResult : ResponseBase { /// - /// The result of the Alliance/GetMerchant call - /// Implements the + /// Gets or sets the reference id for the payment. /// - /// - public class AddInvoiceResult : ResponseBase - { - /// - /// Gets or sets the reference id for the payment. - /// - /// The reference identifier. - [JsonProperty("referenceId")] - public string ReferenceId { get; set; } + /// The reference identifier. + [JsonProperty("referenceId")] + public string ReferenceId { get; set; } - /// - /// Returns a that represents this instance. - /// - /// A that represents this instance. - public override string ToString() - { - return $"AddInvoiceResult (referenceId={ReferenceId})"; - } + /// + /// Returns a that represents this instance. + /// + /// A that represents this instance. + public override string ToString() + { + return $"AddInvoiceResult (referenceId={ReferenceId})"; } -} +} \ No newline at end of file diff --git a/PAYNLSDK/API/Alliance/AddInvoice/Request.cs b/PAYNLSDK/API/Alliance/AddInvoice/Request.cs index 659b0be..d018095 100644 --- a/PAYNLSDK/API/Alliance/AddInvoice/Request.cs +++ b/PAYNLSDK/API/Alliance/AddInvoice/Request.cs @@ -1,152 +1,150 @@ -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; using System.Diagnostics.CodeAnalysis; -namespace PAYNLSDK.API.Alliance.AddInvoice +namespace PayNLSdk.Api.Alliance.AddInvoice; + +/// +[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] +[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] +[SuppressMessage("ReSharper", "UnusedMember.Global")] +public class Request : RequestBase { + /// + /// Initializes a new instance of the class. + /// + /// The merchant identifier. + /// The service identifier. + /// The invoice identifier. + /// The description. + /// The amount in cents. + public Request(string merchantId, string serviceId, string invoiceId, string description, long amountInCents) + { + ServiceId = serviceId; + MerchantId = merchantId; + InvoiceId = invoiceId; + Description = description; + AmountInCents = amountInCents; + } + + /// + protected override int Version => 5; + /// + protected override string Controller => "Alliance"; /// - [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] - [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] - [SuppressMessage("ReSharper", "UnusedMember.Global")] - public class Request : RequestBase + protected override string Method => "addInvoice"; + + /// + public override NameValueCollection GetParameters() { - /// - /// Initializes a new instance of the class. - /// - /// The merchant identifier. - /// The service identifier. - /// The invoice identifier. - /// The description. - /// The amount in cents. - public Request(string merchantId, string serviceId, string invoiceId, string description, long amountInCents) + var retval = new NameValueCollection + { + + // mandatory fields + { "serviceId", ServiceId }, + { "merchantId", MerchantId }, + { "invoiceId", InvoiceId }, + { "amount", AmountInCents.ToString() }, + { "description", Description } + }; + + // Optional fields + if (string.IsNullOrWhiteSpace(InvoiceUrl) == false) { - ServiceId = serviceId; - MerchantId = merchantId; - InvoiceId = invoiceId; - Description = description; - AmountInCents = amountInCents; + retval.Add("invoiceUrl", InvoiceUrl); } - /// - protected override int Version => 5; - /// - protected override string Controller => "Alliance"; - /// - protected override string Method => "addInvoice"; + if (MakeYesterday.HasValue) + { + retval.Add("makeYesterday", MakeYesterday.ToString().ToLower()); + } + + if (string.IsNullOrWhiteSpace(Extra1) == false) + { + retval.Add("extra1", Extra1); + } - /// - public override NameValueCollection GetParameters() + if (string.IsNullOrWhiteSpace(Extra2) == false) { - var retval = new NameValueCollection - { - - // mandatory fields - { "serviceId", ServiceId }, - { "merchantId", MerchantId }, - { "invoiceId", InvoiceId }, - { "amount", AmountInCents.ToString() }, - { "description", Description } - }; - - // Optional fields - if (string.IsNullOrWhiteSpace(InvoiceUrl) == false) - { - retval.Add("invoiceUrl", InvoiceUrl); - } - - if (MakeYesterday.HasValue) - { - retval.Add("makeYesterday", MakeYesterday.ToString().ToLower()); - } - - if (string.IsNullOrWhiteSpace(Extra1) == false) - { - retval.Add("extra1", Extra1); - } - - if (string.IsNullOrWhiteSpace(Extra2) == false) - { - retval.Add("extra2", Extra2); - } - - if (string.IsNullOrWhiteSpace(Extra3) == false) - { - retval.Add("extra2", Extra3); - } - - return retval; + retval.Add("extra2", Extra2); } - /// - /// Gets or sets the third free value. - /// - /// The extra3. - public string Extra3 { get; set; } - - /// - /// Gets or sets the second free value. - /// - /// The extra2. - public string Extra2 { get; set; } - - /// - /// Gets or sets the first free value. - /// - /// The extra1. - public string Extra1 { get; set; } - - /// - /// Gets or sets the id of your invoice. - /// - /// The invoice identifier. - public string InvoiceId { get; set; } - - /// - /// Gets or sets whether the transaction should be backdated to yesterday 23:59:59 - /// - /// true transactions should be booked yesterday; otherwise, false. - public bool? MakeYesterday { get; set; } - - /// - /// Gets or sets the URL pointing to the location of the invoice. - /// - /// The invoice URL. - public string InvoiceUrl { get; set; } - - /// - /// Gets or sets payment description. - /// - /// The description. - public string Description { get; set; } - - /// - /// Gets or sets the amount in cents. - /// - /// The amount in cents. - public long AmountInCents { get; set; } - - /// - /// Gets or sets the merchantId of the merchant to invoice. - /// - /// The merchant identifier. - public string MerchantId { get; set; } - - /// - /// Gets or sets the serviceId of the service the payment should be registered on. - /// - /// The service identifier. - public string ServiceId { get; set; } - - /// - /// rawResponse is empty! - protected override void PrepareAndSetResponse() + if (string.IsNullOrWhiteSpace(Extra3) == false) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } + retval.Add("extra2", Extra3); } + + return retval; } + /// + /// Gets or sets the third free value. + /// + /// The extra3. + public string Extra3 { get; set; } + + /// + /// Gets or sets the second free value. + /// + /// The extra2. + public string Extra2 { get; set; } + + /// + /// Gets or sets the first free value. + /// + /// The extra1. + public string Extra1 { get; set; } + + /// + /// Gets or sets the id of your invoice. + /// + /// The invoice identifier. + public string InvoiceId { get; set; } + + /// + /// Gets or sets whether the transaction should be backdated to yesterday 23:59:59 + /// + /// true transactions should be booked yesterday; otherwise, false. + public bool? MakeYesterday { get; set; } + + /// + /// Gets or sets the URL pointing to the location of the invoice. + /// + /// The invoice URL. + public string InvoiceUrl { get; set; } + + /// + /// Gets or sets payment description. + /// + /// The description. + public string Description { get; set; } + + /// + /// Gets or sets the amount in cents. + /// + /// The amount in cents. + public long AmountInCents { get; set; } + + /// + /// Gets or sets the merchantId of the merchant to invoice. + /// + /// The merchant identifier. + public string MerchantId { get; set; } + + /// + /// Gets or sets the serviceId of the service the payment should be registered on. + /// + /// The service identifier. + public string ServiceId { get; set; } + + /// + /// rawResponse is empty! + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) + { + throw new PayNlException("rawResponse is empty!"); + } + } } diff --git a/PAYNLSDK/API/Alliance/AddMerchant/AddMerchantResult.cs b/PAYNLSDK/API/Alliance/AddMerchant/AddMerchantResult.cs index 6485a4a..1758d04 100644 --- a/PAYNLSDK/API/Alliance/AddMerchant/AddMerchantResult.cs +++ b/PAYNLSDK/API/Alliance/AddMerchant/AddMerchantResult.cs @@ -1,73 +1,72 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; +using PayNLSdk.Converters; -namespace PAYNLSDK.API.Alliance.AddMerchant +namespace PayNLSdk.Api.Alliance.AddMerchant; + +/// +/// The result of the Alliance/AddMerchant call +/// +public class AddMerchantResult { /// - /// The result of the Alliance/AddMerchant call + /// Gets or sets if it was success. /// - public class AddMerchantResult - { - /// - /// Gets or sets if it was success. - /// - /// whether we had a successful call or not. - [JsonProperty("success")] - [JsonConverter(typeof(BooleanConverter))] - public bool Success { get; set; } + /// whether we had a successful call or not. + [JsonProperty("success")] + [JsonConverter(typeof(BooleanConverter))] + public bool Success { get; set; } - /// - /// Gets or sets the error id - /// - /// The error field. - [JsonProperty("error_field")] - public string ErrorField { get; set; } + /// + /// Gets or sets the error id + /// + /// The error field. + [JsonProperty("error_field")] + public string ErrorField { get; set; } - /// - /// Gets or sets the error message. - /// - /// The error message. - [JsonProperty("error_message")] - public string ErrorMessage { get; set; } + /// + /// Gets or sets the error message. + /// + /// The error message. + [JsonProperty("error_message")] + public string ErrorMessage { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// The merchant identifier. - [JsonProperty("merchantId")] - public string MerchantId { get; set; } + /// + /// Gets or sets the merchant identifier. + /// + /// The merchant identifier. + [JsonProperty("merchantId")] + public string MerchantId { get; set; } - /// - /// Gets or sets the merchant token. - /// - /// The merchant token. - [JsonProperty("merchantToken")] - public string MerchantToken { get; set; } + /// + /// Gets or sets the merchant token. + /// + /// The merchant token. + [JsonProperty("merchantToken")] + public string MerchantToken { get; set; } + /// + /// The created accounts for this merchant + /// + [JsonProperty("accounts")] + public Account[] Accounts { get; set; } + + /// + /// Class Account. + /// + public class Account + { /// - /// The created accounts for this merchant + /// Gets or sets the account identifier. /// - [JsonProperty("accounts")] - public Account[] Accounts { get; set; } + /// The account identifier. + [JsonProperty("accountId")] + public string AccountId { get; set; } /// - /// Class Account. + /// Gets or sets the email. /// - public class Account - { - /// - /// Gets or sets the account identifier. - /// - /// The account identifier. - [JsonProperty("accountId")] - public string AccountId { get; set; } - - /// - /// Gets or sets the email. - /// - /// The email. - [JsonProperty("email")] - public string Email { get; set; } - } + /// The email. + [JsonProperty("email")] + public string Email { get; set; } } } diff --git a/PAYNLSDK/API/Alliance/AddMerchant/Request.cs b/PAYNLSDK/API/Alliance/AddMerchant/Request.cs index 2f562f8..329dc75 100644 --- a/PAYNLSDK/API/Alliance/AddMerchant/Request.cs +++ b/PAYNLSDK/API/Alliance/AddMerchant/Request.cs @@ -1,318 +1,313 @@ -using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -namespace PAYNLSDK.API.Alliance.AddMerchant +namespace PayNLSdk.Api.Alliance.AddMerchant; + +public class Request : RequestBase { - public class Request : RequestBase + public Request() + { + Accounts = new List(); + } + + /// + protected override int Version => 6; + /// + protected override string Controller => "Alliance"; + /// + protected override string Method => "addMerchant"; + /// + public override NameValueCollection GetParameters() { - public Request() + var retVal = new NameValueCollection { }; + + retVal.Add("merchant[name]", FullName); + retVal.Add("merchant[coc]", Coc); + retVal.Add("merchant[vat]", Vat); + retVal.Add("merchant[street]", Street); + retVal.Add("merchant[houseNumber]", HouseNumber); + retVal.Add("merchant[houseNumberAddition]", HouseNumberAddition); + retVal.Add("merchant[postalCode]", PostalCode); + retVal.Add("merchant[city]", City); + retVal.Add("merchant[countryCode]", CountryCode); + retVal.Add("merchant[contactEmail]", ContactEmail); + retVal.Add("merchant[contactPhone]", ContactPhone); + + for (var i = 0; i < Accounts.Count; i++) { - Accounts = new List(); + var account = Accounts[i]; + retVal.Add($"accounts[{i}][email]", account.Email); + retVal.Add($"accounts[{i}][firstname]", account.FirstName); + retVal.Add($"accounts[{i}][lastname]", account.LastName); + retVal.Add($"accounts[{i}][gender]", account.Gender.ToString()); + retVal.Add($"accounts[{i}][authorizedToSign]", account.AuthorizedToSign.ToString()); + retVal.Add($"accounts[{i}][ubo]", account.UltimateBeneficialOwner ? "1" : "0"); + retVal.Add($"accounts[{i}][uboPercentage]", account.UboPercentage.ToString()); + retVal.Add($"accounts[{i}][useCompanyAuth]", account.UseCompanyAuth ? "1" : "0"); + retVal.Add($"accounts[{i}][hasAccess]", account.HasAccess ? "1" : "0"); + retVal.Add($"accounts[{i}][language]", account.Language); } - /// - protected override int Version => 6; - /// - protected override string Controller => "Alliance"; - /// - protected override string Method => "addMerchant"; - /// - public override NameValueCollection GetParameters() + if (BankAccount != null) { - var retVal = new NameValueCollection { }; - - retVal.Add("merchant[name]", FullName); - retVal.Add("merchant[coc]", Coc); - retVal.Add("merchant[vat]", Vat); - retVal.Add("merchant[street]", Street); - retVal.Add("merchant[houseNumber]", HouseNumber); - retVal.Add("merchant[houseNumberAddition]", HouseNumberAddition); - retVal.Add("merchant[postalCode]", PostalCode); - retVal.Add("merchant[city]", City); - retVal.Add("merchant[countryCode]", CountryCode); - retVal.Add("merchant[contactEmail]", ContactEmail); - retVal.Add("merchant[contactPhone]", ContactPhone); - - for (var i = 0; i < Accounts.Count; i++) - { - var account = Accounts[i]; - retVal.Add($"accounts[{i}][email]", account.Email); - retVal.Add($"accounts[{i}][firstname]", account.FirstName); - retVal.Add($"accounts[{i}][lastname]", account.LastName); - retVal.Add($"accounts[{i}][gender]", account.Gender.ToString()); - retVal.Add($"accounts[{i}][authorizedToSign]", account.AuthorizedToSign.ToString()); - retVal.Add($"accounts[{i}][ubo]", account.UltimateBeneficialOwner ? "1" : "0"); - retVal.Add($"accounts[{i}][uboPercentage]", account.UboPercentage.ToString()); - retVal.Add($"accounts[{i}][useCompanyAuth]", account.UseCompanyAuth ? "1" : "0"); - retVal.Add($"accounts[{i}][hasAccess]", account.HasAccess ? "1" : "0"); - retVal.Add($"accounts[{i}][language]", account.Language); - } - - if (BankAccount != null) - { - retVal.Add("bankaccount[BankAccountOwner]", BankAccount.BankAccountOwner); - retVal.Add("bankaccount[BankAccountNumber]", BankAccount.BankAccountNumber); - retVal.Add("bankaccount[BankAccountBIC]", BankAccount.BankAccountBic); - } - - if (MerchantSettings != null) - { - retVal.Add("settings[package]", MerchantSettings.Package); - retVal.Add("settings[sendEmail]", MerchantSettings.SendEmail); - retVal.Add("settings[settleBalance]", MerchantSettings.SettleBalance ? "1" : "0"); - retVal.Add("settings[referralProfileId]", MerchantSettings.ReferralProfileId); - retVal.Add("settings[clearingInterval]", MerchantSettings.ClearingInterval); - } - - return retVal; + retVal.Add("bankaccount[BankAccountOwner]", BankAccount.BankAccountOwner); + retVal.Add("bankaccount[BankAccountNumber]", BankAccount.BankAccountNumber); + retVal.Add("bankaccount[BankAccountBIC]", BankAccount.BankAccountBic); } - /// - /// a phone number that customers can use to contact the merchant - /// - public string ContactPhone { get; set; } + if (MerchantSettings != null) + { + retVal.Add("settings[package]", MerchantSettings.Package); + retVal.Add("settings[sendEmail]", MerchantSettings.SendEmail); + retVal.Add("settings[settleBalance]", MerchantSettings.SettleBalance ? "1" : "0"); + retVal.Add("settings[referralProfileId]", MerchantSettings.ReferralProfileId); + retVal.Add("settings[clearingInterval]", MerchantSettings.ClearingInterval); + } - /// - /// an email address that customers can use to contact the merchant - /// - public string ContactEmail { get; set; } + return retVal; + } - /// - /// Countrycode of the country where the company is located - /// - [Required] - public string CountryCode { get; set; } + /// + /// a phone number that customers can use to contact the merchant + /// + public string ContactPhone { get; set; } - /// - /// City where the company is located - /// - [Required] - public string City { get; set; } + /// + /// an email address that customers can use to contact the merchant + /// + public string ContactEmail { get; set; } - /// - /// Postcalcode of the company - /// - [Required] - public string PostalCode { get; set; } + /// + /// Countrycode of the country where the company is located + /// + [Required] + public string CountryCode { get; set; } - /// - /// Housenumber of the company - /// - public string HouseNumber { get; set; } + /// + /// City where the company is located + /// + [Required] + public string City { get; set; } - /// - /// Housenumber addition of the company - /// - public string HouseNumberAddition { get; set; } + /// + /// Postcalcode of the company + /// + [Required] + public string PostalCode { get; set; } - /// - /// Name of the street the company is located - /// - [Required] - public string Street { get; set; } + /// + /// Housenumber of the company + /// + public string HouseNumber { get; set; } - /// - /// VAT number of the company - /// - [Required] - public string Vat { get; set; } + /// + /// Housenumber addition of the company + /// + public string HouseNumberAddition { get; set; } - /// - /// Chamber of Commerce number of the company - /// - /// - [JsonProperty("coc")] - public string Coc { get; set; } + /// + /// Name of the street the company is located + /// + [Required] + public string Street { get; set; } - /// - /// Name of the company - /// - [JsonProperty("name")] - public string FullName { get; set; } + /// + /// VAT number of the company + /// + [Required] + public string Vat { get; set; } - /// - /// Array of accounts to be linked to the merchant. At least 1 account must be added - /// - public List Accounts { get; set; } + /// + /// Chamber of Commerce number of the company + /// + /// + [JsonProperty("coc")] + public string Coc { get; set; } + + /// + /// Name of the company + /// + [JsonProperty("name")] + public string FullName { get; set; } - public BankAccount BankAccount { get; set; } - public MerchantSettings MerchantSettings { get; set; } + /// + /// Array of accounts to be linked to the merchant. At least 1 account must be added + /// + public List Accounts { get; set; } + public BankAccount BankAccount { get; set; } + public MerchantSettings MerchantSettings { get; set; } - /// - protected override void PrepareAndSetResponse() - { - // do nothing - } - } - public class MerchantSettings + /// + protected override void PrepareAndSetResponse() { - /// - /// Available options are day, week, month or manual - /// - public string ClearingInterval { get; set; } + // do nothing + } +} - /// - /// ID of the default merchant settings to be applied to the new signup - /// - public string ReferralProfileId { get; set; } +public class MerchantSettings +{ + /// + /// Available options are day, week, month or manual + /// + public string ClearingInterval { get; set; } - /// - /// Available options are Alliance and AlliancePlus - /// - public string Package { get; set; } + /// + /// ID of the default merchant settings to be applied to the new signup + /// + public string ReferralProfileId { get; set; } - /// - /// Indicates if the new merchant should receive a registration email. 0: No e-mail / 1: Regular registration e-mail / 2: Short registration e-mail - /// - public string SendEmail { get; set; } - /// - /// Whether or not to settle the alliance invoice with the merchants clearing. Available options: 0: No(default) / 1: Yes - /// - public bool SettleBalance { get; set; } - } + /// + /// Available options are Alliance and AlliancePlus + /// + public string Package { get; set; } /// - /// A account linked which can be linked to a merchant + /// Indicates if the new merchant should receive a registration email. 0: No e-mail / 1: Regular registration e-mail / 2: Short registration e-mail /// - public class Account - { - /// - /// Email address - /// - [JsonProperty("email")] - [Required] - public string Email { get; set; } + public string SendEmail { get; set; } + /// + /// Whether or not to settle the alliance invoice with the merchants clearing. Available options: 0: No(default) / 1: Yes + /// + public bool SettleBalance { get; set; } +} - /// - /// Given name - /// - [JsonProperty("firstname")] - [Required] - public string FirstName { get; set; } +/// +/// A account linked which can be linked to a merchant +/// +public class Account +{ + /// + /// Email address + /// + [JsonProperty("email")] + [Required] + public string Email { get; set; } - /// - /// Family name - /// - [JsonProperty("lastname")] - [Required] - public string LastName { get; set; } + /// + /// Given name + /// + [JsonProperty("firstname")] + [Required] + public string FirstName { get; set; } - /// - /// Available options are: - /// M: male - /// F: female - /// - [JsonProperty("gender")] - [JsonConverter(typeof(StringEnumConverter))] - [Required] - public GenderEnum Gender { get; set; } + /// + /// Family name + /// + [JsonProperty("lastname")] + [Required] + public string LastName { get; set; } - /// - /// Indicates if the user is authorised to sign - /// 0 not authorised, 1 authorised independently, 2 shared authorized to sign - /// - [JsonProperty("authorisedToSign")] - [Required] - public AuthorizedToSignEnum AuthorizedToSign { get; set; } + /// + /// Available options are: + /// M: male + /// F: female + /// + [JsonProperty("gender")] + [JsonConverter(typeof(StringEnumConverter))] + [Required] + public GenderEnum Gender { get; set; } - /// - /// Indicates if the user is ubo - /// Ultimate beneficial owner (25% of more shares) - /// - [JsonProperty("ubo")] - [Required] - public bool UltimateBeneficialOwner { get; set; } + /// + /// Indicates if the user is authorised to sign + /// 0 not authorised, 1 authorised independently, 2 shared authorized to sign + /// + [JsonProperty("authorisedToSign")] + [Required] + public AuthorizedToSignEnum AuthorizedToSign { get; set; } - /// - /// If the user is UBO, use this parameter to set the percentage of UBO. Eg. 25 for 25% - /// - [JsonProperty("uboPercentage")] - [Required] - public int UboPercentage { get; set; } + /// + /// Indicates if the user is ubo + /// Ultimate beneficial owner (25% of more shares) + /// + [JsonProperty("ubo")] + [Required] + public bool UltimateBeneficialOwner { get; set; } - /// - /// Indicates if the user has company rights. Available options are 0 and 1 - /// - [Required] - [JsonProperty("useCompanyAuth")] - public bool UseCompanyAuth { get; set; } + /// + /// If the user is UBO, use this parameter to set the percentage of UBO. Eg. 25 for 25% + /// + [JsonProperty("uboPercentage")] + [Required] + public int UboPercentage { get; set; } - /// - /// Indicates whether or not the account can login to the merchant's account. Available options: - /// 1: Yes, account can access the merchant - /// 0: No.Use this setting to add accounts that are only added to define the UBO's - /// - [Required] - [JsonProperty("hasAccess")] - public bool HasAccess { get; set; } + /// + /// Indicates if the user has company rights. Available options are 0 and 1 + /// + [Required] + [JsonProperty("useCompanyAuth")] + public bool UseCompanyAuth { get; set; } - /// - /// Preferred language of the registrant. See API_Langauge_v2::getAll() - /// - [Required] - [JsonProperty("language")] - public string Language { get; set; } + /// + /// Indicates whether or not the account can login to the merchant's account. Available options: + /// 1: Yes, account can access the merchant + /// 0: No.Use this setting to add accounts that are only added to define the UBO's + /// + [Required] + [JsonProperty("hasAccess")] + public bool HasAccess { get; set; } + /// + /// Preferred language of the registrant. See API_Langauge_v2::getAll() + /// + [Required] + [JsonProperty("language")] + public string Language { get; set; } + + /// + /// Gender of a person + /// + public enum GenderEnum + { /// - /// Gender of a person + /// Male /// - public enum GenderEnum - { - /// - /// Male - /// - M, - /// - /// Female - /// - F - } - + M, /// - /// Indicates if the user is authorized to sign. + /// Female /// - [SuppressMessage("ReSharper", "UnusedMember.Global")] - public enum AuthorizedToSignEnum - { - /// - /// No, not authorized - /// - NotAuthorized = 0, - /// - /// Yes, authorized to sign independently - /// - AuthorizedIndependently = 1, - /// - /// Yes, shared authorized to sign - /// - SharedAuthorizedToSign = 2 - } + F } - public class BankAccount + /// + /// Indicates if the user is authorized to sign. + /// + [SuppressMessage("ReSharper", "UnusedMember.Global")] + public enum AuthorizedToSignEnum { /// - /// Owner's name of the bankaccount + /// No, not authorized /// - public string BankAccountOwner { get; set; } + NotAuthorized = 0, /// - /// Bank account number should be an IBAN + /// Yes, authorized to sign independently /// - public string BankAccountNumber { get; set; } + AuthorizedIndependently = 1, /// - /// BIC or SWIFT code + /// Yes, shared authorized to sign /// - public string BankAccountBic { get; set; } + SharedAuthorizedToSign = 2 } } + +public class BankAccount +{ + /// + /// Owner's name of the bankaccount + /// + public string BankAccountOwner { get; set; } + /// + /// Bank account number should be an IBAN + /// + public string BankAccountNumber { get; set; } + /// + /// BIC or SWIFT code + /// + public string BankAccountBic { get; set; } +} diff --git a/PAYNLSDK/API/Alliance/AddService/AddServiceResult.cs b/PAYNLSDK/API/Alliance/AddService/AddServiceResult.cs index 4d1a631..fe671aa 100644 --- a/PAYNLSDK/API/Alliance/AddService/AddServiceResult.cs +++ b/PAYNLSDK/API/Alliance/AddService/AddServiceResult.cs @@ -1,16 +1,15 @@ using Newtonsoft.Json; -namespace PAYNLSDK.API.Alliance.AddService +namespace PayNLSdk.Api.Alliance.AddService; + +/// +/// Class result class for a Add Service call +/// +public class AddServiceResult : ResponseBase { /// - /// Class result class for a Add Service call + /// The newly created service identifier (SL-****-****) /// - public class AddServiceResult : ResponseBase - { - /// - /// The newly created service identifier (SL-****-****) - /// - [JsonProperty("serviceId")] - public string ServiceId { get; set; } - } -} \ No newline at end of file + [JsonProperty("serviceId")] + public string ServiceId { get; set; } +} diff --git a/PAYNLSDK/API/Alliance/AddService/Request.cs b/PAYNLSDK/API/Alliance/AddService/Request.cs index 6493b2f..23f86f4 100644 --- a/PAYNLSDK/API/Alliance/AddService/Request.cs +++ b/PAYNLSDK/API/Alliance/AddService/Request.cs @@ -1,101 +1,100 @@ using System.Collections.Generic; using System.Collections.Specialized; -namespace PAYNLSDK.API.Alliance.AddService +namespace PayNLSdk.Api.Alliance.AddService; + +/// +/// Class Request for a new Service. +/// +/// +public class Request : RequestBase { - /// - /// Class Request for a new Service. - /// - /// - public class Request : RequestBase + /// + protected override int Version => 4; + /// + protected override string Controller => "Alliance"; + /// + protected override string Method => "addService"; + /// + public override NameValueCollection GetParameters() { - /// - protected override int Version => 4; - /// - protected override string Controller => "Alliance"; - /// - protected override string Method => "addService"; - /// - public override NameValueCollection GetParameters() - { - var retval = new NameValueCollection(); - retval.Add("merchantId", MerchantId); - retval.Add("name", Name); - retval.Add("description", Description); - retval.Add("categoryId", CategoryId); - retval.Add("publication", Publication); + var retval = new NameValueCollection(); + retval.Add("merchantId", MerchantId); + retval.Add("name", Name); + retval.Add("description", Description); + retval.Add("categoryId", CategoryId); + retval.Add("publication", Publication); - if (PaymentOptions.Count > 0) + if (PaymentOptions.Count > 0) + { + for (int i = 0; i < PaymentOptions.Count; i++) { - for (int i = 0; i < PaymentOptions.Count; i++) - { - retval.Add("paymentOptions[" + i + "][id]", PaymentOptions[i].Id.ToString()); - retval.Add("paymentOptions[" + i + "][settings]", PaymentOptions[i].Settings); - } + retval.Add("paymentOptions[" + i + "][id]", PaymentOptions[i].Id.ToString()); + retval.Add("paymentOptions[" + i + "][settings]", PaymentOptions[i].Settings); } - - return retval; } - /// - /// Gets or sets the merchant identifier. - /// - /// The merchant identifier. - public string MerchantId { get; set; } - - /// - /// Gets or sets the description of the way you are using the payment methods - /// - /// The publication. - public string Publication { get; set; } + return retval; + } - /// - /// Gets or sets The ID of the category that best descriptions your service. - /// For a list of available categories, see API_Service_v1::getCategories(). - /// - /// The category identifier. - public string CategoryId { get; set; } + /// + /// Gets or sets the merchant identifier. + /// + /// The merchant identifier. + public string MerchantId { get; set; } - /// - /// Gets or sets the description of the service. It is important to be as acurate as possible. - /// - /// The description. - public string Description { get; set; } + /// + /// Gets or sets the description of the way you are using the payment methods + /// + /// The publication. + public string Publication { get; set; } - /// - /// Gets or sets the name of the service. - /// - /// The name. - public string Name { get; set; } + /// + /// Gets or sets The ID of the category that best descriptions your service. + /// For a list of available categories, see API_Service_v1::getCategories(). + /// + /// The category identifier. + public string CategoryId { get; set; } - /// - /// An array of payment options (id & settings) you want to use for this service. - /// For a list of available payment option ids, see API_PaymentProfile_v1::getAvailable() - /// - public List PaymentOptions = new List(); + /// + /// Gets or sets the description of the service. It is important to be as acurate as possible. + /// + /// The description. + public string Description { get; set; } - /// - /// Load the raw response and perform any actions along with it. - /// - protected override void PrepareAndSetResponse() - { - // do nothing - } - } + /// + /// Gets or sets the name of the service. + /// + /// The name. + public string Name { get; set; } /// - /// Payment profile + /// An array of payment options (id & settings) you want to use for this service. /// For a list of available payment option ids, see API_PaymentProfile_v1::getAvailable() /// - public class PaymentProfile + public List PaymentOptions = new List(); + + /// + /// Load the raw response and perform any actions along with it. + /// + protected override void PrepareAndSetResponse() { - /// - /// ID of the payment profile - /// - public int Id { get; set; } - /// - /// Array of settings that belong to this payment profile. - /// - public string Settings { get; set; } + // do nothing } } + +/// +/// Payment profile +/// For a list of available payment option ids, see API_PaymentProfile_v1::getAvailable() +/// +public class PaymentProfile +{ + /// + /// ID of the payment profile + /// + public int Id { get; set; } + /// + /// Array of settings that belong to this payment profile. + /// + public string Settings { get; set; } +} \ No newline at end of file diff --git a/PAYNLSDK/API/Alliance/GetMerchant/GetMerchantResult.cs b/PAYNLSDK/API/Alliance/GetMerchant/GetMerchantResult.cs index adc85bf..10bc675 100644 --- a/PAYNLSDK/API/Alliance/GetMerchant/GetMerchantResult.cs +++ b/PAYNLSDK/API/Alliance/GetMerchant/GetMerchantResult.cs @@ -3,137 +3,135 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -namespace PAYNLSDK.API.Alliance.GetMerchant -{ - /// - /// The result of the Alliance/GetMerchant call - /// - [SuppressMessage("ReSharper", "InconsistentNaming")] - public class GetMerchantResult - { - [JsonProperty("request")] public GetMerchantResult.Request request { get; set; } - [JsonProperty("merchantId")] public string merchantId { get; set; } - [JsonProperty("merchantName")] public string merchantName { get; set; } - [JsonProperty("services")] public Service[] services { get; set; } - [JsonProperty("balance")] public int BalanceInCents { get; set; } - [JsonIgnore] public decimal Balance => Math.Round(BalanceInCents / 100m); - [JsonProperty("documents")] public Document[] documents { get; set; } - [JsonProperty("accounts")] public Account[] accounts { get; set; } - [JsonProperty("bankaccounts")] public Bankaccount[] bankaccounts { get; set; } - [JsonProperty("public_info")] public PublicInfo public_info { get; set; } - [JsonProperty("contract")] public Contract contract { get; set; } +namespace PayNLSdk.Api.Alliance.GetMerchant; - public class Request - { - [JsonProperty("result")] public string result { get; set; } - [JsonProperty("errorId")] public string errorId { get; set; } - [JsonProperty("errorMessage")] public string errorMessage { get; set; } - } +/// +/// The result of the Alliance/GetMerchant call +/// +[SuppressMessage("ReSharper", "InconsistentNaming")] +public class GetMerchantResult +{ + [JsonProperty("request")] public GetMerchantResult.Request request { get; set; } + [JsonProperty("merchantId")] public string merchantId { get; set; } + [JsonProperty("merchantName")] public string merchantName { get; set; } + [JsonProperty("services")] public Service[] services { get; set; } + [JsonProperty("balance")] public int BalanceInCents { get; set; } + [JsonIgnore] public decimal Balance => Math.Round(BalanceInCents / 100m); + [JsonProperty("documents")] public Document[] documents { get; set; } + [JsonProperty("accounts")] public Account[] accounts { get; set; } + [JsonProperty("bankaccounts")] public Bankaccount[] bankaccounts { get; set; } + [JsonProperty("public_info")] public PublicInfo public_info { get; set; } + [JsonProperty("contract")] public Contract contract { get; set; } - public class PublicInfo - { - public string merchantId { get; set; } - public string name { get; set; } - public string type { get; set; } - public string typeName { get; set; } - public PostalAddress postalAddress { get; set; } - public string cocNumber { get; set; } - public string vatNumber { get; set; } - public string image { get; set; } - public List contactData { get; set; } - } + public class Request + { + [JsonProperty("result")] public string result { get; set; } + [JsonProperty("errorId")] public string errorId { get; set; } + [JsonProperty("errorMessage")] public string errorMessage { get; set; } + } - public class PostalAddress - { - public string street { get; set; } - public string houseNumber { get; set; } - public string zipCode { get; set; } - public string city { get; set; } - public string countryCode { get; set; } - public string countryName { get; set; } - } + public class PublicInfo + { + public string merchantId { get; set; } + public string name { get; set; } + public string type { get; set; } + public string typeName { get; set; } + public PostalAddress postalAddress { get; set; } + public string cocNumber { get; set; } + public string vatNumber { get; set; } + public string image { get; set; } + public List contactData { get; set; } + } - public class Contract - { - public string packageType { get; set; } - public string invoiceAllowed { get; set; } - public string payoutInterval { get; set; } - public string createdDate { get; set; } - public string acceptedDate { get; set; } - public string deletedDate { get; set; } - } + public class PostalAddress + { + public string street { get; set; } + public string houseNumber { get; set; } + public string zipCode { get; set; } + public string city { get; set; } + public string countryCode { get; set; } + public string countryName { get; set; } + } - public class Service - { - public string serviceId { get; set; } - public string serviceName { get; set; } - } + public class Contract + { + public string packageType { get; set; } + public string invoiceAllowed { get; set; } + public string payoutInterval { get; set; } + public string createdDate { get; set; } + public string acceptedDate { get; set; } + public string deletedDate { get; set; } + } - public class Document - { - [JsonProperty("id")] - public string id { get; set; } - [JsonProperty("type_id")] - public string type_id { get; set; } - [JsonProperty("type_name")] - public string type_name { get; set; } - /// - /// Can be one of these values: 1 (Requested), 2 (Uploaded), 3 (Approved), 4 (Rejected), 5 (Expired) - /// - [JsonProperty("status_id")] - public int status_id { get; set; } - [JsonProperty("status_name")] - public string status_name { get; set; } - [JsonProperty("expires")] - public string expires { get; set; } - } + public class Service + { + public string serviceId { get; set; } + public string serviceName { get; set; } + } - public class Account - { - [JsonProperty("id")] - public string id { get; set; } - [JsonProperty("account_id")] - public string account_id { get; set; } - [JsonProperty("name")] - public string name { get; set; } - [JsonProperty("accepted")] - public string accepted { get; set; } - [JsonProperty("access")] - public string access { get; set; } - [JsonProperty("ubo")] - public string ubo { get; set; } - [JsonProperty("authorised_to_sign")] - public string authorised_to_sign { get; set; } - [JsonProperty("signature_label")] - public string signature_label { get; set; } - [JsonProperty("documents")] - public Document[] documents { get; set; } - } + public class Document + { + [JsonProperty("id")] + public string id { get; set; } + [JsonProperty("type_id")] + public string type_id { get; set; } + [JsonProperty("type_name")] + public string type_name { get; set; } + /// + /// Can be one of these values: 1 (Requested), 2 (Uploaded), 3 (Approved), 4 (Rejected), 5 (Expired) + /// + [JsonProperty("status_id")] + public int status_id { get; set; } + [JsonProperty("status_name")] + public string status_name { get; set; } + [JsonProperty("expires")] + public string expires { get; set; } + } - public class Bankaccount - { - [JsonProperty("id")] - public string id { get; set; } - [JsonProperty("bankaccountHolder")] - public string bankaccountHolder { get; set; } - [JsonProperty("bankaccountNumber")] - public string bankaccountNumber { get; set; } - [JsonProperty("bic")] - public string bic { get; set; } - [JsonProperty("countryCode")] - public string countryCode { get; set; } - } + public class Account + { + [JsonProperty("id")] + public string id { get; set; } + [JsonProperty("account_id")] + public string account_id { get; set; } + [JsonProperty("name")] + public string name { get; set; } + [JsonProperty("accepted")] + public string accepted { get; set; } + [JsonProperty("access")] + public string access { get; set; } + [JsonProperty("ubo")] + public string ubo { get; set; } + [JsonProperty("authorised_to_sign")] + public string authorised_to_sign { get; set; } + [JsonProperty("signature_label")] + public string signature_label { get; set; } + [JsonProperty("documents")] + public Document[] documents { get; set; } + } - public class ContactData - { - [JsonProperty("type")] - public string Type { get; set; } - [JsonProperty("value")] - public string Value { get; set; } - [JsonProperty("description")] - public string Description { get; set; } - } + public class Bankaccount + { + [JsonProperty("id")] + public string id { get; set; } + [JsonProperty("bankaccountHolder")] + public string bankaccountHolder { get; set; } + [JsonProperty("bankaccountNumber")] + public string bankaccountNumber { get; set; } + [JsonProperty("bic")] + public string bic { get; set; } + [JsonProperty("countryCode")] + public string countryCode { get; set; } + } + public class ContactData + { + [JsonProperty("type")] + public string Type { get; set; } + [JsonProperty("value")] + public string Value { get; set; } + [JsonProperty("description")] + public string Description { get; set; } } -} +} diff --git a/PAYNLSDK/API/Alliance/GetMerchant/Request.cs b/PAYNLSDK/API/Alliance/GetMerchant/Request.cs index b29c98f..4c3b510 100644 --- a/PAYNLSDK/API/Alliance/GetMerchant/Request.cs +++ b/PAYNLSDK/API/Alliance/GetMerchant/Request.cs @@ -1,45 +1,37 @@ -using System; -using System.Collections.Generic; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -using PAYNLSDK.API.Transaction.Info; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; -namespace PAYNLSDK.API.Alliance.GetMerchant +namespace PayNLSdk.Api.Alliance.GetMerchant; + +public class Request : RequestBase { - public class Request : RequestBase - { - /// - protected override int Version => 4; - /// - protected override string Controller => "Alliance"; - /// - protected override string Method => "getMerchant"; + /// + protected override int Version => 4; + /// + protected override string Controller => "Alliance"; + /// + protected override string Method => "getMerchant"; - /// - /// the merchant Id to request - /// - public string MerchantId { get; set; } + /// + /// the merchant Id to request + /// + public string MerchantId { get; set; } - public override NameValueCollection GetParameters() - { - var retval = new NameValueCollection { { "merchantId", MerchantId } }; - return retval; - } + public override NameValueCollection GetParameters() + { + var retval = new NameValueCollection { { "merchantId", MerchantId } }; + return retval; + } - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - // response = JsonConvert.DeserializeObject(RawResponse); - + throw new PayNlException("rawResponse is empty!"); } + // response = JsonConvert.DeserializeObject(RawResponse); + } -} +} \ No newline at end of file diff --git a/PAYNLSDK/API/Banktransfer/Add/Request.cs b/PAYNLSDK/API/Banktransfer/Add/Request.cs index 774d24d..df82868 100644 --- a/PAYNLSDK/API/Banktransfer/Add/Request.cs +++ b/PAYNLSDK/API/Banktransfer/Add/Request.cs @@ -1,201 +1,200 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System; using System.Collections.Specialized; -namespace PAYNLSDK.API.Banktransfer.Add +namespace PayNLSdk.Api.Banktransfer.Add; + +/// +/// A new ADD request for the banktransfer (payment option id 136) +/// +public class Request : RequestBase { /// - /// A new ADD request for the banktransfer (payment option id 136) + /// Create a new bank transfer request object /// - public class Request : RequestBase + /// + /// + /// + /// + public Request(decimal amount, string bankAccountHolder, string bankAccountNumber, string bankAccountBic) { - /// - /// Create a new bank transfer request object - /// - /// - /// - /// - /// - public Request(decimal amount, string bankAccountHolder, string bankAccountNumber, string bankAccountBic) + AmountInCents = (int)Math.Floor(amount * 100); + BankAccountHolder = bankAccountHolder; + BankAccountNumber = bankAccountNumber; + BankAccountBic = bankAccountBic; + } + + /// + /// The amount to be paid should be given in cents. For example € 3.50 becomes 350. + /// + public int AmountInCents { get; set; } + + /// + /// The name of the customer. + /// + public string BankAccountHolder { get; set; } + + /// + /// The bankaccount number of the customer. + /// + public string BankAccountNumber { get; set; } + + /// + /// The BIC of the bank. + /// + public string BankAccountBic { get; set; } + + /// + /// The description to include with the payment. + /// + public string Description { get; set; } + + /// + /// The id of a promotor webmaster / affiliate. + /// In general, you won't use this unless you know the ID's of your affiliate's + /// + public int? PromotorId { get; set; } + + /// + /// The used tool code. + /// + public string Tool { get; set; } + + /// + /// The used info code which can be tracked in the stats + /// + public string Info { get; set; } + + /// + /// The used object. + /// + public string Object { get; set; } + + /// + /// The first free value which can be tracked in the stats + /// + public string Extra1 { get; set; } + + /// + /// The second free value which can be tracked in the stats + /// + public string Extra2 { get; set; } + + /// + /// The third free value which can be tracked in the stats + /// + public string Extra3 { get; set; } + + /// + /// The currency of the amount, default is EUR. + /// + public string Currency { get; set; } + + /// + /// The currency of the amount, default is EUR. + /// + public DateTime? ProcessDate { get; set; } + + /// + protected override int Version => 1; + + /// + protected override string Controller => "Banktransfer"; + + /// + protected override string Method => "add"; + + /// + public override bool RequiresApiToken => true; + + /// + public override bool RequiresServiceId => true; + + /// + public override NameValueCollection GetParameters() + { + var nvc = new NameValueCollection(); + + ParameterValidator.IsNotNull(AmountInCents, "Amount"); + nvc.Add("amount", AmountInCents.ToString()); + + ParameterValidator.IsNotNull(BankAccountHolder, "BankAccountHolder"); + nvc.Add("bankAccountHolder", BankAccountHolder); + + ParameterValidator.IsNotNull(BankAccountNumber, "BankAccountNumber"); + nvc.Add("bankAccountNumber", BankAccountNumber); + + ParameterValidator.IsNotNull(BankAccountBic, "BankAccountBic"); + nvc.Add("bankAccountBic", BankAccountBic); + + if (!ParameterValidator.IsEmpty(Description)) + { + nvc.Add("description", Description); + } + + if (PromotorId.HasValue) { - AmountInCents = (int)Math.Floor(amount * 100); - BankAccountHolder = bankAccountHolder; - BankAccountNumber = bankAccountNumber; - BankAccountBic = bankAccountBic; + nvc.Add("promotorId", PromotorId.Value.ToString()); } - /// - /// The amount to be paid should be given in cents. For example € 3.50 becomes 350. - /// - public int AmountInCents { get; set; } - - /// - /// The name of the customer. - /// - public string BankAccountHolder { get; set; } - - /// - /// The bankaccount number of the customer. - /// - public string BankAccountNumber { get; set; } - - /// - /// The BIC of the bank. - /// - public string BankAccountBic { get; set; } - - /// - /// The description to include with the payment. - /// - public string Description { get; set; } - - /// - /// The id of a promotor webmaster / affiliate. - /// In general, you won't use this unless you know the ID's of your affiliate's - /// - public int? PromotorId { get; set; } - - /// - /// The used tool code. - /// - public string Tool { get; set; } - - /// - /// The used info code which can be tracked in the stats - /// - public string Info { get; set; } - - /// - /// The used object. - /// - public string Object { get; set; } - - /// - /// The first free value which can be tracked in the stats - /// - public string Extra1 { get; set; } - - /// - /// The second free value which can be tracked in the stats - /// - public string Extra2 { get; set; } - - /// - /// The third free value which can be tracked in the stats - /// - public string Extra3 { get; set; } - - /// - /// The currency of the amount, default is EUR. - /// - public string Currency { get; set; } - - /// - /// The currency of the amount, default is EUR. - /// - public DateTime? ProcessDate { get; set; } - - /// - protected override int Version => 1; - - /// - protected override string Controller => "Banktransfer"; - - /// - protected override string Method => "add"; - - /// - public override bool RequiresApiToken => true; - - /// - public override bool RequiresServiceId => true; - - /// - public override NameValueCollection GetParameters() + if (!ParameterValidator.IsEmpty(Tool)) { - var nvc = new NameValueCollection(); - - ParameterValidator.IsNotNull(AmountInCents, "Amount"); - nvc.Add("amount", AmountInCents.ToString()); - - ParameterValidator.IsNotNull(BankAccountHolder, "BankAccountHolder"); - nvc.Add("bankAccountHolder", BankAccountHolder); - - ParameterValidator.IsNotNull(BankAccountNumber, "BankAccountNumber"); - nvc.Add("bankAccountNumber", BankAccountNumber); - - ParameterValidator.IsNotNull(BankAccountBic, "BankAccountBic"); - nvc.Add("bankAccountBic", BankAccountBic); - - if (!ParameterValidator.IsEmpty(Description)) - { - nvc.Add("description", Description); - } - - if (PromotorId.HasValue) - { - nvc.Add("promotorId", PromotorId.Value.ToString()); - } - - if (!ParameterValidator.IsEmpty(Tool)) - { - nvc.Add("tool", Tool); - } - - if (!ParameterValidator.IsEmpty(Info)) - { - nvc.Add("info", Info); - } - - if (!ParameterValidator.IsEmpty(Object)) - { - nvc.Add("object", Object); - } - - if (!ParameterValidator.IsEmpty(Extra1)) - { - nvc.Add("extra1", Extra1); - } - if (!ParameterValidator.IsEmpty(Extra2)) - { - nvc.Add("extra2", Extra2); - } - if (!ParameterValidator.IsEmpty(Extra3)) - { - nvc.Add("extra3", Extra3); - } - - if (!ParameterValidator.IsEmpty(Currency)) - { - nvc.Add("currency", Currency); - } - - if (ProcessDate.HasValue) - { - nvc.Add("processDate", ProcessDate.Value.ToString("yyyy-MM-dd")); - } - - return nvc; + nvc.Add("tool", Tool); } - /// - protected override void PrepareAndSetResponse() + if (!ParameterValidator.IsEmpty(Info)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); - if (!Response.Request.Result) - { - // toss - throw new PayNlException(Response.Request.Message); - } + nvc.Add("info", Info); } - /// - public Response Response => (Response)response; + if (!ParameterValidator.IsEmpty(Object)) + { + nvc.Add("object", Object); + } + + if (!ParameterValidator.IsEmpty(Extra1)) + { + nvc.Add("extra1", Extra1); + } + if (!ParameterValidator.IsEmpty(Extra2)) + { + nvc.Add("extra2", Extra2); + } + if (!ParameterValidator.IsEmpty(Extra3)) + { + nvc.Add("extra3", Extra3); + } + + if (!ParameterValidator.IsEmpty(Currency)) + { + nvc.Add("currency", Currency); + } + + if (ProcessDate.HasValue) + { + nvc.Add("processDate", ProcessDate.Value.ToString("yyyy-MM-dd")); + } + + return nvc; + } + + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) + { + throw new PayNlException("rawResponse is empty!"); + } + response = JsonConvert.DeserializeObject(RawResponse); + if (!Response.Request.Result) + { + // toss + throw new PayNlException(Response.Request.Message); + } } -} + + /// + public Response Response => (Response)response; +} \ No newline at end of file diff --git a/PAYNLSDK/API/Banktransfer/Add/Response.cs b/PAYNLSDK/API/Banktransfer/Add/Response.cs index 9936e4d..1c64ee2 100644 --- a/PAYNLSDK/API/Banktransfer/Add/Response.cs +++ b/PAYNLSDK/API/Banktransfer/Add/Response.cs @@ -1,10 +1,9 @@ using Newtonsoft.Json; -namespace PAYNLSDK.API.Banktransfer.Add +namespace PayNLSdk.Api.Banktransfer.Add; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - [JsonProperty("refundId")] - public string RefundId { get; set; } - } + [JsonProperty("refundId")] + public string RefundId { get; set; } } diff --git a/PAYNLSDK/API/Document/Add/Request.cs b/PAYNLSDK/API/Document/Add/Request.cs index 85193af..f2f7362 100644 --- a/PAYNLSDK/API/Document/Add/Request.cs +++ b/PAYNLSDK/API/Document/Add/Request.cs @@ -1,75 +1,73 @@ -using System; +using Newtonsoft.Json; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; +using System; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel.DataAnnotations; -using Newtonsoft.Json; -using PAYNLSDK.API; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; -namespace PayNLSdk.API.Document.Add +namespace PayNLSdk.Api.Document.Add; + +/// +/// Upload one or multiple files to a document for a merchant or account. +/// +public class Request : RequestBase { + /// + protected override int Version => 1; + /// + protected override string Controller => "document"; + /// + protected override string Method => "add"; + /// - /// Upload one or multiple files to a document for a merchant or account. + /// The id of the document /// - public class Request : RequestBase - { - /// - protected override int Version => 1; - /// - protected override string Controller => "document"; - /// - protected override string Method => "add"; - - /// - /// The id of the document - /// - [Required] - public string DocumentId { get; set; } - - /// - /// the name (and extension) of the file you're adding. - /// - [Required] - public string FileName { get; set; } + [Required] + public string DocumentId { get; set; } - /// - /// The content of the file which should be uploaded - /// - [Required] - public List FileBytes { get; set; } + /// + /// the name (and extension) of the file you're adding. + /// + [Required] + public string FileName { get; set; } - /// - public override NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(DocumentId, "DocumentId"); - ParameterValidator.IsNotEmpty(FileName, "DocumentId"); - ParameterValidator.IsNotNull(FileBytes, "FileBytes"); + /// + /// The content of the file which should be uploaded + /// + [Required] + public List FileBytes { get; set; } - nvc.Add("documentId", DocumentId); - nvc.Add("filename", FileName); + /// + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); + ParameterValidator.IsNotEmpty(DocumentId, "DocumentId"); + ParameterValidator.IsNotEmpty(FileName, "DocumentId"); + ParameterValidator.IsNotNull(FileBytes, "FileBytes"); - //nvc.Add("documentFile", Convert.ToBase64String(FileBytes)); - for (var i = 0; i < FileBytes.Count; i++) - { - var fileBytes = FileBytes[i]; - nvc.Add($"documentFile[{i}]", Convert.ToBase64String(fileBytes)); - } + nvc.Add("documentId", DocumentId); + nvc.Add("filename", FileName); - return nvc; + //nvc.Add("documentFile", Convert.ToBase64String(FileBytes)); + for (var i = 0; i < FileBytes.Count; i++) + { + var fileBytes = FileBytes[i]; + nvc.Add($"documentFile[{i}]", Convert.ToBase64String(fileBytes)); } - /// - protected override void PrepareAndSetResponse() - { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } + return nvc; + } - var r = JsonConvert.DeserializeObject(RawResponse); - response = r; + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) + { + throw new PayNlException("rawResponse is empty!"); } + + var r = JsonConvert.DeserializeObject(RawResponse); + response = r; } -} +} \ No newline at end of file diff --git a/PAYNLSDK/API/Document/Add/Response.cs b/PAYNLSDK/API/Document/Add/Response.cs index 7de28e4..d1a760d 100644 --- a/PAYNLSDK/API/Document/Add/Response.cs +++ b/PAYNLSDK/API/Document/Add/Response.cs @@ -1,29 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Newtonsoft.Json; -using PAYNLSDK.API; +using Newtonsoft.Json; -namespace PayNLSdk.API.Document.Add +namespace PayNLSdk.Api.Document.Add; + +/// +/// The result whether the Upload of one or multiple files to a document for a merchant or account has completed +/// +public class Response : ResponseBase { /// - /// The result whether the Upload of one or multiple files to a document for a merchant or account has completed + /// If true the call was successful /// - public class Response : ResponseBase - { - /// - /// If true the call was successful - /// - [JsonProperty("result")] public bool Result { get; set; } + [JsonProperty("result")] public bool Result { get; set; } - /// - /// ID of the error (if an error occurred) - /// - [JsonProperty("errorId")] public string ErrorId { get; set; } + /// + /// ID of the error (if an error occurred) + /// + [JsonProperty("errorId")] public string ErrorId { get; set; } - /// - /// Description of the error (if an error occurred) - /// - [JsonProperty("errorMessage")] public string ErrorMessage { get; set; } - } -} + /// + /// Description of the error (if an error occurred) + /// + [JsonProperty("errorMessage")] public string ErrorMessage { get; set; } +} \ No newline at end of file diff --git a/PAYNLSDK/API/Language/GetAllRequest.cs b/PAYNLSDK/API/Language/GetAllRequest.cs index 3d72117..43143a7 100644 --- a/PAYNLSDK/API/Language/GetAllRequest.cs +++ b/PAYNLSDK/API/Language/GetAllRequest.cs @@ -1,30 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Specialized; -namespace PAYNLSDK.API.Language +namespace PayNLSdk.Api.Language; + +public class GetAllRequest : RequestBase { - public class GetAllRequest : RequestBase + /// + protected override int Version => 2; + /// + protected override string Controller => "Language"; + /// + protected override string Method => "GetAll"; + /// + public override NameValueCollection GetParameters() { - /// - protected override int Version => 2; - /// - protected override string Controller => "Language"; - /// - protected override string Method => "GetAll"; - /// - public override NameValueCollection GetParameters() - { - return new NameValueCollection(); - } + return new NameValueCollection(); + } - /// - protected override void PrepareAndSetResponse() - { - // do nothing - } + /// + protected override void PrepareAndSetResponse() + { + // do nothing } } diff --git a/PAYNLSDK/API/Language/GetAllResult.cs b/PAYNLSDK/API/Language/GetAllResult.cs index 0ca39b2..f0f2caf 100644 --- a/PAYNLSDK/API/Language/GetAllResult.cs +++ b/PAYNLSDK/API/Language/GetAllResult.cs @@ -1,27 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace PayNLSdk.Api.Language; -namespace PAYNLSDK.API.Language +public class GetAllResult { - public class GetAllResult - { - public Language[] Languages { get; set; } - - public class Language - { - public string id { get; set; } - public string name { get; set; } - public string abbreviation { get; set; } - public string available { get; set; } - public string fallback_language_id { get; set; } - public string created { get; set; } - public string created_by { get; set; } - public string modified { get; set; } - public string modified_by { get; set; } - } + public Language[] Languages { get; set; } + public class Language + { + public string id { get; set; } + public string name { get; set; } + public string abbreviation { get; set; } + public string available { get; set; } + public string fallback_language_id { get; set; } + public string created { get; set; } + public string created_by { get; set; } + public string modified { get; set; } + public string modified_by { get; set; } } + } diff --git a/PAYNLSDK/API/Merchant/Add/Request.cs b/PAYNLSDK/API/Merchant/Add/Request.cs index 82141ee..09a16ce 100644 --- a/PAYNLSDK/API/Merchant/Add/Request.cs +++ b/PAYNLSDK/API/Merchant/Add/Request.cs @@ -1,198 +1,197 @@ -using System.Collections.Generic; +using Newtonsoft.Json; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; +using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel.DataAnnotations; -using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; -namespace PAYNLSDK.API.Merchant.Add +namespace PayNLSdk.Api.Merchant.Add; + +public class Request : RequestBase { - public class Request : RequestBase + /** + * Add a merchant + * + * Create a new submerchant. + * The format of the option array is as follows + * array( + * // Required + * 'companyName' => 'The Name', + * 'cocNumber' => '123456789', + * 'street' => 'Street', + * 'houseNumber' => '123', + * 'postalCode' => '1234 AA', + * 'city' => 'City', + * 'accounts' => array( + * // Minimum of 1 account, you can add more, one account must be primary, the other accounts cannot be primary + * array( + * 'primary' => true, // One account must be primary + * 'email' => 'email@test.nl', + * 'firstname' => 'First', + * 'lastname' => 'Last', + * 'gender' => 'male', // 'male' or 'female' + * 'authorisedToSign' => 2, //0 not authorised, 1 authorised independently, 2 shared authorized to sign + * 'ubo' => true, // Ultimate beneficial owner (25% of more shares) + * ), + * array( + * 'primary' => false, + * 'email' => 'email2@test.nl', + * 'firstname' => 'Mede', + * 'lastname' => 'Eigenaar', + * 'gender' => 'female', // 'male' or 'female' + * 'authorisedToSign' => 2, //0 not authorised, 1 authorised independently, 2 shared authorized to sign + * 'ubo' => true, // Ultimate beneficial owner (25% of more shares) + * ) + * ), + * // Optional + * Do you want to send a registration email to the accounts. + * The options are: + * 0 - No email is sent + * 1 - The default registration email is sent + * 2 - The shortened alliance registration email is sent + * 'sendEmail' => 1, // see above + * 'countryCode' => 'NL', + * 'bankAccountOwner' => 'Firstname Lastname', + * 'bankAccountNumber' => 'NL91ABNA0417164300', + * 'bankAccountBIC' => 'ABNANL2A', + * 'vatNumber' => 'NL123412413', + * 'packageName' => 'Alliance', // Alliance or AlliancePlus + * + * Set to true if you want to be able to add a debit invoice to the account of this merchant. + * Your invoice will be subtracted from the merchants account. + * You will need to ask the merchant for permission before you can set this value to true + * 'settleBalance' => false, // see above + * 'payoutInterval' => 'week' //day, week or month + * ) + */ + + [JsonRequired] + [Required] + public string CompanyName { get; set; } + public string CocNumber { get; set; } + public string Street { get; set; } + public string HouseNumber { get; set; } + public string PostalCode { get; set; } + public string City { get; set; } + public List Accounts { get; set; } + /// + /// Optional + /// Do you want to send a registration email to the accounts. + /// The options are: + /// 0 - No email is sent + /// 1 - The default registration email is sent + /// 2 - The shortened alliance registration email is sent + /// + [JsonProperty("sendEmail")] + public int? SendEmail { get; set; } + + [JsonProperty("countryCode")] + public string TwoLetterCountryCode { get; set; } + + [JsonProperty("bankAccountOwner")] + public string BankAccountOwner { get; set; } + + [JsonProperty("bankAccountNumber")] + public string BankAccountNumber { get; set; } + + [JsonProperty("bankAccountBIC")] + public string BankAccountBic { get; set; } + + [JsonProperty("vatNumber")] + public string VatNumber { get; set; } + + /// + /// Alliance or AlliancePlus + /// + [JsonProperty("packageName")] + public string PackageName { get; set; } + /// + /// settleBalance + /// Set to true if you want to be able to add a debit invoice to the account of this merchant. + /// Your invoice will be subtracted from the merchants account. + /// You will need to ask the merchant for permission before you can set this value to true + /// + [JsonProperty("settleBalance")] + public bool SettleBalance { get; set; } + + /// + /// options are day, week or month + /// + [JsonProperty("payoutInterval")] + public string PayoutInterval { get; set; } + + public class Account { - /** - * Add a merchant - * - * Create a new submerchant. - * The format of the option array is as follows - * array( - * // Required - * 'companyName' => 'The Name', - * 'cocNumber' => '123456789', - * 'street' => 'Street', - * 'houseNumber' => '123', - * 'postalCode' => '1234 AA', - * 'city' => 'City', - * 'accounts' => array( - * // Minimum of 1 account, you can add more, one account must be primary, the other accounts cannot be primary - * array( - * 'primary' => true, // One account must be primary - * 'email' => 'email@test.nl', - * 'firstname' => 'First', - * 'lastname' => 'Last', - * 'gender' => 'male', // 'male' or 'female' - * 'authorisedToSign' => 2, //0 not authorised, 1 authorised independently, 2 shared authorized to sign - * 'ubo' => true, // Ultimate beneficial owner (25% of more shares) - * ), - * array( - * 'primary' => false, - * 'email' => 'email2@test.nl', - * 'firstname' => 'Mede', - * 'lastname' => 'Eigenaar', - * 'gender' => 'female', // 'male' or 'female' - * 'authorisedToSign' => 2, //0 not authorised, 1 authorised independently, 2 shared authorized to sign - * 'ubo' => true, // Ultimate beneficial owner (25% of more shares) - * ) - * ), - * // Optional - * Do you want to send a registration email to the accounts. - * The options are: - * 0 - No email is sent - * 1 - The default registration email is sent - * 2 - The shortened alliance registration email is sent - * 'sendEmail' => 1, // see above - * 'countryCode' => 'NL', - * 'bankAccountOwner' => 'Firstname Lastname', - * 'bankAccountNumber' => 'NL91ABNA0417164300', - * 'bankAccountBIC' => 'ABNANL2A', - * 'vatNumber' => 'NL123412413', - * 'packageName' => 'Alliance', // Alliance or AlliancePlus - * - * Set to true if you want to be able to add a debit invoice to the account of this merchant. - * Your invoice will be subtracted from the merchants account. - * You will need to ask the merchant for permission before you can set this value to true - * 'settleBalance' => false, // see above - * 'payoutInterval' => 'week' //day, week or month - * ) - */ - - [JsonRequired] - [Required] - public string CompanyName { get; set; } - public string CocNumber { get; set; } - public string Street { get; set; } - public string HouseNumber { get; set; } - public string PostalCode { get; set; } - public string City { get; set; } - public List Accounts { get; set; } - /// - /// Optional - /// Do you want to send a registration email to the accounts. - /// The options are: - /// 0 - No email is sent - /// 1 - The default registration email is sent - /// 2 - The shortened alliance registration email is sent - /// - [JsonProperty("sendEmail")] - public int? SendEmail { get; set; } - - [JsonProperty("countryCode")] - public string TwoLetterCountryCode { get; set; } + [JsonProperty("primary")] + public bool Primary { get; set; } - [JsonProperty("bankAccountOwner")] - public string BankAccountOwner { get; set; } + [JsonProperty("email")] + public string Email { get; set; } - [JsonProperty("bankAccountNumber")] - public string BankAccountNumber { get; set; } + [JsonProperty("firstname")] + public string FirstName { get; set; } - [JsonProperty("bankAccountBIC")] - public string BankAccountBic { get; set; } - - [JsonProperty("vatNumber")] - public string VatNumber { get; set; } + [JsonProperty("lastname")] + public string LastName { get; set; } /// - /// Alliance or AlliancePlus + /// "male" or "female" /// - [JsonProperty("packageName")] - public string PackageName { get; set; } + [JsonProperty("gender")] + public string Gender { get; set; } + /// - /// settleBalance - /// Set to true if you want to be able to add a debit invoice to the account of this merchant. - /// Your invoice will be subtracted from the merchants account. - /// You will need to ask the merchant for permission before you can set this value to true + /// 0 not authorised, 1 authorised independently, 2 shared authorized to sign /// - [JsonProperty("settleBalance")] - public bool SettleBalance { get; set; } + [JsonProperty("authorisedToSign")] + public int AuthorizedToSign { get; set; } /// - /// options are day, week or month + /// Ultimate beneficial owner (25% of more shares) /// - [JsonProperty("payoutInterval")] - public string PayoutInterval { get; set; } + [JsonProperty("ubo")] + public bool UltimateBeneficialOwner { get; set; } + } - public class Account - { - [JsonProperty("primary")] - public bool Primary { get; set; } - - [JsonProperty("email")] - public string Email { get; set; } - - [JsonProperty("firstname")] - public string FirstName { get; set; } - - [JsonProperty("lastname")] - public string LastName { get; set; } - - /// - /// "male" or "female" - /// - [JsonProperty("gender")] - public string Gender { get; set; } - - /// - /// 0 not authorised, 1 authorised independently, 2 shared authorized to sign - /// - [JsonProperty("authorisedToSign")] - public int AuthorizedToSign { get; set; } - - /// - /// Ultimate beneficial owner (25% of more shares) - /// - [JsonProperty("ubo")] - public bool UltimateBeneficialOwner { get; set; } - } + /// + protected override int Version { get; } + /// + protected override string Controller => "Merchant"; + /// + protected override string Method => "Add"; - /// - protected override int Version { get; } - /// - protected override string Controller => "Merchant"; - /// - protected override string Method => "Add"; + /// + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - /// - public override NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); + ParameterValidator.IsNotNull(CompanyName, "CompanyName"); + nvc.Add("amount", CompanyName); - ParameterValidator.IsNotNull(CompanyName, "CompanyName"); - nvc.Add("amount", CompanyName); - - if(string.IsNullOrWhiteSpace(CocNumber) == false) { nvc.Add("cocNumber", CocNumber); } - if (string.IsNullOrWhiteSpace(Street) == false) { nvc.Add("street", Street); } - if (string.IsNullOrWhiteSpace(HouseNumber) == false) { nvc.Add("housenumber", HouseNumber); } - if (string.IsNullOrWhiteSpace(PostalCode) == false) { nvc.Add("postalCode", PostalCode); } - if (string.IsNullOrWhiteSpace(City) == false) { nvc.Add("city", City); } - // if (Accounts == null) { nvc.Add("city", Accounts); } + if (string.IsNullOrWhiteSpace(CocNumber) == false) { nvc.Add("cocNumber", CocNumber); } + if (string.IsNullOrWhiteSpace(Street) == false) { nvc.Add("street", Street); } + if (string.IsNullOrWhiteSpace(HouseNumber) == false) { nvc.Add("housenumber", HouseNumber); } + if (string.IsNullOrWhiteSpace(PostalCode) == false) { nvc.Add("postalCode", PostalCode); } + if (string.IsNullOrWhiteSpace(City) == false) { nvc.Add("city", City); } + // if (Accounts == null) { nvc.Add("city", Accounts); } - // TODO ADD MORE!!! + // TODO ADD MORE!!! - return nvc; + return nvc; + } + + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) + { + throw new PayNlException("rawResponse is empty!"); } - - /// - protected override void PrepareAndSetResponse() + response = JsonConvert.DeserializeObject(RawResponse); + if (!response.Request.Result) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); - if (!response.Request.Result) - { - // toss - throw new PayNlException(response.Request.Message); - } + // toss + throw new PayNlException(response.Request.Message); } } -} +} \ No newline at end of file diff --git a/PAYNLSDK/API/Merchant/Add/Response.cs b/PAYNLSDK/API/Merchant/Add/Response.cs index 646145f..314ad58 100644 --- a/PAYNLSDK/API/Merchant/Add/Response.cs +++ b/PAYNLSDK/API/Merchant/Add/Response.cs @@ -1,50 +1,43 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace PAYNLSDK.API.Merchant.Add +namespace PayNLSdk.Api.Merchant.Add; + +/// +/// Reponse from the Merchant add command +/// +public class Response : ResponseBase { + [JsonProperty("merchantId")] + public string MerchantId { get; set; } + /// - /// Reponse from the Merchant add command + /// The merchant name /// - public class Response : ResponseBase - { - [JsonProperty("merchantId")] - public string MerchantId { get; set; } - - /// - /// The merchant name - /// - [JsonProperty("merchantName")] public string MerchantName { get; set; } - /// - /// Alliance or AlliancePlus - /// - [JsonProperty("packageName")] public string PackageName { get; set; } - [JsonProperty("invoiceAllowed")] public bool GetInvoiceAllowed { get; set; } - [JsonProperty("payoutInterval")] public string PayoutInterval { get; set; } - /// - /// The date the contract has been created. - /// - [JsonProperty("createdDate")] public string CreatedDate { get; set; } - /// - /// The date when you can start using the services from PAY - /// - [JsonProperty("acceptedDate")] public string AcceptedDate { get; set; } - [JsonProperty("deletedDate")] public string DeletedDate { get; set; } - [JsonProperty("services")] public string Services { get; set; } + [JsonProperty("merchantName")] public string MerchantName { get; set; } + /// + /// Alliance or AlliancePlus + /// + [JsonProperty("packageName")] public string PackageName { get; set; } + [JsonProperty("invoiceAllowed")] public bool GetInvoiceAllowed { get; set; } + [JsonProperty("payoutInterval")] public string PayoutInterval { get; set; } + /// + /// The date the contract has been created. + /// + [JsonProperty("createdDate")] public string CreatedDate { get; set; } + /// + /// The date when you can start using the services from PAY + /// + [JsonProperty("acceptedDate")] public string AcceptedDate { get; set; } + [JsonProperty("deletedDate")] public string DeletedDate { get; set; } + [JsonProperty("services")] public string Services { get; set; } - /// - /// Convert a raw response to an object - /// - /// - /// - public static Response FromRawResponse(string response) - { - return JsonConvert.DeserializeObject(response); - } + /// + /// Convert a raw response to an object + /// + /// + /// + public static Response FromRawResponse(string response) + { + return JsonConvert.DeserializeObject(response); } -} +} \ No newline at end of file diff --git a/PAYNLSDK/API/Merchant/Clearing/Request.cs b/PAYNLSDK/API/Merchant/Clearing/Request.cs index e399600..0b958ff 100644 --- a/PAYNLSDK/API/Merchant/Clearing/Request.cs +++ b/PAYNLSDK/API/Merchant/Clearing/Request.cs @@ -1,52 +1,49 @@ -using PAYNLSDK.API; -using PAYNLSDK.Utilities; +using PayNLSdk.Utilities; using System; -using System.Collections.Generic; using System.Collections.Specialized; -using System.Text; +using System.Globalization; -namespace PayNLSdk.API.Merchant.Clearing +namespace PayNLSdk.Api.Merchant.Clearing; + +public class Request : RequestBase { - public class Request : RequestBase + protected override int Version => 4; + + protected override string Controller => "merchant"; + + protected override string Method => "addClearing"; + + /// + /// The amount to clear, will round on 2 decimals + /// + public decimal Amount { get; set; } + /// + /// The merchant to clear + /// + public string? MerchantId { get; set; } + + /// + /// The content category Id. + /// + public string? ContentCategoryId { get; set; } + + /// + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); + + ParameterValidator.IsNotNull(Amount, "Amount"); + nvc.Add("amount", Math.Round(Amount * 100).ToString(CultureInfo.InvariantCulture)); + nvc.Add("merchantId", MerchantId); + nvc.Add("contentCategoryId", ContentCategoryId); + + return nvc; + } + + /// + /// + protected override void PrepareAndSetResponse() { - protected override int Version => 4; - - protected override string Controller => "merchant"; - - protected override string Method => "addClearing"; - - /// - /// The amount to clear, will round on 2 decimals - /// - public decimal Amount { get; set; } - /// - /// The merchant to clear - /// - public string? MerchantId { get; set; } - - /// - /// The content category Id. - /// - public string? ContentCategoryId { get; set; } - - /// - public override NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); - - ParameterValidator.IsNotNull(Amount, "Amount"); - nvc.Add("amount", Math.Round(Amount * 100).ToString()); - nvc.Add("merchantId", MerchantId); - nvc.Add("contentCategoryId", ContentCategoryId); - - return nvc; - } - - /// - /// - protected override void PrepareAndSetResponse() - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } } diff --git a/PAYNLSDK/API/Merchant/Clearing/Response.cs b/PAYNLSDK/API/Merchant/Clearing/Response.cs index c0b743f..d2a1907 100644 --- a/PAYNLSDK/API/Merchant/Clearing/Response.cs +++ b/PAYNLSDK/API/Merchant/Clearing/Response.cs @@ -1,23 +1,21 @@ using Newtonsoft.Json; -using PAYNLSDK.API; -namespace PayNLSdk.API.Merchant.Clearing +namespace PayNLSdk.Api.Merchant.Clearing; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - /// - /// The reference of the clearing. - /// - public string Result { get; set; } + /// + /// The reference of the clearing. + /// + public string Result { get; set; } - /// - /// get response - /// - /// - /// - internal static Response FromRawResponse(string response) - { - return JsonConvert.DeserializeObject(response); - } + /// + /// get response + /// + /// + /// + internal static Response FromRawResponse(string response) + { + return JsonConvert.DeserializeObject(response); } } diff --git a/PAYNLSDK/API/Merchant/Info/Request.cs b/PAYNLSDK/API/Merchant/Info/Request.cs index 8104de8..43769f3 100644 --- a/PAYNLSDK/API/Merchant/Info/Request.cs +++ b/PAYNLSDK/API/Merchant/Info/Request.cs @@ -1,49 +1,43 @@ -using System; -using System.Collections.Generic; +using Newtonsoft.Json; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; -namespace PAYNLSDK.API.Merchant.Get +namespace PayNLSdk.Api.Merchant.Info; + +public class Request : RequestBase { - public class Request : RequestBase + [JsonProperty("merchantId")] + public string MerchantId { get; set; } + + /// + protected override int Version { get; } + /// + protected override string Controller => "Merchant"; + /// + protected override string Method => "info"; + + /// + public override NameValueCollection GetParameters() { - [JsonProperty("merchantId")] - public string MerchantId { get; set; } + var nvc = new NameValueCollection(); + nvc.Add("merchantId", MerchantId); - /// - protected override int Version { get; } - /// - protected override string Controller => "Merchant"; - /// - protected override string Method => "info"; + return nvc; + } - /// - public override NameValueCollection GetParameters() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - var nvc = new NameValueCollection(); - nvc.Add("merchantId", MerchantId); - - return nvc; + throw new PayNlException("rawResponse is empty!"); } - - /// - protected override void PrepareAndSetResponse() + response = JsonConvert.DeserializeObject(RawResponse); + if (!response.Request.Result) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); - if (!response.Request.Result) - { - // toss - throw new PayNlException(response.Request.Message); - } + // toss + throw new PayNlException(response.Request.Message); } } } diff --git a/PAYNLSDK/API/Merchant/Info/Response.cs b/PAYNLSDK/API/Merchant/Info/Response.cs index 703a613..0c2f296 100644 --- a/PAYNLSDK/API/Merchant/Info/Response.cs +++ b/PAYNLSDK/API/Merchant/Info/Response.cs @@ -1,162 +1,156 @@ -using System; -using System.Collections.Generic; +using Newtonsoft.Json; using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -namespace PAYNLSDK.API.Merchant.Get +namespace PayNLSdk.Api.Merchant.Info; + +public class Response : ResponseBase { - public class Response : ResponseBase + public static Response FromRawResponse(string response) { - public static Get.Response FromRawResponse(string response) - { - return JsonConvert.DeserializeObject(response); - } + return JsonConvert.DeserializeObject(response); + } + + /// + /// This array contains information whether the request was succesfull yes or no + /// + [JsonProperty("request")] + public ResultInfo request { get; set; } + + [JsonProperty("merchant")] + public Merchant merchant { get; set; } + + /// + /// The different ways of contacting the merchant + /// + [JsonProperty("contactData")] + public Contact contactData { get; set; } + + #region Models (SubClasses) + public class ResultInfo + { + public string result { get; set; } + public string errorId { get; set; } + public string errorMessage { get; set; } + } + + public class Merchant + { + public string merchantId { get; set; } /// - /// This array contains information whether the request was succesfull yes or no + /// Name of the Merchant /// - [JsonProperty("request")] - public ResultInfo request { get; set; } + /// The name. + public string name { get; set; } - [JsonProperty("merchant")] - public Merchant merchant { get; set; } + /// + /// The public name of the merchant + /// + /// The name of the public. + public string publicName { get; set; } + + public string website { get; set; } /// - /// The different ways of contacting the merchant + /// The type of the merchant + ///1 - BV. + ///2 - LTD + ///3 - Foundation + ///4 - One man + ///5 - VOF + ///6 - CV + ///7 - Maatschap + ///8 - NV + ///9 - Union + ///10 - Coop /// - [JsonProperty("contactData")] - public Contact contactData { get; set; } + /// The type. + public string type { get; set; } + + public string typeName { get; set; } + [JsonRequired][Required] public string cocNumber { get; set; } + public string vatNumber { get; set; } + public string iban { get; set; } + public string bic { get; set; } + public string bankaccountHolder { get; set; } + public Address postalAddress { get; set; } + public Address visitAddress { get; set; } + public Tradename[] tradeNames { get; set; } + + public class Address + { + public string street { get; set; } + public string houseNumber { get; set; } + public string zipCode { get; set; } + public string city { get; set; } + public string countryCode { get; set; } + public string countryName { get; set; } + } - #region Models (SubClasses) - public class ResultInfo + public class Tradename { - public string result { get; set; } - public string errorId { get; set; } - public string errorMessage { get; set; } + public string id { get; set; } + public string name { get; set; } } - public class Merchant + public class Contract { - public string merchantId { get; set; } + public string packageType { get; set; } + public string invoiceAllowed { get; set; } + public string payoutInterval { get; set; } + public string createdDate { get; set; } + public string acceptedDate { get; set; } + public string deletedDate { get; set; } + } - /// - /// Name of the Merchant - /// - /// The name. - public string name { get; set; } + public class Service + { + public string serviceId { get; set; } + public string serviceName { get; set; } + } - /// - /// The public name of the merchant - /// - /// The name of the public. - public string publicName { get; set; } - - public string website { get; set; } - - /// - /// The type of the merchant - ///1 - BV. - ///2 - LTD - ///3 - Foundation - ///4 - One man - ///5 - VOF - ///6 - CV - ///7 - Maatschap - ///8 - NV - ///9 - Union - ///10 - Coop - /// - /// The type. - public string type { get; set; } - - public string typeName { get; set; } - [JsonRequired] [Required] public string cocNumber { get; set; } - public string vatNumber { get; set; } - public string iban { get; set; } - public string bic { get; set; } - public string bankaccountHolder { get; set; } - public Address postalAddress { get; set; } - public Address visitAddress { get; set; } - public Tradename[] tradeNames { get; set; } - - public class Address - { - public string street { get; set; } - public string houseNumber { get; set; } - public string zipCode { get; set; } - public string city { get; set; } - public string countryCode { get; set; } - public string countryName { get; set; } - } - - public class Tradename - { - public string id { get; set; } - public string name { get; set; } - } - - public class Contract - { - public string packageType { get; set; } - public string invoiceAllowed { get; set; } - public string payoutInterval { get; set; } - public string createdDate { get; set; } - public string acceptedDate { get; set; } - public string deletedDate { get; set; } - } - - public class Service - { - public string serviceId { get; set; } - public string serviceName { get; set; } - } - - public class Document - { - public string id { get; set; } - public string type_id { get; set; } - public string type_name { get; set; } - public string status_id { get; set; } - public string status_name { get; set; } - public string expires { get; set; } - } - - #endregion - - - public class Account - { - public string id { get; set; } - public string account_id { get; set; } - public string name { get; set; } - public string accepted { get; set; } - public string access { get; set; } - public string ubo { get; set; } - public string authorised_to_sign { get; set; } - public string signature_label { get; set; } - public Document[] documents { get; set; } - } + public class Document + { + public string id { get; set; } + public string type_id { get; set; } + public string type_name { get; set; } + public string status_id { get; set; } + public string status_name { get; set; } + public string expires { get; set; } } - /// - /// The type for the contact row. possible values: - /// - email - ///- email_support - ///- email_msnskype - ///- phone - ///- phone_off_hours - ///- phone_helpdesk - ///- url - /// - public class Contact + #endregion + + + public class Account { - public string type { get; set; } - public string value { get; set; } - public string description { get; set; } + public string id { get; set; } + public string account_id { get; set; } + public string name { get; set; } + public string accepted { get; set; } + public string access { get; set; } + public string ubo { get; set; } + public string authorised_to_sign { get; set; } + public string signature_label { get; set; } + public Document[] documents { get; set; } } + } + /// + /// The type for the contact row. possible values: + /// - email + ///- email_support + ///- email_msnskype + ///- phone + ///- phone_off_hours + ///- phone_helpdesk + ///- url + /// + public class Contact + { + public string type { get; set; } + public string value { get; set; } + public string description { get; set; } } -} \ No newline at end of file + +} diff --git a/PAYNLSDK/API/PaymentMethod/Get/Request.cs b/PAYNLSDK/API/PaymentMethod/Get/Request.cs index afbdbfd..2522142 100644 --- a/PAYNLSDK/API/PaymentMethod/Get/Request.cs +++ b/PAYNLSDK/API/PaymentMethod/Get/Request.cs @@ -1,55 +1,54 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.PaymentMethod.Get +namespace PayNLSdk.Api.PaymentMethod.Get; + +/// +/// The model to request a particular paymentMethod +/// +public class Request : RequestBase { /// - /// The model to request a particular paymentMethod + /// The paymentMethod to be used /// - public class Request : RequestBase - { - /// - /// The paymentMethod to be used - /// - [JsonProperty("paymentMethodId")] - public Enums.PaymentMethodId PaymentMethodId { get; set; } + [JsonProperty("paymentMethodId")] + public Enums.PaymentMethodId PaymentMethodId { get; set; } - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "PaymentMethod"; + /// + protected override string Controller => "PaymentMethod"; - /// - protected override string Method => "get"; + /// + protected override string Method => "get"; - /// - public override System.Collections.Specialized.NameValueCollection GetParameters() - { - var allParameters = new NameValueCollection(); + /// + public override System.Collections.Specialized.NameValueCollection GetParameters() + { + var allParameters = new NameValueCollection(); - ParameterValidator.IsNotNull(PaymentMethodId, "PaymentMethodId"); - allParameters.Add("paymentMethodId", PaymentMethodId.ToString()); + ParameterValidator.IsNotNull(PaymentMethodId, "PaymentMethodId"); + allParameters.Add("paymentMethodId", PaymentMethodId.ToString()); - return allParameters; - } + return allParameters; + } + + public Response Response => (Response)response; - public Response Response => (Response)response; - - protected override void PrepareAndSetResponse() + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - PAYNLSDK.Objects.PaymentMethod pm = JsonConvert.DeserializeObject(RawResponse); - Response r = new Response - { - PaymentMethod = pm - }; - response = r; + throw new PayNlException("rawResponse is empty!"); } + Objects.PaymentMethod pm = JsonConvert.DeserializeObject(RawResponse); + Response r = new Response + { + PaymentMethod = pm + }; + response = r; } } diff --git a/PAYNLSDK/API/PaymentMethod/Get/Response.cs b/PAYNLSDK/API/PaymentMethod/Get/Response.cs index 511cb20..d4d41ce 100644 --- a/PAYNLSDK/API/PaymentMethod/Get/Response.cs +++ b/PAYNLSDK/API/PaymentMethod/Get/Response.cs @@ -1,11 +1,7 @@ -using System; -using Newtonsoft.Json; +namespace PayNLSdk.Api.PaymentMethod.Get; -namespace PAYNLSDK.API.PaymentMethod.Get +public class Response : ResponseBase { - public class Response : ResponseBase - { - public PAYNLSDK.Objects.PaymentMethod PaymentMethod { get; set; } + public Objects.PaymentMethod PaymentMethod { get; set; } - } } diff --git a/PAYNLSDK/API/PaymentMethod/GetAll/Request.cs b/PAYNLSDK/API/PaymentMethod/GetAll/Request.cs index ecca231..c4a1ae7 100644 --- a/PAYNLSDK/API/PaymentMethod/GetAll/Request.cs +++ b/PAYNLSDK/API/PaymentMethod/GetAll/Request.cs @@ -1,46 +1,45 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.PaymentMethod.GetAll +namespace PayNLSdk.Api.PaymentMethod.GetAll; + +/// +/// This function returns an array containing all payment methods. +/// https://admin.pay.nl/docpanel/api/PaymentMethod/getAll/1 +/// +public class Request : RequestBase { - /// - /// This function returns an array containing all payment methods. - /// https://admin.pay.nl/docpanel/api/PaymentMethod/getAll/1 - /// - public class Request : RequestBase - { - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "PaymentMethod"; + /// + protected override string Controller => "PaymentMethod"; - /// - protected override string Method => "getAll"; + /// + protected override string Method => "getAll"; - /// - public override NameValueCollection GetParameters() - { - return new NameValueCollection(); - } + /// + public override NameValueCollection GetParameters() + { + return new NameValueCollection(); + } - public Response Response => (Response)response; + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - PAYNLSDK.Objects.PaymentMethod[] pm = JsonConvert.DeserializeObject(RawResponse); - Response r = new Response - { - PaymentMethods = pm - }; - response = r; + throw new PayNlException("rawResponse is empty!"); } + Objects.PaymentMethod[] pm = JsonConvert.DeserializeObject(RawResponse); + Response r = new Response + { + PaymentMethods = pm + }; + response = r; } } diff --git a/PAYNLSDK/API/PaymentMethod/GetAll/Response.cs b/PAYNLSDK/API/PaymentMethod/GetAll/Response.cs index 1851608..75ffe9c 100644 --- a/PAYNLSDK/API/PaymentMethod/GetAll/Response.cs +++ b/PAYNLSDK/API/PaymentMethod/GetAll/Response.cs @@ -1,14 +1,9 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Objects; +namespace PayNLSdk.Api.PaymentMethod.GetAll; -namespace PAYNLSDK.API.PaymentMethod.GetAll +public class Response : ResponseBase { - public class Response : ResponseBase - { - /// - /// - /// - public PAYNLSDK.Objects.PaymentMethod[] PaymentMethods { get; set; } - } + /// + /// + /// + public Objects.PaymentMethod[] PaymentMethods { get; set; } } diff --git a/PAYNLSDK/API/PaymentProfile/Get/Request.cs b/PAYNLSDK/API/PaymentProfile/Get/Request.cs index 0b079af..d4ade8a 100644 --- a/PAYNLSDK/API/PaymentProfile/Get/Request.cs +++ b/PAYNLSDK/API/PaymentProfile/Get/Request.cs @@ -1,51 +1,50 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.PaymentProfile.Get +namespace PayNLSdk.Api.PaymentProfile.Get; + +public class Request : RequestBase { - public class Request : RequestBase - { - - [JsonProperty("paymentProfileId")] - public int PaymentProfileId { get; set; } - /// - protected override int Version => 1; + [JsonProperty("paymentProfileId")] + public int PaymentProfileId { get; set; } - /// - protected override string Controller => "PaymentProfile"; + /// + protected override int Version => 1; - /// - protected override string Method => "get"; + /// + protected override string Controller => "PaymentProfile"; - /// - public override System.Collections.Specialized.NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); + /// + protected override string Method => "get"; - ParameterValidator.IsNotNull(PaymentProfileId, "PaymentProfileId"); - nvc.Add("paymentProfileId", PaymentProfileId.ToString()); + /// + public override System.Collections.Specialized.NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - return nvc; - } + ParameterValidator.IsNotNull(PaymentProfileId, "PaymentProfileId"); + nvc.Add("paymentProfileId", PaymentProfileId.ToString()); - public Response Response => (Response)response; + return nvc; + } + + public Response Response => (Response)response; - protected override void PrepareAndSetResponse() + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - PAYNLSDK.Objects.PaymentProfile pm = JsonConvert.DeserializeObject(RawResponse); - Response r = new Response - { - PaymentProfile = pm - }; - response = r; + throw new PayNlException("rawResponse is empty!"); } + Objects.PaymentProfile pm = JsonConvert.DeserializeObject(RawResponse); + Response r = new Response + { + PaymentProfile = pm + }; + response = r; } } diff --git a/PAYNLSDK/API/PaymentProfile/Get/Response.cs b/PAYNLSDK/API/PaymentProfile/Get/Response.cs index 091b397..4f3025e 100644 --- a/PAYNLSDK/API/PaymentProfile/Get/Response.cs +++ b/PAYNLSDK/API/PaymentProfile/Get/Response.cs @@ -1,11 +1,7 @@ -using System; -using Newtonsoft.Json; +namespace PayNLSdk.Api.PaymentProfile.Get; -namespace PAYNLSDK.API.PaymentProfile.Get +public class Response : ResponseBase { - public class Response : ResponseBase - { - public PAYNLSDK.Objects.PaymentProfile PaymentProfile { get; set; } + public Objects.PaymentProfile PaymentProfile { get; set; } - } } diff --git a/PAYNLSDK/API/PaymentProfile/GetAll/Request.cs b/PAYNLSDK/API/PaymentProfile/GetAll/Request.cs index 2cf412b..b52f02a 100644 --- a/PAYNLSDK/API/PaymentProfile/GetAll/Request.cs +++ b/PAYNLSDK/API/PaymentProfile/GetAll/Request.cs @@ -1,40 +1,39 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.PaymentProfile.GetAll +namespace PayNLSdk.Api.PaymentProfile.GetAll; + +public class Request : RequestBase { - public class Request : RequestBase - { - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "PaymentProfile"; + /// + protected override string Controller => "PaymentProfile"; - /// - protected override string Method => "getAll"; + /// + protected override string Method => "getAll"; - public override NameValueCollection GetParameters() - { - return new NameValueCollection(); - } + public override NameValueCollection GetParameters() + { + return new NameValueCollection(); + } - public Response Response => (Response)response; + public Response Response => (Response)response; - protected override void PrepareAndSetResponse() + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - PAYNLSDK.Objects.PaymentProfile[] pm = JsonConvert.DeserializeObject(RawResponse); - Response r = new Response - { - PaymentProfiles = pm - }; - response = r; + throw new PayNlException("rawResponse is empty!"); } + Objects.PaymentProfile[] pm = JsonConvert.DeserializeObject(RawResponse); + Response r = new Response + { + PaymentProfiles = pm + }; + response = r; } } diff --git a/PAYNLSDK/API/PaymentProfile/GetAll/Response.cs b/PAYNLSDK/API/PaymentProfile/GetAll/Response.cs index db6bf69..6b53c08 100644 --- a/PAYNLSDK/API/PaymentProfile/GetAll/Response.cs +++ b/PAYNLSDK/API/PaymentProfile/GetAll/Response.cs @@ -1,11 +1,6 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Objects; +namespace PayNLSdk.Api.PaymentProfile.GetAll; -namespace PAYNLSDK.API.PaymentProfile.GetAll +public class Response : ResponseBase { - public class Response : ResponseBase - { - public PAYNLSDK.Objects.PaymentProfile[] PaymentProfiles { get; set; } - } + public Objects.PaymentProfile[] PaymentProfiles { get; set; } } diff --git a/PAYNLSDK/API/PaymentProfile/GetAvailable/Request.cs b/PAYNLSDK/API/PaymentProfile/GetAvailable/Request.cs index 014423c..3f759c1 100644 --- a/PAYNLSDK/API/PaymentProfile/GetAvailable/Request.cs +++ b/PAYNLSDK/API/PaymentProfile/GetAvailable/Request.cs @@ -1,87 +1,85 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Utilities; +using Newtonsoft.Json; +using PayNLSdk.Converters; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -using PAYNLSDK.Converters; -using PAYNLSDK.Exceptions; -namespace PAYNLSDK.API.PaymentProfile.GetAvailable +namespace PayNLSdk.Api.PaymentProfile.GetAvailable; + +public class Request : RequestBase { - public class Request : RequestBase - { - /// - /// The ID of the category of the service the payment options are used for. - /// For a list of available categories, see - /// - [JsonProperty("categoryId")] - public int CategoryId { get; set; } - - /// - /// ID of the program for which the payment options are used. (Only available if the program option is enabled!) - /// - [JsonProperty("programId")] - public int? ProgramId { get; set; } - - /// - /// Optional ID of the payment method - /// - [JsonProperty("paymentMethodId")] - public int? PaymentMethodId { get; set; } - - /// - /// Indicator wether to show profiles that are initially not allowed on registration. - /// - [JsonProperty("showNotAllowedOnRegistration"), JsonConverter(typeof(BooleanConverter))] - public bool? ShowNotAllowedOnRegistration { get; set; } - - /// - protected override int Version => 1; - - /// - protected override string Controller => "PaymentProfile"; - - /// - protected override string Method => "getAvailable"; - - /// - public override NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); + /// + /// The ID of the category of the service the payment options are used for. + /// For a list of available categories, see + /// + [JsonProperty("categoryId")] + public int CategoryId { get; set; } + + /// + /// ID of the program for which the payment options are used. (Only available if the program option is enabled!) + /// + [JsonProperty("programId")] + public int? ProgramId { get; set; } + + /// + /// Optional ID of the payment method + /// + [JsonProperty("paymentMethodId")] + public int? PaymentMethodId { get; set; } + + /// + /// Indicator wether to show profiles that are initially not allowed on registration. + /// + [JsonProperty("showNotAllowedOnRegistration"), JsonConverter(typeof(BooleanConverter))] + public bool? ShowNotAllowedOnRegistration { get; set; } + + /// + protected override int Version => 1; + + /// + protected override string Controller => "PaymentProfile"; + + /// + protected override string Method => "getAvailable"; - ParameterValidator.IsNotNull(CategoryId, "CategoryId"); - nvc.Add("categoryId", CategoryId.ToString()); + /// + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - if (!ParameterValidator.IsNonEmptyInt(ProgramId)) - { - nvc.Add("programId", ProgramId.ToString()); - } + ParameterValidator.IsNotNull(CategoryId, "CategoryId"); + nvc.Add("categoryId", CategoryId.ToString()); - if (!ParameterValidator.IsNonEmptyInt(PaymentMethodId)) - { - nvc.Add("paymentMethodId", PaymentMethodId.ToString()); - } + if (!ParameterValidator.IsNonEmptyInt(ProgramId)) + { + nvc.Add("programId", ProgramId.ToString()); + } - if (!ParameterValidator.IsNull(ShowNotAllowedOnRegistration)) - { - nvc.Add("ShowNotAllowedOnRegistration", ((bool)ShowNotAllowedOnRegistration) ? "1" : "0"); - } + if (!ParameterValidator.IsNonEmptyInt(PaymentMethodId)) + { + nvc.Add("paymentMethodId", PaymentMethodId.ToString()); + } - return nvc; + if (!ParameterValidator.IsNull(ShowNotAllowedOnRegistration)) + { + nvc.Add("ShowNotAllowedOnRegistration", ((bool)ShowNotAllowedOnRegistration) ? "1" : "0"); } - public Response Response { get { return (Response)response; } } + return nvc; + } + + public Response Response { get { return (Response)response; } } - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - PAYNLSDK.Objects.PaymentProfile[] pm = JsonConvert.DeserializeObject(RawResponse); - Response r = new Response(); - r.PaymentProfiles = pm; - response = r; + throw new PayNlException("rawResponse is empty!"); } + Objects.PaymentProfile[] pm = JsonConvert.DeserializeObject(RawResponse); + Response r = new Response(); + r.PaymentProfiles = pm; + response = r; } } diff --git a/PAYNLSDK/API/PaymentProfile/GetAvailable/Response.cs b/PAYNLSDK/API/PaymentProfile/GetAvailable/Response.cs index 55948c7..918e641 100644 --- a/PAYNLSDK/API/PaymentProfile/GetAvailable/Response.cs +++ b/PAYNLSDK/API/PaymentProfile/GetAvailable/Response.cs @@ -1,13 +1,12 @@ -namespace PAYNLSDK.API.PaymentProfile.GetAvailable +namespace PayNLSdk.Api.PaymentProfile.GetAvailable; + +/// +/// Returns a list of available service categories. If a payment option is specified, only the categories linked to the payment option is returned +/// +public class Response : ResponseBase { /// - /// Returns a list of available service categories. If a payment option is specified, only the categories linked to the payment option is returned + /// /// - public class Response : ResponseBase - { - /// - /// - /// - public PAYNLSDK.Objects.PaymentProfile[] PaymentProfiles { get; set; } - } + public Objects.PaymentProfile[] PaymentProfiles { get; set; } } diff --git a/PAYNLSDK/API/Refund/Add/Request.cs b/PAYNLSDK/API/Refund/Add/Request.cs index 1767461..f882bc7 100644 --- a/PAYNLSDK/API/Refund/Add/Request.cs +++ b/PAYNLSDK/API/Refund/Add/Request.cs @@ -1,218 +1,217 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System; using System.Collections.Specialized; -namespace PAYNLSDK.API.Refund.Add +namespace PayNLSdk.Api.Refund.Add; + +/// +/// A refund, not based on a previous transaction, but to another IBAN. +/// If you are looking for a normal refund, use +/// +public class Request : RequestBase { /// - /// A refund, not based on a previous transaction, but to another IBAN. - /// If you are looking for a normal refund, use + /// A refund is the repayment of (part of) a transaction to the end user. + /// + /// + /// + /// + /// + public Request(decimal amount, string bankAccountHolder, string bankAccountNumber, string bankAccountBic) + { + AmountInCents = (int)Math.Floor(amount * 100); + BankAccountHolder = bankAccountHolder; + BankAccountNumber = bankAccountNumber; + BankAccountBic = bankAccountBic; + } + + /// + /// The amount to be paid should be given in cents. For example € 3.50 becomes 350. + /// + [JsonProperty("amount")] + public int AmountInCents { get; set; } + + /// + /// The name of the customer. + /// + public string BankAccountHolder { get; set; } + + /// + /// The bankaccount number of the customer. + /// + public string BankAccountNumber { get; set; } + + /// + /// The BIC of the bank. + /// + public string BankAccountBic { get; set; } + + /// + /// The description to include with the payment. + /// + public string Description { get; set; } + + /// + /// The id of a promotor / affiliate. + /// In general, you won't use this unless you know the ID's of your affiliate's + /// + public int? PromotorId { get; set; } + + /// + /// The used tool code. + /// + public string Tool { get; set; } + + /// + /// The used info code which can be tracked in the stats + /// + public string Info { get; set; } + + /// + /// The used object. + /// + public string Object { get; set; } + + /// + /// The first free value which can be tracked in the stats + /// + public string Extra1 { get; set; } + + /// + /// The second free value which can be tracked in the stats + /// + public string Extra2 { get; set; } + + /// + /// The third free value which can be tracked in the stats + /// + public string Extra3 { get; set; } + + /// + /// id from the payment + /// + public string OrderId { get; set; } + + /// + /// The currency of the amount, default is EUR. + /// + public string Currency { get; set; } + + /// + /// The currency of the amount, default is EUR. + /// + public DateTime? ProcessDate { get; set; } + + /// + protected override int Version => 7; + + /// + protected override string Controller => "Refund"; + + /// + protected override string Method => "add"; + + /// + /// + /// + public override bool RequiresApiToken => true; + /// + /// /// - public class Request : RequestBase + public override bool RequiresServiceId => true; + + /// + public override System.Collections.Specialized.NameValueCollection GetParameters() { - /// - /// A refund is the repayment of (part of) a transaction to the end user. - /// - /// - /// - /// - /// - public Request(decimal amount, string bankAccountHolder, string bankAccountNumber, string bankAccountBic) + NameValueCollection nvc = new NameValueCollection(); + + ParameterValidator.IsNotNull(AmountInCents, "Amount"); + nvc.Add("amount", AmountInCents.ToString()); + + ParameterValidator.IsNotNull(BankAccountHolder, "BankAccountHolder"); + nvc.Add("bankAccountHolder", BankAccountHolder); + + ParameterValidator.IsNotNull(BankAccountNumber, "BankAccountNumber"); + nvc.Add("bankAccountNumber", BankAccountNumber); + + ParameterValidator.IsNotNull(BankAccountBic, "BankAccountBic"); + nvc.Add("bankAccountBic", BankAccountBic); + + if (!ParameterValidator.IsEmpty(Description)) + { + nvc.Add("description", Description); + } + + if (!ParameterValidator.IsNonEmptyInt(PromotorId)) { - AmountInCents = (int)Math.Floor(amount * 100); - BankAccountHolder = bankAccountHolder; - BankAccountNumber = bankAccountNumber; - BankAccountBic = bankAccountBic; + nvc.Add("promotorId", PromotorId.Value.ToString()); } - /// - /// The amount to be paid should be given in cents. For example € 3.50 becomes 350. - /// - [JsonProperty("amount")] - public int AmountInCents { get; set; } - - /// - /// The name of the customer. - /// - public string BankAccountHolder { get; set; } - - /// - /// The bankaccount number of the customer. - /// - public string BankAccountNumber { get; set; } - - /// - /// The BIC of the bank. - /// - public string BankAccountBic { get; set; } - - /// - /// The description to include with the payment. - /// - public string Description { get; set; } - - /// - /// The id of a promotor / affiliate. - /// In general, you won't use this unless you know the ID's of your affiliate's - /// - public int? PromotorId { get; set; } - - /// - /// The used tool code. - /// - public string Tool { get; set; } - - /// - /// The used info code which can be tracked in the stats - /// - public string Info { get; set; } - - /// - /// The used object. - /// - public string Object { get; set; } - - /// - /// The first free value which can be tracked in the stats - /// - public string Extra1 { get; set; } - - /// - /// The second free value which can be tracked in the stats - /// - public string Extra2 { get; set; } - - /// - /// The third free value which can be tracked in the stats - /// - public string Extra3 { get; set; } - - /// - /// id from the payment - /// - public string OrderId { get; set; } - - /// - /// The currency of the amount, default is EUR. - /// - public string Currency { get; set; } - - /// - /// The currency of the amount, default is EUR. - /// - public DateTime? ProcessDate { get; set; } - - /// - protected override int Version => 7; - - /// - protected override string Controller => "Refund"; - - /// - protected override string Method => "add"; - - /// - /// - /// - public override bool RequiresApiToken => true; - /// - /// - /// - public override bool RequiresServiceId => true; - - /// - public override System.Collections.Specialized.NameValueCollection GetParameters() + if (!ParameterValidator.IsEmpty(Tool)) { - NameValueCollection nvc = new NameValueCollection(); - - ParameterValidator.IsNotNull(AmountInCents, "Amount"); - nvc.Add("amount", AmountInCents.ToString()); - - ParameterValidator.IsNotNull(BankAccountHolder, "BankAccountHolder"); - nvc.Add("bankAccountHolder", BankAccountHolder); - - ParameterValidator.IsNotNull(BankAccountNumber, "BankAccountNumber"); - nvc.Add("bankAccountNumber", BankAccountNumber); - - ParameterValidator.IsNotNull(BankAccountBic, "BankAccountBic"); - nvc.Add("bankAccountBic", BankAccountBic); - - if (!ParameterValidator.IsEmpty(Description)) - { - nvc.Add("description", Description); - } - - if (!ParameterValidator.IsNonEmptyInt(PromotorId)) - { - nvc.Add("promotorId", PromotorId.Value.ToString()); - } - - if (!ParameterValidator.IsEmpty(Tool)) - { - nvc.Add("tool", Tool); - } - - if (!ParameterValidator.IsEmpty(Info)) - { - nvc.Add("info", Info); - } - - if (!ParameterValidator.IsEmpty(Object)) - { - nvc.Add("object", Object); - } - - if (!ParameterValidator.IsEmpty(Extra1)) - { - nvc.Add("extra1", Extra1); - } - if (!ParameterValidator.IsEmpty(Extra2)) - { - nvc.Add("extra2", Extra2); - } - if (!ParameterValidator.IsEmpty(Extra3)) - { - nvc.Add("extra3", Extra3); - } - - if (!ParameterValidator.IsEmpty(Currency)) - { - nvc.Add("currency", Currency); - } - - if (!ParameterValidator.IsEmpty(OrderId)) - { - nvc.Add("orderId", OrderId); - } - - if (ProcessDate.HasValue) - { - nvc.Add("processDate", ProcessDate.Value.ToString("yyyy-MM-dd")); - } - - return nvc; + nvc.Add("tool", Tool); } - /// - protected override void PrepareAndSetResponse() + if (!ParameterValidator.IsEmpty(Info)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); - if (!Response.Request.Result) - { - // toss - throw new PayNlException(Response.Request.Message); - } + nvc.Add("info", Info); } - /// - /// - /// - public Response Response => (Response)response; + if (!ParameterValidator.IsEmpty(Object)) + { + nvc.Add("object", Object); + } + + if (!ParameterValidator.IsEmpty(Extra1)) + { + nvc.Add("extra1", Extra1); + } + if (!ParameterValidator.IsEmpty(Extra2)) + { + nvc.Add("extra2", Extra2); + } + if (!ParameterValidator.IsEmpty(Extra3)) + { + nvc.Add("extra3", Extra3); + } + + if (!ParameterValidator.IsEmpty(Currency)) + { + nvc.Add("currency", Currency); + } + + if (!ParameterValidator.IsEmpty(OrderId)) + { + nvc.Add("orderId", OrderId); + } + + if (ProcessDate.HasValue) + { + nvc.Add("processDate", ProcessDate.Value.ToString("yyyy-MM-dd")); + } + + return nvc; } -} + + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) + { + throw new PayNlException("rawResponse is empty!"); + } + response = JsonConvert.DeserializeObject(RawResponse); + if (!Response.Request.Result) + { + // toss + throw new PayNlException(Response.Request.Message); + } + } + + /// + /// + /// + public Response Response => (Response)response; +} \ No newline at end of file diff --git a/PAYNLSDK/API/Refund/Add/Response.cs b/PAYNLSDK/API/Refund/Add/Response.cs index b043cf6..83859cc 100644 --- a/PAYNLSDK/API/Refund/Add/Response.cs +++ b/PAYNLSDK/API/Refund/Add/Response.cs @@ -1,14 +1,12 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace PAYNLSDK.API.Refund.Add +namespace PayNLSdk.Api.Refund.Add; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - /// - /// ID of the refund starting with 'RF-' (optional, emptyfor creditcard transactions) - /// - [JsonProperty("refundId")] - public string RefundId { get; set; } - } + /// + /// ID of the refund starting with 'RF-' (optional, emptyfor creditcard transactions) + /// + [JsonProperty("refundId")] + public string RefundId { get; set; } } diff --git a/PAYNLSDK/API/Refund/Info/Request.cs b/PAYNLSDK/API/Refund/Info/Request.cs index 3c2ee69..bff6c6f 100644 --- a/PAYNLSDK/API/Refund/Info/Request.cs +++ b/PAYNLSDK/API/Refund/Info/Request.cs @@ -1,76 +1,75 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Refund.Info +namespace PayNLSdk.Api.Refund.Info; + +/// +/// +/// +public class Request : RequestBase { /// - /// + /// create new instance /// - public class Request : RequestBase + /// Refund ID + public Request(string refundId) { - /// - /// create new instance - /// - /// Refund ID - public Request(string refundId) - { - RefundId = refundId; - } + RefundId = refundId; + } - /// - /// The refund ID. - /// - public string RefundId { get; set; } + /// + /// The refund ID. + /// + public string RefundId { get; set; } - /// - protected override int Version => 3; + /// + protected override int Version => 3; - /// - protected override string Controller => "Refund"; + /// + protected override string Controller => "Refund"; - /// - protected override string Method => "info"; + /// + protected override string Method => "info"; - /// - public override bool RequiresApiToken => true; + /// + public override bool RequiresApiToken => true; - /// - /// - /// - public override bool RequiresServiceId => true; + /// + /// + /// + public override bool RequiresServiceId => true; - /// - public override System.Collections.Specialized.NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); + /// + public override System.Collections.Specialized.NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - ParameterValidator.IsNotNull(RefundId, "RefundId"); - nvc.Add("refundId", RefundId); + ParameterValidator.IsNotNull(RefundId, "RefundId"); + nvc.Add("refundId", RefundId); - return nvc; - } + return nvc; + } - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); - if (!Response.Request.Result) - { - // toss - throw new PayNlException(Response.Request.Message); - } + throw new PayNlException("rawResponse is empty!"); + } + response = JsonConvert.DeserializeObject(RawResponse); + if (!Response.Request.Result) + { + // toss + throw new PayNlException(Response.Request.Message); } - - /// - /// - /// - public Response Response => (Response)response; } + + /// + /// + /// + public Response Response => (Response)response; } diff --git a/PAYNLSDK/API/Refund/Info/Response.cs b/PAYNLSDK/API/Refund/Info/Response.cs index fe59e80..cdf47f1 100644 --- a/PAYNLSDK/API/Refund/Info/Response.cs +++ b/PAYNLSDK/API/Refund/Info/Response.cs @@ -1,15 +1,13 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Objects; +using Newtonsoft.Json; +using PayNLSdk.Objects; -namespace PAYNLSDK.API.Refund.Info +namespace PayNLSdk.Api.Refund.Info; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - /// - /// Refund information - /// - [JsonProperty("refund")] - public RefundInfo Refund { get; protected set; } - } + /// + /// Refund information + /// + [JsonProperty("refund")] + public RefundInfo Refund { get; protected set; } } diff --git a/PAYNLSDK/API/Refund/Transaction/Request.cs b/PAYNLSDK/API/Refund/Transaction/Request.cs index 985f4cd..2ce3bdb 100644 --- a/PAYNLSDK/API/Refund/Transaction/Request.cs +++ b/PAYNLSDK/API/Refund/Transaction/Request.cs @@ -1,181 +1,180 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Converters; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System; using System.Collections.Generic; using System.Collections.Specialized; -namespace PAYNLSDK.API.Refund.Transaction +namespace PayNLSdk.Api.Refund.Transaction; + +/// +/// A product specific refund for Products like Sofort & Afterpay +/// For normal refunds, you should use +/// +public class Request : RequestBase { /// - /// A product specific refund for Products like Sofort & Afterpay - /// For normal refunds, you should use /// - public class Request : RequestBase + /// The order ID or EX code of the transaction + public Request(string transactionId) + { + TransactionId = transactionId; + Products = new Dictionary(); + } + + /// + /// The order ID or EX code of the transaction. + /// + [JsonProperty("transactionId")] + public string TransactionId { get; set; } + + /// + /// The amount to be paid should be given in cents. For example € 3.50 becomes 350. + /// + [JsonProperty("amount")] + public int? Amount { get; set; } + + /// + /// The description to include with the payment. + /// + [JsonProperty("description")] + public string Description { get; set; } + + /// + /// The description to include with the payment. + /// + [JsonProperty("processDate"), JsonConverter(typeof(DMYConverter))] + public DateTime? ProcessDate { get; set; } + + /// + /// Custom exchange URL overriding the defaultexchange URL. + /// + [JsonProperty("exchangeUrl")] + public string ExchangeUrl { get; set; } + + /// + /// Product items that are refunded (key: product ID, value: quantity). + /// + [JsonProperty("products")] + public Dictionary Products { get; set; } + + /// + /// Add a product reference (key + amount) + /// + /// The order ID or EX code of the transaction + /// Product quantity + public void AddProduct(string productId, int amount) { - /// - /// - /// The order ID or EX code of the transaction - public Request(string transactionId) + if (Products.ContainsKey(productId)) { - TransactionId = transactionId; - Products = new Dictionary(); + Products[productId] += amount; } - - /// - /// The order ID or EX code of the transaction. - /// - [JsonProperty("transactionId")] - public string TransactionId { get; set; } - - /// - /// The amount to be paid should be given in cents. For example € 3.50 becomes 350. - /// - [JsonProperty("amount")] - public int? Amount { get; set; } - - /// - /// The description to include with the payment. - /// - [JsonProperty("description")] - public string Description { get; set; } - - /// - /// The description to include with the payment. - /// - [JsonProperty("processDate"), JsonConverter(typeof(DMYConverter))] - public DateTime? ProcessDate { get; set; } - - /// - /// Custom exchange URL overriding the defaultexchange URL. - /// - [JsonProperty("exchangeUrl")] - public string ExchangeUrl { get; set; } - - /// - /// Product items that are refunded (key: product ID, value: quantity). - /// - [JsonProperty("products")] - public Dictionary Products { get; set; } - - /// - /// Add a product reference (key + amount) - /// - /// The order ID or EX code of the transaction - /// Product quantity - public void AddProduct(string productId, int amount) + else { - if (Products.ContainsKey(productId)) - { - Products[productId] += amount; - } - else - { - Products[productId] = amount; - } + Products[productId] = amount; } + } - /// - protected override int Version => 2; + /// + protected override int Version => 2; - /// + /// - protected override string Controller => "Refund"; + protected override string Controller => "Refund"; - /// - protected override string Method => "transaction"; + /// + protected override string Method => "transaction"; - //public override string Querystring - //{ - // get { return ""; } - //} + //public override string Querystring + //{ + // get { return ""; } + //} - /// - public override bool RequiresApiToken => true; + /// + public override bool RequiresApiToken => true; - /// - public override bool RequiresServiceId => true; + /// + public override bool RequiresServiceId => true; - /// - public override System.Collections.Specialized.NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); - - ParameterValidator.IsNotNull(TransactionId, "TransactionId"); - nvc.Add("transactionId", TransactionId.ToString()); + /// + public override System.Collections.Specialized.NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - if (ParameterValidator.IsNonEmptyInt(Amount)) - { - nvc.Add("amount", Amount.Value.ToString()); - } + ParameterValidator.IsNotNull(TransactionId, "TransactionId"); + nvc.Add("transactionId", TransactionId.ToString()); - if (!ParameterValidator.IsEmpty(Description)) - { - nvc.Add("description", Description); - } + if (ParameterValidator.IsNonEmptyInt(Amount)) + { + nvc.Add("amount", Amount.Value.ToString()); + } - if (ProcessDate.HasValue) - { - nvc.Add("processDate", ProcessDate.Value.ToString("yyyy-MM-dd")); - } + if (!ParameterValidator.IsEmpty(Description)) + { + nvc.Add("description", Description); + } - if (Products.Count > 0) - { - nvc.Add("products", JsonConvert.SerializeObject(Products)); - } + if (ProcessDate.HasValue) + { + nvc.Add("processDate", ProcessDate.Value.ToString("yyyy-MM-dd")); + } - if (!ParameterValidator.IsEmpty(ExchangeUrl)) - { - nvc.Add("exchangeUrl", ExchangeUrl); - } + if (Products.Count > 0) + { + nvc.Add("products", JsonConvert.SerializeObject(Products)); + } - return nvc; + if (!ParameterValidator.IsEmpty(ExchangeUrl)) + { + nvc.Add("exchangeUrl", ExchangeUrl); } - protected override void PrepareAndSetResponse() + return nvc; + } + + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); - if (!Response.Request.Result) - { - // toss - throw new PayNlException(Response.Request.Message); - } + throw new PayNlException("rawResponse is empty!"); + } + response = JsonConvert.DeserializeObject(RawResponse); + if (!Response.Request.Result) + { + // toss + throw new PayNlException(Response.Request.Message); } + } - /// - /// - /// - public Response Response => (Response)response; + /// + /// + /// + public Response Response => (Response)response; - private static Dictionary NvcToDictionary(NameValueCollection nvc, bool handleMultipleValuesPerKey) + private static Dictionary NvcToDictionary(NameValueCollection nvc, bool handleMultipleValuesPerKey) + { + var result = new Dictionary(); + foreach (string key in nvc.Keys) { - var result = new Dictionary(); - foreach (string key in nvc.Keys) + if (handleMultipleValuesPerKey) { - if (handleMultipleValuesPerKey) + string[] values = nvc.GetValues(key); + if (values.Length == 1) { - string[] values = nvc.GetValues(key); - if (values.Length == 1) - { - result.Add(key, values[0]); - } - else - { - result.Add(key, values); - } + result.Add(key, values[0]); } else { - result.Add(key, nvc[key]); + result.Add(key, values); } } - - return result; + else + { + result.Add(key, nvc[key]); + } } + + return result; } -} +} \ No newline at end of file diff --git a/PAYNLSDK/API/Refund/Transaction/Response.cs b/PAYNLSDK/API/Refund/Transaction/Response.cs index 75ca98b..89fc26a 100644 --- a/PAYNLSDK/API/Refund/Transaction/Response.cs +++ b/PAYNLSDK/API/Refund/Transaction/Response.cs @@ -1,14 +1,12 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace PAYNLSDK.API.Refund.Transaction +namespace PayNLSdk.Api.Refund.Transaction; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - /// - /// ID of the refund starting with 'RF-' (optional, emptyfor creditcard transactions) - /// - [JsonProperty("refundId")] - public string RefundId { get; set; } - } + /// + /// ID of the refund starting with 'RF-' (optional, emptyfor creditcard transactions) + /// + [JsonProperty("refundId")] + public string RefundId { get; set; } } diff --git a/PAYNLSDK/API/RequestBase.cs b/PAYNLSDK/API/RequestBase.cs index bf5a1b0..a8df013 100644 --- a/PAYNLSDK/API/RequestBase.cs +++ b/PAYNLSDK/API/RequestBase.cs @@ -1,96 +1,91 @@ using Newtonsoft.Json; -using PAYNLSDK.Utilities; -using System; using System.Collections.Specialized; -using System.Text; -namespace PAYNLSDK.API +namespace PayNLSdk.Api; + +/// +/// The base class to perform a request to the Pay.NL api +/// +public abstract class RequestBase { /// - /// The base class to perform a request to the Pay.NL api + /// Indicator stating whether or not a API Token is required for a specific request /// - public abstract class RequestBase - { - /// - /// Indicator stating whether or not a API Token is required for a specific request - /// - public virtual bool RequiresApiToken { get { return true; } } + public virtual bool RequiresApiToken { get { return true; } } - /// - /// Indicator stating whether or not a Service ID is required for a specific request - /// - public virtual bool RequiresServiceId { get { return false; } } - - /// - /// Return as JSON - /// - /// JSON string - public override string ToString() - { - //return base.ToString(); - return JsonConvert.SerializeObject(this, Formatting.Indented); - } + /// + /// Indicator stating whether or not a Service ID is required for a specific request + /// + public virtual bool RequiresServiceId { get { return false; } } - /// - /// URL used to perform this specific request - /// - public string Url => $"v{Version}/{Controller}/{Method}/json"; + /// + /// Return as JSON + /// + /// JSON string + public override string ToString() + { + //return base.ToString(); + return JsonConvert.SerializeObject(this, Formatting.Indented); + } - /// - /// Api Version for this request - /// - protected abstract int Version { get; } + /// + /// URL used to perform this specific request + /// + public string Url => $"v{Version}/{Controller}/{Method}/json"; - /// - /// Controller used for this request - /// - protected abstract string Controller { get; } + /// + /// Api Version for this request + /// + protected abstract int Version { get; } - /// - /// Controller method for this request - /// - protected abstract string Method { get; } + /// + /// Controller used for this request + /// + protected abstract string Controller { get; } - ///// - ///// Extra querystring parameters used for this request - ///// - //public abstract string Querystring { get; } + /// + /// Controller method for this request + /// + protected abstract string Method { get; } + + ///// + ///// Extra querystring parameters used for this request + ///// + //public abstract string Querystring { get; } - /// - /// Get all properties as a nameValueCollection - /// - public abstract NameValueCollection GetParameters(); + /// + /// Get all properties as a nameValueCollection + /// + public abstract NameValueCollection GetParameters(); - /// - /// Response belonging to this request - /// - protected ResponseBase response; + /// + /// Response belonging to this request + /// + protected ResponseBase response; - /// - /// The raw response stroing - /// - protected string rawResponse; + /// + /// The raw response stroing + /// + protected string rawResponse; - /// - /// Raw response data - /// - public string RawResponse + /// + /// Raw response data + /// + public string RawResponse + { + get { - get - { - return rawResponse; - } - set - { - rawResponse = value; - PrepareAndSetResponse(); - } + return rawResponse; + } + set + { + rawResponse = value; + PrepareAndSetResponse(); } - - /// - /// Load the raw response and perform any actions along with it. - /// - protected abstract void PrepareAndSetResponse(); } -} + /// + /// Load the raw response and perform any actions along with it. + /// + protected abstract void PrepareAndSetResponse(); +} \ No newline at end of file diff --git a/PAYNLSDK/API/ResponseBase.cs b/PAYNLSDK/API/ResponseBase.cs index f250ae9..4d541f3 100644 --- a/PAYNLSDK/API/ResponseBase.cs +++ b/PAYNLSDK/API/ResponseBase.cs @@ -1,27 +1,26 @@ using Newtonsoft.Json; -using PAYNLSDK.Objects; +using PayNLSdk.Objects; -namespace PAYNLSDK.API +namespace PayNLSdk.Api; + +/// +/// A abstract base class for every response from the API +/// +public abstract class ResponseBase { /// - /// A abstract base class for every response from the API + /// The Error if the request led to a failed response /// - public abstract class ResponseBase - { - /// - /// The Error if the request led to a failed response - /// - [JsonProperty("request")] - public Error Request { get; protected set; } + [JsonProperty("request")] + public Error Request { get; protected set; } - /// - /// Return response as formatted JSON - /// - /// JSON string - public override string ToString() - { - //return base.ToString(); - return JsonConvert.SerializeObject(this, Formatting.Indented); - } + /// + /// Return response as formatted JSON + /// + /// JSON string + public override string ToString() + { + //return base.ToString(); + return JsonConvert.SerializeObject(this, Formatting.Indented); } } diff --git a/PAYNLSDK/API/SMS/BulkMessage/Request.cs b/PAYNLSDK/API/SMS/BulkMessage/Request.cs index fb7d8c4..c238d18 100644 --- a/PAYNLSDK/API/SMS/BulkMessage/Request.cs +++ b/PAYNLSDK/API/SMS/BulkMessage/Request.cs @@ -1,59 +1,58 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.SMS.BulkMessage +namespace PayNLSdk.Api.SMS.BulkMessage; + +public class Request : RequestBase { - public class Request : RequestBase - { - [JsonProperty("org")] - public string Sender { get; set; } + [JsonProperty("org")] + public string Sender { get; set; } - [JsonProperty("dest")] - public string Recipient { get; set; } + [JsonProperty("dest")] + public string Recipient { get; set; } - [JsonProperty("body")] - public string Message { get; set; } + [JsonProperty("body")] + public string Message { get; set; } - //[JsonProperty("starttime")] - //public int SendTime { get; set; } + //[JsonProperty("starttime")] + //public int SendTime { get; set; } - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "SMS"; + /// + protected override string Controller => "SMS"; - /// - protected override string Method => "sendBulkMessage"; + /// + protected override string Method => "sendBulkMessage"; - /// - public override NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); + /// + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(Sender, "Sender"); - nvc.Add("org", Sender); + ParameterValidator.IsNotEmpty(Sender, "Sender"); + nvc.Add("org", Sender); - ParameterValidator.IsNotEmpty(Recipient, "Recipient"); - nvc.Add("dest", Recipient); + ParameterValidator.IsNotEmpty(Recipient, "Recipient"); + nvc.Add("dest", Recipient); - ParameterValidator.IsNotEmpty(Message, "Message"); - nvc.Add("body", Message); + ParameterValidator.IsNotEmpty(Message, "Message"); + nvc.Add("body", Message); - return nvc; - } - public Response Response => (Response)response; + return nvc; + } + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/SMS/BulkMessage/Response.cs b/PAYNLSDK/API/SMS/BulkMessage/Response.cs index f2304e8..96c3e39 100644 --- a/PAYNLSDK/API/SMS/BulkMessage/Response.cs +++ b/PAYNLSDK/API/SMS/BulkMessage/Response.cs @@ -1,16 +1,10 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using PayNLSdk.Converters; -namespace PAYNLSDK.API.SMS.BulkMessage +namespace PayNLSdk.Api.SMS.BulkMessage; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - [JsonProperty("result"),JsonConverter(typeof(BooleanConverter))] - public bool result { get; protected set; } - } + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + public bool result { get; protected set; } } diff --git a/PAYNLSDK/API/SMS/PremiumMessage/Request.cs b/PAYNLSDK/API/SMS/PremiumMessage/Request.cs index 39f79f6..30919d5 100644 --- a/PAYNLSDK/API/SMS/PremiumMessage/Request.cs +++ b/PAYNLSDK/API/SMS/PremiumMessage/Request.cs @@ -1,56 +1,55 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.SMS.PremiumMessage +namespace PayNLSdk.Api.SMS.PremiumMessage; + +public class Request : RequestBase { - public class Request : RequestBase - { - [JsonProperty("sms_id")] - public string SmsId { get; set; } + [JsonProperty("sms_id")] + public string SmsId { get; set; } - [JsonProperty("secret")] - public string Secret { get; set; } + [JsonProperty("secret")] + public string Secret { get; set; } - [JsonProperty("message")] - public string Message { get; set; } + [JsonProperty("message")] + public string Message { get; set; } - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "SMS"; + /// + protected override string Controller => "SMS"; - /// - protected override string Method => "sendPremiumMessage"; + /// + protected override string Method => "sendPremiumMessage"; - public override NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(SmsId, "SmsId"); - nvc.Add("sms_id", SmsId); + ParameterValidator.IsNotEmpty(SmsId, "SmsId"); + nvc.Add("sms_id", SmsId); - ParameterValidator.IsNotEmpty(Secret, "secret"); - nvc.Add("secret", Secret); + ParameterValidator.IsNotEmpty(Secret, "secret"); + nvc.Add("secret", Secret); - ParameterValidator.IsNotEmpty(Message, "message"); - nvc.Add("message", Message); + ParameterValidator.IsNotEmpty(Message, "message"); + nvc.Add("message", Message); - return nvc; - } - public Response Response => (Response)response; + return nvc; + } + public Response Response => (Response)response; - protected override void PrepareAndSetResponse() + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } - + response = JsonConvert.DeserializeObject(RawResponse); } + } diff --git a/PAYNLSDK/API/SMS/PremiumMessage/Response.cs b/PAYNLSDK/API/SMS/PremiumMessage/Response.cs index c354f8d..5967a29 100644 --- a/PAYNLSDK/API/SMS/PremiumMessage/Response.cs +++ b/PAYNLSDK/API/SMS/PremiumMessage/Response.cs @@ -1,12 +1,10 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using System; +using PayNLSdk.Converters; -namespace PAYNLSDK.API.SMS.PremiumMessage +namespace PayNLSdk.Api.SMS.PremiumMessage; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] - public bool result { get; protected set; } - } + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + public bool result { get; protected set; } } diff --git a/PAYNLSDK/API/Service/GetCategories/Request.cs b/PAYNLSDK/API/Service/GetCategories/Request.cs index 20885bc..72e755e 100644 --- a/PAYNLSDK/API/Service/GetCategories/Request.cs +++ b/PAYNLSDK/API/Service/GetCategories/Request.cs @@ -1,57 +1,57 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Objects; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Service.GetCategories +namespace PayNLSdk.Api.Service.GetCategories; + +/// +/// Returns a list of available service categories. +/// If a payment option is specified, only the categories linked to the payment option is returned +/// +public class Request : RequestBase { /// - /// Returns a list of available service categories. - /// If a payment option is specified, only the categories linked to the payment option is returned + /// The optional ID of the payment profile /// - public class Request : RequestBase - { - /// - /// The optional ID of the payment profile - /// - [JsonProperty("paymentOptionId")] - public int? PaymentOptionId { get; set; } + [JsonProperty("paymentOptionId")] + public int? PaymentOptionId { get; set; } - /// - protected override int Version => 3; + /// + protected override int Version => 3; - /// - protected override string Controller => "Service"; + /// + protected override string Controller => "Service"; - /// - protected override string Method => "getCategories"; + /// + protected override string Method => "getCategories"; - /// - public override NameValueCollection GetParameters() + /// + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); + if (!ParameterValidator.IsNonEmptyInt(PaymentOptionId)) { - NameValueCollection nvc = new NameValueCollection(); - if (!ParameterValidator.IsNonEmptyInt(PaymentOptionId)) - { - nvc.Add("paymentOptionId", PaymentOptionId.ToString()); - } - return nvc; + nvc.Add("paymentOptionId", PaymentOptionId.ToString()); } + return nvc; + } - public Response Response => (Response)response; + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - PAYNLSDK.Objects.ServiceCategory[] pm = JsonConvert.DeserializeObject(RawResponse); - Response r = new Response - { - ServiceCategories = pm - }; - response = r; + throw new PayNlException("rawResponse is empty!"); } + ServiceCategory[] pm = JsonConvert.DeserializeObject(RawResponse); + Response r = new Response + { + ServiceCategories = pm + }; + response = r; } -} +} \ No newline at end of file diff --git a/PAYNLSDK/API/Service/GetCategories/Response.cs b/PAYNLSDK/API/Service/GetCategories/Response.cs index cde74a7..ece8b76 100644 --- a/PAYNLSDK/API/Service/GetCategories/Response.cs +++ b/PAYNLSDK/API/Service/GetCategories/Response.cs @@ -1,11 +1,8 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Objects; +using PayNLSdk.Objects; -namespace PAYNLSDK.API.Service.GetCategories +namespace PayNLSdk.Api.Service.GetCategories; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - public PAYNLSDK.Objects.ServiceCategory[] ServiceCategories { get; set; } - } + public ServiceCategory[] ServiceCategories { get; set; } } diff --git a/PAYNLSDK/API/Statistics/GetManagement/GetStatsMultiLevel.cs b/PAYNLSDK/API/Statistics/GetManagement/GetStatsMultiLevel.cs index 0628d1e..107650a 100644 --- a/PAYNLSDK/API/Statistics/GetManagement/GetStatsMultiLevel.cs +++ b/PAYNLSDK/API/Statistics/GetManagement/GetStatsMultiLevel.cs @@ -1,25 +1,20 @@ using Newtonsoft.Json; -namespace PayNLSdk.API.Statistics.GetManagement -{ - /// - /// If 2 groupBy parameters are added to the request, - /// we have a Top-level and a sublevel of data - /// - public class GetStatsMultiLevel : GetStatsResultBase - { - [JsonProperty("arrStatsData")] - public TopLevelStatsData[] TopLevelGroup { get; set; } - } - - public class TopLevelStatsData - { - public string Id { get; set; } - public string Label { get; set; } - public GetStatsResultBase.StatsData[] Data { get; set; } - } - - +namespace PayNLSdk.Api.Statistics.GetManagement; +/// +/// If 2 groupBy parameters are added to the request, +/// we have a Top-level and a sublevel of data +/// +public class GetStatsMultiLevel : GetStatsResultBase +{ + [JsonProperty("arrStatsData")] + public TopLevelStatsData[] TopLevelGroup { get; set; } +} +public class TopLevelStatsData +{ + public string Id { get; set; } + public string Label { get; set; } + public GetStatsResultBase.StatsData[] Data { get; set; } } diff --git a/PAYNLSDK/API/Statistics/GetManagement/GetStatsResult.cs b/PAYNLSDK/API/Statistics/GetManagement/GetStatsResult.cs index 6041e6d..c08d5d3 100644 --- a/PAYNLSDK/API/Statistics/GetManagement/GetStatsResult.cs +++ b/PAYNLSDK/API/Statistics/GetManagement/GetStatsResult.cs @@ -1,18 +1,15 @@ -using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; +using Newtonsoft.Json; +using System.Diagnostics.CodeAnalysis; -namespace PayNLSdk.API.Statistics.GetManagement -{ +namespace PayNLSdk.Api.Statistics.GetManagement; - /// - /// The result of the Statistics/Management call - /// With a maximum of one group - /// - [SuppressMessage("ReSharper", "InconsistentNaming")] - public class GetStatsResult : GetStatsResultBase - { - [JsonProperty("arrStatsData")] - public StatsData[] ArrStatsData { get; set; } - } +/// +/// The result of the Statistics/Management call +/// With a maximum of one group +/// +[SuppressMessage("ReSharper", "InconsistentNaming")] +public class GetStatsResult : GetStatsResultBase +{ + [JsonProperty("arrStatsData")] + public StatsData[] ArrStatsData { get; set; } } - diff --git a/PAYNLSDK/API/Statistics/GetManagement/GetStatsResultBase.cs b/PAYNLSDK/API/Statistics/GetManagement/GetStatsResultBase.cs index d863340..e66ca14 100644 --- a/PAYNLSDK/API/Statistics/GetManagement/GetStatsResultBase.cs +++ b/PAYNLSDK/API/Statistics/GetManagement/GetStatsResultBase.cs @@ -3,627 +3,626 @@ using System; using System.Globalization; -namespace PayNLSdk.API.Statistics.GetManagement +namespace PayNLSdk.Api.Statistics.GetManagement; + +/// +/// Class GetStatsResultBase. +/// +public abstract class GetStatsResultBase { /// - /// Class GetStatsResultBase. + /// Gets or sets the login. + /// + /// The login. + [JsonProperty("login")] + public string Login { get; set; } + + /// + /// Gets or sets the arr label list. /// - public abstract class GetStatsResultBase + /// The arr label list. + [JsonProperty("arrLabelList")] + public LabelList ArrLabelList { get; set; } + + /// + /// Gets or sets the total. + /// + /// The total. + [JsonProperty("totals")] + public Totals Total { get; set; } + + /// + /// Gets or sets the total rows. + /// + /// The total rows. + [JsonProperty("totalRows")] + public int TotalRows { get; set; } + + /// + /// Gets or sets the page. + /// + /// The page. + [JsonProperty("page")] + public int Page { get; set; } + + /// + /// Gets or sets the page data. + /// + /// The page data. + [JsonProperty("pageData")] + public Pagedata PageData { get; set; } + + /// + /// Gets or sets the currency symbol. + /// + /// The currency symbol. + [JsonProperty("currency_symbol")] + public string CurrencySymbol { get; set; } + + /// + /// Class LabelList. + /// + public class LabelList { /// - /// Gets or sets the login. + /// Gets or sets the 4. /// - /// The login. - [JsonProperty("login")] - public string Login { get; set; } + /// The 4. + [JsonProperty("4")] + public _4 _4 { get; set; } + } + /// + /// Class _4. + /// + public class _4 + { /// - /// Gets or sets the arr label list. + /// Gets or sets the name. /// - /// The arr label list. - [JsonProperty("arrLabelList")] - public LabelList ArrLabelList { get; set; } + /// The name. + [JsonProperty("name")] + public string name { get; set; } /// - /// Gets or sets the total. + /// Gets or sets the cols. /// - /// The total. - [JsonProperty("totals")] - public Totals Total { get; set; } + /// The cols. + [JsonProperty("cols")] + public ColumnLabels ColumnLabels { get; set; } + } + /// + /// Class Cols. + /// + public class ColumnLabels + { /// - /// Gets or sets the total rows. + /// Gets or sets the number. /// - /// The total rows. - [JsonProperty("totalRows")] - public int TotalRows { get; set; } + /// The number. + [JsonProperty("num")] + public string num { get; set; } /// - /// Gets or sets the page. + /// Gets or sets the average pay. /// - /// The page. - [JsonProperty("page")] - public int Page { get; set; } + /// The average pay. + [JsonProperty("avg_pay")] + public string avg_pay { get; set; } /// - /// Gets or sets the page data. + /// Gets or sets the org. /// - /// The page data. - [JsonProperty("pageData")] - public Pagedata PageData { get; set; } + /// The org. + [JsonProperty("org")] + public string org { get; set; } /// - /// Gets or sets the currency symbol. + /// Gets or sets the org vat. /// - /// The currency symbol. - [JsonProperty("currency_symbol")] - public string CurrencySymbol { get; set; } + /// The org vat. + [JsonProperty("org_vat")] + public string org_vat { get; set; } /// - /// Class LabelList. + /// Gets or sets the org ext. /// - public class LabelList - { - /// - /// Gets or sets the 4. - /// - /// The 4. - [JsonProperty("4")] - public _4 _4 { get; set; } - } + /// The org ext. + [JsonProperty("org_ext")] + public string org_ext { get; set; } /// - /// Class _4. + /// Gets or sets the org tot. /// - public class _4 - { - /// - /// Gets or sets the name. - /// - /// The name. - [JsonProperty("name")] - public string name { get; set; } - - /// - /// Gets or sets the cols. - /// - /// The cols. - [JsonProperty("cols")] - public ColumnLabels ColumnLabels { get; set; } - } + /// The org tot. + [JsonProperty("org_tot")] + public string org_tot { get; set; } /// - /// Class Cols. + /// Gets or sets the CST. /// - public class ColumnLabels - { - /// - /// Gets or sets the number. - /// - /// The number. - [JsonProperty("num")] - public string num { get; set; } - - /// - /// Gets or sets the average pay. - /// - /// The average pay. - [JsonProperty("avg_pay")] - public string avg_pay { get; set; } - - /// - /// Gets or sets the org. - /// - /// The org. - [JsonProperty("org")] - public string org { get; set; } - - /// - /// Gets or sets the org vat. - /// - /// The org vat. - [JsonProperty("org_vat")] - public string org_vat { get; set; } - - /// - /// Gets or sets the org ext. - /// - /// The org ext. - [JsonProperty("org_ext")] - public string org_ext { get; set; } - - /// - /// Gets or sets the org tot. - /// - /// The org tot. - [JsonProperty("org_tot")] - public string org_tot { get; set; } - - /// - /// Gets or sets the CST. - /// - /// The CST. - [JsonProperty("cst")] - public string cst { get; set; } - - /// - /// Gets or sets the pay. - /// - /// The pay. - [JsonProperty("pay")] - public string pay { get; set; } - } + /// The CST. + [JsonProperty("cst")] + public string cst { get; set; } /// - /// Class ColumnValues. + /// Gets or sets the pay. /// - public class ColumnValues - { - /// - /// Gets or sets the number. - /// - /// The number. - [JsonProperty("num")] - public string num { get; set; } - - /// - /// Gets or sets the average pay. - /// - /// The average pay. - [JsonProperty("avg_pay")] - public string avg_pay { get; set; } - - /// - /// Gets or sets the org. - /// - /// The org. - [JsonProperty("org")] - public string org { get; set; } - - /// - /// Gets or sets the org vat. - /// - /// The org vat. - [JsonProperty("org_vat")] - public string org_vat { get; set; } - - /// - /// Gets or sets the org ext. - /// - /// The org ext. - [JsonProperty("org_ext")] - public string org_ext { get; set; } - - /// - /// Gets or sets the org tot. - /// - /// The org tot. - [JsonProperty("org_tot")] - public string org_tot { get; set; } - - /// - /// Gets or sets the CST. - /// - /// The CST. - [JsonProperty("cst")] - public string cst { get; set; } - - /// - /// Gets or sets the pay. - /// - /// The pay. - [JsonProperty("pay")] - public string pay { get; set; } - } + /// The pay. + [JsonProperty("pay")] + public string pay { get; set; } + } + /// + /// Class ColumnValues. + /// + public class ColumnValues + { /// - /// Class Totals. + /// Gets or sets the number. /// - public class Totals - { - /// - /// Gets or sets the sub data - which is oddly called "4" - /// - /// The 4. - [JsonProperty("4")] public Data _4 { get; set; } - } + /// The number. + [JsonProperty("num")] + public string num { get; set; } /// - /// Class Pagedata. + /// Gets or sets the average pay. /// - public class Pagedata - { - /// - /// Gets or sets the colors. - /// - /// The colors. - [JsonProperty("pay")] public Colors colors { get; set; } - } + /// The average pay. + [JsonProperty("avg_pay")] + public string avg_pay { get; set; } /// - /// Class Colors. + /// Gets or sets the org. /// - public class Colors - { - /// - /// Gets or sets the color 1. - /// - /// The color 1. - [JsonProperty("COLOR_1")] public string COLOR_1 { get; set; } - /// - /// Gets or sets the color 2. - /// - /// The color 2. - [JsonProperty("COLOR_2")] public string COLOR_2 { get; set; } - /// - /// Gets or sets the color 3. - /// - /// The color 3. - [JsonProperty("COLOR_3")] public string COLOR_3 { get; set; } - /// - /// Gets or sets the color 4. - /// - /// The color 4. - [JsonProperty("COLOR_4")] public string COLOR_4 { get; set; } - /// - /// Gets or sets the color 5. - /// - /// The color 5. - [JsonProperty("COLOR_5")] public string COLOR_5 { get; set; } - /// - /// Gets or sets the color 6. - /// - /// The color 6. - [JsonProperty("COLOR_6")] public string COLOR_6 { get; set; } - /// - /// Gets or sets the color 7. - /// - /// The color 7. - [JsonProperty("COLOR_7")] public string COLOR_7 { get; set; } - /// - /// Gets or sets the color 8. - /// - /// The color 8. - [JsonProperty("COLOR_8")] public string COLOR_8 { get; set; } - /// - /// Gets or sets the color 9. - /// - /// The color 9. - [JsonProperty("COLOR_9")] public string COLOR_9 { get; set; } - /// - /// Gets or sets the color 10. - /// - /// The color 10. - [JsonProperty("COLOR_10")] public string COLOR_10 { get; set; } - /// - /// Gets or sets the color 11. - /// - /// The color 11. - [JsonProperty("COLOR_11")] public string COLOR_11 { get; set; } - /// - /// Gets or sets the color 12. - /// - /// The color 12. - [JsonProperty("COLOR_12")] public string COLOR_12 { get; set; } - /// - /// Gets or sets the color 13. - /// - /// The color 13. - [JsonProperty("COLOR_13")] public string COLOR_13 { get; set; } - /// - /// Gets or sets the color 14. - /// - /// The color 14. - [JsonProperty("COLOR_14")] public string COLOR_14 { get; set; } - /// - /// Gets or sets the color 15. - /// - /// The color 15. - [JsonProperty("COLOR_15")] public string COLOR_15 { get; set; } - /// - /// Gets or sets the color 16. - /// - /// The color 16. - [JsonProperty("COLOR_16")] public string COLOR_16 { get; set; } - /// - /// Gets or sets the color 17. - /// - /// The color 17. - [JsonProperty("COLOR_17")] public string COLOR_17 { get; set; } - /// - /// Gets or sets the color 18. - /// - /// The color 18. - [JsonProperty("COLOR_18")] public string COLOR_18 { get; set; } - /// - /// Gets or sets the color 19. - /// - /// The color 19. - [JsonProperty("COLOR_19")] public string COLOR_19 { get; set; } - /// - /// Gets or sets the color 20. - /// - /// The color 20. - [JsonProperty("COLOR_20")] public string COLOR_20 { get; set; } - /// - /// Gets or sets the color 21. - /// - /// The color 21. - [JsonProperty("COLOR_21")] public string COLOR_21 { get; set; } - /// - /// Gets or sets the color 22. - /// - /// The color 22. - [JsonProperty("COLOR_22")] public string COLOR_22 { get; set; } - /// - /// Gets or sets the color 23. - /// - /// The color 23. - [JsonProperty("COLOR_23")] public string COLOR_23 { get; set; } - /// - /// Gets or sets the color 24. - /// - /// The color 24. - [JsonProperty("COLOR_24")] public string COLOR_24 { get; set; } - /// - /// Gets or sets the color 25. - /// - /// The color 25. - [JsonProperty("COLOR_25")] public string COLOR_25 { get; set; } - /// - /// Gets or sets the color 26. - /// - /// The color 26. - [JsonProperty("COLOR_26")] public string COLOR_26 { get; set; } - /// - /// Gets or sets the color 27. - /// - /// The color 27. - [JsonProperty("COLOR_27")] public string COLOR_27 { get; set; } - /// - /// Gets or sets the color 28. - /// - /// The color 28. - [JsonProperty("COLOR_28")] public string COLOR_28 { get; set; } - /// - /// Gets or sets the color 29. - /// - /// The color 29. - [JsonProperty("COLOR_29")] public string COLOR_29 { get; set; } - /// - /// Gets or sets the color 30. - /// - /// The color 30. - [JsonProperty("COLOR_30")] public string COLOR_30 { get; set; } - /// - /// Gets or sets the color 31. - /// - /// The color 31. - [JsonProperty("COLOR_31")] public string COLOR_31 { get; set; } - /// - /// Gets or sets the color 32. - /// - /// The color 32. - [JsonProperty("COLOR_32")] public string COLOR_32 { get; set; } - /// - /// Gets or sets the color 33. - /// - /// The color 33. - [JsonProperty("COLOR_33")] public string COLOR_33 { get; set; } - /// - /// Gets or sets the color 34. - /// - /// The color 34. - [JsonProperty("COLOR_34")] public string COLOR_34 { get; set; } - /// - /// Gets or sets the color 35. - /// - /// The color 35. - [JsonProperty("COLOR_35")] public string COLOR_35 { get; set; } - /// - /// Gets or sets the color 36. - /// - /// The color 36. - [JsonProperty("COLOR_36")] public string COLOR_36 { get; set; } - } + /// The org. + [JsonProperty("org")] + public string org { get; set; } /// - /// Class StatsData. + /// Gets or sets the org vat. /// - public class StatsData - { - /// - /// Gets or sets the identifier. - /// - /// The identifier. - [JsonProperty("Id")] - public string Id { get; set; } - - /// - /// Gets or sets the grouped by. - /// - /// The grouped by. - [JsonProperty("Label")] - public string GroupedBy { get; set; } - - /// - /// Gets or sets the data. - /// - /// The data. - [JsonProperty("Data")] - public StatsLine[] Data { get; set; } - } + /// The org vat. + [JsonProperty("org_vat")] + public string org_vat { get; set; } /// - /// Class StatsLine. + /// Gets or sets the org ext. /// - public class StatsLine - { - /// - /// Gets or sets the identifier. - /// - /// The identifier. - public string Id { get; set; } - - /// - /// Gets or sets the type. - /// - /// The type. - [JsonProperty("Label")] - public string Type { get; set; } - - /// - /// Gets or sets the data. - /// - /// The data. - public Data Data { get; set; } - } + /// The org ext. + [JsonProperty("org_ext")] + public string org_ext { get; set; } /// - /// Class Data. + /// Gets or sets the org tot. /// - public class Data - { - /// - /// Gets or sets the sum. - /// - /// The sum. - [JsonProperty("sum")] - public decimal sum { get; set; } - - /// - /// Gets or sets the costs - /// - /// The CST. - [JsonProperty("cst")] - public decimal cst { get; set; } - - /// - /// Gets or sets the number of transactions - /// - /// The number. - [JsonProperty("num")] - public decimal num { get; set; } - - /// - /// Gets or sets the average duration. Probably the average duration of seconds in a transaction. - /// - /// The average dur. - [JsonProperty("avg_dur")] - public decimal avg_dur { get; set; } - - /// - /// Gets or sets the average payout amount - /// - /// The average pay. - [JsonProperty("avg_pay")] - public decimal avg_pay { get; set; } - - /// - /// Gets or sets the paid costs. - /// - /// The pay. - [JsonProperty("pay")] - public decimal pay { get; set; } - - /// - /// Gets or sets the organization total. Same as org_tot - /// - /// The org. - [JsonProperty("org")] - public string org { get; set; } - - /// - /// Gets or sets the org vat. - /// - /// The org vat. - [JsonProperty("org_vat")] - public string org_vat { get; set; } - - /// - /// Gets or sets the org ext. - /// - /// The org ext. - [JsonProperty("org_ext")] - public string org_ext { get; set; } - - /// - /// Gets or sets the org tot. - /// - /// The org tot. - [JsonProperty("org_tot")] - public decimal org_tot { get; set; } - } + /// The org tot. + [JsonProperty("org_tot")] + public string org_tot { get; set; } + + /// + /// Gets or sets the CST. + /// + /// The CST. + [JsonProperty("cst")] + public string cst { get; set; } + + /// + /// Gets or sets the pay. + /// + /// The pay. + [JsonProperty("pay")] + public string pay { get; set; } } /// - /// Class DecimalConverter. + /// Class Totals. /// - /// https://stackoverflow.com/q/24051206/97615 - /// - internal class DecimalConverter : JsonConverter + public class Totals { /// - /// Determines whether this instance can convert the specified object type. + /// Gets or sets the sub data - which is oddly called "4" /// - /// Type of the object. - /// true if this instance can convert the specified object type; otherwise, false. - public override bool CanConvert(Type objectType) - { - return objectType == typeof(decimal) || objectType == typeof(decimal?); - } + /// The 4. + [JsonProperty("4")] public Data _4 { get; set; } + } + /// + /// Class Pagedata. + /// + public class Pagedata + { /// - /// Reads the JSON representation of the object. + /// Gets or sets the colors. /// - /// The to read from. - /// Type of the object. - /// The existing value of object being read. - /// The calling serializer. - /// The object value. - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) - { - var token = JToken.Load(reader); - switch (token.Type) - { - case JTokenType.Float: - case JTokenType.Integer: - return token.ToObject(); - case JTokenType.String when decimal.TryParse( - token.ToString(), - NumberStyles.Any, - CultureInfo.InvariantCulture, - out var d): - return d; - case JTokenType.String: - case JTokenType.Null when objectType == typeof(decimal?): - return null; - default: - throw new JsonSerializationException($"Unexpected token type: {token.Type}"); - } - } + /// The colors. + [JsonProperty("pay")] public Colors colors { get; set; } + } + /// + /// Class Colors. + /// + public class Colors + { + /// + /// Gets or sets the color 1. + /// + /// The color 1. + [JsonProperty("COLOR_1")] public string COLOR_1 { get; set; } + /// + /// Gets or sets the color 2. + /// + /// The color 2. + [JsonProperty("COLOR_2")] public string COLOR_2 { get; set; } + /// + /// Gets or sets the color 3. + /// + /// The color 3. + [JsonProperty("COLOR_3")] public string COLOR_3 { get; set; } + /// + /// Gets or sets the color 4. + /// + /// The color 4. + [JsonProperty("COLOR_4")] public string COLOR_4 { get; set; } + /// + /// Gets or sets the color 5. + /// + /// The color 5. + [JsonProperty("COLOR_5")] public string COLOR_5 { get; set; } + /// + /// Gets or sets the color 6. + /// + /// The color 6. + [JsonProperty("COLOR_6")] public string COLOR_6 { get; set; } + /// + /// Gets or sets the color 7. + /// + /// The color 7. + [JsonProperty("COLOR_7")] public string COLOR_7 { get; set; } + /// + /// Gets or sets the color 8. + /// + /// The color 8. + [JsonProperty("COLOR_8")] public string COLOR_8 { get; set; } + /// + /// Gets or sets the color 9. + /// + /// The color 9. + [JsonProperty("COLOR_9")] public string COLOR_9 { get; set; } + /// + /// Gets or sets the color 10. + /// + /// The color 10. + [JsonProperty("COLOR_10")] public string COLOR_10 { get; set; } + /// + /// Gets or sets the color 11. + /// + /// The color 11. + [JsonProperty("COLOR_11")] public string COLOR_11 { get; set; } + /// + /// Gets or sets the color 12. + /// + /// The color 12. + [JsonProperty("COLOR_12")] public string COLOR_12 { get; set; } + /// + /// Gets or sets the color 13. + /// + /// The color 13. + [JsonProperty("COLOR_13")] public string COLOR_13 { get; set; } + /// + /// Gets or sets the color 14. + /// + /// The color 14. + [JsonProperty("COLOR_14")] public string COLOR_14 { get; set; } + /// + /// Gets or sets the color 15. + /// + /// The color 15. + [JsonProperty("COLOR_15")] public string COLOR_15 { get; set; } + /// + /// Gets or sets the color 16. + /// + /// The color 16. + [JsonProperty("COLOR_16")] public string COLOR_16 { get; set; } /// - /// Writes the JSON representation of the object. + /// Gets or sets the color 17. /// - /// The to write to. - /// The value. - /// The calling serializer. - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + /// The color 17. + [JsonProperty("COLOR_17")] public string COLOR_17 { get; set; } + /// + /// Gets or sets the color 18. + /// + /// The color 18. + [JsonProperty("COLOR_18")] public string COLOR_18 { get; set; } + /// + /// Gets or sets the color 19. + /// + /// The color 19. + [JsonProperty("COLOR_19")] public string COLOR_19 { get; set; } + /// + /// Gets or sets the color 20. + /// + /// The color 20. + [JsonProperty("COLOR_20")] public string COLOR_20 { get; set; } + /// + /// Gets or sets the color 21. + /// + /// The color 21. + [JsonProperty("COLOR_21")] public string COLOR_21 { get; set; } + /// + /// Gets or sets the color 22. + /// + /// The color 22. + [JsonProperty("COLOR_22")] public string COLOR_22 { get; set; } + /// + /// Gets or sets the color 23. + /// + /// The color 23. + [JsonProperty("COLOR_23")] public string COLOR_23 { get; set; } + /// + /// Gets or sets the color 24. + /// + /// The color 24. + [JsonProperty("COLOR_24")] public string COLOR_24 { get; set; } + /// + /// Gets or sets the color 25. + /// + /// The color 25. + [JsonProperty("COLOR_25")] public string COLOR_25 { get; set; } + /// + /// Gets or sets the color 26. + /// + /// The color 26. + [JsonProperty("COLOR_26")] public string COLOR_26 { get; set; } + /// + /// Gets or sets the color 27. + /// + /// The color 27. + [JsonProperty("COLOR_27")] public string COLOR_27 { get; set; } + /// + /// Gets or sets the color 28. + /// + /// The color 28. + [JsonProperty("COLOR_28")] public string COLOR_28 { get; set; } + /// + /// Gets or sets the color 29. + /// + /// The color 29. + [JsonProperty("COLOR_29")] public string COLOR_29 { get; set; } + /// + /// Gets or sets the color 30. + /// + /// The color 30. + [JsonProperty("COLOR_30")] public string COLOR_30 { get; set; } + /// + /// Gets or sets the color 31. + /// + /// The color 31. + [JsonProperty("COLOR_31")] public string COLOR_31 { get; set; } + /// + /// Gets or sets the color 32. + /// + /// The color 32. + [JsonProperty("COLOR_32")] public string COLOR_32 { get; set; } + /// + /// Gets or sets the color 33. + /// + /// The color 33. + [JsonProperty("COLOR_33")] public string COLOR_33 { get; set; } + /// + /// Gets or sets the color 34. + /// + /// The color 34. + [JsonProperty("COLOR_34")] public string COLOR_34 { get; set; } + /// + /// Gets or sets the color 35. + /// + /// The color 35. + [JsonProperty("COLOR_35")] public string COLOR_35 { get; set; } + /// + /// Gets or sets the color 36. + /// + /// The color 36. + [JsonProperty("COLOR_36")] public string COLOR_36 { get; set; } + } + + /// + /// Class StatsData. + /// + public class StatsData + { + /// + /// Gets or sets the identifier. + /// + /// The identifier. + [JsonProperty("Id")] + public string Id { get; set; } + + /// + /// Gets or sets the grouped by. + /// + /// The grouped by. + [JsonProperty("Label")] + public string GroupedBy { get; set; } + + /// + /// Gets or sets the data. + /// + /// The data. + [JsonProperty("Data")] + public StatsLine[] Data { get; set; } + } + + /// + /// Class StatsLine. + /// + public class StatsLine + { + /// + /// Gets or sets the identifier. + /// + /// The identifier. + public string Id { get; set; } + + /// + /// Gets or sets the type. + /// + /// The type. + [JsonProperty("Label")] + public string Type { get; set; } + + /// + /// Gets or sets the data. + /// + /// The data. + public Data Data { get; set; } + } + + /// + /// Class Data. + /// + public class Data + { + /// + /// Gets or sets the sum. + /// + /// The sum. + [JsonProperty("sum")] + public decimal sum { get; set; } + + /// + /// Gets or sets the costs + /// + /// The CST. + [JsonProperty("cst")] + public decimal cst { get; set; } + + /// + /// Gets or sets the number of transactions + /// + /// The number. + [JsonProperty("num")] + public decimal num { get; set; } + + /// + /// Gets or sets the average duration. Probably the average duration of seconds in a transaction. + /// + /// The average dur. + [JsonProperty("avg_dur")] + public decimal avg_dur { get; set; } + + /// + /// Gets or sets the average payout amount + /// + /// The average pay. + [JsonProperty("avg_pay")] + public decimal avg_pay { get; set; } + + /// + /// Gets or sets the paid costs. + /// + /// The pay. + [JsonProperty("pay")] + public decimal pay { get; set; } + + /// + /// Gets or sets the organization total. Same as org_tot + /// + /// The org. + [JsonProperty("org")] + public string org { get; set; } + + /// + /// Gets or sets the org vat. + /// + /// The org vat. + [JsonProperty("org_vat")] + public string org_vat { get; set; } + + /// + /// Gets or sets the org ext. + /// + /// The org ext. + [JsonProperty("org_ext")] + public string org_ext { get; set; } + + /// + /// Gets or sets the org tot. + /// + /// The org tot. + [JsonProperty("org_tot")] + public decimal org_tot { get; set; } + } +} + +/// +/// Class DecimalConverter. +/// +/// https://stackoverflow.com/q/24051206/97615 +/// +internal class DecimalConverter : JsonConverter +{ + /// + /// Determines whether this instance can convert the specified object type. + /// + /// Type of the object. + /// true if this instance can convert the specified object type; otherwise, false. + public override bool CanConvert(Type objectType) + { + return objectType == typeof(decimal) || objectType == typeof(decimal?); + } + + /// + /// Reads the JSON representation of the object. + /// + /// The to read from. + /// Type of the object. + /// The existing value of object being read. + /// The calling serializer. + /// The object value. + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, + JsonSerializer serializer) + { + var token = JToken.Load(reader); + switch (token.Type) + { + case JTokenType.Float: + case JTokenType.Integer: + return token.ToObject(); + case JTokenType.String when decimal.TryParse( + token.ToString(), + NumberStyles.Any, + CultureInfo.InvariantCulture, + out var d): + return d; + case JTokenType.String: + case JTokenType.Null when objectType == typeof(decimal?): + return null; + default: + throw new JsonSerializationException($"Unexpected token type: {token.Type}"); + } + } + + /// + /// Writes the JSON representation of the object. + /// + /// The to write to. + /// The value. + /// The calling serializer. + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + var d = default(decimal?); + if (value != null) { - var d = default(decimal?); - if (value != null) + d = value as decimal?; + if (d.HasValue) // If value was a decimal?, then this is possible { - d = value as decimal?; - if (d.HasValue) // If value was a decimal?, then this is possible - { - d = new decimal( - decimal.ToDouble(d.Value)); // The ToDouble-conversion removes all unnecessary precision - } + d = new decimal( + decimal.ToDouble(d.Value)); // The ToDouble-conversion removes all unnecessary precision } - - JToken.FromObject(d).WriteTo(writer); } + + JToken.FromObject(d).WriteTo(writer); } } diff --git a/PAYNLSDK/API/Statistics/GetManagement/Request.cs b/PAYNLSDK/API/Statistics/GetManagement/Request.cs index 0c568c8..f02750e 100644 --- a/PAYNLSDK/API/Statistics/GetManagement/Request.cs +++ b/PAYNLSDK/API/Statistics/GetManagement/Request.cs @@ -1,274 +1,272 @@ -using PayNLSdk.ExtentionMethods; -using PAYNLSDK.API; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.ExtentionMethods; +using PayNLSdk.Utilities; using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics.CodeAnalysis; -namespace PayNLSdk.API.Statistics.GetManagement +namespace PayNLSdk.Api.Statistics.GetManagement; + +/// +/// The parameters to be requested when requesting the management statistics +/// +public class Request : RequestBase { /// - /// The parameters to be requested when requesting the management statistics + /// A predefined period to request statistics /// - public class Request : RequestBase + public enum StatsPeriod { /// - /// A predefined period to request statistics + /// Last week /// - public enum StatsPeriod - { - /// - /// Last week - /// - LastWeek, - /// - /// Current week - /// - ThisWeek, - /// - /// Last month - /// - LastMonth, - /// - /// Current month - /// - ThisMonth - } - + LastWeek, /// - /// Creates a new instance of a stats request + /// Current week /// - /// a current time implementation - /// The period for the request - public static Request Create(IDateTime dateTime, StatsPeriod period) - { - var retval = new Request(); - - switch (period) - { - case StatsPeriod.LastWeek: - retval.StartDate = dateTime.Now.LastWeek(DayOfWeek.Monday); - retval.EndDate = retval.StartDate.AddDays(6); - break; - case StatsPeriod.ThisWeek: - retval.StartDate = dateTime.Now.ThisWeek(DayOfWeek.Monday); - retval.EndDate = retval.StartDate.AddDays(6); - break; - case StatsPeriod.LastMonth: - retval.StartDate = dateTime.Now.LastMonthFirstDay(); - retval.EndDate = dateTime.Now.LastMonthLastDay(); - break; - case StatsPeriod.ThisMonth: - retval.StartDate = new DateTime(dateTime.Now.Year, dateTime.Now.Month, 1); - retval.EndDate = dateTime.Now; - break; - default: - throw new ArgumentOutOfRangeException(nameof(period), period, null); - } - - return retval; - } - + ThisWeek, /// - /// Creates a new instance of a stats request + /// Last month /// - public Request() + LastMonth, + /// + /// Current month + /// + ThisMonth + } + + /// + /// Creates a new instance of a stats request + /// + /// a current time implementation + /// The period for the request + public static Request Create(IDateTime dateTime, StatsPeriod period) + { + var retval = new Request(); + + switch (period) { - ExcludeSandbox = true; - Filters = new List(); - GroupByFieldNames = new HashSet(); + case StatsPeriod.LastWeek: + retval.StartDate = dateTime.Now.LastWeek(DayOfWeek.Monday); + retval.EndDate = retval.StartDate.AddDays(6); + break; + case StatsPeriod.ThisWeek: + retval.StartDate = dateTime.Now.ThisWeek(DayOfWeek.Monday); + retval.EndDate = retval.StartDate.AddDays(6); + break; + case StatsPeriod.LastMonth: + retval.StartDate = dateTime.Now.LastMonthFirstDay(); + retval.EndDate = dateTime.Now.LastMonthLastDay(); + break; + case StatsPeriod.ThisMonth: + retval.StartDate = new DateTime(dateTime.Now.Year, dateTime.Now.Month, 1); + retval.EndDate = dateTime.Now; + break; + default: + throw new ArgumentOutOfRangeException(nameof(period), period, null); } - /// - protected override int Version => 5; - /// - protected override string Controller => "Statistics"; - /// - protected override string Method => "management"; + return retval; + } - /// - /// the first date to be included in the report - /// - public DateTime StartDate { get; set; } + /// + /// Creates a new instance of a stats request + /// + public Request() + { + ExcludeSandbox = true; + Filters = new List(); + GroupByFieldNames = new HashSet(); + } - /// - /// The last date to be included in the Report - /// - public DateTime EndDate { get; set; } + /// + protected override int Version => 5; + /// + protected override string Controller => "Statistics"; + /// + protected override string Method => "management"; - /// - /// Use this parameter to indicate whether to take your volume discount into account - /// (note that this is an estimate based on your transactions this month. Default=false). - /// - public bool Staffels { get; set; } + /// + /// the first date to be included in the report + /// + public DateTime StartDate { get; set; } - /// - /// The currency in which the data is returned (default=1 : EUR) - /// - public int? CurrencyId { get; set; } + /// + /// The last date to be included in the Report + /// + public DateTime EndDate { get; set; } - /// - /// This property can be used to filter events - /// - public List Filters { get; set; } + /// + /// Use this parameter to indicate whether to take your volume discount into account + /// (note that this is an estimate based on your transactions this month. Default=false). + /// + public bool Staffels { get; set; } - /// - /// Use this field to sort the results - /// - internal HashSet GroupByFieldNames { get; set; } + /// + /// The currency in which the data is returned (default=1 : EUR) + /// + public int? CurrencyId { get; set; } - /// - /// Exclude calls from the sandbox. Default = true - /// - public bool ExcludeSandbox { get; set; } + /// + /// This property can be used to filter events + /// + public List Filters { get; set; } - /// - /// Show turnover for: Own merchant, submerchants or all - /// - public CompanySelectEnum CompanySelect { get; set; } + /// + /// Use this field to sort the results + /// + internal HashSet GroupByFieldNames { get; set; } - /// - public override NameValueCollection GetParameters() - { - var retval = new NameValueCollection - { - { "startDate", StartDate.ToString("yyyy-MM-dd")}, - { "endDate", EndDate.ToString("yyyy-MM-dd")}, - { "staffels", Staffels.ToString()}, - { "CurrencyId", CurrencyId?.ToString()}, - { "company_select", CompanySelect.ToString().ToLower()} - }; - - retval.Add(GenerateFiltersNameValueCollection()); - retval.Add(GenerateGroupByClause()); - return retval; - } + /// + /// Exclude calls from the sandbox. Default = true + /// + public bool ExcludeSandbox { get; set; } + + /// + /// Show turnover for: Own merchant, submerchants or all + /// + public CompanySelectEnum CompanySelect { get; set; } - private NameValueCollection GenerateGroupByClause() + /// + public override NameValueCollection GetParameters() + { + var retval = new NameValueCollection { - var groupByNvc = new NameValueCollection(); + { "startDate", StartDate.ToString("yyyy-MM-dd")}, + { "endDate", EndDate.ToString("yyyy-MM-dd")}, + { "staffels", Staffels.ToString()}, + { "CurrencyId", CurrencyId?.ToString()}, + { "company_select", CompanySelect.ToString().ToLower()} + }; + + retval.Add(GenerateFiltersNameValueCollection()); + retval.Add(GenerateGroupByClause()); + return retval; + } - var i = 0; - foreach (var sortByFieldName in GroupByFieldNames) - { - groupByNvc.Add($"groupBy[{i}]", sortByFieldName); - i++; - } + private NameValueCollection GenerateGroupByClause() + { + var groupByNvc = new NameValueCollection(); - return groupByNvc; + var i = 0; + foreach (var sortByFieldName in GroupByFieldNames) + { + groupByNvc.Add($"groupBy[{i}]", sortByFieldName); + i++; } - private NameValueCollection GenerateFiltersNameValueCollection() + return groupByNvc; + } + + private NameValueCollection GenerateFiltersNameValueCollection() + { + var filterNvc = new NameValueCollection(); + + var i = 0; + + if (ExcludeSandbox) { - var filterNvc = new NameValueCollection(); - - var i = 0; - - if (ExcludeSandbox) - { - // from the PHP source - // https://github.com/paynl/sdk-alliance/blob/master/src/Statistics.php#L36 - // $api->addFilter('payment_profile_id', 613, 'neq'); - - filterNvc.Add($"filterType[{i}]", "payment_profile_id"); - filterNvc.Add($"filterOperator[{i}]", "neq"); - filterNvc.Add($"filterValue[{i}]", 613.ToString()); - i++; - } - - if (Filters == null) - { - return filterNvc; - } - - foreach (var filterItem in Filters) - { - filterNvc.Add($"filterType[{i}]", filterItem.Key); - filterNvc.Add($"filterOperator[{i}]", filterItem.Operator?.ToString() ?? ValidOperators.Eq.ToString().ToLowerInvariant()); - filterNvc.Add($"filterValue[{i}]", filterItem.Value); - i++; - } + // from the PHP source + // https://github.com/paynl/sdk-alliance/blob/master/src/Statistics.php#L36 + // $api->addFilter('payment_profile_id', 613, 'neq'); + + filterNvc.Add($"filterType[{i}]", "payment_profile_id"); + filterNvc.Add($"filterOperator[{i}]", "neq"); + filterNvc.Add($"filterValue[{i}]", 613.ToString()); + i++; + } + if (Filters == null) + { return filterNvc; } - - /// - protected override void PrepareAndSetResponse() + foreach (var filterItem in Filters) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } + filterNvc.Add($"filterType[{i}]", filterItem.Key); + filterNvc.Add($"filterOperator[{i}]", filterItem.Operator?.ToString() ?? ValidOperators.Eq.ToString().ToLowerInvariant()); + filterNvc.Add($"filterValue[{i}]", filterItem.Value); + i++; } - /// - /// A filter for statistics - /// - public struct FilterItem + return filterNvc; + } + + + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - /// - /// the field to filter upon - /// - public string Key { get; set; } - /// - /// the operator for the filter on the specified field - /// - public ValidOperators? Operator { get; set; } - /// - /// The value to compare against - /// - public string Value { get; set; } + throw new PayNlException("rawResponse is empty!"); } + } + /// + /// A filter for statistics + /// + public struct FilterItem + { /// - /// The operators for filtering management statistics + /// the field to filter upon /// - [SuppressMessage("ReSharper", "UnusedMember.Global")] - public enum ValidOperators - { - /// - /// Equals - /// - Eq, - /// - /// Not equals - /// - Neq, - /// - /// Greater - /// - Gt, - /// - /// Smaller - /// - Lt, - /// - /// Like - /// - Like - } - + public string Key { get; set; } + /// + /// the operator for the filter on the specified field + /// + public ValidOperators? Operator { get; set; } + /// + /// The value to compare against + /// + public string Value { get; set; } } /// - /// Filter the turnover on the Statistics export + /// The operators for filtering management statistics /// - public enum CompanySelectEnum + [SuppressMessage("ReSharper", "UnusedMember.Global")] + public enum ValidOperators { /// - /// Own merchant and sub merchants + /// Equals + /// + Eq, + /// + /// Not equals + /// + Neq, + /// + /// Greater /// - All, + Gt, /// - /// Only the current merchant + /// Smaller /// - Self, + Lt, /// - /// Only sub merchants + /// Like /// - Other + Like } + } + +/// +/// Filter the turnover on the Statistics export +/// +public enum CompanySelectEnum +{ + /// + /// Own merchant and sub merchants + /// + All, + /// + /// Only the current merchant + /// + Self, + /// + /// Only sub merchants + /// + Other +} \ No newline at end of file diff --git a/PAYNLSDK/API/Transaction/Approve/Request.cs b/PAYNLSDK/API/Transaction/Approve/Request.cs index 9bcf470..ed32da7 100644 --- a/PAYNLSDK/API/Transaction/Approve/Request.cs +++ b/PAYNLSDK/API/Transaction/Approve/Request.cs @@ -1,70 +1,69 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Transaction.Approve +namespace PayNLSdk.Api.Transaction.Approve; + +/// +/// function to approve a suspicious transaction +/// +public class Request : RequestBase { /// - /// function to approve a suspicious transaction + /// /// - public class Request : RequestBase - { - /// - /// - /// - [JsonProperty("transactionId")] - public string TransactionId { get; set; } + [JsonProperty("transactionId")] + public string TransactionId { get; set; } - /// - /// Entrance-code of transaction - /// - [JsonProperty("entranceCode")] - public string EntranceCode { get; set; } + /// + /// Entrance-code of transaction + /// + [JsonProperty("entranceCode")] + public string EntranceCode { get; set; } - /// - protected override int Version => 16; + /// + protected override int Version => 16; - /// - protected override string Controller => "Transaction"; + /// + protected override string Controller => "Transaction"; - /// - protected override string Method => "approve"; + /// + protected override string Method => "approve"; - /// - /// - /// - /// - public override NameValueCollection GetParameters() - { - var nvc = new NameValueCollection(); + /// + /// + /// + /// + public override NameValueCollection GetParameters() + { + var nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(TransactionId, "TransactionId"); - nvc.Add("orderId", TransactionId); + ParameterValidator.IsNotEmpty(TransactionId, "TransactionId"); + nvc.Add("orderId", TransactionId); - if (string.IsNullOrWhiteSpace(EntranceCode) == false) - { - nvc.Add("entranceCode", EntranceCode); - } + if (string.IsNullOrWhiteSpace(EntranceCode) == false) + { + nvc.Add("entranceCode", EntranceCode); + } - return nvc; + return nvc; - } + } - /// - public Response Response => (Response)response; + /// + public Response Response => (Response)response; - /// - /// - /// - protected override void PrepareAndSetResponse() + /// + /// + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/Transaction/Approve/Response.cs b/PAYNLSDK/API/Transaction/Approve/Response.cs index 85db187..72996ea 100644 --- a/PAYNLSDK/API/Transaction/Approve/Response.cs +++ b/PAYNLSDK/API/Transaction/Approve/Response.cs @@ -1,12 +1,10 @@ -using Newtonsoft.Json; -using System; +using Newtonsoft.Json; -namespace PAYNLSDK.API.Transaction.Approve +namespace PayNLSdk.Api.Transaction.Approve; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - [JsonProperty("message")] - public string Message { get; protected set; } - } -} + [JsonProperty("message")] + public string Message { get; protected set; } +} \ No newline at end of file diff --git a/PAYNLSDK/API/Transaction/Decline/Request.cs b/PAYNLSDK/API/Transaction/Decline/Request.cs index 5e9a862..bad6e35 100644 --- a/PAYNLSDK/API/Transaction/Decline/Request.cs +++ b/PAYNLSDK/API/Transaction/Decline/Request.cs @@ -1,72 +1,70 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Transaction.Decline +namespace PayNLSdk.Api.Transaction.Decline; + +/// +/// function to approve a suspicious transaction +/// +public class Request : RequestBase { /// - /// function to approve a suspicious transaction + /// /// - public class Request : RequestBase - { - /// - /// - /// - [JsonProperty("transactionId")] - public string TransactionId { get; set; } + [JsonProperty("transactionId")] + public string TransactionId { get; set; } - /// - /// not implemented - /// - // [JsonProperty("entranceCode")] - // public string EntranceCode { get; set; } + /// + /// not implemented + /// + // [JsonProperty("entranceCode")] + // public string EntranceCode { get; set; } - /* overrides */ - /// - protected override int Version => 7; + /* overrides */ + /// + protected override int Version => 7; - /// - protected override string Controller => "Transaction"; + /// + protected override string Controller => "Transaction"; - /// - protected override string Method => "decline"; + /// + protected override string Method => "decline"; - /// - /// - /// - /// - public override NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); + /// + /// + /// + /// + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(TransactionId, "TransactionId"); - nvc.Add("orderId", TransactionId); + ParameterValidator.IsNotEmpty(TransactionId, "TransactionId"); + nvc.Add("orderId", TransactionId); - // if (!ParameterValidator.IsEmpty(EntranceCode)) - // { - // nvc.Add("entranceCode", EntranceCode); - // } + // if (!ParameterValidator.IsEmpty(EntranceCode)) + // { + // nvc.Add("entranceCode", EntranceCode); + // } - return nvc; - } + return nvc; + } - /// - /// - /// - public Response Response => (Response)response; + /// + /// + /// + public Response Response => (Response)response; - /// - /// - /// - protected override void PrepareAndSetResponse() + /// + /// + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } - diff --git a/PAYNLSDK/API/Transaction/Decline/Response.cs b/PAYNLSDK/API/Transaction/Decline/Response.cs index 5e0a12e..dd0896d 100644 --- a/PAYNLSDK/API/Transaction/Decline/Response.cs +++ b/PAYNLSDK/API/Transaction/Decline/Response.cs @@ -1,11 +1,9 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace PAYNLSDK.API.Transaction.Decline +namespace PayNLSdk.Api.Transaction.Decline; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - [JsonProperty("message")] - public string Message { get; protected set; } - } + [JsonProperty("message")] + public string Message { get; protected set; } } diff --git a/PAYNLSDK/API/Transaction/GetLastTransactions/Request.cs b/PAYNLSDK/API/Transaction/GetLastTransactions/Request.cs index b0d1561..310dea4 100644 --- a/PAYNLSDK/API/Transaction/GetLastTransactions/Request.cs +++ b/PAYNLSDK/API/Transaction/GetLastTransactions/Request.cs @@ -1,74 +1,72 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Utilities; +using Newtonsoft.Json; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -using PAYNLSDK.Exceptions; -namespace PAYNLSDK.API.Transaction.GetLastTransactions +namespace PayNLSdk.Api.Transaction.GetLastTransactions; + +public class Request : RequestBase { - public class Request : RequestBase - { - [JsonProperty("merchantId")] - public string MerchantId { get; set; } + [JsonProperty("merchantId")] + public string MerchantId { get; set; } - [JsonProperty("paid")] - public bool? Paid { get; set; } + [JsonProperty("paid")] + public bool? Paid { get; set; } - [JsonProperty("limit")] - public int? Limit { get; set; } + [JsonProperty("limit")] + public int? Limit { get; set; } - public override bool RequiresServiceId - { - get - { - return true; - } - } - /// - protected override int Version + public override bool RequiresServiceId + { + get { - get { return 5; } + return true; } + } + /// + protected override int Version + { + get { return 5; } + } - /// - protected override string Controller + /// + protected override string Controller + { + get { return "Transaction"; } + } + + /// + protected override string Method + { + get { return "getLastTransactions"; } + } + + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); + if (!ParameterValidator.IsNull(MerchantId)) { - get { return "Transaction"; } + nvc.Add("merchantId", MerchantId); } - - /// - protected override string Method + if (!ParameterValidator.IsNull(Paid)) { - get { return "getLastTransactions"; } + nvc.Add("paid", ((bool)Paid) ? "1" : "0"); } - - public override NameValueCollection GetParameters() + if (!ParameterValidator.IsNull(Limit)) { - NameValueCollection nvc = new NameValueCollection(); - if (!ParameterValidator.IsNull(MerchantId)) - { - nvc.Add("merchantId", MerchantId); - } - if (!ParameterValidator.IsNull(Paid)) - { - nvc.Add("paid", ((bool)Paid) ? "1" : "0"); - } - if (!ParameterValidator.IsNull(Limit)) - { - nvc.Add("limit", Limit.ToString()); - } - return nvc; + nvc.Add("limit", Limit.ToString()); } - - public Response Response { get { return (Response)response; } } + return nvc; + } - protected override void PrepareAndSetResponse() + public Response Response { get { return (Response)response; } } + + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/Transaction/GetLastTransactions/Response.cs b/PAYNLSDK/API/Transaction/GetLastTransactions/Response.cs index 6c9a102..91b8b94 100644 --- a/PAYNLSDK/API/Transaction/GetLastTransactions/Response.cs +++ b/PAYNLSDK/API/Transaction/GetLastTransactions/Response.cs @@ -1,12 +1,10 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Objects; +using Newtonsoft.Json; +using PayNLSdk.Objects; -namespace PAYNLSDK.API.Transaction.GetLastTransactions +namespace PayNLSdk.Api.Transaction.GetLastTransactions; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - [JsonProperty("arrStatsData")] - public TransactionStatsList TransactionStats { get; set; } - } + [JsonProperty("arrStatsData")] + public TransactionStatsList TransactionStats { get; set; } } diff --git a/PAYNLSDK/API/Transaction/GetService/Request.cs b/PAYNLSDK/API/Transaction/GetService/Request.cs index 48ef95f..a4fbf79 100644 --- a/PAYNLSDK/API/Transaction/GetService/Request.cs +++ b/PAYNLSDK/API/Transaction/GetService/Request.cs @@ -1,47 +1,47 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Enums; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Transaction.GetService +namespace PayNLSdk.Api.Transaction.GetService; + +public class Request : RequestBase { - public class Request : RequestBase - { - public override bool RequiresServiceId => true; + public override bool RequiresServiceId => true; - [JsonProperty("paymentMethodId")] - public PAYNLSDK.Enums.PaymentMethodId? PaymentMethodId { get; set; } + [JsonProperty("paymentMethodId")] + public PaymentMethodId? PaymentMethodId { get; set; } - /// - protected override int Version => 5; + /// + protected override int Version => 5; - /// - protected override string Controller => "Transaction"; + /// + protected override string Controller => "Transaction"; - /// - protected override string Method => "getService"; + /// + protected override string Method => "getService"; - /// - public override NameValueCollection GetParameters() + /// + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); + if (!ParameterValidator.IsNull(PaymentMethodId)) { - NameValueCollection nvc = new NameValueCollection(); - if (!ParameterValidator.IsNull(PaymentMethodId)) - { - nvc.Add("paymentMethodId", ((int)PaymentMethodId).ToString()); - } - return nvc; + nvc.Add("paymentMethodId", ((int)PaymentMethodId).ToString()); } + return nvc; + } - public Response Response => (Response)response; + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/Transaction/GetService/Response.cs b/PAYNLSDK/API/Transaction/GetService/Response.cs index 1345878..caed988 100644 --- a/PAYNLSDK/API/Transaction/GetService/Response.cs +++ b/PAYNLSDK/API/Transaction/GetService/Response.cs @@ -1,19 +1,16 @@ -using System; -using PAYNLSDK.API; -using Newtonsoft.Json; -using PAYNLSDK.Objects; +using Newtonsoft.Json; +using PayNLSdk.Objects; -namespace PAYNLSDK.API.Transaction.GetService +namespace PayNLSdk.Api.Transaction.GetService; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - [JsonProperty("merchant")] - public Objects.Merchant Merchant { get; set; } + [JsonProperty("merchant")] + public Objects.Merchant Merchant { get; set; } - [JsonProperty("service")] - public PAYNLSDK.Objects.Service Service { get; set; } + [JsonProperty("service")] + public Objects.Service Service { get; set; } - [JsonProperty("countryOptionList")] - public CountryOptions CountryOptions { get; set; } - } + [JsonProperty("countryOptionList")] + public CountryOptions CountryOptions { get; set; } } diff --git a/PAYNLSDK/API/Transaction/Info/Request.cs b/PAYNLSDK/API/Transaction/Info/Request.cs index 2c03829..1cde020 100644 --- a/PAYNLSDK/API/Transaction/Info/Request.cs +++ b/PAYNLSDK/API/Transaction/Info/Request.cs @@ -1,57 +1,56 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Transaction.Info +namespace PayNLSdk.Api.Transaction.Info; + +public class Request : RequestBase { - public class Request : RequestBase - { - /// - /// Mandatory transaction identifier - /// - [System.ComponentModel.DataAnnotations.Required] - public string TransactionId { get; set; } + /// + /// Mandatory transaction identifier + /// + [System.ComponentModel.DataAnnotations.Required] + public string TransactionId { get; set; } + + /// + /// Unique code related to the order. + /// + public string EntranceCode { get; set; } + + /// + protected override int Version => 5; - /// - /// Unique code related to the order. - /// - public string EntranceCode { get; set; } + /// + protected override string Controller => "Transaction"; - /// - protected override int Version => 5; + /// + protected override string Method => "info"; - /// - protected override string Controller => "Transaction"; + /// + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - /// - protected override string Method => "info"; + ParameterValidator.IsNotEmpty(TransactionId, "TransactionId"); + nvc.Add("transactionId", TransactionId); - /// - public override NameValueCollection GetParameters() + if (!ParameterValidator.IsEmpty(EntranceCode)) { - NameValueCollection nvc = new NameValueCollection(); - - ParameterValidator.IsNotEmpty(TransactionId, "TransactionId"); - nvc.Add("transactionId", TransactionId); - - if (!ParameterValidator.IsEmpty(EntranceCode)) - { - nvc.Add("entranceCode", EntranceCode); - } - return nvc; + nvc.Add("entranceCode", EntranceCode); } - public Response Response => (Response)response; + return nvc; + } + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } - + response = JsonConvert.DeserializeObject(RawResponse); } + } diff --git a/PAYNLSDK/API/Transaction/Info/Response.cs b/PAYNLSDK/API/Transaction/Info/Response.cs index e66aea0..47e75bb 100644 --- a/PAYNLSDK/API/Transaction/Info/Response.cs +++ b/PAYNLSDK/API/Transaction/Info/Response.cs @@ -1,34 +1,32 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Objects; +using Newtonsoft.Json; +using PayNLSdk.Objects; -namespace PAYNLSDK.API.Transaction.Info +namespace PayNLSdk.Api.Transaction.Info; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - [JsonProperty("connection")] - public Connection Connection { get; protected set; } + [JsonProperty("connection")] + public Connection Connection { get; protected set; } - [JsonProperty("enduser")] - public EndUser EndUser { get; protected set; } + [JsonProperty("enduser")] + public EndUser EndUser { get; protected set; } - //[JsonProperty("saledata")] - //public SalesData SalesData { get; protected set; } + //[JsonProperty("saledata")] + //public SalesData SalesData { get; protected set; } - /// - /// All details from the payment - /// - [JsonProperty("paymentDetails")] - public PaymentDetails PaymentDetails { get; protected set; } + /// + /// All details from the payment + /// + [JsonProperty("paymentDetails")] + public PaymentDetails PaymentDetails { get; protected set; } - /// - /// Details regarding the refund (if any) - /// - [JsonProperty("stornoDetails")] - public StornoDetails StornoDetails { get; protected set; } + /// + /// Details regarding the refund (if any) + /// + [JsonProperty("stornoDetails")] + public StornoDetails StornoDetails { get; protected set; } - [JsonProperty("statsDetails")] - public StatsDetails StatsDetails { get; protected set; } + [JsonProperty("statsDetails")] + public StatsDetails StatsDetails { get; protected set; } - } } diff --git a/PAYNLSDK/API/Transaction/Refund/Request.cs b/PAYNLSDK/API/Transaction/Refund/Request.cs index 28d737c..a584f92 100644 --- a/PAYNLSDK/API/Transaction/Refund/Request.cs +++ b/PAYNLSDK/API/Transaction/Refund/Request.cs @@ -1,111 +1,110 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Converters; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System; using System.Collections.Specialized; using System.Globalization; -namespace PAYNLSDK.API.Transaction.Refund +namespace PayNLSdk.Api.Transaction.Refund; + +/// +/// A normal refund from a previously placed transaction. +/// If you are doing a refund from Sofort or AfterPay, you'll need to use +/// +public class Request : RequestBase { /// - /// A normal refund from a previously placed transaction. - /// If you are doing a refund from Sofort or AfterPay, you'll need to use + /// The order ID or EX code of the transaction. /// - public class Request : RequestBase + [JsonProperty("transactionId")] + public string TransactionId { get; set; } + + /// + /// Amount to be paid in cents. + /// For example € 3.50 becomes 350. + /// If no amount is specified, the full amount is refunded and currency is not used. + /// + [JsonProperty("amount")] + public decimal? Amount { get; set; } + + /// + /// description to include with the payment. + /// + [JsonProperty("description")] + public string Description { get; set; } + + /// + /// The date on which the refund needs to be processed. Only works for IBAN refunds. + /// + /// Internal format should be dd-mm-yyyy(eg. 25-09-2016) + [JsonProperty("processDate"), JsonConverter(typeof(DMYConverter))] + public DateTime? ProcessDate { get; set; } + + /// + protected override int Version => 16; + + /// + protected override string Controller => "Transaction"; + + /// + protected override string Method => "refund"; + + /// + public override NameValueCollection GetParameters() { - /// - /// The order ID or EX code of the transaction. - /// - [JsonProperty("transactionId")] - public string TransactionId { get; set; } - - /// - /// Amount to be paid in cents. - /// For example € 3.50 becomes 350. - /// If no amount is specified, the full amount is refunded and currency is not used. - /// - [JsonProperty("amount")] - public decimal? Amount { get; set; } - - /// - /// description to include with the payment. - /// - [JsonProperty("description")] - public string Description { get; set; } - - /// - /// The date on which the refund needs to be processed. Only works for IBAN refunds. - /// - /// Internal format should be dd-mm-yyyy(eg. 25-09-2016) - [JsonProperty("processDate"), JsonConverter(typeof(DMYConverter))] - public DateTime? ProcessDate { get; set; } - - /// - protected override int Version => 16; - - /// - protected override string Controller => "Transaction"; - - /// - protected override string Method => "refund"; - - /// - public override NameValueCollection GetParameters() + var nvc = new NameValueCollection(); + + ParameterValidator.IsNotEmpty(TransactionId, "TransactionId"); + nvc.Add("transactionId", TransactionId); + + if (Amount.HasValue) { - var nvc = new NameValueCollection(); + nvc.Add("amount", ((int)Math.Floor(Amount.Value * 100)).ToString()); + } - ParameterValidator.IsNotEmpty(TransactionId, "TransactionId"); - nvc.Add("transactionId", TransactionId); + if (!ParameterValidator.IsEmpty(Description)) + { + nvc.Add("description", Description); + } + + if (ProcessDate.HasValue) + { + nvc.Add("processDate", ProcessDate.Value.ToString("dd-MM-yyyy")); + } - if (Amount.HasValue) - { - nvc.Add("amount", ((int)Math.Floor(Amount.Value * 100)).ToString()); - } + if (VatPercentage.HasValue) + { + nvc.Add("vatPercentage", VatPercentage.Value.ToString(CultureInfo.InvariantCulture)); + } - if (!ParameterValidator.IsEmpty(Description)) - { - nvc.Add("description", Description); - } + return nvc; + } - if (ProcessDate.HasValue) - { - nvc.Add("processDate", ProcessDate.Value.ToString("dd-MM-yyyy")); - } + /// + /// the vat percentage this refund applies to (AfterPay/Focum only) + /// + [JsonProperty("vatPercentage")] + public decimal? VatPercentage { get; set; } - if (VatPercentage.HasValue) - { - nvc.Add("vatPercentage", VatPercentage.Value.ToString(CultureInfo.InvariantCulture)); - } + /// + /// Optional field. The currency in which the amount is specified. Standard in euro. + /// + [JsonProperty("currency")] + public string Currency { get; set; } - return nvc; - } + /// + /// the response from the request + /// + public Response Response => (Response)response; - /// - /// the vat percentage this refund applies to (AfterPay/Focum only) - /// - [JsonProperty("vatPercentage")] - public decimal? VatPercentage { get; set; } - - /// - /// Optional field. The currency in which the amount is specified. Standard in euro. - /// - [JsonProperty("currency")] - public string Currency { get; set; } - - /// - /// the response from the request - /// - public Response Response => (Response)response; - - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/Transaction/Refund/Response.cs b/PAYNLSDK/API/Transaction/Refund/Response.cs index 8781999..c5ff770 100644 --- a/PAYNLSDK/API/Transaction/Refund/Response.cs +++ b/PAYNLSDK/API/Transaction/Refund/Response.cs @@ -1,11 +1,9 @@ using Newtonsoft.Json; -using System; -namespace PAYNLSDK.API.Transaction.Refund +namespace PayNLSdk.Api.Transaction.Refund; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - [JsonProperty("refundId")] - public string RefundId { get; protected set; } - } + [JsonProperty("refundId")] + public string RefundId { get; protected set; } } diff --git a/PAYNLSDK/API/Transaction/Start/Request.cs b/PAYNLSDK/API/Transaction/Start/Request.cs index 841f907..cd6a67e 100644 --- a/PAYNLSDK/API/Transaction/Start/Request.cs +++ b/PAYNLSDK/API/Transaction/Start/Request.cs @@ -1,432 +1,431 @@ using Newtonsoft.Json; -using PAYNLSDK.Enums; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Objects; -using PAYNLSDK.Utilities; +using PayNLSdk.Enums; +using PayNLSdk.Exceptions; +using PayNLSdk.Objects; +using PayNLSdk.Utilities; using System; using System.Collections.Specialized; -namespace PAYNLSDK.API.Transaction.Start +namespace PayNLSdk.Api.Transaction.Start; + +/// +/// The HTTP request to request the start of a new transaction +/// +/// +public class Request : RequestBase { /// - /// The HTTP request to request the start of a new transaction + /// Initializes a new instance of the class. /// - /// - public class Request : RequestBase + public Request() { - /// - /// Initializes a new instance of the class. - /// - public Request() - { - TransactionData = new TransactionData(); - Enduser = new EndUser(); - SalesData = new SalesData(); - StatsData = new StatsDetails(); - } + TransactionData = new TransactionData(); + Enduser = new EndUser(); + SalesData = new SalesData(); + StatsData = new StatsDetails(); + } - /// - public override bool RequiresApiToken => true; - - /// - public override bool RequiresServiceId => true; - - /// - /// The amount to be paid should be given in cents. For example € 3.50 becomes 350. - /// - public int Amount { get; set; } - /// - /// The IP address of the customer - /// - public string IPAddress { get; set; } - /// - /// The URL where the customer has to be send to after the payment. - /// - public string ReturnUrl { get; set; } - /// - /// The payment PROFILE to be used - /// - public int? PaymentOptionId { get; set; } - /// - /// In case of an iDEAL payment this is the ID of the bank (see the paymentOptionSubList in the getService function). - /// - public int? PaymentOptionSubId { get; set; } - /// - /// define if this is running in test or not - /// - public bool TestMode { get; set; } - /// - /// Use transaction, merchant or alliance to change the benificiary owner of the transaction - /// - public string TransferType { get; set; } - /// - /// MerchantId (M-xxxx-xxxx) or orderId - /// - public string TransferValue { get; set; } - - /// - /// Optional information about the transaction - /// - public TransactionData TransactionData { get; set; } - public StatsDetails StatsData { get; set; } - public EndUser Enduser { get; set; } - public SalesData SalesData { get; set; } - - /// - protected override int Version - { - get { return 5; } - } + /// + public override bool RequiresApiToken => true; + + /// + public override bool RequiresServiceId => true; + + /// + /// The amount to be paid should be given in cents. For example € 3.50 becomes 350. + /// + public int Amount { get; set; } + /// + /// The IP address of the customer + /// + public string IPAddress { get; set; } + /// + /// The URL where the customer has to be send to after the payment. + /// + public string ReturnUrl { get; set; } + /// + /// The payment PROFILE to be used + /// + public int? PaymentOptionId { get; set; } + /// + /// In case of an iDEAL payment this is the ID of the bank (see the paymentOptionSubList in the getService function). + /// + public int? PaymentOptionSubId { get; set; } + /// + /// define if this is running in test or not + /// + public bool TestMode { get; set; } + /// + /// Use transaction, merchant or alliance to change the benificiary owner of the transaction + /// + public string TransferType { get; set; } + /// + /// MerchantId (M-xxxx-xxxx) or orderId + /// + public string TransferValue { get; set; } - /// - protected override string Controller + /// + /// Optional information about the transaction + /// + public TransactionData TransactionData { get; set; } + public StatsDetails StatsData { get; set; } + public EndUser Enduser { get; set; } + public SalesData SalesData { get; set; } + + /// + protected override int Version + { + get { return 5; } + } + + /// + protected override string Controller + { + get { return "Transaction"; } + } + + protected override string Method + { + get { return "start"; } + } + + public override NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); + + // Basic params + ParameterValidator.IsNotNull(Amount, "Amount"); + nvc.Add("amount", Amount.ToString()); + + ParameterValidator.IsNotNull(IPAddress, "IPAddress"); + nvc.Add("ipAddress", IPAddress); + + ParameterValidator.IsNotNull(ReturnUrl, "ReturnUrl"); + nvc.Add("finishUrl", ReturnUrl); + + if (ParameterValidator.IsNonEmptyInt(PaymentOptionId)) { - get { return "Transaction"; } + nvc.Add("paymentOptionId", PaymentOptionId.ToString()); } - protected override string Method + if (ParameterValidator.IsNonEmptyInt(PaymentOptionSubId)) { - get { return "start"; } + nvc.Add("paymentOptionSubId", PaymentOptionSubId.ToString()); } - public override NameValueCollection GetParameters() + if (!ParameterValidator.IsEmpty(TransferValue)) { - NameValueCollection nvc = new NameValueCollection(); - - // Basic params - ParameterValidator.IsNotNull(Amount, "Amount"); - nvc.Add("amount", Amount.ToString()); - ParameterValidator.IsNotNull(IPAddress, "IPAddress"); - nvc.Add("ipAddress", IPAddress); - - ParameterValidator.IsNotNull(ReturnUrl, "ReturnUrl"); - nvc.Add("finishUrl", ReturnUrl); - - if (ParameterValidator.IsNonEmptyInt(PaymentOptionId)) + if (TransferType == "transaction" || TransferType == "merchant") { - nvc.Add("paymentOptionId", PaymentOptionId.ToString()); + nvc.Add("transferType", TransferType); + nvc.Add("transferValue", TransferValue); } - - if (ParameterValidator.IsNonEmptyInt(PaymentOptionSubId)) + else { - nvc.Add("paymentOptionSubId", PaymentOptionSubId.ToString()); + throw new Exception("TransferValue cannot be set, without valid TransferType, please fix this."); } + } - if (!ParameterValidator.IsEmpty(TransferValue)) + // Transaction + if (TransactionData != null) + { + if (string.IsNullOrWhiteSpace(TransactionData.Currency) == false) { - - if (TransferType == "transaction" || TransferType == "merchant") - { - nvc.Add("transferType", TransferType); - nvc.Add("transferValue", TransferValue); - } - else - { - throw new Exception("TransferValue cannot be set, without valid TransferType, please fix this."); - } + nvc.Add("transaction[currency]", TransactionData.Currency); + } + if (!ParameterValidator.IsNonEmptyInt(TransactionData.CostsVat)) + { + nvc.Add("transaction[costsVat]", TransactionData.CostsVat.ToString()); + } + // TODO: exclude cost? + if (!ParameterValidator.IsEmpty(TransactionData.OrderExchangeUrl)) + { + nvc.Add("transaction[orderExchangeUrl]", TransactionData.OrderExchangeUrl); + } + if (!ParameterValidator.IsNull(TransactionData.OrderNumber)) + { + nvc.Add("transaction[orderNumber]", TransactionData.OrderNumber); + } + if (!ParameterValidator.IsEmpty(TransactionData.Description)) + { + nvc.Add("transaction[description]", TransactionData.Description); } - // Transaction - if (TransactionData != null) + if (!ParameterValidator.IsNonEmptyInt(TransactionData.EnduserId)) { - if (string.IsNullOrWhiteSpace(TransactionData.Currency) == false) - { - nvc.Add("transaction[currency]", TransactionData.Currency); - } - if (!ParameterValidator.IsNonEmptyInt(TransactionData.CostsVat)) - { - nvc.Add("transaction[costsVat]", TransactionData.CostsVat.ToString()); - } - // TODO: exclude cost? - if (!ParameterValidator.IsEmpty(TransactionData.OrderExchangeUrl)) - { - nvc.Add("transaction[orderExchangeUrl]", TransactionData.OrderExchangeUrl); - } - if (!ParameterValidator.IsNull(TransactionData.OrderNumber)) - { - nvc.Add("transaction[orderNumber]", TransactionData.OrderNumber); - } - if (!ParameterValidator.IsEmpty(TransactionData.Description)) - { - nvc.Add("transaction[description]", TransactionData.Description); - } + nvc.Add("transaction[enduserId]", TransactionData.EnduserId.ToString()); + } - if (!ParameterValidator.IsNonEmptyInt(TransactionData.EnduserId)) - { - nvc.Add("transaction[enduserId]", TransactionData.EnduserId.ToString()); - } + if (TransactionData.ExpireDate != null) + { + nvc.Add("transaction[expireDate]", ((DateTime)TransactionData.ExpireDate).ToString("dd-MM-yyyy HH:mm:ss")); + } + // TODO: Are these right? Shouldn't this be BOOL / INT? + /* + if (!ParameterValidator.IsEmpty(Transaction.SendReminderEmail)) + { + nvc.Add("transaction[sendReminderEmail]", Transaction.SendReminderEmail); + } + if (!ParameterValidator.IsEmpty(Transaction.ReminderMailTemplateId)) + { + nvc.Add("transaction[reminderMailTemplateId]", Transaction.ReminderMailTemplateId); + } + */ + } - if (TransactionData.ExpireDate != null) - { - nvc.Add("transaction[expireDate]", ((DateTime)TransactionData.ExpireDate).ToString("dd-MM-yyyy HH:mm:ss")); - } - // TODO: Are these right? Shouldn't this be BOOL / INT? - /* - if (!ParameterValidator.IsEmpty(Transaction.SendReminderEmail)) - { - nvc.Add("transaction[sendReminderEmail]", Transaction.SendReminderEmail); - } - if (!ParameterValidator.IsEmpty(Transaction.ReminderMailTemplateId)) - { - nvc.Add("transaction[reminderMailTemplateId]", Transaction.ReminderMailTemplateId); - } - */ + // StatsData + if (StatsData != null) + { + if (ParameterValidator.IsNonEmptyInt(StatsData.PromotorId)) + { + nvc.Add("statsData[promotorId]", StatsData.PromotorId.ToString()); } + if (!ParameterValidator.IsEmpty(StatsData.Info)) + { + nvc.Add("statsData[info]", StatsData.Info); + } + if (!ParameterValidator.IsEmpty(StatsData.Tool)) + { + nvc.Add("statsData[tool]", StatsData.Tool); + } + if (!ParameterValidator.IsEmpty(StatsData.Extra1)) + { + nvc.Add("statsData[extra1]", StatsData.Extra1); + } + if (!ParameterValidator.IsEmpty(StatsData.Extra2)) + { + nvc.Add("statsData[extra2]", StatsData.Extra2); + } + if (!ParameterValidator.IsEmpty(StatsData.Extra3)) + { + nvc.Add("statsData[extra3]", StatsData.Extra3); + } + //if (!ParameterValidator.IsEmpty(StatsData.TransferData)) + //{ + // nvc.Add("statsData[transferData]", StatsData.TransferData); + //} + } - // StatsData - if (StatsData != null) + // End user + if (Enduser != null) + { + /* + if (!ParameterValidator.IsEmpty(Enduser.AccessCode)) + { + nvc.Add("enduser[accessCode]", Enduser.AccessCode); + } + * */ + if (!ParameterValidator.IsEmpty(Enduser.Language)) + { + nvc.Add("enduser[language]", Enduser.Language); + } + if (!ParameterValidator.IsEmpty(Enduser.Initials)) + { + nvc.Add("enduser[initials]", Enduser.Initials); + } + if (!ParameterValidator.IsEmpty(Enduser.Lastname)) + { + nvc.Add("enduser[lastName]", Enduser.Lastname); + } + if (!ParameterValidator.IsNull(Enduser.Gender)) + { + nvc.Add("enduser[gender]", EnumUtil.ToEnumString((Gender)Enduser.Gender)); + } + if (!ParameterValidator.IsNull(Enduser.BirthDate)) + { + nvc.Add("enduser[dob]", ((DateTime)Enduser.BirthDate).ToString("dd-MM-yyyy")); + } + if (!ParameterValidator.IsEmpty(Enduser.PhoneNumber)) + { + nvc.Add("enduser[phoneNumber]", Enduser.PhoneNumber); + } + if (!ParameterValidator.IsEmpty(Enduser.EmailAddress)) { - if (ParameterValidator.IsNonEmptyInt(StatsData.PromotorId)) + nvc.Add("enduser[emailAddress]", Enduser.EmailAddress); + } + if (!ParameterValidator.IsEmpty(Enduser.BankAccount)) + { + nvc.Add("enduser[bankAccount]", Enduser.BankAccount); + } + if (!ParameterValidator.IsEmpty(Enduser.IBAN)) + { + nvc.Add("enduser[iban]", Enduser.IBAN); + } + /* + if (!ParameterValidator.IsNull(Enduser.SendConfirmMail)) + { + nvc.Add("enduser[sendConfirmMail]", ((bool)Enduser.SendConfirmMail) ? "1" : "0"); + } + if (!ParameterValidator.IsEmpty(Enduser.ConfirmMailTemplate)) + { + nvc.Add("enduser[confirmMailTemplate]", Enduser.ConfirmMailTemplate); + } + * */ + if (!ParameterValidator.IsEmpty(Enduser.CustomerReference)) + { + nvc.Add("enduser[customerReference]", Enduser.CustomerReference); + } + // Address + if (Enduser.Address != null) + { + if (!ParameterValidator.IsEmpty(Enduser.Address.StreetName)) { - nvc.Add("statsData[promotorId]", StatsData.PromotorId.ToString()); + nvc.Add("enduser[address][streetName]", Enduser.Address.StreetName); } - if (!ParameterValidator.IsEmpty(StatsData.Info)) + if (!ParameterValidator.IsEmpty(Enduser.Address.StreetNumber)) { - nvc.Add("statsData[info]", StatsData.Info); + nvc.Add("enduser[address][streetNumber]", Enduser.Address.StreetNumber); } - if (!ParameterValidator.IsEmpty(StatsData.Tool)) + if (!ParameterValidator.IsEmpty(Enduser.Address.StreetNumberExtension)) { - nvc.Add("statsData[tool]", StatsData.Tool); + nvc.Add("enduser[address][streetNumberExtension]", Enduser.Address.StreetNumberExtension); } - if (!ParameterValidator.IsEmpty(StatsData.Extra1)) + if (!ParameterValidator.IsEmpty(Enduser.Address.ZipCode)) { - nvc.Add("statsData[extra1]", StatsData.Extra1); + nvc.Add("enduser[address][zipCode]", Enduser.Address.ZipCode); } - if (!ParameterValidator.IsEmpty(StatsData.Extra2)) + if (!ParameterValidator.IsEmpty(Enduser.Address.City)) { - nvc.Add("statsData[extra2]", StatsData.Extra2); + nvc.Add("enduser[address][city]", Enduser.Address.City); } - if (!ParameterValidator.IsEmpty(StatsData.Extra3)) + if (!ParameterValidator.IsEmpty(Enduser.Address.CountryCode)) { - nvc.Add("statsData[extra3]", StatsData.Extra3); + nvc.Add("enduser[address][countryCode]", Enduser.Address.CountryCode); } - //if (!ParameterValidator.IsEmpty(StatsData.TransferData)) - //{ - // nvc.Add("statsData[transferData]", StatsData.TransferData); - //} } - // End user - if (Enduser != null) + // InvoiceAddress + if (Enduser.InvoiceAddress != null) { - /* - if (!ParameterValidator.IsEmpty(Enduser.AccessCode)) + if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.Initials)) { - nvc.Add("enduser[accessCode]", Enduser.AccessCode); + nvc.Add("enduser[invoiceAddress][initials]", Enduser.InvoiceAddress.Initials); } - * */ - if (!ParameterValidator.IsEmpty(Enduser.Language)) + if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.LastName)) { - nvc.Add("enduser[language]", Enduser.Language); + nvc.Add("enduser[invoiceAddress][lastName]", Enduser.InvoiceAddress.LastName); } - if (!ParameterValidator.IsEmpty(Enduser.Initials)) + if (!ParameterValidator.IsNull(Enduser.InvoiceAddress.Gender)) { - nvc.Add("enduser[initials]", Enduser.Initials); + string gender = EnumUtil.ToEnumString((Gender)Enduser.InvoiceAddress.Gender); + nvc.Add("enduser[invoiceAddress][gender]", gender); } - if (!ParameterValidator.IsEmpty(Enduser.Lastname)) + if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.StreetName)) { - nvc.Add("enduser[lastName]", Enduser.Lastname); + nvc.Add("enduser[invoiceAddress][streetName]", Enduser.InvoiceAddress.StreetName); } - if (!ParameterValidator.IsNull(Enduser.Gender)) + if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.StreetNumber)) { - nvc.Add("enduser[gender]", EnumUtil.ToEnumString((Gender)Enduser.Gender)); + nvc.Add("enduser[invoiceAddress][streetNumber]", Enduser.InvoiceAddress.StreetNumber); } - if (!ParameterValidator.IsNull(Enduser.BirthDate)) + if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.StreetNumberExtension)) { - nvc.Add("enduser[dob]", ((DateTime)Enduser.BirthDate).ToString("dd-MM-yyyy")); + nvc.Add("enduser[invoiceAddress][streetNumberExtension]", Enduser.InvoiceAddress.StreetNumberExtension); } - if (!ParameterValidator.IsEmpty(Enduser.PhoneNumber)) + if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.ZipCode)) { - nvc.Add("enduser[phoneNumber]", Enduser.PhoneNumber); + nvc.Add("enduser[invoiceAddress][zipCode]", Enduser.InvoiceAddress.ZipCode); } - if (!ParameterValidator.IsEmpty(Enduser.EmailAddress)) + if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.City)) { - nvc.Add("enduser[emailAddress]", Enduser.EmailAddress); + nvc.Add("enduser[invoiceAddress][city]", Enduser.InvoiceAddress.City); } - if (!ParameterValidator.IsEmpty(Enduser.BankAccount)) + if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.CountryCode)) { - nvc.Add("enduser[bankAccount]", Enduser.BankAccount); + nvc.Add("enduser[invoiceAddress][countryCode]", Enduser.InvoiceAddress.CountryCode); } - if (!ParameterValidator.IsEmpty(Enduser.IBAN)) - { - nvc.Add("enduser[iban]", Enduser.IBAN); - } - /* - if (!ParameterValidator.IsNull(Enduser.SendConfirmMail)) + } + + //Company info + if (Enduser.Company != null) + { + if (!ParameterValidator.IsEmpty(Enduser.Company.CocNumber)) { - nvc.Add("enduser[sendConfirmMail]", ((bool)Enduser.SendConfirmMail) ? "1" : "0"); + nvc.Add("enduser[company][cocNumber]", Enduser.Company.CocNumber); } - if (!ParameterValidator.IsEmpty(Enduser.ConfirmMailTemplate)) + if (!ParameterValidator.IsEmpty(Enduser.Company.CountryCode)) { - nvc.Add("enduser[confirmMailTemplate]", Enduser.ConfirmMailTemplate); + nvc.Add("enduser[company][countryCode]", Enduser.Company.CountryCode); } - * */ - if (!ParameterValidator.IsEmpty(Enduser.CustomerReference)) + if (!ParameterValidator.IsEmpty(Enduser.Company.Name)) { - nvc.Add("enduser[customerReference]", Enduser.CustomerReference); + nvc.Add("enduser[company][name]", Enduser.Company.Name); } - // Address - if (Enduser.Address != null) + if (!ParameterValidator.IsEmpty(Enduser.Company.VatNumber)) { - if (!ParameterValidator.IsEmpty(Enduser.Address.StreetName)) - { - nvc.Add("enduser[address][streetName]", Enduser.Address.StreetName); - } - if (!ParameterValidator.IsEmpty(Enduser.Address.StreetNumber)) - { - nvc.Add("enduser[address][streetNumber]", Enduser.Address.StreetNumber); - } - if (!ParameterValidator.IsEmpty(Enduser.Address.StreetNumberExtension)) - { - nvc.Add("enduser[address][streetNumberExtension]", Enduser.Address.StreetNumberExtension); - } - if (!ParameterValidator.IsEmpty(Enduser.Address.ZipCode)) - { - nvc.Add("enduser[address][zipCode]", Enduser.Address.ZipCode); - } - if (!ParameterValidator.IsEmpty(Enduser.Address.City)) - { - nvc.Add("enduser[address][city]", Enduser.Address.City); - } - if (!ParameterValidator.IsEmpty(Enduser.Address.CountryCode)) - { - nvc.Add("enduser[address][countryCode]", Enduser.Address.CountryCode); - } + nvc.Add("enduser[company][vatNumber]", Enduser.Company.VatNumber); } + } - // InvoiceAddress - if (Enduser.InvoiceAddress != null) - { - if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.Initials)) - { - nvc.Add("enduser[invoiceAddress][initials]", Enduser.InvoiceAddress.Initials); - } - if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.LastName)) - { - nvc.Add("enduser[invoiceAddress][lastName]", Enduser.InvoiceAddress.LastName); - } - if (!ParameterValidator.IsNull(Enduser.InvoiceAddress.Gender)) - { - string gender = EnumUtil.ToEnumString((Gender)Enduser.InvoiceAddress.Gender); - nvc.Add("enduser[invoiceAddress][gender]", gender); - } - if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.StreetName)) - { - nvc.Add("enduser[invoiceAddress][streetName]", Enduser.InvoiceAddress.StreetName); - } - if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.StreetNumber)) - { - nvc.Add("enduser[invoiceAddress][streetNumber]", Enduser.InvoiceAddress.StreetNumber); - } - if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.StreetNumberExtension)) - { - nvc.Add("enduser[invoiceAddress][streetNumberExtension]", Enduser.InvoiceAddress.StreetNumberExtension); - } - if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.ZipCode)) - { - nvc.Add("enduser[invoiceAddress][zipCode]", Enduser.InvoiceAddress.ZipCode); - } - if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.City)) - { - nvc.Add("enduser[invoiceAddress][city]", Enduser.InvoiceAddress.City); - } - if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.CountryCode)) - { - nvc.Add("enduser[invoiceAddress][countryCode]", Enduser.InvoiceAddress.CountryCode); - } - } + } - //Company info - if (Enduser.Company != null) + // SaleData + if (SalesData != null) + { + if (!ParameterValidator.IsNull(SalesData.DeliveryDate)) + { + nvc.Add("saleData[deliveryDate]", SalesData.DeliveryDate?.ToString("dd-MM-yyyy")); + } + if (!ParameterValidator.IsNull(SalesData.InvoiceDate)) + { + nvc.Add("saleData[invoiceDate]", SalesData.InvoiceDate?.ToString("dd-MM-yyyy")); + } + if (!ParameterValidator.IsNull(SalesData.OrderData)) + { + int i = 0; + foreach (OrderData data in SalesData.OrderData) { - if (!ParameterValidator.IsEmpty(Enduser.Company.CocNumber)) - { - nvc.Add("enduser[company][cocNumber]", Enduser.Company.CocNumber); - } - if (!ParameterValidator.IsEmpty(Enduser.Company.CountryCode)) + ParameterValidator.IsNotNull(data.ProductId, "SalesData.OrderData.ProductId"); + nvc.Add(string.Format("saleData[orderData][{0}][productId]", i), data.ProductId); + + if (!ParameterValidator.IsNull(data.Description)) { - nvc.Add("enduser[company][countryCode]", Enduser.Company.CountryCode); + nvc.Add(string.Format("saleData[orderData][{0}][description]", i), data.Description); } - if (!ParameterValidator.IsEmpty(Enduser.Company.Name)) + + ParameterValidator.IsNotNull(data.Price, "SalesData.OrderData.Price"); + nvc.Add(string.Format("saleData[orderData][{0}][price]", i), data.Price.ToString()); + + ParameterValidator.IsNotNull(data.Quantity, "SalesData.OrderData.Quantity"); + nvc.Add(string.Format("saleData[orderData][{0}][quantity]", i), data.Quantity.ToString()); + + if (!ParameterValidator.IsNull(data.VatCode)) { - nvc.Add("enduser[company][name]", Enduser.Company.Name); + nvc.Add(string.Format("saleData[orderData][{0}][vatCode]", i), EnumUtil.ToEnumString((TaxClass)data.VatCode)); } - if (!ParameterValidator.IsEmpty(Enduser.Company.VatNumber)) + if (!ParameterValidator.IsNull(data.ProductType)) { - nvc.Add("enduser[company][vatNumber]", Enduser.Company.VatNumber); + nvc.Add(string.Format("saleData[orderData][{0}][productType]", i), EnumUtil.ToEnumString((ProductType)data.ProductType)); } - } - - } - // SaleData - if (SalesData != null) - { - if (!ParameterValidator.IsNull(SalesData.DeliveryDate)) - { - nvc.Add("saleData[deliveryDate]", SalesData.DeliveryDate?.ToString("dd-MM-yyyy")); - } - if (!ParameterValidator.IsNull(SalesData.InvoiceDate)) - { - nvc.Add("saleData[invoiceDate]", SalesData.InvoiceDate?.ToString("dd-MM-yyyy")); - } - if (!ParameterValidator.IsNull(SalesData.OrderData)) - { - int i = 0; - foreach (OrderData data in SalesData.OrderData) - { - ParameterValidator.IsNotNull(data.ProductId, "SalesData.OrderData.ProductId"); - nvc.Add(string.Format("saleData[orderData][{0}][productId]", i), data.ProductId); - - if (!ParameterValidator.IsNull(data.Description)) - { - nvc.Add(string.Format("saleData[orderData][{0}][description]", i), data.Description); - } - - ParameterValidator.IsNotNull(data.Price, "SalesData.OrderData.Price"); - nvc.Add(string.Format("saleData[orderData][{0}][price]", i), data.Price.ToString()); - - ParameterValidator.IsNotNull(data.Quantity, "SalesData.OrderData.Quantity"); - nvc.Add(string.Format("saleData[orderData][{0}][quantity]", i), data.Quantity.ToString()); - - if (!ParameterValidator.IsNull(data.VatCode)) - { - nvc.Add(string.Format("saleData[orderData][{0}][vatCode]", i), EnumUtil.ToEnumString((TaxClass)data.VatCode)); - } - if (!ParameterValidator.IsNull(data.ProductType)) - { - nvc.Add(string.Format("saleData[orderData][{0}][productType]", i), EnumUtil.ToEnumString((ProductType)data.ProductType)); - } - - i++; - } + i++; } } + } - // TestMode - if (!ParameterValidator.IsNull(TestMode)) - { - nvc.Add("testMode", (bool)TestMode ? "1" : "0"); - } - - return nvc; + // TestMode + if (!ParameterValidator.IsNull(TestMode)) + { + nvc.Add("testMode", (bool)TestMode ? "1" : "0"); } - public Response Response { get { return (Response)response; } } + return nvc; + } + + public Response Response { get { return (Response)response; } } - protected override void PrepareAndSetResponse() + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); - if (!Response.Request.Result) - { - // toss - throw new PayNlException(Response.Request.Code + " " + Response.Request.Message); - } + throw new PayNlException("rawResponse is empty!"); + } + response = JsonConvert.DeserializeObject(RawResponse); + if (!Response.Request.Result) + { + // toss + throw new PayNlException(Response.Request.Code + " " + Response.Request.Message); } } } diff --git a/PAYNLSDK/API/Transaction/Start/Response.cs b/PAYNLSDK/API/Transaction/Start/Response.cs index 1a58975..2155d5e 100644 --- a/PAYNLSDK/API/Transaction/Start/Response.cs +++ b/PAYNLSDK/API/Transaction/Start/Response.cs @@ -1,35 +1,31 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Objects; +using Newtonsoft.Json; -namespace PAYNLSDK.API.Transaction.Start -{ - public class Response : ResponseBase - { - /// - /// Information about the enduser - /// - [JsonProperty("endUser")] - public Enduser EndUser { get; set; } - /// - /// The for the started tranaction. Containing the url and transactionId - /// - [JsonProperty("transaction")] - public TransactionData Transaction { get; set; } +namespace PayNLSdk.Api.Transaction.Start; - public class Enduser - { - public string blacklist { get; set; } - } +public class Response : ResponseBase +{ + /// + /// Information about the enduser + /// + [JsonProperty("endUser")] + public Enduser EndUser { get; set; } + /// + /// The for the started tranaction. Containing the url and transactionId + /// + [JsonProperty("transaction")] + public TransactionData Transaction { get; set; } - public class TransactionData - { - [JsonProperty("transactionId")]public string TransactionId { get; set; } - [JsonProperty("paymentURL")] public string PaymentUrl { get; set; } - [JsonProperty("popupAllowed")] public string PopupAllowed { get; set; } - [JsonProperty("paymentReference")] public string PaymentReference { get; set; } - } + public class Enduser + { + public string blacklist { get; set; } + } + public class TransactionData + { + [JsonProperty("transactionId")] public string TransactionId { get; set; } + [JsonProperty("paymentURL")] public string PaymentUrl { get; set; } + [JsonProperty("popupAllowed")] public string PopupAllowed { get; set; } + [JsonProperty("paymentReference")] public string PaymentReference { get; set; } } -} +} diff --git a/PAYNLSDK/API/Validate/BankAccountNumber/Request.cs b/PAYNLSDK/API/Validate/BankAccountNumber/Request.cs index 9f1a609..3e7d1f5 100644 --- a/PAYNLSDK/API/Validate/BankAccountNumber/Request.cs +++ b/PAYNLSDK/API/Validate/BankAccountNumber/Request.cs @@ -1,57 +1,56 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Validate.BankAccountNumber +namespace PayNLSdk.Api.Validate.BankAccountNumber; + +/// +/// The request object to validate a bank account number +/// +public class Request : RequestBase { /// - /// The request object to validate a bank account number + /// The bank account number /// - public class Request : RequestBase - { - /// - /// The bank account number - /// - [JsonProperty("bankAccountNumber")] - public string BankAccountNumber { get; set; } + [JsonProperty("bankAccountNumber")] + public string BankAccountNumber { get; set; } - /// - public override bool RequiresApiToken => false; + /// + public override bool RequiresApiToken => false; - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "Validate"; + /// + protected override string Controller => "Validate"; - /// - protected override string Method => "BankAccountNumber"; + /// + protected override string Method => "BankAccountNumber"; - /// - public override System.Collections.Specialized.NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); + /// + public override System.Collections.Specialized.NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(BankAccountNumber, "bankAccountNumber"); - nvc.Add("bankAccountNumber", BankAccountNumber); + ParameterValidator.IsNotEmpty(BankAccountNumber, "bankAccountNumber"); + nvc.Add("bankAccountNumber", BankAccountNumber); - return nvc; - } + return nvc; + } - /// - /// the response from the request - /// - public Response Response => (Response)response; + /// + /// the response from the request + /// + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/BankAccountNumber/Response.cs b/PAYNLSDK/API/Validate/BankAccountNumber/Response.cs index 68c53ee..ea58229 100644 --- a/PAYNLSDK/API/Validate/BankAccountNumber/Response.cs +++ b/PAYNLSDK/API/Validate/BankAccountNumber/Response.cs @@ -1,19 +1,18 @@ -using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; -using PAYNLSDK.Converters; +using Newtonsoft.Json; +using PayNLSdk.Converters; +using System.Diagnostics.CodeAnalysis; -namespace PAYNLSDK.API.Validate.BankAccountNumber +namespace PayNLSdk.Api.Validate.BankAccountNumber; + +/// +/// The reponse object for the bank account number validation +/// +public class Response : ResponseBase { /// - /// The reponse object for the bank account number validation + /// the result from the bank account number validation /// - public class Response : ResponseBase - { - /// - /// the result from the bank account number validation - /// - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] - [SuppressMessage("ReSharper", "InconsistentNaming")] - public bool result { get; protected set; } - } + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [SuppressMessage("ReSharper", "InconsistentNaming")] + public bool result { get; protected set; } } diff --git a/PAYNLSDK/API/Validate/BankAccountNumberInternational/Request.cs b/PAYNLSDK/API/Validate/BankAccountNumberInternational/Request.cs index f1ff6f8..d752168 100644 --- a/PAYNLSDK/API/Validate/BankAccountNumberInternational/Request.cs +++ b/PAYNLSDK/API/Validate/BankAccountNumberInternational/Request.cs @@ -1,57 +1,56 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Validate.BankAccountNumberInternational +namespace PayNLSdk.Api.Validate.BankAccountNumberInternational; + +/// +/// +/// Validation request class for an international bank account number +/// +public class Request : RequestBase { - /// /// - /// Validation request class for an international bank account number + /// Bank account number /// - public class Request : RequestBase - { - /// - /// Bank account number - /// - [JsonProperty("bankAccountNumber")] - public string BankAccountNumber { get; set; } + [JsonProperty("bankAccountNumber")] + public string BankAccountNumber { get; set; } - /// - public override bool RequiresApiToken => false;// base.RequiresApiToken; + /// + public override bool RequiresApiToken => false;// base.RequiresApiToken; - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "Validate"; + /// + protected override string Controller => "Validate"; - /// - protected override string Method => "BankAccountNumberInternational"; + /// + protected override string Method => "BankAccountNumberInternational"; - /// - public override NameValueCollection GetParameters() - { - var nvc = new NameValueCollection(); + /// + public override NameValueCollection GetParameters() + { + var nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(BankAccountNumber, "bankAccountNumber"); - nvc.Add("bankAccountNumber", BankAccountNumber); + ParameterValidator.IsNotEmpty(BankAccountNumber, "bankAccountNumber"); + nvc.Add("bankAccountNumber", BankAccountNumber); - return nvc; - } + return nvc; + } - /// Gets the response. - /// The response. - public Response Response => (Response)response; + /// Gets the response. + /// The response. + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } -} +} \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/BankAccountNumberInternational/Response.cs b/PAYNLSDK/API/Validate/BankAccountNumberInternational/Response.cs index b85a1cd..7da7bb6 100644 --- a/PAYNLSDK/API/Validate/BankAccountNumberInternational/Response.cs +++ b/PAYNLSDK/API/Validate/BankAccountNumberInternational/Response.cs @@ -1,18 +1,16 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using System; +using PayNLSdk.Converters; -namespace PAYNLSDK.API.Validate.BankAccountNumberInternational +namespace PayNLSdk.Api.Validate.BankAccountNumberInternational; + +/// Class Response. +/// Implements the +public class Response : ResponseBase { - /// Class Response. - /// Implements the - public class Response : ResponseBase - { - /// - /// Gets or sets a value indicating whether this is succesful. - /// - /// true if succesful; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] - public bool Result { get; protected set; } - } -} + /// + /// Gets or sets a value indicating whether this is succesful. + /// + /// true if succesful; otherwise, false. + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + public bool Result { get; protected set; } +} \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/GetServerIps/Request.cs b/PAYNLSDK/API/Validate/GetServerIps/Request.cs index ce8c437..dddd192 100644 --- a/PAYNLSDK/API/Validate/GetServerIps/Request.cs +++ b/PAYNLSDK/API/Validate/GetServerIps/Request.cs @@ -1,52 +1,51 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Validate.GetServerIps +namespace PayNLSdk.Api.Validate.GetServerIps; + +/// +/// +/// Request class for the SERVER IPs request. +/// Implements the +/// +/// +public class Request : RequestBase { /// - /// - /// Request class for the SERVER IPs request. - /// Implements the - /// - /// - public class Request : RequestBase - { - /// - protected override int Version => 1; + protected override int Version => 1; - /// - protected override string Controller => "Validate"; + /// + protected override string Controller => "Validate"; - /// - protected override string Method => "getPayServerIps"; + /// + protected override string Method => "getPayServerIps"; - /// - public override NameValueCollection GetParameters() - { - return new NameValueCollection(); - } + /// + public override NameValueCollection GetParameters() + { + return new NameValueCollection(); + } - /// - /// Gets the response. - /// - /// The response. - public Response Response => (Response)response; + /// + /// Gets the response. + /// + /// The response. + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - string[] ips = JsonConvert.DeserializeObject(RawResponse); - Response r = new Response - { - IPAddresses = ips - }; - response = r; + throw new PayNlException("rawResponse is empty!"); } + string[] ips = JsonConvert.DeserializeObject(RawResponse); + Response r = new Response + { + IPAddresses = ips + }; + response = r; } } diff --git a/PAYNLSDK/API/Validate/GetServerIps/Response.cs b/PAYNLSDK/API/Validate/GetServerIps/Response.cs index 4d001c4..b7d7aee 100644 --- a/PAYNLSDK/API/Validate/GetServerIps/Response.cs +++ b/PAYNLSDK/API/Validate/GetServerIps/Response.cs @@ -1,20 +1,18 @@ -using System; -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; -namespace PAYNLSDK.API.Validate.GetServerIps +namespace PayNLSdk.Api.Validate.GetServerIps; + +/// +/// Response object for the . +/// Implements the +/// +/// +public class Response : ResponseBase { /// - /// Response object for the . - /// Implements the + /// Gets or sets the ip addresses. /// - /// - public class Response : ResponseBase - { - /// - /// Gets or sets the ip addresses. - /// - /// The ip addresses. - [SuppressMessage("ReSharper", "InconsistentNaming")] - public string[] IPAddresses { get; set; } - } + /// The ip addresses. + [SuppressMessage("ReSharper", "InconsistentNaming")] + public string[] IPAddresses { get; set; } } diff --git a/PAYNLSDK/API/Validate/IBAN/Request.cs b/PAYNLSDK/API/Validate/IBAN/Request.cs index 4ad35a4..e01485b 100644 --- a/PAYNLSDK/API/Validate/IBAN/Request.cs +++ b/PAYNLSDK/API/Validate/IBAN/Request.cs @@ -1,64 +1,63 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; using System.Diagnostics.CodeAnalysis; -namespace PAYNLSDK.API.Validate.IBAN +namespace PayNLSdk.Api.Validate.IBAN; + +/// +/// +/// Validate Iban Request +/// Implements the +/// +/// +public class Request : RequestBase { - /// /// - /// Validate Iban Request - /// Implements the + /// Gets or sets the iban. /// - /// - public class Request : RequestBase - { - /// - /// Gets or sets the iban. - /// - /// The iban. - [JsonProperty("iban")] - [SuppressMessage("ReSharper", "InconsistentNaming")] - public string IBAN { get; set; } + /// The iban. + [JsonProperty("iban")] + [SuppressMessage("ReSharper", "InconsistentNaming")] + public string IBAN { get; set; } - /// - public override bool RequiresApiToken => false;// base.RequiresApiToken; + /// + public override bool RequiresApiToken => false;// base.RequiresApiToken; - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "Validate"; + /// + protected override string Controller => "Validate"; - /// - protected override string Method => "IBAN"; + /// + protected override string Method => "IBAN"; - /// - public override System.Collections.Specialized.NameValueCollection GetParameters() - { - var nvc = new NameValueCollection(); + /// + public override System.Collections.Specialized.NameValueCollection GetParameters() + { + var nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(IBAN, "iban"); - nvc.Add("iban", IBAN); + ParameterValidator.IsNotEmpty(IBAN, "iban"); + nvc.Add("iban", IBAN); - return nvc; - } + return nvc; + } - /// - /// Gets the response. - /// - /// The response. - public Response Response => (Response)response; + /// + /// Gets the response. + /// + /// The response. + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/IBAN/Response.cs b/PAYNLSDK/API/Validate/IBAN/Response.cs index 35545be..7ea2073 100644 --- a/PAYNLSDK/API/Validate/IBAN/Response.cs +++ b/PAYNLSDK/API/Validate/IBAN/Response.cs @@ -1,21 +1,19 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using System; +using PayNLSdk.Converters; -namespace PAYNLSDK.API.Validate.IBAN +namespace PayNLSdk.Api.Validate.IBAN; + +/// +/// The response of . +/// Implements the +/// +/// +public class Response : ResponseBase { /// - /// The response of . - /// Implements the + /// Gets or sets a value indicating whether this is succesful. /// - /// - public class Response : ResponseBase - { - /// - /// Gets or sets a value indicating whether this is succesful. - /// - /// true if succesful; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] - public bool result { get; protected set; } - } -} + /// true if succesful; otherwise, false. + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + public bool result { get; protected set; } +} \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/IsPayServerIp/Request.cs b/PAYNLSDK/API/Validate/IsPayServerIp/Request.cs index aad4b77..116b113 100644 --- a/PAYNLSDK/API/Validate/IsPayServerIp/Request.cs +++ b/PAYNLSDK/API/Validate/IsPayServerIp/Request.cs @@ -1,62 +1,61 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Validate.IsPayServerIp +namespace PayNLSdk.Api.Validate.IsPayServerIp; + +/// +/// +/// Request to validate whether the ipaddress is a PAY server ip +/// Implements the +/// +/// +public class Request : RequestBase { - /// /// - /// Request to validate whether the ipaddress is a PAY server ip - /// Implements the + /// Gets or sets the ip address. /// - /// - public class Request : RequestBase - { - /// - /// Gets or sets the ip address. - /// - /// The ip address. - [JsonProperty("ipAddress")] - public string IpAddress { get; set; } + /// The ip address. + [JsonProperty("ipAddress")] + public string IpAddress { get; set; } - /// - public override bool RequiresApiToken => false; + /// + public override bool RequiresApiToken => false; - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "Validate"; + /// + protected override string Controller => "Validate"; - /// - protected override string Method => "isPayServerIp"; + /// + protected override string Method => "isPayServerIp"; - /// - public override System.Collections.Specialized.NameValueCollection GetParameters() - { - var nvc = new NameValueCollection(); + /// + public override System.Collections.Specialized.NameValueCollection GetParameters() + { + var nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(IpAddress, "IpAddress"); - nvc.Add("ipAddress", IpAddress); + ParameterValidator.IsNotEmpty(IpAddress, "IpAddress"); + nvc.Add("ipAddress", IpAddress); - return nvc; - } + return nvc; + } - /// - /// Gets the response. - /// - /// The response. - public Response Response => (Response)response; + /// + /// Gets the response. + /// + /// The response. + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/IsPayServerIp/Response.cs b/PAYNLSDK/API/Validate/IsPayServerIp/Response.cs index 57f8606..7e40776 100644 --- a/PAYNLSDK/API/Validate/IsPayServerIp/Response.cs +++ b/PAYNLSDK/API/Validate/IsPayServerIp/Response.cs @@ -1,21 +1,19 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using System; +using PayNLSdk.Converters; -namespace PAYNLSDK.API.Validate.IsPayServerIp +namespace PayNLSdk.Api.Validate.IsPayServerIp; + +/// +/// Response for the . +/// Implements the +/// +/// +public class Response : ResponseBase { /// - /// Response for the . - /// Implements the + /// Gets or sets a value indicating whether this is succesful. /// - /// - public class Response : ResponseBase - { - /// - /// Gets or sets a value indicating whether this is succesful. - /// - /// true if succesful; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] - public bool result { get; protected set; } - } -} + /// true if succesful; otherwise, false. + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + public bool result { get; protected set; } +} \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/KVK/Request.cs b/PAYNLSDK/API/Validate/KVK/Request.cs index 3b64f6d..553a027 100644 --- a/PAYNLSDK/API/Validate/KVK/Request.cs +++ b/PAYNLSDK/API/Validate/KVK/Request.cs @@ -1,64 +1,63 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; using System.Diagnostics.CodeAnalysis; -namespace PAYNLSDK.API.Validate.KVK +namespace PayNLSdk.Api.Validate.KVK; + +/// +/// Request to validate the KVK number +/// Implements the +/// +/// +/// +public class Request : RequestBase { /// - /// Request to validate the KVK number - /// Implements the + /// Gets or sets the "kamer van koophandel" number. /// - /// - /// - public class Request : RequestBase - { - /// - /// Gets or sets the "kamer van koophandel" number. - /// - /// The KVK. - [JsonProperty("kvk")] - [SuppressMessage("ReSharper", "InconsistentNaming")] - public string KVK { get; set; } + /// The KVK. + [JsonProperty("kvk")] + [SuppressMessage("ReSharper", "InconsistentNaming")] + public string KVK { get; set; } - /// - public override bool RequiresApiToken => false;// base.RequiresApiToken; + /// + public override bool RequiresApiToken => false;// base.RequiresApiToken; - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "Validate"; + /// + protected override string Controller => "Validate"; - /// - protected override string Method => "KVK"; + /// + protected override string Method => "KVK"; - /// - public override NameValueCollection GetParameters() - { - var nvc = new NameValueCollection(); + /// + public override NameValueCollection GetParameters() + { + var nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(KVK, "kvk"); - nvc.Add("kvk", KVK); + ParameterValidator.IsNotEmpty(KVK, "kvk"); + nvc.Add("kvk", KVK); - return nvc; - } + return nvc; + } - /// - /// Gets the response. - /// - /// The response. - public Response Response => (Response)response; + /// + /// Gets the response. + /// + /// The response. + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/KVK/Response.cs b/PAYNLSDK/API/Validate/KVK/Response.cs index 14f3d77..eda489e 100644 --- a/PAYNLSDK/API/Validate/KVK/Response.cs +++ b/PAYNLSDK/API/Validate/KVK/Response.cs @@ -1,22 +1,20 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using System; +using PayNLSdk.Converters; -namespace PAYNLSDK.API.Validate.KVK +namespace PayNLSdk.Api.Validate.KVK; + +/// +/// The response object for +/// Implements the +/// +/// +/// +public class Response : ResponseBase { /// - /// The response object for - /// Implements the + /// Gets or sets a value indicating whether this is result. /// - /// - /// - public class Response : ResponseBase - { - /// - /// Gets or sets a value indicating whether this is result. - /// - /// true if result; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] - public bool result { get; protected set; } - } + /// true if result; otherwise, false. + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + public bool result { get; protected set; } } diff --git a/PAYNLSDK/API/Validate/SOFI/Request.cs b/PAYNLSDK/API/Validate/SOFI/Request.cs index 3ffd4bd..0ad05da 100644 --- a/PAYNLSDK/API/Validate/SOFI/Request.cs +++ b/PAYNLSDK/API/Validate/SOFI/Request.cs @@ -1,55 +1,52 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; -using System; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; -namespace PAYNLSDK.API.Validate.SOFI +namespace PayNLSdk.Api.Validate.SOFI; + +public class Request : RequestBase { - public class Request : RequestBase - { - [JsonProperty("sofi")] - public string SOFI { get; set; } + [JsonProperty("sofi")] + public string SOFI { get; set; } - public override bool RequiresApiToken + public override bool RequiresApiToken + { + get { - get - { - return false;// base.RequiresApiToken; - } + return false;// base.RequiresApiToken; } + } - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "Validate"; + /// + protected override string Controller => "Validate"; - /// - protected override string Method => "SOFI"; + /// + protected override string Method => "SOFI"; - /// - public override System.Collections.Specialized.NameValueCollection GetParameters() - { - NameValueCollection nvc = new NameValueCollection(); + /// + public override System.Collections.Specialized.NameValueCollection GetParameters() + { + NameValueCollection nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(SOFI, "sofi"); - nvc.Add("sofi", SOFI); + ParameterValidator.IsNotEmpty(SOFI, "sofi"); + nvc.Add("sofi", SOFI); - return nvc; - } + return nvc; + } - public Response Response { get { return (Response)response; } } + public Response Response { get { return (Response)response; } } - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/SOFI/Response.cs b/PAYNLSDK/API/Validate/SOFI/Response.cs index c80d5c5..b24e22a 100644 --- a/PAYNLSDK/API/Validate/SOFI/Response.cs +++ b/PAYNLSDK/API/Validate/SOFI/Response.cs @@ -1,12 +1,10 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using System; +using PayNLSdk.Converters; -namespace PAYNLSDK.API.Validate.SOFI +namespace PayNLSdk.Api.Validate.SOFI; + +public class Response : ResponseBase { - public class Response : ResponseBase - { - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] - public bool result { get; protected set; } - } + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + public bool result { get; protected set; } } diff --git a/PAYNLSDK/API/Validate/SWIFT/Request.cs b/PAYNLSDK/API/Validate/SWIFT/Request.cs index 6065fd6..a3cc985 100644 --- a/PAYNLSDK/API/Validate/SWIFT/Request.cs +++ b/PAYNLSDK/API/Validate/SWIFT/Request.cs @@ -1,64 +1,63 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; using System.Diagnostics.CodeAnalysis; -namespace PAYNLSDK.API.Validate.SWIFT +namespace PayNLSdk.Api.Validate.SWIFT; + +/// +/// Request to validate a swift number. +/// Implements the +/// +/// +/// +public class Request : RequestBase { /// - /// Request to validate a swift number. - /// Implements the + /// Gets or sets the SWIFT number. /// - /// - /// - public class Request : RequestBase - { - /// - /// Gets or sets the SWIFT number. - /// - /// The swift. - [JsonProperty("swift")] - [SuppressMessage("ReSharper", "InconsistentNaming")] - public string SWIFT { get; set; } + /// The swift. + [JsonProperty("swift")] + [SuppressMessage("ReSharper", "InconsistentNaming")] + public string SWIFT { get; set; } - /// - public override bool RequiresApiToken => false; + /// + public override bool RequiresApiToken => false; - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "Validate"; + /// + protected override string Controller => "Validate"; - /// - protected override string Method => "SWIFT"; + /// + protected override string Method => "SWIFT"; - /// - public override NameValueCollection GetParameters() - { - var nvc = new NameValueCollection(); + /// + public override NameValueCollection GetParameters() + { + var nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(SWIFT, "swift"); - nvc.Add("swift", SWIFT); + ParameterValidator.IsNotEmpty(SWIFT, "swift"); + nvc.Add("swift", SWIFT); - return nvc; - } + return nvc; + } - /// - /// Gets the response. - /// - /// The response. - public Response Response => (Response)response; + /// + /// Gets the response. + /// + /// The response. + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/SWIFT/Response.cs b/PAYNLSDK/API/Validate/SWIFT/Response.cs index bea90c2..36ad2bb 100644 --- a/PAYNLSDK/API/Validate/SWIFT/Response.cs +++ b/PAYNLSDK/API/Validate/SWIFT/Response.cs @@ -1,21 +1,19 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using System; +using PayNLSdk.Converters; -namespace PAYNLSDK.API.Validate.SWIFT +namespace PayNLSdk.Api.Validate.SWIFT; + +/// +/// Response of the . +/// Implements the +/// +/// +public class Response : ResponseBase { /// - /// Response of the . - /// Implements the + /// Gets or sets a value indicating whether this is successful. /// - /// - public class Response : ResponseBase - { - /// - /// Gets or sets a value indicating whether this is successful. - /// - /// true if successful; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] - public bool result { get; protected set; } - } -} + /// true if successful; otherwise, false. + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + public bool result { get; protected set; } +} \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/Util.cs b/PAYNLSDK/API/Validate/Util.cs index 9199c89..68093f8 100644 --- a/PAYNLSDK/API/Validate/Util.cs +++ b/PAYNLSDK/API/Validate/Util.cs @@ -1,106 +1,104 @@ using Newtonsoft.Json; -using PAYNLSDK.Net; -using System; +using PayNLSdk.Net; -namespace PAYNLSDK.API.Validate +namespace PayNLSdk.Api.Validate; + +public class Util { - public class Util - { - public IClient Client { get; set; } + public IClient Client { get; set; } - private JsonSerializerSettings serializerSettings; - public JsonSerializerSettings SerializerSettings - { - get - { - if (serializerSettings == null) - { - serializerSettings = new JsonSerializerSettings(); - serializerSettings.NullValueHandling = NullValueHandling.Ignore; - } - return serializerSettings; - } - set - { - serializerSettings = value; + private JsonSerializerSettings serializerSettings; + public JsonSerializerSettings SerializerSettings + { + get + { + if (serializerSettings == null) + { + serializerSettings = new JsonSerializerSettings(); + serializerSettings.NullValueHandling = NullValueHandling.Ignore; } + return serializerSettings; } - - public Util(IClient client) : this(client, null) + set { + serializerSettings = value; } + } - public Util(IClient client, JsonSerializerSettings serializerSettings) - { - Client = client; - SerializerSettings = serializerSettings; - } + public Util(IClient client) : this(client, null) + { + } - public bool ValidatePayIP(string ipAddress) - { - IsPayServerIp.Request request = new IsPayServerIp.Request(); - request.IpAddress = ipAddress; - Client.PerformRequest(request); - return request.Response.result; - } + public Util(IClient client, JsonSerializerSettings serializerSettings) + { + Client = client; + SerializerSettings = serializerSettings; + } - public bool ValidateBankAccountNumber(string bankAccountNumber, bool international) - { - if (international) - { - BankAccountNumberInternational.Request request = new BankAccountNumberInternational.Request(); - request.BankAccountNumber = bankAccountNumber; - Client.PerformRequest(request); - return request.Response.Result; - } - else - { - BankAccountNumber.Request request = new BankAccountNumber.Request(); - request.BankAccountNumber = bankAccountNumber; - Client.PerformRequest(request); - return request.Response.result; - } - } + public bool ValidatePayIP(string ipAddress) + { + IsPayServerIp.Request request = new IsPayServerIp.Request(); + request.IpAddress = ipAddress; + Client.PerformRequest(request); + return request.Response.result; + } - public bool ValidateIBAN(string iban) + public bool ValidateBankAccountNumber(string bankAccountNumber, bool international) + { + if (international) { - IBAN.Request request = new IBAN.Request(); - request.IBAN = iban; + BankAccountNumberInternational.Request request = new BankAccountNumberInternational.Request(); + request.BankAccountNumber = bankAccountNumber; Client.PerformRequest(request); - return request.Response.result; + return request.Response.Result; } - - public bool ValidateSWIFT(string swift) + else { - SWIFT.Request request = new SWIFT.Request(); - request.SWIFT = swift; + BankAccountNumber.Request request = new BankAccountNumber.Request(); + request.BankAccountNumber = bankAccountNumber; Client.PerformRequest(request); return request.Response.result; } + } - public bool ValidateKVK(string kvk) - { - KVK.Request request = new KVK.Request(); - request.KVK = kvk; - Client.PerformRequest(request); - return request.Response.result; - } + public bool ValidateIBAN(string iban) + { + IBAN.Request request = new IBAN.Request(); + request.IBAN = iban; + Client.PerformRequest(request); + return request.Response.result; + } - public bool ValidateVAT(string vat) - { - VAT.Request request = new VAT.Request(); - request.VAT = vat; - Client.PerformRequest(request); - return request.Response.result; - } + public bool ValidateSWIFT(string swift) + { + SWIFT.Request request = new SWIFT.Request(); + request.SWIFT = swift; + Client.PerformRequest(request); + return request.Response.result; + } - public bool ValidateSOFI(string sofi) - { - SOFI.Request request = new SOFI.Request(); - request.SOFI = sofi; - Client.PerformRequest(request); - return request.Response.result; - } + public bool ValidateKVK(string kvk) + { + KVK.Request request = new KVK.Request(); + request.KVK = kvk; + Client.PerformRequest(request); + return request.Response.result; + } + + public bool ValidateVAT(string vat) + { + VAT.Request request = new VAT.Request(); + request.VAT = vat; + Client.PerformRequest(request); + return request.Response.result; + } + public bool ValidateSOFI(string sofi) + { + SOFI.Request request = new SOFI.Request(); + request.SOFI = sofi; + Client.PerformRequest(request); + return request.Response.result; } + } diff --git a/PAYNLSDK/API/Validate/VAT/Request.cs b/PAYNLSDK/API/Validate/VAT/Request.cs index 0d32c66..05f36b7 100644 --- a/PAYNLSDK/API/Validate/VAT/Request.cs +++ b/PAYNLSDK/API/Validate/VAT/Request.cs @@ -1,64 +1,63 @@ using Newtonsoft.Json; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Utilities; +using PayNLSdk.Exceptions; +using PayNLSdk.Utilities; using System.Collections.Specialized; using System.Diagnostics.CodeAnalysis; -namespace PAYNLSDK.API.Validate.VAT +namespace PayNLSdk.Api.Validate.VAT; + +/// +/// A request to validate a VAT number +/// Implements the +/// +/// +/// +public class Request : RequestBase { /// - /// A request to validate a VAT number - /// Implements the + /// Gets or sets the vat. /// - /// - /// - public class Request : RequestBase - { - /// - /// Gets or sets the vat. - /// - /// The vat. - [JsonProperty("vat")] - [SuppressMessage("ReSharper", "InconsistentNaming")] - public string VAT { get; set; } + /// The vat. + [JsonProperty("vat")] + [SuppressMessage("ReSharper", "InconsistentNaming")] + public string VAT { get; set; } - /// - public override bool RequiresApiToken => false;// base.RequiresApiToken; + /// + public override bool RequiresApiToken => false;// base.RequiresApiToken; - /// - protected override int Version => 1; + /// + protected override int Version => 1; - /// - protected override string Controller => "Validate"; + /// + protected override string Controller => "Validate"; - /// - protected override string Method => "VAT"; + /// + protected override string Method => "VAT"; - /// - public override System.Collections.Specialized.NameValueCollection GetParameters() - { - var nvc = new NameValueCollection(); + /// + public override System.Collections.Specialized.NameValueCollection GetParameters() + { + var nvc = new NameValueCollection(); - ParameterValidator.IsNotEmpty(VAT, "vat"); - nvc.Add("vat", VAT); + ParameterValidator.IsNotEmpty(VAT, "vat"); + nvc.Add("vat", VAT); - return nvc; - } + return nvc; + } - /// - /// Gets the response. - /// - /// The response. - public Response Response => (Response)response; + /// + /// Gets the response. + /// + /// The response. + public Response Response => (Response)response; - /// - protected override void PrepareAndSetResponse() + /// + protected override void PrepareAndSetResponse() + { + if (ParameterValidator.IsEmpty(rawResponse)) { - if (ParameterValidator.IsEmpty(rawResponse)) - { - throw new PayNlException("rawResponse is empty!"); - } - response = JsonConvert.DeserializeObject(RawResponse); + throw new PayNlException("rawResponse is empty!"); } + response = JsonConvert.DeserializeObject(RawResponse); } -} +} \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/VAT/Response.cs b/PAYNLSDK/API/Validate/VAT/Response.cs index 5fd185b..09861ed 100644 --- a/PAYNLSDK/API/Validate/VAT/Response.cs +++ b/PAYNLSDK/API/Validate/VAT/Response.cs @@ -1,22 +1,19 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using System; +using PayNLSdk.Converters; -namespace PAYNLSDK.API.Validate.VAT -{ +namespace PayNLSdk.Api.Validate.VAT; +/// +/// Reponse of the . +/// Implements the +/// +/// +public class Response : ResponseBase +{ /// - /// Reponse of the . - /// Implements the + /// Gets or sets a value indicating whether this is succesful. /// - /// - public class Response : ResponseBase - { - /// - /// Gets or sets a value indicating whether this is succesful. - /// - /// true if succesful; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] - public bool result { get; protected set; } - } + /// true if succesful; otherwise, false. + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + public bool result { get; protected set; } } diff --git a/PAYNLSDK/Alliance.cs b/PAYNLSDK/Alliance.cs index f986c74..66ce4e2 100644 --- a/PAYNLSDK/Alliance.cs +++ b/PAYNLSDK/Alliance.cs @@ -1,51 +1,55 @@ -using System.Diagnostics.CodeAnalysis; -using PAYNLSDK.Net; +using PayNLSdk.Api.Alliance.AddInvoice; +using PayNLSdk.Api.Alliance.AddMerchant; +using PayNLSdk.Api.Alliance.AddService; +using PayNLSdk.Api.Alliance.GetMerchant; +using PayNLSdk.Net; +using System.Diagnostics.CodeAnalysis; +using Request = PayNLSdk.Api.Alliance.GetMerchant.Request; -namespace PAYNLSDK +namespace PayNLSdk; + +/// +/// This is a part of the alliance SDK +/// +[SuppressMessage("ReSharper", "UnusedMember.Global")] +public class Alliance : IAlliance { + private readonly IClient _webClient; + /// - /// This is a part of the alliance SDK + /// Create a new API client for the Alliance API /// - [SuppressMessage("ReSharper", "UnusedMember.Global")] - public class Alliance : IAlliance + /// + public Alliance(IClient webClient) { - private readonly IClient _webClient; - - /// - /// Create a new API client for the Alliance API - /// - /// - public Alliance(IClient webClient) - { - _webClient = webClient; - } + _webClient = webClient; + } - /// - public PAYNLSDK.API.Alliance.GetMerchant.GetMerchantResult GetMerchant(API.Alliance.GetMerchant.Request request) - { - var response = _webClient.PerformRequest(request); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); - } + /// + public GetMerchantResult GetMerchant(Request request) + { + var response = _webClient.PerformRequest(request); + return Newtonsoft.Json.JsonConvert.DeserializeObject(response); + } - /// - public API.Alliance.AddMerchant.AddMerchantResult AddMerchant(API.Alliance.AddMerchant.Request request) - { - var response = _webClient.PerformRequest(request); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); - } + /// + public AddMerchantResult AddMerchant(Api.Alliance.AddMerchant.Request request) + { + var response = _webClient.PerformRequest(request); + return Newtonsoft.Json.JsonConvert.DeserializeObject(response); + } - /// - public API.Alliance.AddService.AddServiceResult AddService(API.Alliance.AddService.Request request) - { - var response = _webClient.PerformRequest(request); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); - } + /// + public AddServiceResult AddService(Api.Alliance.AddService.Request request) + { + var response = _webClient.PerformRequest(request); + return Newtonsoft.Json.JsonConvert.DeserializeObject(response); + } - /// - public API.Alliance.AddInvoice.AddInvoiceResult AddInvoice(API.Alliance.AddInvoice.Request request) - { - var response = _webClient.PerformRequest(request); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); - } + /// + public AddInvoiceResult AddInvoice(Api.Alliance.AddInvoice.Request request) + { + var response = _webClient.PerformRequest(request); + return Newtonsoft.Json.JsonConvert.DeserializeObject(response); } -} +} \ No newline at end of file diff --git a/PAYNLSDK/Api/IPayNlConfiguration.cs b/PAYNLSDK/Api/IPayNlConfiguration.cs index 9ece6bb..fcf0c04 100644 --- a/PAYNLSDK/Api/IPayNlConfiguration.cs +++ b/PAYNLSDK/Api/IPayNlConfiguration.cs @@ -1,17 +1,16 @@ -namespace PAYNLSDK.API +namespace PayNLSdk.Api; + +/// +/// An object containing all configuration for +/// +public interface IPayNlConfiguration { /// - /// An object containing all configuration for + /// The security token /// - public interface IPayNlConfiguration - { - /// - /// The security token - /// - string ApiToken { get; } - /// - /// The service Id, - /// - string ServiceId { get; } - } -} \ No newline at end of file + string ApiToken { get; } + /// + /// The service Id, + /// + string ServiceId { get; } +} diff --git a/PAYNLSDK/Api/PayNlConfiguration.cs b/PAYNLSDK/Api/PayNlConfiguration.cs index f698463..24292d3 100644 --- a/PAYNLSDK/Api/PayNlConfiguration.cs +++ b/PAYNLSDK/Api/PayNlConfiguration.cs @@ -1,34 +1,27 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace PayNLSdk.Api; -namespace PAYNLSDK.API +/// +public class PayNlConfiguration : IPayNlConfiguration { /// - public class PayNlConfiguration : IPayNlConfiguration + public PayNlConfiguration() { - /// - public PayNlConfiguration() - { - } + } - /// - public PayNlConfiguration(string serviceId, string apiToken) - { - ServiceId = serviceId; - ApiToken = apiToken; - } + /// + public PayNlConfiguration(string serviceId, string apiToken) + { + ServiceId = serviceId; + ApiToken = apiToken; + } - /// - /// PAYNL Service ID - /// - public string ServiceId { get; set; } + /// + /// PAYNL Service ID + /// + public string ServiceId { get; set; } - /// - /// PAYNL API Token - /// - public string ApiToken { get; set; } - } + /// + /// PAYNL API Token + /// + public string ApiToken { get; set; } } diff --git a/PAYNLSDK/Api/Transaction/Enduser.cs b/PAYNLSDK/Api/Transaction/Enduser.cs index 6e11ba4..e24c67e 100644 --- a/PAYNLSDK/Api/Transaction/Enduser.cs +++ b/PAYNLSDK/Api/Transaction/Enduser.cs @@ -1,131 +1,131 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; -using PAYNLSDK.Converters; - -namespace PAYNLSDK.Objects +using Newtonsoft.Json; +using PayNLSdk.Api.Transaction.Info; +using PayNLSdk.Converters; +using PayNLSdk.Enums; +using PayNLSdk.Objects; +using System; + +namespace PayNLSdk.Api.Transaction; + +/// +/// Provides details of the EndUser. +/// +public class EndUser { + // @DISABLED@ + //[JsonProperty("accessCode")] + //public string AccessCode { get; set; } + + /// + /// Unique reference of customer + /// + [JsonProperty("customerReference")] + public string CustomerReference { get; set; } + + /// + /// End User's Language + /// + [JsonProperty("language")] + public string Language { get; set; } + + /// + /// End User's Initials + /// + [JsonProperty("initials")] + public string Initials { get; set; } + + /// + /// End User's Gender + /// + [JsonProperty("gender"), JsonConverter(typeof(GenderConverter))] + public Gender? Gender { get; set; } + + /// + /// End User's Last Name + /// + [JsonProperty("lastName")] + public string Lastname { get; set; } + + /// + /// End User's Date of Birth + /// + [JsonProperty("dob"), JsonConverter(typeof(DMYConverter))] + public DateTime? BirthDate { get; set; } + + /// + /// End User's Phone Number + /// + [JsonProperty("phoneNumber")] + public string PhoneNumber { get; set; } + + /// + /// End User's Email Address + /// + [JsonProperty("emailAddress")] + public string EmailAddress { get; set; } + + /// + /// End User's Bank Account Number. + /// Note in most cases the IBAN will be used. + /// + [JsonProperty("bankAccount")] + public string BankAccount { get; set; } + + /// + /// End User's IBAN + /// + [JsonProperty("iban")] + public string IBAN { get; set; } + + /// + /// End User's BIC + /// + [JsonProperty("bic")] + public string BIC { get; set; } + + [JsonProperty("sendConfirmMail")] + public bool? SendConfirmMail { get; set; } + + //[JsonProperty("confirmMailTemplate")] + //public string ConfirmMailTemplate { get; set; } + /// - /// Provides details of the EndUser. - /// - public class EndUser - { - // @DISABLED@ - //[JsonProperty("accessCode")] - //public string AccessCode { get; set; } - - /// - /// Unique reference of customer - /// - [JsonProperty("customerReference")] - public string CustomerReference { get; set; } - - /// - /// End User's Language - /// - [JsonProperty("language")] - public string Language { get; set; } - - /// - /// End User's Initials - /// - [JsonProperty("initials")] - public string Initials { get; set; } - - /// - /// End User's Gender - /// - [JsonProperty("gender"), JsonConverter(typeof(GenderConverter))] - public Gender? Gender { get; set; } - - /// - /// End User's Last Name - /// - [JsonProperty("lastName")] - public string Lastname { get; set; } - - /// - /// End User's Date of Birth - /// - [JsonProperty("dob"), JsonConverter(typeof(DMYConverter))] - public DateTime? BirthDate { get; set; } - - /// - /// End User's Phone Number - /// - [JsonProperty("phoneNumber")] - public string PhoneNumber { get; set; } - - /// - /// End User's Email Address - /// - [JsonProperty("emailAddress")] - public string EmailAddress { get; set; } - - /// - /// End User's Bank Account Number. - /// Note in most cases the IBAN will be used. - /// - [JsonProperty("bankAccount")] - public string BankAccount { get; set; } - - /// - /// End User's IBAN - /// - [JsonProperty("iban")] - public string IBAN { get; set; } - - /// - /// End User's BIC - /// - [JsonProperty("bic")] - public string BIC { get; set; } - - [JsonProperty("sendConfirmMail")] - public bool? SendConfirmMail { get; set; } - - //[JsonProperty("confirmMailTemplate")] - //public string ConfirmMailTemplate { get; set; } - - /// - /// End User's Address - /// - [JsonProperty("address")] - public Address Address { get; set; } - - /// - /// End User's Invoice Address - /// - [JsonProperty("invoiceAddress")] - public Address InvoiceAddress { get; set; } - - //[JsonProperty("saleData")] - //public SaleData? SalesData { get; protected set; } - - /// - /// End User's Payment Details - /// - [JsonProperty("paymentDetails")] - public PaymentDetails PaymentDetails { get; set; } - - /// - /// End User's Storno Details if applicable - /// - [JsonProperty("stornoDetails")] - public StornoDetails StornoDetails { get; set; } - - /// - /// End User's Stats Details if applicable - /// - [JsonProperty("statsDetails")] - public StatsDetails StatsDetails { get; set; } - - /// - /// Company information of the EndUser - /// - [JsonProperty("company")] - public Company Company { get; set; } - - } + /// End User's Address + /// + [JsonProperty("address")] + public Address Address { get; set; } + + /// + /// End User's Invoice Address + /// + [JsonProperty("invoiceAddress")] + public Address InvoiceAddress { get; set; } + + //[JsonProperty("saleData")] + //public SaleData? SalesData { get; protected set; } + + /// + /// End User's Payment Details + /// + [JsonProperty("paymentDetails")] + public PaymentDetails PaymentDetails { get; set; } + + /// + /// End User's Storno Details if applicable + /// + [JsonProperty("stornoDetails")] + public StornoDetails StornoDetails { get; set; } + + /// + /// End User's Stats Details if applicable + /// + [JsonProperty("statsDetails")] + public StatsDetails StatsDetails { get; set; } + + /// + /// Company information of the EndUser + /// + [JsonProperty("company")] + public Company Company { get; set; } } diff --git a/PAYNLSDK/Api/Transaction/Info/ResponseExtentions.cs b/PAYNLSDK/Api/Transaction/Info/ResponseExtentions.cs index c03570d..ec39292 100644 --- a/PAYNLSDK/Api/Transaction/Info/ResponseExtentions.cs +++ b/PAYNLSDK/Api/Transaction/Info/ResponseExtentions.cs @@ -1,51 +1,50 @@ -using PAYNLSDK.Enums; +using PayNLSdk.Enums; -namespace PAYNLSDK.API.Transaction.Info +namespace PayNLSdk.Api.Transaction.Info; + +/// +/// Extentions methods +/// +public static class ResponseExtentions { /// - /// Extentions methods + /// Checks whether a status is a PAID status /// - public static class ResponseExtentions + /// True if PAID, false otherwise + public static bool IsPaid(this Response response) { - /// - /// Checks whether a status is a PAID status - /// - /// True if PAID, false otherwise - public static bool IsPaid(this Response response) - { - return response?.PaymentDetails?.State == PaymentStatus.PAID; - } + return response?.PaymentDetails?.State == PaymentStatus.PAID; + } - /// - /// Checks whether a status is a CANCELLED status - /// - /// True if CANCELLED, false otherwise - public static bool IsCancelled(this Response response) - { - return response?.PaymentDetails?.State == PaymentStatus.CANCEL; - } + /// + /// Checks whether a status is a CANCELLED status + /// + /// True if CANCELLED, false otherwise + public static bool IsCancelled(this Response response) + { + return response?.PaymentDetails?.State == PaymentStatus.CANCEL; + } - /// - /// Checks whether a status is a PENDING status - /// - /// True if PENDING, false otherwise - public static bool IsPending(this Response response) - { - var status = response?.PaymentDetails?.State; - return status == PaymentStatus.PENDING_1 || - status == PaymentStatus.PENDING_2 || - status == PaymentStatus.PENDING_3 || - status == PaymentStatus.VERIFY; - } + /// + /// Checks whether a status is a PENDING status + /// + /// True if PENDING, false otherwise + public static bool IsPending(this Response response) + { + var status = response?.PaymentDetails?.State; + return status == PaymentStatus.PENDING_1 || + status == PaymentStatus.PENDING_2 || + status == PaymentStatus.PENDING_3 || + status == PaymentStatus.VERIFY; + } - /// - /// Checks whether a status is a VERIFY status - /// - /// - /// True if VERIFY, false otherwise - public static bool IsVerify(this Response response) - { - return response?.PaymentDetails?.State == PaymentStatus.VERIFY; - } + /// + /// Checks whether a status is a VERIFY status + /// + /// + /// True if VERIFY, false otherwise + public static bool IsVerify(this Response response) + { + return response?.PaymentDetails?.State == PaymentStatus.VERIFY; } -} \ No newline at end of file +} diff --git a/PAYNLSDK/Api/Transaction/Info/StornoDetails.cs b/PAYNLSDK/Api/Transaction/Info/StornoDetails.cs index d08d2cb..19e5221 100644 --- a/PAYNLSDK/Api/Transaction/Info/StornoDetails.cs +++ b/PAYNLSDK/Api/Transaction/Info/StornoDetails.cs @@ -1,66 +1,64 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Api.Transaction.Info; + +/// +/// Storno Details +/// +public class StornoDetails { /// - /// Storno Details + /// ID of the refund /// - public class StornoDetails - { - /// - /// ID of the refund - /// - [JsonProperty("stornoId")] - public int? StornoId { get; protected set; } + [JsonProperty("stornoId")] + public int? StornoId { get; protected set; } - /// - /// Refund amount - /// - [JsonProperty("stornoAmount")] - public int? StornoAmount { get; protected set; } + /// + /// Refund amount + /// + [JsonProperty("stornoAmount")] + public int? StornoAmount { get; protected set; } - /// - /// Number of the bankaccount the refund is deposited to - /// - [JsonProperty("bankAccount")] - public string BankAccount { get; protected set; } + /// + /// Number of the bankaccount the refund is deposited to + /// + [JsonProperty("bankAccount")] + public string BankAccount { get; protected set; } - /// - /// IBAN of the bankaccount the refund is deposited to - /// - [JsonProperty("iban")] - public string IBAN { get; protected set; } + /// + /// IBAN of the bankaccount the refund is deposited to + /// + [JsonProperty("iban")] + public string IBAN { get; protected set; } - /// - /// BIC of the bankaccount the refund is deposited to - /// - [JsonProperty("bic")] - public string bic { get; protected set; } + /// + /// BIC of the bankaccount the refund is deposited to + /// + [JsonProperty("bic")] + public string bic { get; protected set; } - /// - /// City of the bankaccount owner - /// - [JsonProperty("city")] - public string City { get; protected set; } + /// + /// City of the bankaccount owner + /// + [JsonProperty("city")] + public string City { get; protected set; } - /// - /// Date and time the payment is refunded - /// - [JsonProperty("datetime")] - public string Date { get; protected set; } + /// + /// Date and time the payment is refunded + /// + [JsonProperty("datetime")] + public string Date { get; protected set; } - /// - /// Reason of the refund - /// - [JsonProperty("reason")] - public string Reason { get; protected set; } + /// + /// Reason of the refund + /// + [JsonProperty("reason")] + public string Reason { get; protected set; } - /// - /// The email address the refund confirmation is sent to - /// - [JsonProperty("emailAdress")] - public string EmailAddress { get; protected set; } + /// + /// The email address the refund confirmation is sent to + /// + [JsonProperty("emailAdress")] + public string EmailAddress { get; protected set; } - } } diff --git a/PAYNLSDK/Api/Transaction/Start/TransactionData.cs b/PAYNLSDK/Api/Transaction/Start/TransactionData.cs index d1e56ed..1cd42ba 100644 --- a/PAYNLSDK/Api/Transaction/Start/TransactionData.cs +++ b/PAYNLSDK/Api/Transaction/Start/TransactionData.cs @@ -1,72 +1,71 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Converters; +using Newtonsoft.Json; +using PayNLSdk.Converters; +using System; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Api.Transaction.Start; + +/// +/// Transaction data +/// +public class TransactionData { /// - /// Transaction data + /// The currency of the transaction. If omitted, EUR is used. /// - public class TransactionData - { - /// - /// The currency of the transaction. If omitted, EUR is used. - /// - [JsonProperty("currency")] - public string Currency { get; set; } + [JsonProperty("currency")] + public string Currency { get; set; } - /// - /// Cost for VAT - /// - [JsonProperty("costsVat")] - public int? CostsVat { get; set; } + /// + /// Cost for VAT + /// + [JsonProperty("costsVat")] + public int? CostsVat { get; set; } - // No documentation is available to implement this - //[JsonProperty("excludeCosts")] - //public Array ExcludeCosts { get; set; } + // No documentation is available to implement this + //[JsonProperty("excludeCosts")] + //public Array ExcludeCosts { get; set; } - /// - /// The URL of the exchange file that needs to be called - /// - [JsonProperty("orderExchangeUrl")] - public string OrderExchangeUrl { get; set; } + /// + /// The URL of the exchange file that needs to be called + /// + [JsonProperty("orderExchangeUrl")] + public string OrderExchangeUrl { get; set; } - /// - /// Description belonging to the order - /// - [JsonProperty("description")] - public string Description { get; set; } + /// + /// Description belonging to the order + /// + [JsonProperty("description")] + public string Description { get; set; } + + /// + /// Expire date of the transaction + /// + [JsonProperty("expireDate")] + public DateTime? ExpireDate { get; set; } - /// - /// Expire date of the transaction - /// - [JsonProperty("expireDate")] - public DateTime? ExpireDate { get; set; } + /// + /// The number belonging to the order + /// + [JsonProperty("orderNumber")] + public string OrderNumber { get; set; } - /// - /// The number belonging to the order - /// - [JsonProperty("orderNumber")] - public string OrderNumber { get; set; } + /// + /// Unique id of the enduser + /// + [JsonProperty("enduserId")] + public int? EnduserId { get; set; } - /// - /// Unique id of the enduser - /// - [JsonProperty("enduserId")] - public int? EnduserId { get; set; } - - /// - /// Whether to sent a confimation email - /// - [JsonProperty("sendReminderEmail"), JsonConverter(typeof(BooleanConverter))] - public bool SendReminderEmail { get; set; } + /// + /// Whether to sent a confimation email + /// + [JsonProperty("sendReminderEmail"), JsonConverter(typeof(BooleanConverter))] + public bool SendReminderEmail { get; set; } - /// - /// The id of mailtemplate in case a confirmation mail needs to be sent - /// - [JsonProperty("reminderMailTemplateId")] - public int? ReminderMailTemplateId { get; set; } + /// + /// The id of mailtemplate in case a confirmation mail needs to be sent + /// + [JsonProperty("reminderMailTemplateId")] + public int? ReminderMailTemplateId { get; set; } - } } diff --git a/PAYNLSDK/Api/Transaction/StatsDetails.cs b/PAYNLSDK/Api/Transaction/StatsDetails.cs index 183e047..233cc20 100644 --- a/PAYNLSDK/Api/Transaction/StatsDetails.cs +++ b/PAYNLSDK/Api/Transaction/StatsDetails.cs @@ -1,65 +1,62 @@ using Newtonsoft.Json; -using System; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Api.Transaction; + +/// +/// General Statistics details. +/// These can be used to track your own statistics on transactions and will be returned when Transaction Info is requested. +/// +public class StatsDetails { /// - /// General Statistics details. - /// These can be used to track your own statistics on transactions and will be returned when Transaction Info is requested. + /// ID for the Payment session these details belong to /// - public class StatsDetails - { - /// - /// ID for the Payment session these details belong to - /// - [JsonProperty("paymentSessionId")] - public long PaymentSessionId { get; set; } - - /// - /// The used tool code which can be tracked in the stats - /// - [JsonProperty("tool")] - public string Tool { get; set; } + [JsonProperty("paymentSessionId")] + public long PaymentSessionId { get; set; } - /// - /// The used info code which can be tracked in the stats - /// - [JsonProperty("info")] - public string Info { get; set; } + /// + /// The used tool code which can be tracked in the stats + /// + [JsonProperty("tool")] + public string Tool { get; set; } - /// - /// The id of a promotor / affiliate. - /// In general, you won't use this unless you know the ID's of your affiliate's - /// - [JsonProperty("promotorId")] - public int? PromotorId { get; set; } + /// + /// The used info code which can be tracked in the stats + /// + [JsonProperty("info")] + public string Info { get; set; } - /// - /// The first free value which can be tracked in the stats - /// - [JsonProperty("extra1")] - public string Extra1 { get; set; } + /// + /// The id of a promotor / affiliate. + /// In general, you won't use this unless you know the ID's of your affiliate's + /// + [JsonProperty("promotorId")] + public int? PromotorId { get; set; } - /// - /// The second free value which can be tracked in the stats - /// - [JsonProperty("extra2")] - public string Extra2 { get; set; } + /// + /// The first free value which can be tracked in the stats + /// + [JsonProperty("extra1")] + public string Extra1 { get; set; } - /// - /// The third free value which can be tracked in the stats - /// - [JsonProperty("extra3")] - public string Extra3 { get; set; } + /// + /// The second free value which can be tracked in the stats + /// + [JsonProperty("extra2")] + public string Extra2 { get; set; } - /// - /// Option to send multiple values via an array which can be tracked in the stats - /// - [JsonProperty("transferData")] - public string[] TransferData { get; set; } + /// + /// The third free value which can be tracked in the stats + /// + [JsonProperty("extra3")] + public string Extra3 { get; set; } - [JsonProperty("object")] - public object Object { get; set; } - } + /// + /// Option to send multiple values via an array which can be tracked in the stats + /// + [JsonProperty("transferData")] + public string[] TransferData { get; set; } + [JsonProperty("object")] + public object Object { get; set; } } diff --git a/PAYNLSDK/Api/Validate/Util.cs.orig b/PAYNLSDK/Api/Validate/Util.cs.orig new file mode 100644 index 0000000..b48f2f2 --- /dev/null +++ b/PAYNLSDK/Api/Validate/Util.cs.orig @@ -0,0 +1,171 @@ +using Newtonsoft.Json; +using PayNLSdk.Net; +using System; +using System.Diagnostics.Contracts; + +namespace PayNLSdk.API.Validate +{ + /// +<<<<<<< HEAD + /// Utility methods which you can use to validate your input data +======= + /// Internal utilities +>>>>>>> origin/main + /// + public class Util + { + private readonly IClient _client; + + private JsonSerializerSettings serializerSettings; + + /// + /// settings for the JSON serializer + /// + public JsonSerializerSettings SerializerSettings + { + get + { + if (serializerSettings != null) + { + return serializerSettings; + } + + serializerSettings = new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore + }; + return serializerSettings; + } + set => serializerSettings = value; + } + + /// + /// Creates a new instance from the Utility class + /// + /// + public Util(IClient client) : this(client, null) + { + } + + /// + /// Creates a new instance from the Utility class + /// + /// + /// + public Util(IClient client, JsonSerializerSettings serializerSettings) + { + _client = client; + SerializerSettings = serializerSettings; + } + + /// + /// use the payNl service to validate the ipaddress which called you + /// + /// an input string + /// true if it matches + public bool ValidatePayIP(string ipAddress) + { + IsPayServerIp.Request request = new IsPayServerIp.Request(); + request.IpAddress = ipAddress; + _client.PerformRequest(request); + return request.Response.result; + } + + /// + /// use the payNl service to validate the bank account + /// + /// an input string + /// true if it is an international number + /// true if it matches + public bool ValidateBankAccountNumber(string bankAccountNumber, bool international) + { + if (international) + { + BankAccountNumberInternational.Request request = new BankAccountNumberInternational.Request(); + request.BankAccountNumber = bankAccountNumber; + _client.PerformRequest(request); + return request.Response.Result; + } + else + { + BankAccountNumber.Request request = new BankAccountNumber.Request(); + request.BankAccountNumber = bankAccountNumber; + _client.PerformRequest(request); + return request.Response.result; + } + } + + /// +<<<<<<< HEAD + /// use the payNl service to validate the IBAN number + /// + /// an input string + /// true if it matches +======= + /// Validates an iban number + /// + /// + /// +>>>>>>> origin/main + public bool ValidateIBAN(string iban) + { + IBAN.Request request = new IBAN.Request(); + request.IBAN = iban; + _client.PerformRequest(request); + return request.Response.result; + } + + /// + /// use the payNl service to validate the SWIFT number + /// + /// an input string + /// true if it matches + public bool ValidateSWIFT(string swift) + { + SWIFT.Request request = new SWIFT.Request(); + request.SWIFT = swift; + _client.PerformRequest(request); + return request.Response.result; + } + + /// + /// use the payNl service to validate the KVK number + /// + /// an input string + /// true if it matches + public bool ValidateKVK(string kvk) + { + KVK.Request request = new KVK.Request(); + request.KVK = kvk; + _client.PerformRequest(request); + return request.Response.result; + } + + /// + /// use the payNl service to validate the VAT number + /// + /// an input string + /// true if it matches + public bool ValidateVAT(string vat) + { + VAT.Request request = new VAT.Request(); + request.VAT = vat; + _client.PerformRequest(request); + return request.Response.result; + } + + /// + /// use the payNl service to validate the SOFI number + /// + /// an input string + /// true if it matches + public bool ValidateSOFI(string sofi) + { + SOFI.Request request = new SOFI.Request(); + request.SOFI = sofi; + _client.PerformRequest(request); + return request.Response.result; + } + + } +} diff --git a/PAYNLSDK/Banktransfer.cs b/PAYNLSDK/Banktransfer.cs index 69d96a5..289f758 100644 --- a/PAYNLSDK/Banktransfer.cs +++ b/PAYNLSDK/Banktransfer.cs @@ -1,52 +1,47 @@ -using PAYNLSDK.Net; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using PayNLSdk.Api.Banktransfer.Add; +using PayNLSdk.Net; -namespace PAYNLSDK +namespace PayNLSdk; + +/// +/// the Bank Transfer API +/// +public class Banktransfer { + private readonly IClient _webClient; + /// - /// the Bank Transfer API + /// Create a new BankTransfer api object /// - public class Banktransfer + /// + public Banktransfer(IClient webClient) { - private readonly IClient _webClient; - - /// - /// Create a new BankTransfer api object - /// - /// - public Banktransfer(IClient webClient) - { - _webClient = webClient; - } + _webClient = webClient; + } - /// - /// - /// - /// - /// - public API.Banktransfer.Add.Response Add(PAYNLSDK.API.Banktransfer.Add.Request request) - { - _webClient.PerformRequest(request); - return request.Response; - } + /// + /// + /// + /// + /// + public Response Add(Request request) + { + _webClient.PerformRequest(request); + return request.Response; + } - /// - /// - /// - /// - /// - /// - /// - /// - public API.Banktransfer.Add.Response Add(int amount, string bankAccountHolder, string bankAccountNumber, string bankAccountBic) - { - var request = new API.Banktransfer.Add.Request(amount, bankAccountHolder, bankAccountNumber, bankAccountBic); - _webClient.PerformRequest(request); - return request.Response; - } + /// + /// + /// + /// + /// + /// + /// + /// + public Response Add(int amount, string bankAccountHolder, string bankAccountNumber, string bankAccountBic) + { + var request = new Request(amount, bankAccountHolder, bankAccountNumber, bankAccountBic); + _webClient.PerformRequest(request); + return request.Response; } } diff --git a/PAYNLSDK/Converters/BooleanConverter.cs b/PAYNLSDK/Converters/BooleanConverter.cs index 24621e7..2f2621a 100644 --- a/PAYNLSDK/Converters/BooleanConverter.cs +++ b/PAYNLSDK/Converters/BooleanConverter.cs @@ -1,36 +1,35 @@ using Newtonsoft.Json; using System; -namespace PAYNLSDK.Converters +namespace PayNLSdk.Converters; + +/// +/// A boolean json converter for newtonsoft +/// +internal class BooleanConverter : JsonConverter { - /// - /// A boolean json converter for newtonsoft - /// - internal class BooleanConverter : JsonConverter + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + try { - try - { - var result = serializer.Deserialize(reader); - return (result == 1); - } - catch (Exception) - { - return Boolean.Parse(serializer.Deserialize(reader)); - } + var result = serializer.Deserialize(reader); + return (result == 1); } - - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + catch (Exception) { - bool result = Convert.ToBoolean(value); - writer.WriteValue(result); - return; + return Boolean.Parse(serializer.Deserialize(reader)); } + } - public override bool CanConvert(Type objectType) - { - return typeof(Boolean).IsAssignableFrom(objectType); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + bool result = Convert.ToBoolean(value); + writer.WriteValue(result); + return; + } + + public override bool CanConvert(Type objectType) + { + return typeof(Boolean).IsAssignableFrom(objectType); } -} +} \ No newline at end of file diff --git a/PAYNLSDK/Converters/CountryOptionConverter.cs b/PAYNLSDK/Converters/CountryOptionConverter.cs index 9bb0f60..ecd4a0f 100644 --- a/PAYNLSDK/Converters/CountryOptionConverter.cs +++ b/PAYNLSDK/Converters/CountryOptionConverter.cs @@ -1,34 +1,30 @@ using Newtonsoft.Json; -using PAYNLSDK.Objects; +using PayNLSdk.Objects; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace PAYNLSDK.Converters +namespace PayNLSdk.Converters; + +internal class CountryOptionConverter : JsonConverter { - internal class CountryOptionConverter : JsonConverter + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + if (reader.TokenType == JsonToken.StartObject) { - if (reader.TokenType == JsonToken.StartObject) - { - var dict = serializer.Deserialize>(reader); - return dict; - } - throw new JsonSerializationException(String.Format("Unexpected token '{0}' when parsing country options.", reader.TokenType)); - + var dict = serializer.Deserialize>(reader); + return dict; } + throw new JsonSerializationException(String.Format("Unexpected token '{0}' when parsing country options.", reader.TokenType)); - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - //throw new NotImplementedException(); - } + } - public override bool CanConvert(Type objectType) - { - return typeof(CountryOptions).IsAssignableFrom(objectType); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + //throw new NotImplementedException(); + } + + public override bool CanConvert(Type objectType) + { + return typeof(CountryOptions).IsAssignableFrom(objectType); } } diff --git a/PAYNLSDK/Converters/DMYConverter.cs b/PAYNLSDK/Converters/DMYConverter.cs index c0e5af1..05893d0 100644 --- a/PAYNLSDK/Converters/DMYConverter.cs +++ b/PAYNLSDK/Converters/DMYConverter.cs @@ -1,40 +1,40 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Utilities; +using Newtonsoft.Json; +using PayNLSdk.Utilities; +using System; -namespace PAYNLSDK.Converters +namespace PayNLSdk.Converters; + +internal class DMYConverter : JsonConverter { - internal class DMYConverter : JsonConverter + private const string Format = "dd-MM-yyyy"; + private static readonly string[] ParseFormats = { + // - argument. + "d-M-yyyy", "dd-MM-yyyy", + // Slash argument. + "d/M/yyyy", "dd/MM/yyyy" + }; + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - private const string Format = "dd-MM-yyyy"; - private static readonly string[] ParseFormats = { - // - argument. - "d-M-yyyy", "dd-MM-yyyy", - // Slash argument. - "d/M/yyyy", "dd/MM/yyyy" - }; - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + if (!(value is DateTime dateTime)) { - if (!(value is DateTime dateTime)) - { - throw new JsonSerializationException("Expected value of type 'DateTime'."); - } + throw new JsonSerializationException("Expected value of type 'DateTime'."); + } - if (dateTime.Kind == DateTimeKind.Unspecified) - { - throw new JsonSerializationException("Cannot convert date time with an unspecified kind"); - } - var convertedDateTime = dateTime.ToString(Format); - writer.WriteValue(convertedDateTime); + if (dateTime.Kind == DateTimeKind.Unspecified) + { + throw new JsonSerializationException("Cannot convert date time with an unspecified kind"); } + var convertedDateTime = dateTime.ToString(Format); + writer.WriteValue(convertedDateTime); + } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch (reader.TokenType) { - switch (reader.TokenType) - { - case JsonToken.Null: - return null; - case JsonToken.Date: + case JsonToken.Null: + return null; + case JsonToken.Date: { var dateTime = (DateTime)reader.Value; if (dateTime.Kind == DateTimeKind.Unspecified) @@ -43,7 +43,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } return dateTime; } - case JsonToken.String: + case JsonToken.String: { DateTime dateTime; /*string[] formats = { "d/M/yyyy", "dd/MM/yyyy", "d-M-yyyy", "dd-MM-yyyy" };*/ @@ -64,18 +64,17 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } return null; } - default: - throw new JsonSerializationException($"Unexpected token '{reader.TokenType}' when parsing date."); - } + default: + throw new JsonSerializationException($"Unexpected token '{reader.TokenType}' when parsing date."); } + } - public override bool CanConvert(Type objectType) - { - Type t = (Reflection.IsNullable(objectType)) - ? Nullable.GetUnderlyingType(objectType) - : objectType; + public override bool CanConvert(Type objectType) + { + Type t = (Reflection.IsNullable(objectType)) + ? Nullable.GetUnderlyingType(objectType) + : objectType; - return t == typeof(DateTime); - } + return t == typeof(DateTime); } } diff --git a/PAYNLSDK/Converters/EnumConversionBase.cs b/PAYNLSDK/Converters/EnumConversionBase.cs index e08d811..889c5f6 100644 --- a/PAYNLSDK/Converters/EnumConversionBase.cs +++ b/PAYNLSDK/Converters/EnumConversionBase.cs @@ -1,21 +1,20 @@ using Newtonsoft.Json; using System; -namespace PAYNLSDK.Converters +namespace PayNLSdk.Converters; + +internal abstract class EnumConversionBase : JsonConverter { - internal abstract class EnumConversionBase : JsonConverter - { - public abstract Type EnumType { get; } + public abstract Type EnumType { get; } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - return Enums.EnumUtil.ToEnum(serializer.Deserialize(reader), EnumType); - } + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + return Enums.EnumUtil.ToEnum(serializer.Deserialize(reader), EnumType); + } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - string result = Enums.EnumUtil.ToEnumString(value, EnumType); - writer.WriteValue(result); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + string result = Enums.EnumUtil.ToEnumString(value, EnumType); + writer.WriteValue(result); } } diff --git a/PAYNLSDK/Converters/ErrorIdConverter.cs b/PAYNLSDK/Converters/ErrorIdConverter.cs index d901030..5b52c9d 100644 --- a/PAYNLSDK/Converters/ErrorIdConverter.cs +++ b/PAYNLSDK/Converters/ErrorIdConverter.cs @@ -1,48 +1,43 @@ using Newtonsoft.Json; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace PAYNLSDK.Converters +namespace PayNLSdk.Converters; + +internal class ErrorIdConverter : JsonConverter { - internal class ErrorIdConverter : JsonConverter + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + string result = serializer.Deserialize(reader); + if (result == String.Empty) { - string result = serializer.Deserialize(reader); - if (result == String.Empty) - { - return 0; - } - try - { - return Int32.Parse(result); - } - catch (Exception e) - { - throw new JsonSerializationException(String.Format("Unexpected conversion '{0}' when parsing errorId.", result), e); - } + return 0; } - - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + try { - if (value == null) - { - writer.WriteNull(); - return; - } - //if (CanConvert(value.GetType())) - //{ - serializer.Serialize(writer, value); - //} - //throw new JsonSerializationException(String.Format("Can't serialize type {0} to Integer.", value.GetType())); + return Int32.Parse(result); } + catch (Exception e) + { + throw new JsonSerializationException(String.Format("Unexpected conversion '{0}' when parsing errorId.", result), e); + } + } - public override bool CanConvert(Type objectType) + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + if (value == null) { - return typeof(int).IsAssignableFrom(objectType); + writer.WriteNull(); + return; } + //if (CanConvert(value.GetType())) + //{ + serializer.Serialize(writer, value); + //} + //throw new JsonSerializationException(String.Format("Can't serialize type {0} to Integer.", value.GetType())); + } + + public override bool CanConvert(Type objectType) + { + return typeof(int).IsAssignableFrom(objectType); } -} +} \ No newline at end of file diff --git a/PAYNLSDK/Converters/GenderConverter.cs b/PAYNLSDK/Converters/GenderConverter.cs index 4fd65d6..eb22ba0 100644 --- a/PAYNLSDK/Converters/GenderConverter.cs +++ b/PAYNLSDK/Converters/GenderConverter.cs @@ -1,17 +1,16 @@ using System; -namespace PAYNLSDK.Converters +namespace PayNLSdk.Converters; + +internal class GenderConverter : EnumConversionBase { - internal class GenderConverter : EnumConversionBase + public override Type EnumType { - public override Type EnumType - { - get { return typeof(Enums.Gender); } - } + get { return typeof(Enums.Gender); } + } - public override bool CanConvert(Type objectType) - { - throw new NotImplementedException(); - } + public override bool CanConvert(Type objectType) + { + throw new NotImplementedException(); } } diff --git a/PAYNLSDK/Converters/ProductTypeConverter.cs b/PAYNLSDK/Converters/ProductTypeConverter.cs index 61546f9..2b35e58 100644 --- a/PAYNLSDK/Converters/ProductTypeConverter.cs +++ b/PAYNLSDK/Converters/ProductTypeConverter.cs @@ -1,14 +1,13 @@ using System; -namespace PAYNLSDK.Converters +namespace PayNLSdk.Converters; + +internal class ProductTypeConverter : EnumConversionBase { - internal class ProductTypeConverter : EnumConversionBase - { - public override Type EnumType => typeof(Enums.ProductType); + public override Type EnumType => typeof(Enums.ProductType); - public override bool CanConvert(Type objectType) - { - throw new NotImplementedException(); - } + public override bool CanConvert(Type objectType) + { + throw new NotImplementedException(); } } diff --git a/PAYNLSDK/Converters/TaxClassConverter.cs b/PAYNLSDK/Converters/TaxClassConverter.cs index f0d5787..87bbdeb 100644 --- a/PAYNLSDK/Converters/TaxClassConverter.cs +++ b/PAYNLSDK/Converters/TaxClassConverter.cs @@ -1,17 +1,16 @@ using System; -namespace PAYNLSDK.Converters +namespace PayNLSdk.Converters; + +internal class TaxClassConverter : EnumConversionBase { - internal class TaxClassConverter : EnumConversionBase + public override Type EnumType { - public override Type EnumType - { - get { return typeof(Enums.TaxClass); } - } + get { return typeof(Enums.TaxClass); } + } - public override bool CanConvert(Type objectType) - { - throw new NotImplementedException(); - } + public override bool CanConvert(Type objectType) + { + throw new NotImplementedException(); } } diff --git a/PAYNLSDK/Converters/YMDConverter.cs b/PAYNLSDK/Converters/YMDConverter.cs index 205573d..dbc5f2d 100644 --- a/PAYNLSDK/Converters/YMDConverter.cs +++ b/PAYNLSDK/Converters/YMDConverter.cs @@ -1,84 +1,83 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Utilities; +using Newtonsoft.Json; +using PayNLSdk.Utilities; +using System; -namespace PAYNLSDK.Converters +namespace PayNLSdk.Converters; + +internal class YMDConverter : JsonConverter { - internal class YMDConverter : JsonConverter + private const string Format = "yyyy-MM-dd"; + private static string[] ParseFormats = { + // - argument. + "yyyy-M-d", "yyyy-MM-dd", + // Slash argument. + "yyyy/M/d", "yyyy/MM/dd" + }; + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - private const string Format = "yyyy-MM-dd"; - private static string[] ParseFormats = { - // - argument. - "yyyy-M-d", "yyyy-MM-dd", - // Slash argument. - "yyyy/M/d", "yyyy/MM/dd" - }; - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + if (value is DateTime) { - if (value is DateTime) - { - var dateTime = (DateTime)value; - if (dateTime.Kind == DateTimeKind.Unspecified) - { - throw new JsonSerializationException("Cannot convert date time with an unspecified kind"); - } - string convertedDateTime = dateTime.ToString(Format); - writer.WriteValue(convertedDateTime); - } - else + var dateTime = (DateTime)value; + if (dateTime.Kind == DateTimeKind.Unspecified) { - throw new JsonSerializationException("Expected value of type 'DateTime'."); + throw new JsonSerializationException("Cannot convert date time with an unspecified kind"); } + string convertedDateTime = dateTime.ToString(Format); + writer.WriteValue(convertedDateTime); + } + else + { + throw new JsonSerializationException("Expected value of type 'DateTime'."); + } + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Null) + { + return null; } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + if (reader.TokenType == JsonToken.Date) { - if (reader.TokenType == JsonToken.Null) + var dateTime = (DateTime)reader.Value; + if (dateTime.Kind == DateTimeKind.Unspecified) { - return null; + throw new JsonSerializationException("Parsed date time is not in the expected RFC3339 format"); } + return dateTime; + } - if (reader.TokenType == JsonToken.Date) + if (reader.TokenType == JsonToken.String) + { + DateTime dateTime; + /*string[] formats = { "yyyy/M/d", "yyyy/MM/dd", "yyyy-M-d", "yyyy-MM-dd" };*/ + string timeString = (string)reader.Value; + if (!ParameterValidator.IsEmpty(timeString)) { - var dateTime = (DateTime)reader.Value; - if (dateTime.Kind == DateTimeKind.Unspecified) + if (DateTime.TryParseExact(timeString, ParseFormats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime)) { - throw new JsonSerializationException("Parsed date time is not in the expected RFC3339 format"); + // Gelukt we kunnen doorgaan + return dateTime; } - return dateTime; - } - - if (reader.TokenType == JsonToken.String) - { - DateTime dateTime; - /*string[] formats = { "yyyy/M/d", "yyyy/MM/dd", "yyyy-M-d", "yyyy-MM-dd" };*/ - string timeString = (string)reader.Value; - if (!ParameterValidator.IsEmpty(timeString)) + else { - if (DateTime.TryParseExact(timeString, ParseFormats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime)) - { - // Gelukt we kunnen doorgaan - return dateTime; - } - else - { - // De opgegeven timeString is niet juist. - return null; - } - + // De opgegeven timeString is niet juist. + return null; } - return null; + } - throw new JsonSerializationException(String.Format("Unexpected token '{0}' when parsing date.", reader.TokenType)); + return null; } + throw new JsonSerializationException(String.Format("Unexpected token '{0}' when parsing date.", reader.TokenType)); + } - public override bool CanConvert(Type objectType) - { - Type t = (Reflection.IsNullable(objectType)) - ? Nullable.GetUnderlyingType(objectType) - : objectType; + public override bool CanConvert(Type objectType) + { + Type t = (Reflection.IsNullable(objectType)) + ? Nullable.GetUnderlyingType(objectType) + : objectType; - return t == typeof(DateTime); - } + return t == typeof(DateTime); } } diff --git a/PAYNLSDK/Converters/YMDHISConverter.cs b/PAYNLSDK/Converters/YMDHISConverter.cs index db38bed..852864c 100644 --- a/PAYNLSDK/Converters/YMDHISConverter.cs +++ b/PAYNLSDK/Converters/YMDHISConverter.cs @@ -1,108 +1,107 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Utilities; +using Newtonsoft.Json; +using PayNLSdk.Utilities; +using System; -namespace PAYNLSDK.Converters +namespace PayNLSdk.Converters; + +internal class YMDHISConverter : JsonConverter { - internal class YMDHISConverter : JsonConverter - { - private const string Format = "yyyy-MM-dd HH:ii:ss"; - private static string[] ParseFormats = { - // - argument. - "yyyy-M-d h:mm:ss tt", "yyyy-M-d h:mm tt", - "yyyy-MM-dd hh:mm:ss", "yyyy-M-d h:mm:ss", - "yyyy-M-d hh:mm tt", "yyyy-M-d hh tt", - "yyyy-M-d h:mm", "yyyy-M-d h:mm", - "yyyy-MM-dd hh:mm", "yyyy-M-dd hh:mm", - // Slash argument. - "yyyy/M/d h:mm:ss tt", "yyyy/M/d h:mm tt", - "yyyy/MM/dd hh:mm:ss", "yyyy/M/d h:mm:ss", - "yyyy/M/d hh:mm tt", "yyyy/M/d hh tt", - "yyyy/M/d h:mm", "yyyy/M/d h:mm", - "yyyy/MM/dd hh:mm", "yyyy/M/dd hh:mm" - }; + private const string Format = "yyyy-MM-dd HH:ii:ss"; + private static string[] ParseFormats = { + // - argument. + "yyyy-M-d h:mm:ss tt", "yyyy-M-d h:mm tt", + "yyyy-MM-dd hh:mm:ss", "yyyy-M-d h:mm:ss", + "yyyy-M-d hh:mm tt", "yyyy-M-d hh tt", + "yyyy-M-d h:mm", "yyyy-M-d h:mm", + "yyyy-MM-dd hh:mm", "yyyy-M-dd hh:mm", + // Slash argument. + "yyyy/M/d h:mm:ss tt", "yyyy/M/d h:mm tt", + "yyyy/MM/dd hh:mm:ss", "yyyy/M/d h:mm:ss", + "yyyy/M/d hh:mm tt", "yyyy/M/d hh tt", + "yyyy/M/d h:mm", "yyyy/M/d h:mm", + "yyyy/MM/dd hh:mm", "yyyy/M/dd hh:mm" + }; - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + if (value is DateTime) { - if (value is DateTime) - { - var dateTime = (DateTime)value; - if (dateTime.Kind == DateTimeKind.Unspecified) - { - throw new JsonSerializationException("Cannot convert date time with an unspecified kind"); - } - string convertedDateTime = dateTime.ToString(Format); - writer.WriteValue(convertedDateTime); - } - else + var dateTime = (DateTime)value; + if (dateTime.Kind == DateTimeKind.Unspecified) { - throw new JsonSerializationException("Expected value of type 'DateTime'."); + throw new JsonSerializationException("Cannot convert date time with an unspecified kind"); } + string convertedDateTime = dateTime.ToString(Format); + writer.WriteValue(convertedDateTime); } + else + { + throw new JsonSerializationException("Expected value of type 'DateTime'."); + } + } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Null) { - if (reader.TokenType == JsonToken.Null) + return null; + } + + if (reader.TokenType == JsonToken.Date) + { + var dateTime = (DateTime)reader.Value; + if (dateTime.Kind == DateTimeKind.Unspecified) { - return null; + throw new JsonSerializationException("Parsed date time is not in the expected RFC3339 format"); } + return dateTime; + } - if (reader.TokenType == JsonToken.Date) + if (reader.TokenType == JsonToken.String) + { + DateTime dateTime; + /* + string[] formats = { + // - argument. + "yyyy-M-d h:mm:ss tt", "yyyy-M-d h:mm tt", + "yyyy-MM-dd hh:mm:ss", "yyyy-M-d h:mm:ss", + "yyyy-M-d hh:mm tt", "yyyy-M-d hh tt", + "yyyy-M-d h:mm", "yyyy-M-d h:mm", + "yyyy-MM-dd hh:mm", "yyyy-M-dd hh:mm", + // Slash argument. + "yyyy/M/d h:mm:ss tt", "yyyy/M/d h:mm tt", + "yyyy/MM/dd hh:mm:ss", "yyyy/M/d h:mm:ss", + "yyyy/M/d hh:mm tt", "yyyy/M/d hh tt", + "yyyy/M/d h:mm", "yyyy/M/d h:mm", + "yyyy/MM/dd hh:mm", "yyyy/M/dd hh:mm" + }; + */ + string timeString = (string)reader.Value; + if (!ParameterValidator.IsEmpty(timeString)) { - var dateTime = (DateTime)reader.Value; - if (dateTime.Kind == DateTimeKind.Unspecified) + if (DateTime.TryParseExact(timeString, ParseFormats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime)) { - throw new JsonSerializationException("Parsed date time is not in the expected RFC3339 format"); + // Gelukt we kunnen doorgaan + return dateTime; } - return dateTime; - } - - if (reader.TokenType == JsonToken.String) - { - DateTime dateTime; -/* - string[] formats = { - // - argument. - "yyyy-M-d h:mm:ss tt", "yyyy-M-d h:mm tt", - "yyyy-MM-dd hh:mm:ss", "yyyy-M-d h:mm:ss", - "yyyy-M-d hh:mm tt", "yyyy-M-d hh tt", - "yyyy-M-d h:mm", "yyyy-M-d h:mm", - "yyyy-MM-dd hh:mm", "yyyy-M-dd hh:mm", - // Slash argument. - "yyyy/M/d h:mm:ss tt", "yyyy/M/d h:mm tt", - "yyyy/MM/dd hh:mm:ss", "yyyy/M/d h:mm:ss", - "yyyy/M/d hh:mm tt", "yyyy/M/d hh tt", - "yyyy/M/d h:mm", "yyyy/M/d h:mm", - "yyyy/MM/dd hh:mm", "yyyy/M/dd hh:mm" - }; - */ - string timeString = (string)reader.Value; - if (!ParameterValidator.IsEmpty(timeString)) + else { - if (DateTime.TryParseExact(timeString, ParseFormats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime)) - { - // Gelukt we kunnen doorgaan - return dateTime; - } - else - { - // De opgegeven timeString is niet juist. - return null; - } - + // De opgegeven timeString is niet juist. + return null; } - return null; + } - throw new JsonSerializationException(String.Format("Unexpected token '{0}' when parsing date.", reader.TokenType)); + return null; } + throw new JsonSerializationException(String.Format("Unexpected token '{0}' when parsing date.", reader.TokenType)); + } - public override bool CanConvert(Type objectType) - { - Type t = (Reflection.IsNullable(objectType)) - ? Nullable.GetUnderlyingType(objectType) - : objectType; + public override bool CanConvert(Type objectType) + { + Type t = (Reflection.IsNullable(objectType)) + ? Nullable.GetUnderlyingType(objectType) + : objectType; - return t == typeof(DateTime); - } + return t == typeof(DateTime); } } diff --git a/PAYNLSDK/DateTime.cs b/PAYNLSDK/DateTime.cs index f505cbb..0a6dc89 100644 --- a/PAYNLSDK/DateTime.cs +++ b/PAYNLSDK/DateTime.cs @@ -1,29 +1,28 @@ using System; -namespace PayNLSdk +namespace PayNLSdk; + +/// +/// A DateTime abstraction to make it easier to unittest DateTime.Now +/// +public interface IDateTime { /// - /// A DateTime abstraction to make it easier to unittest DateTime.Now + /// Get the current dateTime /// - public interface IDateTime - { - /// - /// Get the current dateTime - /// - DateTime Now { get; } - } + DateTime Now { get; } +} +/// +public class LocalDateTime : IDateTime +{ /// - public class LocalDateTime : IDateTime - { - /// - public DateTime Now => DateTime.Now; - } + public DateTime Now => DateTime.Now; +} +/// +public class UtcDateTime : IDateTime +{ /// - public class UtcDateTime : IDateTime - { - /// - public DateTime Now => DateTime.UtcNow; - } + public DateTime Now => DateTime.UtcNow; } diff --git a/PAYNLSDK/Enums/enums.cs b/PAYNLSDK/Enums/enums.cs index 9871400..6e9b722 100644 --- a/PAYNLSDK/Enums/enums.cs +++ b/PAYNLSDK/Enums/enums.cs @@ -1,345 +1,341 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -namespace PAYNLSDK.Enums +namespace PayNLSdk.Enums; + +/// +/// Utility to convert Enum Values to EnumMember Values and vice versa. +/// +public static class EnumUtil { /// - /// Utility to convert Enum Values to EnumMember Values and vice versa. + /// Return the value of an EnumMember /// - public static class EnumUtil + /// Type of Enum + /// Enum value + /// Value of the EnumMember attribute + public static string ToEnumString(T type) { - /// - /// Return the value of an EnumMember - /// - /// Type of Enum - /// Enum value - /// Value of the EnumMember attribute - public static string ToEnumString(T type) - { - var enumType = typeof(T); - var name = Enum.GetName(enumType, type); - var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single(); - return enumMemberAttribute.Value; - } - - /// - /// - /// Return the value of an EnumMember - /// - /// Enum value - /// Enum type - /// Value of the EnumMember attribute - public static string ToEnumString(object value, Type enumType) - { - var name = Enum.GetName(enumType, value); - var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single(); - return enumMemberAttribute.Value; - } + var enumType = typeof(T); + var name = Enum.GetName(enumType, type); + var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single(); + return enumMemberAttribute.Value; + } - /// - /// Transform the value for an EnumMember attribute to the Enum Value - /// - /// Enum Type - /// EnumMember Value - /// Enum Value - public static T ToEnum(string str) - { - var enumType = typeof(T); - foreach (var name in Enum.GetNames(enumType)) - { - var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single(); - if (enumMemberAttribute.Value == str) return (T)Enum.Parse(enumType, name); - } - return default(T); - } + /// + /// + /// Return the value of an EnumMember + /// + /// Enum value + /// Enum type + /// Value of the EnumMember attribute + public static string ToEnumString(object value, Type enumType) + { + var name = Enum.GetName(enumType, value); + var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single(); + return enumMemberAttribute.Value; + } - /// - /// Transform the value for an EnumMember attribute to the Enum Value - /// - /// EnumMember Value - /// Enum Type - /// Enum Value - public static object ToEnum(string str, Type enumType) + /// + /// Transform the value for an EnumMember attribute to the Enum Value + /// + /// Enum Type + /// EnumMember Value + /// Enum Value + public static T ToEnum(string str) + { + var enumType = typeof(T); + foreach (var name in Enum.GetNames(enumType)) { - foreach (var name in Enum.GetNames(enumType)) - { - var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single(); - if (enumMemberAttribute.Value == str) return Enum.Parse(enumType, name); - } - return Enum.Parse(enumType, enumType.GetEnumName(0)); + var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single(); + if (enumMemberAttribute.Value == str) return (T)Enum.Parse(enumType, name); } + return default(T); } /// - /// Gender enumeration + /// Transform the value for an EnumMember attribute to the Enum Value /// - public enum Gender + /// EnumMember Value + /// Enum Type + /// Enum Value + public static object ToEnum(string str, Type enumType) { - /// - /// A male gender - /// - [EnumMember(Value="m")] - Male, - /// - /// A female gender - /// - [EnumMember(Value = "f")] - Female + foreach (var name in Enum.GetNames(enumType)) + { + var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single(); + if (enumMemberAttribute.Value == str) return Enum.Parse(enumType, name); + } + return Enum.Parse(enumType, enumType.GetEnumName(0)); } +} +/// +/// Gender enumeration +/// +public enum Gender +{ /// - /// TaxClass enumeration + /// A male gender /// - public enum TaxClass - { - /// - /// No tax - /// - [EnumMember(Value = "N")] - None = 0, - - /// - /// A low tax class - /// - [EnumMember(Value = "L")] - Low = 6, + [EnumMember(Value = "m")] + Male, + /// + /// A female gender + /// + [EnumMember(Value = "f")] + Female +} - /// - /// High tax class - /// - [EnumMember(Value = "H")] - High = 21 - } +/// +/// TaxClass enumeration +/// +public enum TaxClass +{ + /// + /// No tax + /// + [EnumMember(Value = "N")] + None = 0, /// - /// PaymentMethodId enumeration + /// A low tax class /// - public enum PaymentMethodId - { - /// - /// Payment with SMS - /// - [EnumMember(Value = "1")] - Sms = 1, - /// - /// Payment method with fixed price - /// - [EnumMember(Value = "2")] - PayFixedPrice = 2, - /// - /// Pay per call - /// - [EnumMember(Value = "3")] - PayPerCall = 3, - /// - /// Pay per transaction - /// - [EnumMember(Value = "4")] - PayPerTransaction = 4, - /// - /// Pay per minute - /// - [EnumMember(Value = "5")] - PayPerMinute = 5 - } + [EnumMember(Value = "L")] + Low = 6, /// - /// ExchangeState enumeration + /// High tax class /// - public enum ExchangeState - { - /// - /// The exchange state failed - /// - [EnumMember(Value = "-1")] - Failed = -1, + [EnumMember(Value = "H")] + High = 21 +} - /// - /// The exchange was not called - /// - [EnumMember(Value = "0")] - NotCalled = 0, +/// +/// PaymentMethodId enumeration +/// +public enum PaymentMethodId +{ + /// + /// Payment with SMS + /// + [EnumMember(Value = "1")] + Sms = 1, + /// + /// Payment method with fixed price + /// + [EnumMember(Value = "2")] + PayFixedPrice = 2, + /// + /// Pay per call + /// + [EnumMember(Value = "3")] + PayPerCall = 3, + /// + /// Pay per transaction + /// + [EnumMember(Value = "4")] + PayPerTransaction = 4, + /// + /// Pay per minute + /// + [EnumMember(Value = "5")] + PayPerMinute = 5 +} - /// - /// The exchange call was successful - /// - [EnumMember(Value = "1")] - Success = 1 - } +/// +/// ExchangeState enumeration +/// +public enum ExchangeState +{ + /// + /// The exchange state failed + /// + [EnumMember(Value = "-1")] + Failed = -1, /// - /// ActiveState enumeration + /// The exchange was not called /// - public enum ActiveState - { - /// - /// Is inactive - /// - [EnumMember(Value = "0")] - Inactive = 0, + [EnumMember(Value = "0")] + NotCalled = 0, - /// - /// Is active - /// - [EnumMember(Value = "1")] - Active = 1 - } + /// + /// The exchange call was successful + /// + [EnumMember(Value = "1")] + Success = 1 +} +/// +/// ActiveState enumeration +/// +public enum ActiveState +{ /// - /// 3D Secure enumeration + /// Is inactive /// - public enum Secure - { - /// - /// No additional security was used - /// - [EnumMember(Value = "0")] - NotSecure = 0, + [EnumMember(Value = "0")] + Inactive = 0, - /// - /// Security uses Secure3D - /// - [EnumMember(Value = "1")] - Secure3D = 1 - } + /// + /// Is active + /// + [EnumMember(Value = "1")] + Active = 1 +} +/// +/// 3D Secure enumeration +/// +public enum Secure +{ /// - /// Availability enumeration + /// No additional security was used /// - public enum Availability - { - /// - /// Is not unavailable - /// - [EnumMember(Value = "0")] - Unavailable = 0, + [EnumMember(Value = "0")] + NotSecure = 0, - /// - /// Is available - /// - [EnumMember(Value = "1")] - Available = 1 - } + /// + /// Security uses Secure3D + /// + [EnumMember(Value = "1")] + Secure3D = 1 +} +/// +/// Availability enumeration +/// +public enum Availability +{ /// - /// Blacklist type enumeration + /// Is not unavailable /// - public enum Blacklist - { - /// - /// not blacklisted - /// - [EnumMember(Value = "0")] - NotBlacklisted = 0, + [EnumMember(Value = "0")] + Unavailable = 0, - /// - /// blacklisted - /// - [EnumMember(Value = "1")] - Blacklisted = 1, + /// + /// Is available + /// + [EnumMember(Value = "1")] + Available = 1 +} - /// - /// blacklisted by others - /// - [EnumMember(Value = "2")] - BlacklistedByOthers = 2 - } +/// +/// Blacklist type enumeration +/// +public enum Blacklist +{ + /// + /// not blacklisted + /// + [EnumMember(Value = "0")] + NotBlacklisted = 0, /// - /// Payment status enumeration representing PAYNL Payment statuses + /// blacklisted /// - public enum PaymentStatus - { - [EnumMember(Value = "-90")] - CANCEL = -90, - [EnumMember(Value = "-60")] - CANCEL_2 = -60, - [EnumMember(Value = "-82")] - PARTIAL_REFUND = -82, - [EnumMember(Value = "-81")] - REFUND = -81, - [EnumMember(Value = "-80")] - EXPIRED = -80, - [EnumMember(Value = "-72")] - REFUNDING = -72, - [EnumMember(Value = "-71")] - CHARGEBACK_1 = -71, - [EnumMember(Value = "-70")] - CHARGEBACK_2 = -70, - [EnumMember(Value = "-51")] - PAID_CHECKAMOUNT = -51, - [EnumMember(Value = "0")] - WAIT = 0, - [EnumMember(Value = "20")] - PENDING_1 = 20, - [EnumMember(Value = "25")] - PENDING_2 = 25, - [EnumMember(Value = "50")] - PENDING_3 = 50, - [EnumMember(Value = "90")] - PENDING_4 = 90, - [EnumMember(Value = "60")] - OPEN = 60, - [EnumMember(Value = "75")] - CONFIRMED_1 = 75, - [EnumMember(Value = "76")] - CONFIRMED_2 = 76, - [EnumMember(Value = "80")] - PARTIAL_PAYMENT = 80, - [EnumMember(Value = "85")] - VERIFY = 85, - [EnumMember(Value = "100")] - PAID = 100, - [EnumMember(Value = "95")] - AUTHORIZE = 95, - [EnumMember(Value = "-63")] - DENIED = -63, - } + [EnumMember(Value = "1")] + Blacklisted = 1, /// - /// Type of the order line. + /// blacklisted by others /// - public enum ProductType - { - [EnumMember(Value = "ARTICLE")] - ARTICLE, - [EnumMember(Value = "SHIPPING")] - SHIPPING, - [EnumMember(Value = "HANDLING")] - HANDLING, - [EnumMember(Value = "DISCOUNT")] - DISCOUNT, - [EnumMember(Value = "ARTICLE_H")] - ARTICLE_H, - [EnumMember(Value = "VOUCHER")] - VOUCHER, - [EnumMember(Value = "GIFTCARD")] - GIFTCARD, - [EnumMember(Value = "EMONEY")] - EMONEY, - [EnumMember(Value = "TOPUP")] - TOPUP, - [EnumMember(Value = "TICKET")] - TICKET, - [EnumMember(Value = "CRYPTO")] - CRYPTO, - [EnumMember(Value = "IDENTITY")] - IDENTITY, - [EnumMember(Value = "INVOICE")] - INVOICE, - [EnumMember(Value = "DOWNLOAD")] - DOWNLOAD, - [EnumMember(Value = "VIRTUAL")] - VIRTUAL, - [EnumMember(Value = "CREDIT")] - CREDIT, - [EnumMember(Value = "PAYMENT")] - PAYMENT, - [EnumMember(Value = "ROUNDING")] - ROUNDING, - } + [EnumMember(Value = "2")] + BlacklistedByOthers = 2 } + +/// +/// Payment status enumeration representing PAYNL Payment statuses +/// +public enum PaymentStatus +{ + [EnumMember(Value = "-90")] + CANCEL = -90, + [EnumMember(Value = "-60")] + CANCEL_2 = -60, + [EnumMember(Value = "-82")] + PARTIAL_REFUND = -82, + [EnumMember(Value = "-81")] + REFUND = -81, + [EnumMember(Value = "-80")] + EXPIRED = -80, + [EnumMember(Value = "-72")] + REFUNDING = -72, + [EnumMember(Value = "-71")] + CHARGEBACK_1 = -71, + [EnumMember(Value = "-70")] + CHARGEBACK_2 = -70, + [EnumMember(Value = "-51")] + PAID_CHECKAMOUNT = -51, + [EnumMember(Value = "0")] + WAIT = 0, + [EnumMember(Value = "20")] + PENDING_1 = 20, + [EnumMember(Value = "25")] + PENDING_2 = 25, + [EnumMember(Value = "50")] + PENDING_3 = 50, + [EnumMember(Value = "90")] + PENDING_4 = 90, + [EnumMember(Value = "60")] + OPEN = 60, + [EnumMember(Value = "75")] + CONFIRMED_1 = 75, + [EnumMember(Value = "76")] + CONFIRMED_2 = 76, + [EnumMember(Value = "80")] + PARTIAL_PAYMENT = 80, + [EnumMember(Value = "85")] + VERIFY = 85, + [EnumMember(Value = "100")] + PAID = 100, + [EnumMember(Value = "95")] + AUTHORIZE = 95, + [EnumMember(Value = "-63")] + DENIED = -63, +} + +/// +/// Type of the order line. +/// +public enum ProductType +{ + [EnumMember(Value = "ARTICLE")] + ARTICLE, + [EnumMember(Value = "SHIPPING")] + SHIPPING, + [EnumMember(Value = "HANDLING")] + HANDLING, + [EnumMember(Value = "DISCOUNT")] + DISCOUNT, + [EnumMember(Value = "ARTICLE_H")] + ARTICLE_H, + [EnumMember(Value = "VOUCHER")] + VOUCHER, + [EnumMember(Value = "GIFTCARD")] + GIFTCARD, + [EnumMember(Value = "EMONEY")] + EMONEY, + [EnumMember(Value = "TOPUP")] + TOPUP, + [EnumMember(Value = "TICKET")] + TICKET, + [EnumMember(Value = "CRYPTO")] + CRYPTO, + [EnumMember(Value = "IDENTITY")] + IDENTITY, + [EnumMember(Value = "INVOICE")] + INVOICE, + [EnumMember(Value = "DOWNLOAD")] + DOWNLOAD, + [EnumMember(Value = "VIRTUAL")] + VIRTUAL, + [EnumMember(Value = "CREDIT")] + CREDIT, + [EnumMember(Value = "PAYMENT")] + PAYMENT, + [EnumMember(Value = "ROUNDING")] + ROUNDING, +} \ No newline at end of file diff --git a/PAYNLSDK/Exceptions/PayNlException.cs b/PAYNLSDK/Exceptions/PayNlException.cs index 4d5c8e6..781524d 100644 --- a/PAYNLSDK/Exceptions/PayNlException.cs +++ b/PAYNLSDK/Exceptions/PayNlException.cs @@ -1,62 +1,61 @@ -using PAYNLSDK.Objects; +using PayNLSdk.Objects; using System; -namespace PAYNLSDK.Exceptions +namespace PayNLSdk.Exceptions; + +/// +/// PayNlException implementation +/// +public class PayNlException : Exception { /// - /// PayNlException implementation + /// Error, if any + /// + public Error Error { get; } + + /// + /// Return whether or not there's an Error object associated with this Exception + /// + public bool HasError => Error != null; + + /// + /// Create a new PayNlException with an Error attached + /// + /// Error object + /// Inner Exception + public PayNlException(Error error, Exception innerException) + : base(error.Message, innerException) + { + this.Error = error; + } + + /// + /// Create a new PayNlException with an Error attached /// - public class PayNlException : Exception + /// Error object + public PayNlException(Error error) + : base(error.Message, null) { - /// - /// Error, if any - /// - public Error Error { get; } - - /// - /// Return whether or not there's an Error object associated with this Exception - /// - public bool HasError => Error != null; - - /// - /// Create a new PayNlException with an Error attached - /// - /// Error object - /// Inner Exception - public PayNlException(Error error, Exception innerException) - : base(error.Message, innerException) - { - this.Error = error; - } - - /// - /// Create a new PayNlException with an Error attached - /// - /// Error object - public PayNlException(Error error) - : base(error.Message, null) - { - this.Error = error; - } - - /// - /// Creates an PayNlException from a string - /// - /// error message - /// inner Exception - public PayNlException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Creates an PayNlException from a string - /// - /// error message - public PayNlException(string message) - : base(message) - { - } + this.Error = error; + } + /// + /// Creates an PayNlException from a string + /// + /// error message + /// inner Exception + public PayNlException(string message, Exception innerException) + : base(message, innerException) + { } + + /// + /// Creates an PayNlException from a string + /// + /// error message + public PayNlException(string message) + : base(message) + { + } + } diff --git a/PAYNLSDK/ExtentionMethods/DateTimeExtension.cs b/PAYNLSDK/ExtentionMethods/DateTimeExtension.cs index ea564ba..7da31d7 100644 --- a/PAYNLSDK/ExtentionMethods/DateTimeExtension.cs +++ b/PAYNLSDK/ExtentionMethods/DateTimeExtension.cs @@ -1,62 +1,61 @@ using System; -namespace PayNLSdk.ExtentionMethods +namespace PayNLSdk.ExtentionMethods; + +public static class DateTimeExtension { - public static class DateTimeExtension + /// + /// Get the first day of the previous week + /// + /// + /// + /// + /// + /// original from https://stackoverflow.com/a/41784250/97615 + /// + public static DateTime LastWeek(this DateTime date, DayOfWeek dow) + { + var dayOfWeek = (int)date.DayOfWeek - 1; + if (dayOfWeek < 0) dayOfWeek = 6; + + var thisWeeksMonday = date.AddDays(-dayOfWeek).Date; + return thisWeeksMonday.AddDays(-7); + } + + /// + /// Get this weeks' monday + /// + /// + /// + /// + public static DateTime ThisWeek(this DateTime date, DayOfWeek dow) + { + var dayOfWeek = (int)date.DayOfWeek - 1; + if (dayOfWeek < 0) dayOfWeek = 6; + + return date.AddDays(-dayOfWeek).Date; + } + + /// + /// Get the first day of the previous month + /// + /// + /// + + public static DateTime LastMonthFirstDay(this DateTime currentDate) + { + DateTime d = currentDate.LastMonthLastDay(); + + return new DateTime(d.Year, d.Month, 1); + } + + /// + /// get the last months last day + /// + /// + /// + public static DateTime LastMonthLastDay(this DateTime currentDate) { - /// - /// Get the first day of the previous week - /// - /// - /// - /// - /// - /// original from https://stackoverflow.com/a/41784250/97615 - /// - public static DateTime LastWeek(this DateTime date, DayOfWeek dow) - { - var dayOfWeek = (int)date.DayOfWeek - 1; - if (dayOfWeek < 0) dayOfWeek = 6; - - var thisWeeksMonday = date.AddDays(-dayOfWeek).Date; - return thisWeeksMonday.AddDays(-7); - } - - /// - /// Get this weeks' monday - /// - /// - /// - /// - public static DateTime ThisWeek(this DateTime date, DayOfWeek dow) - { - var dayOfWeek = (int)date.DayOfWeek - 1; - if (dayOfWeek < 0) dayOfWeek = 6; - - return date.AddDays(-dayOfWeek).Date; - } - - /// - /// Get the first day of the previous month - /// - /// - /// - - public static DateTime LastMonthFirstDay(this DateTime currentDate) - { - DateTime d = currentDate.LastMonthLastDay(); - - return new DateTime(d.Year, d.Month, 1); - } - - /// - /// get the last months last day - /// - /// - /// - public static DateTime LastMonthLastDay(this DateTime currentDate) - { - return new DateTime(currentDate.Year, currentDate.Month, 1).AddDays(-1); - } + return new DateTime(currentDate.Year, currentDate.Month, 1).AddDays(-1); } } diff --git a/PAYNLSDK/IAlliance.cs b/PAYNLSDK/IAlliance.cs index a7131de..a085469 100644 --- a/PAYNLSDK/IAlliance.cs +++ b/PAYNLSDK/IAlliance.cs @@ -1,36 +1,41 @@ -namespace PAYNLSDK +using PayNLSdk.Api.Alliance.AddInvoice; +using PayNLSdk.Api.Alliance.AddMerchant; +using PayNLSdk.Api.Alliance.AddService; +using PayNLSdk.Api.Alliance.GetMerchant; +using Request = PayNLSdk.Api.Alliance.GetMerchant.Request; + +namespace PayNLSdk; + +/// +/// Alliance methods +/// +public interface IAlliance { /// - /// Alliance methods + /// This function can be used to retrieve alliance merchant information. /// - public interface IAlliance - { - /// - /// This function can be used to retrieve alliance merchant information. - /// - /// - /// - API.Alliance.GetMerchant.GetMerchantResult GetMerchant(API.Alliance.GetMerchant.Request request); + /// + /// + GetMerchantResult GetMerchant(Request request); - /// - /// Adds the merchant. - /// - /// The request. - /// AddMerchantResult. - API.Alliance.AddMerchant.AddMerchantResult AddMerchant(API.Alliance.AddMerchant.Request request); + /// + /// Adds the merchant. + /// + /// The request. + /// AddMerchantResult. + AddMerchantResult AddMerchant(Api.Alliance.AddMerchant.Request request); - /// - /// Adds a service for a merchant - /// - /// The request. - /// AddServiceResult. - API.Alliance.AddService.AddServiceResult AddService(API.Alliance.AddService.Request request); - - /// - /// Inserts a transaction to collect an invoice fee. - /// - /// The request. - /// API.Alliance.AddInvoice.AddInvoiceResult. - API.Alliance.AddInvoice.AddInvoiceResult AddInvoice(API.Alliance.AddInvoice.Request request); - } -} + /// + /// Adds a service for a merchant + /// + /// The request. + /// AddServiceResult. + AddServiceResult AddService(Api.Alliance.AddService.Request request); + + /// + /// Inserts a transaction to collect an invoice fee. + /// + /// The request. + /// API.Alliance.AddInvoice.AddInvoiceResult. + AddInvoiceResult AddInvoice(Api.Alliance.AddInvoice.Request request); +} \ No newline at end of file diff --git a/PAYNLSDK/IMerchant.cs b/PAYNLSDK/IMerchant.cs index 4041a85..63ed799 100644 --- a/PAYNLSDK/IMerchant.cs +++ b/PAYNLSDK/IMerchant.cs @@ -1,12 +1,10 @@ -using PAYNLSDK.API.Merchant.Add; -using PAYNLSDK.API.Merchant.Get; +using PayNLSdk.Api.Merchant.Add; -namespace PAYNLSDK +namespace PayNLSdk; + +public interface IMerchant { - public interface IMerchant - { - API.Merchant.Add.Response Create(API.Merchant.Add.Request request); - API.Merchant.Get.Response Get(string merchantId); - PayNLSdk.API.Merchant.Clearing.Response AddClearing(PayNLSdk.API.Merchant.Clearing.Request request); - } + Response Create(Request request); + Api.Merchant.Info.Response Get(string merchantId); + Api.Merchant.Clearing.Response AddClearing(Api.Merchant.Clearing.Request request); } diff --git a/PAYNLSDK/IService.cs b/PAYNLSDK/IService.cs index bdbe9df..b83a0f6 100644 --- a/PAYNLSDK/IService.cs +++ b/PAYNLSDK/IService.cs @@ -1,12 +1,11 @@ -using PAYNLSDK.API.Service.GetCategories; +using PayNLSdk.Api.Service.GetCategories; -namespace PAYNLSDK +namespace PayNLSdk; + +/// +/// A +/// +public interface IService { - /// - /// A - /// - public interface IService - { - Response GetCategories(int? paymentOptionId = null); - } -} \ No newline at end of file + Response GetCategories(int? paymentOptionId = null); +} diff --git a/PAYNLSDK/ITransaction.cs b/PAYNLSDK/ITransaction.cs index c29a019..493303d 100644 --- a/PAYNLSDK/ITransaction.cs +++ b/PAYNLSDK/ITransaction.cs @@ -1,38 +1,33 @@ -using System; -using PAYNLSDK.API.Transaction.Approve; -using PAYNLSDK.API.Transaction.Decline; -using PAYNLSDK.API.Transaction.GetService; -using PAYNLSDK.API.Transaction.Info; -using PAYNLSDK.API.Transaction.Refund; -using PAYNLSDK.API.Transaction.Start; -using PAYNLSDK.Enums; +using PayNLSdk.Api.Transaction.Approve; +using PayNLSdk.Enums; +using System; +using Request = PayNLSdk.Api.Transaction.Start.Request; -namespace PAYNLSDK +namespace PayNLSdk; + +public interface ITransaction { - public interface ITransaction - { - /// - /// Approve a suspicious transaction - /// - /// The transaction id - API.Transaction.Approve.Response Approve(string transactionId); - API.Transaction.Decline.Response Decline(string transactionId); - API.Transaction.GetService.Response GetService(); - API.Transaction.GetService.Response GetService(PaymentMethodId? paymentMethodId); - API.Transaction.Info.Response Info(string transactionId); - bool IsCancelled(string transactionId); - bool IsPaid(string transactionId); - bool IsPending(string transactionId); - bool IsVerify(string transactionId); - API.Transaction.Refund.Response Refund(string transactionId, string description = null, decimal? amount = null, DateTime? processDate = null); - /// - /// If a customer has chosen to pay per transaction this API needs to be called. - /// - /// - /// The parameter bankId for GiroPay has a length of 8 characters, see http://www.giropay.de for more information. - /// After the payment extra GET parameters will be added to the orderReturnUrl. - /// These parameters are also available if the payment is cancelled, or if the payment could not be completed. - /// - API.Transaction.Start.Response Start(API.Transaction.Start.Request request); - } + /// + /// Approve a suspicious transaction + /// + /// The transaction id + Response Approve(string transactionId); + Api.Transaction.Decline.Response Decline(string transactionId); + Api.Transaction.GetService.Response GetService(); + Api.Transaction.GetService.Response GetService(PaymentMethodId? paymentMethodId); + Api.Transaction.Info.Response Info(string transactionId); + bool IsCancelled(string transactionId); + bool IsPaid(string transactionId); + bool IsPending(string transactionId); + bool IsVerify(string transactionId); + Api.Transaction.Refund.Response Refund(string transactionId, string description = null, decimal? amount = null, DateTime? processDate = null); + /// + /// If a customer has chosen to pay per transaction this API needs to be called. + /// + /// + /// The parameter bankId for GiroPay has a length of 8 characters, see http://www.giropay.de for more information. + /// After the payment extra GET parameters will be added to the orderReturnUrl. + /// These parameters are also available if the payment is cancelled, or if the payment could not be completed. + /// + Api.Transaction.Start.Response Start(Request request); } diff --git a/PAYNLSDK/Language.cs b/PAYNLSDK/Language.cs index 28af4f1..bc3f00b 100644 --- a/PAYNLSDK/Language.cs +++ b/PAYNLSDK/Language.cs @@ -1,41 +1,34 @@ -using PAYNLSDK.Net; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using PAYNLSDK.API.Alliance; -using PAYNLSDK.API.Alliance.GetMerchant; -using PAYNLSDK.API.Language; +using PayNLSdk.Api.Alliance.GetMerchant; +using PayNLSdk.Api.Language; +using PayNLSdk.Net; -namespace PAYNLSDK -{ - /// - /// This is a part of the alliance SDK - /// - public class Language : ILanguage - { - private readonly IClient _webClient; +namespace PayNLSdk; - /// - public Language(IClient webClient) - { - _webClient = webClient; - } +/// +/// This is a part of the alliance SDK +/// +public class Language : ILanguage +{ + private readonly IClient _webClient; - /// - public GetMerchantResult GetAll() - { - var response = _webClient.PerformRequest(new GetAllRequest()); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); - } + /// + public Language(IClient webClient) + { + _webClient = webClient; } - /// - /// - /// - public interface ILanguage + /// + public GetMerchantResult GetAll() { - GetMerchantResult GetAll(); + var response = _webClient.PerformRequest(new GetAllRequest()); + return Newtonsoft.Json.JsonConvert.DeserializeObject(response); } +} + +/// +/// +/// +public interface ILanguage +{ + GetMerchantResult GetAll(); } \ No newline at end of file diff --git a/PAYNLSDK/Merchant.cs b/PAYNLSDK/Merchant.cs index 47f7fcc..583a1ed 100644 --- a/PAYNLSDK/Merchant.cs +++ b/PAYNLSDK/Merchant.cs @@ -1,101 +1,97 @@ -using PAYNLSDK.Net; +using PayNLSdk.Api.Merchant.Clearing; +using PayNLSdk.Net; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace PAYNLSDK +namespace PayNLSdk; + +/// +/// This is a part of the alliance SDK +/// +public class Merchant : IMerchant { + private readonly IClient _webClient; + /// - /// This is a part of the alliance SDK + /// The merchant api. This is a part from the alliance SDK. /// - public class Merchant : IMerchant + /// + public Merchant(IClient webClient) { - private readonly IClient _webClient; + _webClient = webClient; + } - /// - /// The merchant api. This is a part from the alliance SDK. - /// - /// - public Merchant(IClient webClient) - { - _webClient = webClient; - } - - /// - /// Add a clearing for a particular merchant for a certain amount - /// - /// - /// - public PayNLSdk.API.Merchant.Clearing.Response AddClearing(PayNLSdk.API.Merchant.Clearing.Request request) - { - var response = _webClient.PerformRequest(request); - return PayNLSdk.API.Merchant.Clearing.Response.FromRawResponse(response); - } - - /// Create a new merchant - /// - /// A new object - public API.Merchant.Add.Response Create(API.Merchant.Add.Request request) - { - var response = _webClient.PerformRequest(request); - return API.Merchant.Add.Response.FromRawResponse(response); - } - - /// - /// Get a specific merchant by id - /// - /// - /// - public API.Merchant.Get.Response Get(string merchantId) - { - //api = new Api\GetMerchant(); - // if (!String.IsNullOrEmpty( options['merchantId'])) - // { - // api->setMerchantId( options['merchantId']); - // } - - //result = api->doRequest(); - - var request = new API.Merchant.Get.Request - { - MerchantId = merchantId - }; - - var response = _webClient.PerformRequest(request); - return API.Merchant.Get.Response.FromRawResponse(response); - } - - /// - /// Get a list of all merchants - /// - public object GetAll( /*options = array()*/) + /// + /// Add a clearing for a particular merchant for a certain amount + /// + /// + /// + public Response AddClearing(Request request) + { + var response = _webClient.PerformRequest(request); + return Response.FromRawResponse(response); + } + + /// Create a new merchant + /// + /// A new object + public Api.Merchant.Add.Response Create(Api.Merchant.Add.Request request) + { + var response = _webClient.PerformRequest(request); + return Api.Merchant.Add.Response.FromRawResponse(response); + } + + /// + /// Get a specific merchant by id + /// + /// + /// + public Api.Merchant.Info.Response Get(string merchantId) + { + //api = new Api\GetMerchant(); + // if (!String.IsNullOrEmpty( options['merchantId'])) + // { + // api->setMerchantId( options['merchantId']); + // } + + //result = api->doRequest(); + + var request = new Api.Merchant.Info.Request { - throw new NotImplementedException("this is not yet implemented"); - //api = new Api\GetMerchants(); + MerchantId = merchantId + }; + + var response = _webClient.PerformRequest(request); + return Api.Merchant.Info.Response.FromRawResponse(response); + } - // if (!String.IsNullOrEmpty( options['state'])) - // { - // api->setState( options['state']); - // } + /// + /// Get a list of all merchants + /// + public object GetAll( /*options = array()*/) + { + throw new NotImplementedException("this is not yet implemented"); + //api = new Api\GetMerchants(); + // if (!String.IsNullOrEmpty( options['state'])) + // { + // api->setState( options['state']); + // } - //var request = new API.Merchant.GetAll.Request - //{ - // MerchantId = "TODO" - //}; - //var response = _webClient.PerformRequest(request); - //return API.Merchant.GetAll.Response.FromRawResponse(response); + //var request = new API.Merchant.GetAll.Request + //{ + // MerchantId = "TODO" + //}; - return new object(); // Result\Merchant\GetList( result); - } + //var response = _webClient.PerformRequest(request); + //return API.Merchant.GetAll.Response.FromRawResponse(response); - public enum MerchantState - { - NewMerchant, + return new object(); // Result\Merchant\GetList( result); + } + + public enum MerchantState + { + NewMerchant, - } } } diff --git a/PAYNLSDK/Net/ApiTokenClient.cs b/PAYNLSDK/Net/ApiTokenClient.cs index 2af4dbc..8d90c44 100644 --- a/PAYNLSDK/Net/ApiTokenClient.cs +++ b/PAYNLSDK/Net/ApiTokenClient.cs @@ -1,46 +1,36 @@ -using PAYNLSDK.Net.ProxyConfigurationInjector; -using System; -using System.Collections.Generic; -using System.Collections.Specialized; +using PayNLSdk.Api; +using PayNLSdk.Net.ProxyConfigurationInjector; using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Net; -using System.Text; -using PAYNLSDK.API; -using PAYNLSDK.Exceptions; -using Newtonsoft.Json; -using PAYNLSDK.Utilities; -namespace PAYNLSDK.Net +namespace PayNLSdk.Net; + +/// +/// +/// A client which can be constructed with an apiToken and a serviceId +/// +/// +[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "It can be used by other applications")] +public class ApiTokenClient : Client { - /// /// - /// A client which can be constructed with an apiToken and a serviceId + /// Initializes a new instance of the class. /// - /// - [SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "It can be used by other applications")] - public class ApiTokenClient : Client + /// The service identifier. + /// The API token. + /// The proxy configuration injector. + /// + public ApiTokenClient(string serviceId, string apiToken, IProxyConfigurationInjector proxyConfigurationInjector = null) + : base(new PayNlConfiguration(serviceId, apiToken), proxyConfigurationInjector) { - /// - /// Initializes a new instance of the class. - /// - /// The service identifier. - /// The API token. - /// The proxy configuration injector. - /// - public ApiTokenClient(string serviceId, string apiToken, IProxyConfigurationInjector proxyConfigurationInjector = null) - : base(new PayNlConfiguration(serviceId, apiToken), proxyConfigurationInjector) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// The security configuration. - /// The proxy configuration injector. - /// - public ApiTokenClient(IPayNlConfiguration securityConfiguration, IProxyConfigurationInjector proxyConfigurationInjector = null) : base(securityConfiguration, proxyConfigurationInjector) - { - } + /// + /// Initializes a new instance of the class. + /// + /// The security configuration. + /// The proxy configuration injector. + /// + public ApiTokenClient(IPayNlConfiguration securityConfiguration, IProxyConfigurationInjector proxyConfigurationInjector = null) : base(securityConfiguration, proxyConfigurationInjector) + { } -} +} \ No newline at end of file diff --git a/PAYNLSDK/Net/Client.cs b/PAYNLSDK/Net/Client.cs index ddc2085..6b1dbd1 100644 --- a/PAYNLSDK/Net/Client.cs +++ b/PAYNLSDK/Net/Client.cs @@ -1,8 +1,8 @@ using Newtonsoft.Json; -using PAYNLSDK.API; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Net.ProxyConfigurationInjector; -using PAYNLSDK.Utilities; +using PayNLSdk.Api; +using PayNLSdk.Exceptions; +using PayNLSdk.Net.ProxyConfigurationInjector; +using PayNLSdk.Utilities; using System; using System.Collections.Generic; using System.Collections.Specialized; @@ -11,284 +11,283 @@ using System.Net; using System.Text; -namespace PAYNLSDK.Net +namespace PayNLSdk.Net; + +/// +/// +/// This is the default client to be used by the PayNl function calls +/// +[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] +public class Client : IClient { - /// - /// - /// This is the default client to be used by the PayNl function calls + /// + /// If the client needs to work with a proxy, inject it here + /// + protected readonly IProxyConfigurationInjector ProxyConfigurationInjector; + /// + /// The PayNL configuration /// - [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] - public class Client : IClient + protected readonly IPayNlConfiguration SecurityConfiguration; + + /// + [SuppressMessage("ReSharper", "MemberCanBeProtected.Global")] + public Client(IPayNlConfiguration securityConfiguration, IProxyConfigurationInjector proxyConfigurationInjector = null) { - /// - /// If the client needs to work with a proxy, inject it here - /// - protected readonly IProxyConfigurationInjector ProxyConfigurationInjector; - /// - /// The PayNL configuration - /// - protected readonly IPayNlConfiguration SecurityConfiguration; - - /// - [SuppressMessage("ReSharper", "MemberCanBeProtected.Global")] - public Client(IPayNlConfiguration securityConfiguration, IProxyConfigurationInjector proxyConfigurationInjector = null) - { - SecurityConfiguration = securityConfiguration; - ProxyConfigurationInjector = proxyConfigurationInjector; - } + SecurityConfiguration = securityConfiguration; + ProxyConfigurationInjector = proxyConfigurationInjector; + } - private const string Endpoint = "https://rest-api.pay.nl"; + private const string Endpoint = "https://rest-api.pay.nl"; - /// - public string ClientVersion => "1.1.0.0"; + /// + public string ClientVersion => "1.1.0.0"; - /// - public string UserAgent => $"PAYNL/SDK/{ClientVersion} DotNet/{Environment.Version.Major}"; + /// + public string UserAgent => $"PAYNL/SDK/{ClientVersion} DotNet/{Environment.Version.Major}"; - /// - /// Performs an actual request - /// - /// Specific request implementation to perform - /// raw response string - public string PerformRequest(RequestBase request) - { - var webRequest = PrepareRequest(request.Url, "POST"); - var rawResponse = PerformRoundTrip2(webRequest, HttpStatusCode.OK, () => + /// + /// Performs an actual request + /// + /// Specific request implementation to perform + /// raw response string + public string PerformRequest(RequestBase request) + { + var webRequest = PrepareRequest(request.Url, "POST"); + var rawResponse = PerformRoundTrip2(webRequest, HttpStatusCode.OK, () => + { + using (var requestWriter = new StreamWriter(webRequest.GetRequestStream())) { - using (var requestWriter = new StreamWriter(webRequest.GetRequestStream())) - { - //string serializedResource = resource.Serialize(); - string serializedResource = ToQueryString(request); - requestWriter.Write(serializedResource); - } + //string serializedResource = resource.Serialize(); + string serializedResource = ToQueryString(request); + requestWriter.Write(serializedResource); } - ); - request.RawResponse = rawResponse; - return rawResponse; + } + ); + request.RawResponse = rawResponse; + return rawResponse; - //var webClient = new WebClient(); - //// we are not using the client.Credentials for the reason stated here: https://stackoverflow.com/a/26016919/97615 - ////string credentials = Convert.ToBase64String( - //// Encoding.ASCII.GetBytes("token:" + _securityConfiguration.ApiToken)); - ////webClient.Headers[HttpRequestHeader.Authorization] = $"Basic {credentials}"; - //webClient.Credentials = new NetworkCredential("token", _securityConfiguration.ApiToken); - //webClient.Headers[HttpRequestHeader.UserAgent] = this.UserAgent; - //webClient.QueryString = GetParameters(request); - //webClient.BaseAddress = Endpoint; + //var webClient = new WebClient(); + //// we are not using the client.Credentials for the reason stated here: https://stackoverflow.com/a/26016919/97615 + ////string credentials = Convert.ToBase64String( + //// Encoding.ASCII.GetBytes("token:" + _securityConfiguration.ApiToken)); + ////webClient.Headers[HttpRequestHeader.Authorization] = $"Basic {credentials}"; + //webClient.Credentials = new NetworkCredential("token", _securityConfiguration.ApiToken); + //webClient.Headers[HttpRequestHeader.UserAgent] = this.UserAgent; + //webClient.QueryString = GetParameters(request); + //webClient.BaseAddress = Endpoint; - //// download data - //var rawResponse = webClient.DownloadString(request.Url); + //// download data + //var rawResponse = webClient.DownloadString(request.Url); - return rawResponse; - } + return rawResponse; + } - /// - /// Returns a NameValueCollection of all parameters used for this call. - /// - /// Name Value collection of parameters - private NameValueCollection GetParameters(RequestBase request) + /// + /// Returns a NameValueCollection of all parameters used for this call. + /// + /// Name Value collection of parameters + private NameValueCollection GetParameters(RequestBase request) + { + var nvc = request.GetParameters(); + if (request.RequiresApiToken) { - var nvc = request.GetParameters(); - if (request.RequiresApiToken) - { - ParameterValidator.IsNotEmpty(SecurityConfiguration.ApiToken, nameof(SecurityConfiguration.ApiToken)); - nvc.Add("token", SecurityConfiguration.ApiToken); - } - if (request.RequiresServiceId) - { - ParameterValidator.IsNotEmpty(SecurityConfiguration.ServiceId, nameof(SecurityConfiguration.ServiceId)); - nvc.Add("serviceId", SecurityConfiguration.ServiceId); - } + ParameterValidator.IsNotEmpty(SecurityConfiguration.ApiToken, nameof(SecurityConfiguration.ApiToken)); + nvc.Add("token", SecurityConfiguration.ApiToken); + } + if (request.RequiresServiceId) + { + ParameterValidator.IsNotEmpty(SecurityConfiguration.ServiceId, nameof(SecurityConfiguration.ServiceId)); + nvc.Add("serviceId", SecurityConfiguration.ServiceId); + } - return nvc; + return nvc; + } + + /// + /// Transform NameValueCollection to a querystring + /// + /// querystring ready to be appended to the url + private string ToQueryString(RequestBase request) + { + var nvc = GetParameters(request); + if (nvc.Count == 0) + { + return ""; } - /// - /// Transform NameValueCollection to a querystring - /// - /// querystring ready to be appended to the url - private string ToQueryString(RequestBase request) + var sb = new StringBuilder(); + // TODO: add "?" if GET? + + var first = true; + + foreach (var key in nvc.AllKeys) { - var nvc = GetParameters(request); - if (nvc.Count == 0) + var values = nvc.GetValues(key); + if (values == null) { - return ""; + // don't add empty parameters + continue; } - var sb = new StringBuilder(); - // TODO: add "?" if GET? - - var first = true; - - foreach (var key in nvc.AllKeys) + foreach (var value in values) { - var values = nvc.GetValues(key); - if (values == null) + if (!first) { - // don't add empty parameters - continue; + sb.Append("&"); } - foreach (var value in values) - { - if (!first) - { - sb.Append("&"); - } - - sb.AppendFormat("{0}={1}", Uri.EscapeDataString(key), Uri.EscapeDataString(value)); + sb.AppendFormat("{0}={1}", Uri.EscapeDataString(key), Uri.EscapeDataString(value)); - first = false; - } + first = false; } - - return sb.ToString(); } - /// - /// Prepares a request - /// - /// URL to call - /// Request Method (get, post, delete, put) - /// A new WebRequest - private HttpWebRequest PrepareRequest(string requestUriString, string method) + return sb.ToString(); + } + + /// + /// Prepares a request + /// + /// URL to call + /// Request Method (get, post, delete, put) + /// A new WebRequest + private HttpWebRequest PrepareRequest(string requestUriString, string method) + { + var uriString = $"{Endpoint}/{requestUriString}"; + var uri = new Uri(uriString); + var request = WebRequest.Create(uri) as HttpWebRequest; + request.UserAgent = UserAgent; + const string applicationJsonContentType = "application/json"; // http://tools.ietf.org/html/rfc4627 + const string wwwUrlContentType = "application/x-www-form-urlencoded"; // http://tools.ietf.org/html/rfc4627 + request.Accept = applicationJsonContentType; + //request.ContentType = ApplicationJsonContentType; + request.ContentType = wwwUrlContentType; + request.Method = method; + + if (null != ProxyConfigurationInjector) { - var uriString = $"{Endpoint}/{requestUriString}"; - var uri = new Uri(uriString); - var request = WebRequest.Create(uri) as HttpWebRequest; - request.UserAgent = UserAgent; - const string applicationJsonContentType = "application/json"; // http://tools.ietf.org/html/rfc4627 - const string wwwUrlContentType = "application/x-www-form-urlencoded"; // http://tools.ietf.org/html/rfc4627 - request.Accept = applicationJsonContentType; - //request.ContentType = ApplicationJsonContentType; - request.ContentType = wwwUrlContentType; - request.Method = method; - - if (null != ProxyConfigurationInjector) - { - request.Proxy = ProxyConfigurationInjector.InjectProxyConfiguration(request.Proxy, uri); - } - return request; + request.Proxy = ProxyConfigurationInjector.InjectProxyConfiguration(request.Proxy, uri); } + return request; + } - /// - /// Performs the actual HTTP Request - /// - /// the http request - /// expected http status code - /// Any action that can be executed before actually performing the http request - /// raw response - private string PerformRoundTrip2(HttpWebRequest request, HttpStatusCode expectedHttpStatusCode, Action requestAction) + /// + /// Performs the actual HTTP Request + /// + /// the http request + /// expected http status code + /// Any action that can be executed before actually performing the http request + /// raw response + private string PerformRoundTrip2(HttpWebRequest request, HttpStatusCode expectedHttpStatusCode, Action requestAction) + { + try { - try - { - requestAction(); + requestAction(); - using (var response = request.GetResponse() as HttpWebResponse) + using (var response = request.GetResponse() as HttpWebResponse) + { + var statusCode = (HttpStatusCode)response.StatusCode; + if (statusCode != expectedHttpStatusCode) { - var statusCode = (HttpStatusCode)response.StatusCode; - if (statusCode != expectedHttpStatusCode) - { - throw new PayNlException(string.Format("Unexpected status code {0}", statusCode)); - } + throw new PayNlException(string.Format("Unexpected status code {0}", statusCode)); + } - Stream responseStream = response.GetResponseStream(); - Encoding encoding = GetEncoding(response); + Stream responseStream = response.GetResponseStream(); + Encoding encoding = GetEncoding(response); - using (var responseReader = new StreamReader(responseStream, encoding)) - { - return responseReader.ReadToEnd(); - } + using (var responseReader = new StreamReader(responseStream, encoding)) + { + return responseReader.ReadToEnd(); } } - catch (WebException e) - { - throw ErrorExceptionFromWebException(e); - } - catch (Exception e) - { - throw new PayNlException($"Unhandled exception {e.Message}", e); - } } - - /// - /// Get the Encoding - /// - /// http response - /// Encoding - private static Encoding GetEncoding(HttpWebResponse response) + catch (WebException e) { - // TODO: Make this conditional on the encoding of the response. - Encoding encode = Encoding.UTF8; // GetEncoding("utf-8"); // Encoding.GetEncoding(response.CharacterSet); - return encode; + throw ErrorExceptionFromWebException(e); } + catch (Exception e) + { + throw new PayNlException($"Unhandled exception {e.Message}", e); + } + } - /// - /// Build an error exception from a Web Exception - /// - /// web exception - /// PayNlException - private PayNlException ErrorExceptionFromWebException(WebException e) + /// + /// Get the Encoding + /// + /// http response + /// Encoding + private static Encoding GetEncoding(HttpWebResponse response) + { + // TODO: Make this conditional on the encoding of the response. + Encoding encode = Encoding.UTF8; // GetEncoding("utf-8"); // Encoding.GetEncoding(response.CharacterSet); + return encode; + } + + /// + /// Build an error exception from a Web Exception + /// + /// web exception + /// PayNlException + private PayNlException ErrorExceptionFromWebException(WebException e) + { + var httpWebResponse = e.Response as HttpWebResponse; + if (null == httpWebResponse) { - var httpWebResponse = e.Response as HttpWebResponse; - if (null == httpWebResponse) - { - // some kind of network error: didn't even make a connection - return new PayNlException(e.Message, e); - } + // some kind of network error: didn't even make a connection + return new PayNlException(e.Message, e); + } - var statusCode = (HttpStatusCode)httpWebResponse.StatusCode; - switch (statusCode) - { - case HttpStatusCode.Unauthorized: - case HttpStatusCode.NotFound: - case HttpStatusCode.MethodNotAllowed: - case HttpStatusCode.UnprocessableEntity: - case HttpStatusCode.BadRequest: - using (var responseReader = new StreamReader(httpWebResponse.GetResponseStream())) + var statusCode = (HttpStatusCode)httpWebResponse.StatusCode; + switch (statusCode) + { + case HttpStatusCode.Unauthorized: + case HttpStatusCode.NotFound: + case HttpStatusCode.MethodNotAllowed: + case HttpStatusCode.UnprocessableEntity: + case HttpStatusCode.BadRequest: + using (var responseReader = new StreamReader(httpWebResponse.GetResponseStream())) + { + string rawResponse = responseReader.ReadToEnd(); + // Try JSON parsing. + try { - string rawResponse = responseReader.ReadToEnd(); - // Try JSON parsing. - try + Dictionary errors = JsonConvert.DeserializeObject>(rawResponse); + string errMessage = ""; + if (errors.ContainsKey("error")) { - Dictionary errors = JsonConvert.DeserializeObject>(rawResponse); - string errMessage = ""; - if (errors.ContainsKey("error")) - { - errMessage = errors["error"]; - } - else if (errors.ContainsKey("message")) - { - errMessage = errors["message"]; - } - - return new PayNlException(errMessage, e); + errMessage = errors["error"]; } - catch (Exception ex1) + else if (errors.ContainsKey("message")) { - return new PayNlException(string.Format("Unknown error for {0}", statusCode), ex1); + errMessage = errors["message"]; } + + return new PayNlException(errMessage, e); } - case HttpStatusCode.InternalServerError: - case HttpStatusCode.NotImplemented: - case HttpStatusCode.BadGateway: - case HttpStatusCode.ServiceUnavailable: - case HttpStatusCode.GatewayTimeout: - case HttpStatusCode.HttpVersionNotSupported: - case HttpStatusCode.VariantAlsoNegotiates: - case HttpStatusCode.InsufficientStorage: - case HttpStatusCode.LoopDetected: - case HttpStatusCode.BandwidthLimitExceeded: - case HttpStatusCode.NotExtended: - case HttpStatusCode.NetworkAuthenticationRequired: - case HttpStatusCode.NetworkReadTimeoutError: - case HttpStatusCode.NetworkConnectTimeoutError: - return new PayNlException("Something went wrong on our end, please try again", e); - default: - return new PayNlException(string.Format("Unhandled status code {0}", statusCode), e); - } + catch (Exception ex1) + { + return new PayNlException(string.Format("Unknown error for {0}", statusCode), ex1); + } + } + case HttpStatusCode.InternalServerError: + case HttpStatusCode.NotImplemented: + case HttpStatusCode.BadGateway: + case HttpStatusCode.ServiceUnavailable: + case HttpStatusCode.GatewayTimeout: + case HttpStatusCode.HttpVersionNotSupported: + case HttpStatusCode.VariantAlsoNegotiates: + case HttpStatusCode.InsufficientStorage: + case HttpStatusCode.LoopDetected: + case HttpStatusCode.BandwidthLimitExceeded: + case HttpStatusCode.NotExtended: + case HttpStatusCode.NetworkAuthenticationRequired: + case HttpStatusCode.NetworkReadTimeoutError: + case HttpStatusCode.NetworkConnectTimeoutError: + return new PayNlException("Something went wrong on our end, please try again", e); + default: + return new PayNlException(string.Format("Unhandled status code {0}", statusCode), e); } - } + } diff --git a/PAYNLSDK/Net/HttpStatusCodes.cs b/PAYNLSDK/Net/HttpStatusCodes.cs index 408e485..8ae012e 100644 --- a/PAYNLSDK/Net/HttpStatusCodes.cs +++ b/PAYNLSDK/Net/HttpStatusCodes.cs @@ -1,92 +1,85 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace PayNLSdk.Net; -namespace PAYNLSDK.Net +// A more complete list of http status codes from http://httpstatus.es/ +enum HttpStatusCode { - // A more complete list of http status codes from http://httpstatus.es/ - enum HttpStatusCode - { - // 1xx informational - Continue = 100, - SwitchingProtocols = 101, - Processing = 102, - Checkpoint = 103, - MaximumRequestUri = 122, + // 1xx informational + Continue = 100, + SwitchingProtocols = 101, + Processing = 102, + Checkpoint = 103, + MaximumRequestUri = 122, - // 2xx success - OK = 200, - Created = 201, - Accepted = 202, - NonAuthoritativeInformation = 203, - NoContent = 204, - ResetContent = 205, - PartialContent = 206, - MultiStatus = 207, - AlreadyReported = 208, - IMUsed = 226, + // 2xx success + OK = 200, + Created = 201, + Accepted = 202, + NonAuthoritativeInformation = 203, + NoContent = 204, + ResetContent = 205, + PartialContent = 206, + MultiStatus = 207, + AlreadyReported = 208, + IMUsed = 226, - // 3xx redirection - MultipleChoices = 300, - MovedPermanently = 301, - Found = 302, - SeeOther = 303, - NotModified = 304, - UseProxy = 305, - SwitchProxy = 306, - TemporaryRedirect = 307, - PermanentRedirect = 308, + // 3xx redirection + MultipleChoices = 300, + MovedPermanently = 301, + Found = 302, + SeeOther = 303, + NotModified = 304, + UseProxy = 305, + SwitchProxy = 306, + TemporaryRedirect = 307, + PermanentRedirect = 308, - // 4xx client error - BadRequest = 400, - Unauthorized = 401, - PaymentRequired = 402, - Forbidden = 403, - NotFound = 404, - MethodNotAllowed = 405, - NotAcceptable = 406, - ProxyAuthenticationRequired = 407, - RequestTimeout = 408, - Conflict = 409, - Gone = 410, - LengthRequired = 411, - PreconditionFailed = 412, - RequestEntityTooLarge = 413, - RequestUriTooLong = 414, - UnsupportedMediaType = 415, - RequestRangeNotSatisfiable = 416, - ExpectationFailed = 417, - IamATeapot = 418, - EnhanceYourCalm = 420, - UnprocessableEntity = 422, - Locked = 423, - FailedDependency = 424, - UpgradeRequired = 426, - PreconditionRequired = 428, - TooManyRequests = 429, - RequestHeaderFieldsTooLarge = 431, - NoResponse = 444, - RetryWith = 449, - BlockedByWindowsParentalControls = 450, - WrongExchangeServer = 451, - ClientClosedRequest = 499, + // 4xx client error + BadRequest = 400, + Unauthorized = 401, + PaymentRequired = 402, + Forbidden = 403, + NotFound = 404, + MethodNotAllowed = 405, + NotAcceptable = 406, + ProxyAuthenticationRequired = 407, + RequestTimeout = 408, + Conflict = 409, + Gone = 410, + LengthRequired = 411, + PreconditionFailed = 412, + RequestEntityTooLarge = 413, + RequestUriTooLong = 414, + UnsupportedMediaType = 415, + RequestRangeNotSatisfiable = 416, + ExpectationFailed = 417, + IamATeapot = 418, + EnhanceYourCalm = 420, + UnprocessableEntity = 422, + Locked = 423, + FailedDependency = 424, + UpgradeRequired = 426, + PreconditionRequired = 428, + TooManyRequests = 429, + RequestHeaderFieldsTooLarge = 431, + NoResponse = 444, + RetryWith = 449, + BlockedByWindowsParentalControls = 450, + WrongExchangeServer = 451, + ClientClosedRequest = 499, - // 5xx server errror - InternalServerError = 500, - NotImplemented = 501, - BadGateway = 502, - ServiceUnavailable = 503, - GatewayTimeout = 504, - HttpVersionNotSupported = 505, - VariantAlsoNegotiates = 506, - InsufficientStorage = 507, - LoopDetected = 508, - BandwidthLimitExceeded = 509, - NotExtended = 510, - NetworkAuthenticationRequired = 511, - NetworkReadTimeoutError = 598, - NetworkConnectTimeoutError = 599 - } + // 5xx server errror + InternalServerError = 500, + NotImplemented = 501, + BadGateway = 502, + ServiceUnavailable = 503, + GatewayTimeout = 504, + HttpVersionNotSupported = 505, + VariantAlsoNegotiates = 506, + InsufficientStorage = 507, + LoopDetected = 508, + BandwidthLimitExceeded = 509, + NotExtended = 510, + NetworkAuthenticationRequired = 511, + NetworkReadTimeoutError = 598, + NetworkConnectTimeoutError = 599 } diff --git a/PAYNLSDK/Net/IClient.cs b/PAYNLSDK/Net/IClient.cs index 3f23cf3..7108c39 100644 --- a/PAYNLSDK/Net/IClient.cs +++ b/PAYNLSDK/Net/IClient.cs @@ -1,27 +1,26 @@ -using PAYNLSDK.API; +using PayNLSdk.Api; -namespace PAYNLSDK.Net +namespace PayNLSdk.Net; + +/// +/// The wrapper for performing HTTP REST calls to the api +/// +public interface IClient { /// - /// The wrapper for performing HTTP REST calls to the api + /// Client version /// - public interface IClient - { - /// - /// Client version - /// - string ClientVersion { get; } + string ClientVersion { get; } - /// - /// User agent - /// - string UserAgent { get; } + /// + /// User agent + /// + string UserAgent { get; } - /// - /// Performs an actual request - /// - /// Specific request implementation to perform - /// raw response string - string PerformRequest(RequestBase request); - } + /// + /// Performs an actual request + /// + /// Specific request implementation to perform + /// raw response string + string PerformRequest(RequestBase request); } diff --git a/PAYNLSDK/Net/ProxyConfigurationInjector/IProxyConfigurationInjector.cs b/PAYNLSDK/Net/ProxyConfigurationInjector/IProxyConfigurationInjector.cs index b0078de..c6e7bf1 100644 --- a/PAYNLSDK/Net/ProxyConfigurationInjector/IProxyConfigurationInjector.cs +++ b/PAYNLSDK/Net/ProxyConfigurationInjector/IProxyConfigurationInjector.cs @@ -1,10 +1,9 @@ using System; using System.Net; -namespace PAYNLSDK.Net.ProxyConfigurationInjector +namespace PayNLSdk.Net.ProxyConfigurationInjector; + +public interface IProxyConfigurationInjector { - public interface IProxyConfigurationInjector - { - IWebProxy InjectProxyConfiguration(IWebProxy webProxy, Uri uri); - } -} \ No newline at end of file + IWebProxy InjectProxyConfiguration(IWebProxy webProxy, Uri uri); +} diff --git a/PAYNLSDK/Net/ProxyConfigurationInjector/InjectCredentialsForProxiedUris.cs b/PAYNLSDK/Net/ProxyConfigurationInjector/InjectCredentialsForProxiedUris.cs index e36259f..1cd0120 100644 --- a/PAYNLSDK/Net/ProxyConfigurationInjector/InjectCredentialsForProxiedUris.cs +++ b/PAYNLSDK/Net/ProxyConfigurationInjector/InjectCredentialsForProxiedUris.cs @@ -1,26 +1,25 @@ using System; using System.Net; -namespace PAYNLSDK.Net.ProxyConfigurationInjector +namespace PayNLSdk.Net.ProxyConfigurationInjector; + +public class InjectCredentialsForProxiedUris : IProxyConfigurationInjector { - public class InjectCredentialsForProxiedUris : IProxyConfigurationInjector - { - private readonly ICredentials credentials; + private readonly ICredentials credentials; - public InjectCredentialsForProxiedUris(ICredentials credentials) - { - this.credentials = credentials; - } + public InjectCredentialsForProxiedUris(ICredentials credentials) + { + this.credentials = credentials; + } - public IWebProxy InjectProxyConfiguration(IWebProxy webProxy, Uri uri) + public IWebProxy InjectProxyConfiguration(IWebProxy webProxy, Uri uri) + { + Uri proxy = WebRequest.DefaultWebProxy.GetProxy(uri); + if (uri != proxy) // request goes through proxy { - Uri proxy = WebRequest.DefaultWebProxy.GetProxy(uri); - if (uri != proxy) // request goes through proxy - { - // webProxy.UseDefaultCredentials = true; // not accessible through IWebProxy - webProxy.Credentials = credentials; // same as setting `webProxy.UseDefaultCredentials = true` - } - return webProxy; + // webProxy.UseDefaultCredentials = true; // not accessible through IWebProxy + webProxy.Credentials = credentials; // same as setting `webProxy.UseDefaultCredentials = true` } + return webProxy; } -} \ No newline at end of file +} diff --git a/PAYNLSDK/Net/ProxyConfigurationInjector/InjectDefaultCredentialsForProxiedUris.cs b/PAYNLSDK/Net/ProxyConfigurationInjector/InjectDefaultCredentialsForProxiedUris.cs index 95da5bc..9db7858 100644 --- a/PAYNLSDK/Net/ProxyConfigurationInjector/InjectDefaultCredentialsForProxiedUris.cs +++ b/PAYNLSDK/Net/ProxyConfigurationInjector/InjectDefaultCredentialsForProxiedUris.cs @@ -1,11 +1,10 @@ using System.Net; -namespace PAYNLSDK.Net.ProxyConfigurationInjector +namespace PayNLSdk.Net.ProxyConfigurationInjector; + +public class InjectDefaultCredentialsForProxiedUris : InjectCredentialsForProxiedUris { - public class InjectDefaultCredentialsForProxiedUris: InjectCredentialsForProxiedUris + public InjectDefaultCredentialsForProxiedUris() : base(CredentialCache.DefaultCredentials) { - public InjectDefaultCredentialsForProxiedUris(): base (CredentialCache.DefaultCredentials) - { - } } } diff --git a/PAYNLSDK/Net/ProxyConfigurationInjector/InjectWebProxy.cs b/PAYNLSDK/Net/ProxyConfigurationInjector/InjectWebProxy.cs index 03a01bd..93d8a16 100644 --- a/PAYNLSDK/Net/ProxyConfigurationInjector/InjectWebProxy.cs +++ b/PAYNLSDK/Net/ProxyConfigurationInjector/InjectWebProxy.cs @@ -1,29 +1,28 @@ using System; using System.Net; -namespace PAYNLSDK.Net.ProxyConfigurationInjector +namespace PayNLSdk.Net.ProxyConfigurationInjector; + +/// +/// Completely overwrites the web proxy so you can hard configure it. Example: +/// +/// ICredentials credentials = new NetworkCredential("xxxx", "xxxx"); +/// IWebProxy webProxy = new WebProxy (new Uri("http://xx.xx.xx.xxx:xxxx")); +/// webProxy.Credentials = credentials; +/// new InjectWebProxy(webProxy); +/// +/// +public class InjectWebProxy : IProxyConfigurationInjector { - /// - /// Completely overwrites the web proxy so you can hard configure it. Example: - /// - /// ICredentials credentials = new NetworkCredential("xxxx", "xxxx"); - /// IWebProxy webProxy = new WebProxy (new Uri("http://xx.xx.xx.xxx:xxxx")); - /// webProxy.Credentials = credentials; - /// new InjectWebProxy(webProxy); - /// - /// - public class InjectWebProxy: IProxyConfigurationInjector - { - private readonly IWebProxy webProxyToInject; + private readonly IWebProxy webProxyToInject; - public InjectWebProxy(IWebProxy webProxyToInject) - { - this.webProxyToInject = webProxyToInject; - } + public InjectWebProxy(IWebProxy webProxyToInject) + { + this.webProxyToInject = webProxyToInject; + } - public IWebProxy InjectProxyConfiguration(IWebProxy webProxy, Uri uri) - { - return webProxyToInject; - } + public IWebProxy InjectProxyConfiguration(IWebProxy webProxy, Uri uri) + { + return webProxyToInject; } -} \ No newline at end of file +} diff --git a/PAYNLSDK/Objects/Address.cs b/PAYNLSDK/Objects/Address.cs index cfbdcc8..9a22e04 100644 --- a/PAYNLSDK/Objects/Address.cs +++ b/PAYNLSDK/Objects/Address.cs @@ -1,68 +1,65 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; -using PAYNLSDK.Converters; +using Newtonsoft.Json; +using PayNLSdk.Converters; +using PayNLSdk.Enums; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// General Address Details +/// +public class Address { /// - /// General Address Details + /// Initials for Address /// - public class Address - { - /// - /// Initials for Address - /// - [JsonProperty("initials")] - public string Initials { get; set; } - - /// - /// Lastname of receiver - /// - [JsonProperty("lastName")] - public string LastName { get; set; } + [JsonProperty("initials")] + public string Initials { get; set; } - /// - /// Gender of receiver - /// - [JsonProperty("gender"), JsonConverter(typeof(GenderConverter))] - public Gender? Gender { get; set; } + /// + /// Lastname of receiver + /// + [JsonProperty("lastName")] + public string LastName { get; set; } - /// - /// Street name - /// - [JsonProperty("streetName")] - public string StreetName { get; set; } + /// + /// Gender of receiver + /// + [JsonProperty("gender"), JsonConverter(typeof(GenderConverter))] + public Gender? Gender { get; set; } - /// - /// Street number - /// - [JsonProperty("streetNumber")] - public string StreetNumber { get; set; } + /// + /// Street name + /// + [JsonProperty("streetName")] + public string StreetName { get; set; } - /// - /// Street number - /// - [JsonProperty("streetNumberExtension")] - public string StreetNumberExtension { get; set; } + /// + /// Street number + /// + [JsonProperty("streetNumber")] + public string StreetNumber { get; set; } - /// - /// Zipcode - /// - [JsonProperty("zipCode")] - public string ZipCode { get; set; } + /// + /// Street number + /// + [JsonProperty("streetNumberExtension")] + public string StreetNumberExtension { get; set; } - /// - /// City - /// - [JsonProperty("city")] - public string City { get; set; } + /// + /// Zipcode + /// + [JsonProperty("zipCode")] + public string ZipCode { get; set; } - /// - /// ISO2 Country code - /// - [JsonProperty("countryCode")] - public string CountryCode { get; set; } - } + /// + /// City + /// + [JsonProperty("city")] + public string City { get; set; } -} + /// + /// ISO2 Country code + /// + [JsonProperty("countryCode")] + public string CountryCode { get; set; } +} \ No newline at end of file diff --git a/PAYNLSDK/Objects/Company.cs b/PAYNLSDK/Objects/Company.cs index ccc498c..d8d4908 100644 --- a/PAYNLSDK/Objects/Company.cs +++ b/PAYNLSDK/Objects/Company.cs @@ -1,34 +1,33 @@ using Newtonsoft.Json; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Company information, used in the enduser. +/// +public class Company { /// - /// Company information, used in the enduser. + /// The name of the company /// - public class Company - { - /// - /// The name of the company - /// - [JsonProperty("name")] - public string Name { get; set; } + [JsonProperty("name")] + public string Name { get; set; } - /// - /// The COC number of the company - /// - [JsonProperty("cocNumber")] - public string CocNumber { get; set; } + /// + /// The COC number of the company + /// + [JsonProperty("cocNumber")] + public string CocNumber { get; set; } - /// - /// The VAT number of the company - /// - [JsonProperty("vatNumber")] - public string VatNumber { get; set; } + /// + /// The VAT number of the company + /// + [JsonProperty("vatNumber")] + public string VatNumber { get; set; } - /// - /// ID of the country (2 char country code) - /// - [JsonProperty("countryCode")] - public string CountryCode { get; set; } - } + /// + /// ID of the country (2 char country code) + /// + [JsonProperty("countryCode")] + public string CountryCode { get; set; } } diff --git a/PAYNLSDK/Objects/Connection.cs b/PAYNLSDK/Objects/Connection.cs index 13202d4..67f4b25 100644 --- a/PAYNLSDK/Objects/Connection.cs +++ b/PAYNLSDK/Objects/Connection.cs @@ -1,90 +1,88 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; +using Newtonsoft.Json; +using PayNLSdk.Enums; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Connection information +/// +public class Connection { /// - /// Connection information + /// Trust indicator, from -10 to 10 /// - public class Connection - { - /// - /// Trust indicator, from -10 to 10 - /// - [JsonProperty("trust")] - public int? Trust { get; protected set; } + [JsonProperty("trust")] + public int? Trust { get; protected set; } - /// - /// Country code fo the customer - /// - [JsonProperty("country")] - public string Country { get; protected set; } + /// + /// Country code fo the customer + /// + [JsonProperty("country")] + public string Country { get; protected set; } - /// - /// name of the city of the customer - /// - [JsonProperty("city")] - public string City { get; protected set; } + /// + /// name of the city of the customer + /// + [JsonProperty("city")] + public string City { get; protected set; } - /// - /// Customer location, latitude - /// - [JsonProperty("locationLat")] - public string LocationLat { get; protected set; } + /// + /// Customer location, latitude + /// + [JsonProperty("locationLat")] + public string LocationLat { get; protected set; } - /// - /// Customer location, longitude - /// - [JsonProperty("locationLon")] - public string LocationLon { get; protected set; } + /// + /// Customer location, longitude + /// + [JsonProperty("locationLon")] + public string LocationLon { get; protected set; } - /// - /// Details of the cusomers browser. Specified on transaction start - /// - [JsonProperty("browserData")] - public string BrowserData { get; protected set; } + /// + /// Details of the cusomers browser. Specified on transaction start + /// + [JsonProperty("browserData")] + public string BrowserData { get; protected set; } - /// - /// IP address of the customer (during payment) - /// - [JsonProperty("ipAddress")] - public string IP { get; protected set; } + /// + /// IP address of the customer (during payment) + /// + [JsonProperty("ipAddress")] + public string IP { get; protected set; } - /// - /// Indicator whether or not the cusomer is blacklisted - /// - [JsonProperty("blacklist")] - public Blacklist? Blacklist { get; protected set; } + /// + /// Indicator whether or not the cusomer is blacklisted + /// + [JsonProperty("blacklist")] + public Blacklist? Blacklist { get; protected set; } - /// - /// Hostaddress of the customer - /// - [JsonProperty("host")] - public string Host { get; protected set; } + /// + /// Hostaddress of the customer + /// + [JsonProperty("host")] + public string Host { get; protected set; } - /// - /// Ip used in the order - /// - [JsonProperty("orderIpAddress")] - public string OrderIP { get; protected set; } + /// + /// Ip used in the order + /// + [JsonProperty("orderIpAddress")] + public string OrderIP { get; protected set; } - /// - /// Used return URl in request - /// - [JsonProperty("orderReturnUrl")] - public string OrderReturnUrl { get; protected set; } + /// + /// Used return URl in request + /// + [JsonProperty("orderReturnUrl")] + public string OrderReturnUrl { get; protected set; } - /// - /// The corresponding merchant-code of the merchant - /// - [JsonProperty("merchantCode")] - public string MerchantCode { get; protected set; } + /// + /// The corresponding merchant-code of the merchant + /// + [JsonProperty("merchantCode")] + public string MerchantCode { get; protected set; } - /// - /// The corresponding name of the merchant - /// - [JsonProperty("merchantName")] - public string MerchantName { get; protected set; } - } + /// + /// The corresponding name of the merchant + /// + [JsonProperty("merchantName")] + public string MerchantName { get; protected set; } } diff --git a/PAYNLSDK/Objects/CountryOption.cs b/PAYNLSDK/Objects/CountryOption.cs index 6803211..febb581 100644 --- a/PAYNLSDK/Objects/CountryOption.cs +++ b/PAYNLSDK/Objects/CountryOption.cs @@ -1,64 +1,61 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; -using PAYNLSDK.Converters; +using Newtonsoft.Json; +using PayNLSdk.Converters; using System.Collections.Generic; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// General Payment options details for an individual country. +/// +public class CountryOption { /// - /// General Payment options details for an individual country. + /// Country option ID /// - public class CountryOption - { - /// - /// Country option ID - /// - [JsonProperty("id")] - public string ID { get; set; } - - /// - /// Country name - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// Country visible name - /// - [JsonProperty("visibleName")] - public string VisibleName { get; set; } + [JsonProperty("id")] + public string ID { get; set; } - /// - /// Filename of the country icon - /// - [JsonProperty("img")] - public string Image { get; set; } + /// + /// Country name + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// Path for the country icon. The full icon URL is a concatenation of $basePath, $path and $img. - /// - [JsonProperty("path")] - public string IconPath { get; set; } + /// + /// Country visible name + /// + [JsonProperty("visibleName")] + public string VisibleName { get; set; } - /// - /// Indicator whether or not the country is located in the EU. - /// - [JsonProperty("in_eu"), JsonConverter(typeof(BooleanConverter))] - public bool InEU { get; protected set; } + /// + /// Filename of the country icon + /// + [JsonProperty("img")] + public string Image { get; set; } - /// - /// List of available payment options for this country - /// - [JsonProperty("paymentOptionList")] - public PaymentOptions PaymentOptions { get; set; } + /// + /// Path for the country icon. The full icon URL is a concatenation of $basePath, $path and $img. + /// + [JsonProperty("path")] + public string IconPath { get; set; } - } + /// + /// Indicator whether or not the country is located in the EU. + /// + [JsonProperty("in_eu"), JsonConverter(typeof(BooleanConverter))] + public bool InEU { get; protected set; } /// - /// Country Options + /// List of available payment options for this country /// - public class CountryOptions : Dictionary - { - } + [JsonProperty("paymentOptionList")] + public PaymentOptions PaymentOptions { get; set; } + +} + +/// +/// Country Options +/// +public class CountryOptions : Dictionary +{ } diff --git a/PAYNLSDK/Objects/Error.cs b/PAYNLSDK/Objects/Error.cs index 8303262..2166eed 100644 --- a/PAYNLSDK/Objects/Error.cs +++ b/PAYNLSDK/Objects/Error.cs @@ -1,30 +1,28 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Converters; +using Newtonsoft.Json; +using PayNLSdk.Converters; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Error definition +/// +public class Error { /// - /// Error definition + /// Result of a call. In case of a real error, this SHOULD always be false. /// - public class Error - { - /// - /// Result of a call. In case of a real error, this SHOULD always be false. - /// - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] - public bool Result { get; protected set; } + [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + public bool Result { get; protected set; } - /// - /// Error code - /// - [JsonProperty("errorId")] - public string Code { get; protected set; } + /// + /// Error code + /// + [JsonProperty("errorId")] + public string Code { get; protected set; } - /// - /// Error message - /// - [JsonProperty("errorMessage")] - public string Message { get; protected set; } - } + /// + /// Error message + /// + [JsonProperty("errorMessage")] + public string Message { get; protected set; } } diff --git a/PAYNLSDK/Objects/Merchant.cs b/PAYNLSDK/Objects/Merchant.cs index d5b75e5..edaf055 100644 --- a/PAYNLSDK/Objects/Merchant.cs +++ b/PAYNLSDK/Objects/Merchant.cs @@ -1,37 +1,35 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; +using Newtonsoft.Json; +using PayNLSdk.Enums; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Merchant information +/// +public class Merchant { /// - /// Merchant information + /// Merchant ID /// - public class Merchant - { - /// - /// Merchant ID - /// - [JsonProperty("id")] - public string ID { get; set; } + [JsonProperty("id")] + public string ID { get; set; } - /// - /// Merchant Name - /// - [JsonProperty("name")] - public string Name { get; set; } + /// + /// Merchant Name + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// Merchant Public Name - /// - [JsonProperty("publicName")] - public string PublicName { get; set; } + /// + /// Merchant Public Name + /// + [JsonProperty("publicName")] + public string PublicName { get; set; } - /// - /// Active State of the merchant - /// - [JsonProperty("state")] - public ActiveState State { get; set; } + /// + /// Active State of the merchant + /// + [JsonProperty("state")] + public ActiveState State { get; set; } - } -} +} \ No newline at end of file diff --git a/PAYNLSDK/Objects/OrderData.cs b/PAYNLSDK/Objects/OrderData.cs index 369e260..d1cf760 100644 --- a/PAYNLSDK/Objects/OrderData.cs +++ b/PAYNLSDK/Objects/OrderData.cs @@ -1,276 +1,274 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Converters; -using PAYNLSDK.Enums; +using Newtonsoft.Json; +using PayNLSdk.Converters; +using PayNLSdk.Enums; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Ordered product information +/// +public class OrderData { /// - /// Ordered product information + /// Your systems product ID /// - public class OrderData - { - /// - /// Your systems product ID - /// - [JsonProperty("productId")] - public string ProductId { get; set; } + [JsonProperty("productId")] + public string ProductId { get; set; } - /// - /// Description of the product (max 45 characters) - /// - [JsonProperty("description")] - public string Description { get; set; } + /// + /// Description of the product (max 45 characters) + /// + [JsonProperty("description")] + public string Description { get; set; } - /// - /// Amount in cents of the product (amount incl. vat) - /// - [JsonProperty("price")] - public int Price { get; set; } + /// + /// Amount in cents of the product (amount incl. vat) + /// + [JsonProperty("price")] + public int Price { get; set; } - /// - /// Quantity of products with this product id - /// - [JsonProperty("quantity")] - public int Quantity { get; set; } + /// + /// Quantity of products with this product id + /// + [JsonProperty("quantity")] + public int Quantity { get; set; } - /// - /// The vat code - /// - [JsonProperty("vatCode"),JsonConverter(typeof(TaxClassConverter))] - public TaxClass VatCode { get; set; } + /// + /// The vat code + /// + [JsonProperty("vatCode"), JsonConverter(typeof(TaxClassConverter))] + public TaxClass VatCode { get; set; } - /// - /// Type of the order line. Possible values: ARTICLE, SHIPPING, HANDLING, DISCOUNT - /// - [JsonProperty("productType"), JsonConverter(typeof(ProductTypeConverter))] - public ProductType ProductType { get; set; } + /// + /// Type of the order line. Possible values: ARTICLE, SHIPPING, HANDLING, DISCOUNT + /// + [JsonProperty("productType"), JsonConverter(typeof(ProductTypeConverter))] + public ProductType ProductType { get; set; } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Quantity of products with this product id - /// Product Type - public OrderData(string productId, string description, int price, string vatCode, int quantity, string productType) - { - ProductId = productId; - Description = description; - Price = price; - Quantity = quantity; - VatCode = VatCode = EnumUtil.ToEnum(vatCode); - ProductType = EnumUtil.ToEnum(productType); - } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Quantity of products with this product id + /// Product Type + public OrderData(string productId, string description, int price, string vatCode, int quantity, string productType) + { + ProductId = productId; + Description = description; + Price = price; + Quantity = quantity; + VatCode = VatCode = EnumUtil.ToEnum(vatCode); + ProductType = EnumUtil.ToEnum(productType); + } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Quantity of products with this product id - /// Product Type - public OrderData(string productId, string description, int price, string vatCode, int quantity, ProductType productType) - { - ProductId = productId; - Description = description; - Price = price; - Quantity = quantity; - VatCode = VatCode = EnumUtil.ToEnum(vatCode); - ProductType = productType; - } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Quantity of products with this product id + /// Product Type + public OrderData(string productId, string description, int price, string vatCode, int quantity, ProductType productType) + { + ProductId = productId; + Description = description; + Price = price; + Quantity = quantity; + VatCode = VatCode = EnumUtil.ToEnum(vatCode); + ProductType = productType; + } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Product Type - public OrderData(string productId, string description, int price, string vatCode, string productType) : this(productId, description, price, vatCode, 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Product Type + public OrderData(string productId, string description, int price, string vatCode, string productType) : this(productId, description, price, vatCode, 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Product Type - public OrderData(string productId, int price, string vatCode, string productType) : this(productId, "", price, vatCode, 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Product Type + public OrderData(string productId, int price, string vatCode, string productType) : this(productId, "", price, vatCode, 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// Product Type - public OrderData(string productId, string description, int price, string productType) : this(productId, description, price, "N", 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// Product Type + public OrderData(string productId, string description, int price, string productType) : this(productId, description, price, "N", 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Amount in cents of the product (amount incl. vat) - /// Product Type - public OrderData(string productId, int price, string productType) : this(productId, "", price, "N", 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Amount in cents of the product (amount incl. vat) + /// Product Type + public OrderData(string productId, int price, string productType) : this(productId, "", price, "N", 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Product Type - public OrderData(string productId, string description, int price, string vatCode, ProductType productType) : this(productId, description, price, vatCode, 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Product Type + public OrderData(string productId, string description, int price, string vatCode, ProductType productType) : this(productId, description, price, vatCode, 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Product Type - public OrderData(string productId, int price, string vatCode, ProductType productType) : this(productId, "", price, vatCode, 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Product Type + public OrderData(string productId, int price, string vatCode, ProductType productType) : this(productId, "", price, vatCode, 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// Product Type - public OrderData(string productId, string description, int price, ProductType productType) : this(productId, description, price, "N", 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// Product Type + public OrderData(string productId, string description, int price, ProductType productType) : this(productId, description, price, "N", 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Amount in cents of the product (amount incl. vat) - /// Product Type - public OrderData(string productId, int price, ProductType productType) : this(productId, "", price, "N", 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Amount in cents of the product (amount incl. vat) + /// Product Type + public OrderData(string productId, int price, ProductType productType) : this(productId, "", price, "N", 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Quantity of products with this product id - /// Product Type - public OrderData(string productId, string description, int price, TaxClass vatCode, int quantity, string productType) - { - ProductId = productId; - Description = description; - Price = price; - Quantity = quantity; - VatCode = vatCode; - //VatCode = EnumUtil.ToEnumString((TaxClass)vatCode); - //VatCode = EnumUtil.ToEnum(vatCode); - ProductType = EnumUtil.ToEnum(productType); - } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Quantity of products with this product id + /// Product Type + public OrderData(string productId, string description, int price, TaxClass vatCode, int quantity, string productType) + { + ProductId = productId; + Description = description; + Price = price; + Quantity = quantity; + VatCode = vatCode; + //VatCode = EnumUtil.ToEnumString((TaxClass)vatCode); + //VatCode = EnumUtil.ToEnum(vatCode); + ProductType = EnumUtil.ToEnum(productType); + } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Quantity of products with this product id - /// Product Type - public OrderData(string productId, string description, int price, TaxClass vatCode, int quantity, ProductType productType) - { - ProductId = productId; - Description = description; - Price = price; - Quantity = quantity; - VatCode = vatCode; - //VatCode = EnumUtil.ToEnumString((TaxClass)vatCode); - //VatCode = EnumUtil.ToEnum(vatCode); - ProductType = productType; - } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Quantity of products with this product id + /// Product Type + public OrderData(string productId, string description, int price, TaxClass vatCode, int quantity, ProductType productType) + { + ProductId = productId; + Description = description; + Price = price; + Quantity = quantity; + VatCode = vatCode; + //VatCode = EnumUtil.ToEnumString((TaxClass)vatCode); + //VatCode = EnumUtil.ToEnum(vatCode); + ProductType = productType; + } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Quantity of products with this product id - public OrderData(string productId, string description, int price, string vatCode, int quantity) : this(productId, description, price, vatCode, quantity, ProductType.ARTICLE) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Quantity of products with this product id + public OrderData(string productId, string description, int price, string vatCode, int quantity) : this(productId, description, price, vatCode, quantity, ProductType.ARTICLE) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Quantity of products with this product id - public OrderData(string productId, string description, int price, TaxClass vatCode, int quantity) : this(productId, description, price, vatCode, quantity, ProductType.ARTICLE) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Quantity of products with this product id + public OrderData(string productId, string description, int price, TaxClass vatCode, int quantity) : this(productId, description, price, vatCode, quantity, ProductType.ARTICLE) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Product Type - public OrderData(string productId, string description, int price, TaxClass vatCode, string productType) : this(productId, description, price, vatCode, 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Product Type + public OrderData(string productId, string description, int price, TaxClass vatCode, string productType) : this(productId, description, price, vatCode, 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Product Type - public OrderData(string productId, int price, TaxClass vatCode, string productType) : this(productId, "", price, vatCode, 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Product Type + public OrderData(string productId, int price, TaxClass vatCode, string productType) : this(productId, "", price, vatCode, 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Amount in cents of the product (amount incl. vat) - /// The vat code - public OrderData(string productId, int price, TaxClass vatCode) : this(productId, "", price, vatCode, 1, ProductType.ARTICLE) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Amount in cents of the product (amount incl. vat) + /// The vat code + public OrderData(string productId, int price, TaxClass vatCode) : this(productId, "", price, vatCode, 1, ProductType.ARTICLE) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Description of the product (max 45 characters) - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Product Type - public OrderData(string productId, string description, int price, TaxClass vatCode, ProductType productType) : this(productId, description, price, vatCode, 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Description of the product (max 45 characters) + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Product Type + public OrderData(string productId, string description, int price, TaxClass vatCode, ProductType productType) : this(productId, description, price, vatCode, 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Amount in cents of the product (amount incl. vat) - /// The vat code - /// Product Type - public OrderData(string productId, int price, TaxClass vatCode, ProductType productType) : this(productId, "", price, vatCode, 1, productType) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Amount in cents of the product (amount incl. vat) + /// The vat code + /// Product Type + public OrderData(string productId, int price, TaxClass vatCode, ProductType productType) : this(productId, "", price, vatCode, 1, productType) { } - /// - /// Create a new OrderData specification - /// - /// Your systems product ID - /// Amount in cents of the product (amount incl. vat) - /// The vat code - public OrderData(string productId, int price) : this(productId, "", price, "N", 1, ProductType.ARTICLE) { } + /// + /// Create a new OrderData specification + /// + /// Your systems product ID + /// Amount in cents of the product (amount incl. vat) + /// The vat code + public OrderData(string productId, int price) : this(productId, "", price, "N", 1, ProductType.ARTICLE) { } - } } diff --git a/PAYNLSDK/Objects/PaymentDetails.cs b/PAYNLSDK/Objects/PaymentDetails.cs index 2254fcb..9e24e86 100644 --- a/PAYNLSDK/Objects/PaymentDetails.cs +++ b/PAYNLSDK/Objects/PaymentDetails.cs @@ -1,233 +1,231 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; -using PAYNLSDK.Converters; +using Newtonsoft.Json; +using PayNLSdk.Converters; +using PayNLSdk.Enums; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// General details regarding the payment +/// +public class PaymentDetails { /// - /// General details regarding the payment - /// - public class PaymentDetails - { - /// - /// Amount of the session (in cents, eg. 1235) - /// - [JsonProperty("amount")] - public int Amount { get; protected set; } - - /// - /// Currency Amount of the session (in cents, eg. 1235) - /// - [JsonProperty("currencyAmount")] - public int CurrencyAmount { get; protected set; } - - /// - /// The total amount paid for this transaction - /// - [JsonProperty("paidAmount")] - public string PaidAmount { get; protected set; } - - /// - /// The total currency amount paid for this transaction - /// - [JsonProperty("paidCurrencyAmount")] - public string PaidCurrencyAmount { get; protected set; } - - /// - /// Basic amount without the cost - /// - [JsonProperty("paidBase")] - public string PaidBase { get; protected set; } - - /// - /// Payment costs paid by the customer (ex. VAT) - /// - [JsonProperty("paidCosts")] - public string PaidCosts { get; protected set; } - - /// - /// VAT rate for costs - /// - [JsonProperty("paidCostsVat")] - public string PaidCostsVat { get; protected set; } - - /// - /// Currency of the payment - /// - [JsonProperty("PaidCurreny")] - public string PaidCurrency { get; protected set; } - - /// - /// Number of payment attempts - /// - [JsonProperty("paidAttemps")] - public string PaidAttemps { get; protected set; } - - /// - /// Duration of the phonecall (only for phone payments) - /// - [JsonProperty("paidDuration")] - public string PaidDuration { get; protected set; } - - /// - /// Order description - /// - [JsonProperty("description")] - public string Description { get; protected set; } - - /// - /// Time passed from payment start to payment finish - /// - [JsonProperty("processTime")] - public string ProcessTime { get; protected set; } - - /// - /// Payment Status indicator - /// - [JsonProperty("state")] - public PaymentStatus State { get; protected set; } - - /// - /// Payment status name - /// - [JsonProperty("stateName")] - public string StateName { get; protected set; } - - /// - /// Payment status description - /// - [JsonProperty("stateDescription")] - public string StateDescription { get; protected set; } - - /// - /// Indicator whether or not the exchange URL has been called succesfully - /// - [JsonProperty("exchange")] - //public ExchangeState Exchange { get; protected set; } - public string Exchange { get; protected set; } - - /// - /// Indicator whether or not the transaction is refunded - /// - [JsonProperty("storno"), JsonConverter(typeof(BooleanConverter))] - public bool Storno { get; protected set; } - - /// - /// The payment options used (eq. iDeal/creditcard) - /// - [JsonProperty("paymentOptionId")] - public int PaymentOptionId { get; protected set; } - - /// - /// The payment options sub id used (eq. the selected bank for iDeal) - /// - [JsonProperty("paymentOptionSubId")] - public int PaymentOptionSubId { get; protected set; } - - /// - /// For creditcard transactions - /// - [JsonProperty("secure")] - public Secure Secure { get; protected set; } - - /// - /// Returns the 3d secure status - /// - [JsonProperty("secureStatus")] - public string SecureStatus { get; protected set; } - - /// - /// Name of the consumer - /// - [JsonProperty("identifierName")] - public string IdentifierName { get; protected set; } - - /// - /// Payment identifier that can be displayed to the customer for reference - /// - [JsonProperty("identifierPublic")] - public string IdentifierPublic { get; protected set; } - - /// - /// Customer ID, a unique hash based upon the bankaccount/creditcard number of the customer - /// - [JsonProperty("identifierHash")] - public string IdentifierHash { get; protected set; } - - /// - /// ID of the service/website for which the transaction is started - /// - [JsonProperty("serviceId")] - public string ServiceId { get; protected set; } - - /// - /// Name of the service/website - /// - [JsonProperty("serviceName")] - public string ServiceName { get; protected set; } - - /// - /// Description of the service/website - /// - [JsonProperty("serviceDescription")] - public string ServiceDescription { get; protected set; } - - /// - /// Date time of the moment the transaction was started - /// - [JsonProperty("created")] - public string Created { get; protected set; } - - /// - /// Date time of the last status change of the transaction - /// - [JsonProperty("modified")] - public string Modified { get; protected set; } - - /// - /// ID of the type of the payment method - /// - [JsonProperty("paymentMethodId")] - public string PaymentMethodId { get; protected set; } - - /// - /// Name of the type of the payment method - /// - [JsonProperty("paymentMethodName")] - public string PaymentMethodName { get; protected set; } - - /// - /// Description of the type of the payment method - /// - [JsonProperty("paymentMethodDescription")] - public string PaymentMethodDescription { get; protected set; } - - /// - /// Name of the payment profile used to pay the transaction - /// - [JsonProperty("paymentProfileName")] - public string PaymentProfileName { get; protected set; } - - /// - /// Gets or sets the Order number of the transaction . - /// - /// The order number. - [JsonProperty("orderNumber")] public string OrderNumber { get; set; } - - /// - /// Name of the creditcard supplier - /// - [JsonProperty("cardBrand")] public string CardBrand { get; set; } - - /// - /// Debit or credit - /// - [JsonProperty("cardType")] public string CardType { get; set; } - - /// - /// Countrycode of the creditcards origin - /// - [JsonProperty("cardCountryCode")] public string CardCountryCode { get; set; } - } + /// Amount of the session (in cents, eg. 1235) + /// + [JsonProperty("amount")] + public int Amount { get; protected set; } + + /// + /// Currency Amount of the session (in cents, eg. 1235) + /// + [JsonProperty("currencyAmount")] + public int CurrencyAmount { get; protected set; } + + /// + /// The total amount paid for this transaction + /// + [JsonProperty("paidAmount")] + public string PaidAmount { get; protected set; } + + /// + /// The total currency amount paid for this transaction + /// + [JsonProperty("paidCurrencyAmount")] + public string PaidCurrencyAmount { get; protected set; } + + /// + /// Basic amount without the cost + /// + [JsonProperty("paidBase")] + public string PaidBase { get; protected set; } + + /// + /// Payment costs paid by the customer (ex. VAT) + /// + [JsonProperty("paidCosts")] + public string PaidCosts { get; protected set; } + + /// + /// VAT rate for costs + /// + [JsonProperty("paidCostsVat")] + public string PaidCostsVat { get; protected set; } + + /// + /// Currency of the payment + /// + [JsonProperty("PaidCurreny")] + public string PaidCurrency { get; protected set; } + + /// + /// Number of payment attempts + /// + [JsonProperty("paidAttemps")] + public string PaidAttemps { get; protected set; } + + /// + /// Duration of the phonecall (only for phone payments) + /// + [JsonProperty("paidDuration")] + public string PaidDuration { get; protected set; } + + /// + /// Order description + /// + [JsonProperty("description")] + public string Description { get; protected set; } + + /// + /// Time passed from payment start to payment finish + /// + [JsonProperty("processTime")] + public string ProcessTime { get; protected set; } + + /// + /// Payment Status indicator + /// + [JsonProperty("state")] + public PaymentStatus State { get; protected set; } + + /// + /// Payment status name + /// + [JsonProperty("stateName")] + public string StateName { get; protected set; } + + /// + /// Payment status description + /// + [JsonProperty("stateDescription")] + public string StateDescription { get; protected set; } + + /// + /// Indicator whether or not the exchange URL has been called succesfully + /// + [JsonProperty("exchange")] + //public ExchangeState Exchange { get; protected set; } + public string Exchange { get; protected set; } + + /// + /// Indicator whether or not the transaction is refunded + /// + [JsonProperty("storno"), JsonConverter(typeof(BooleanConverter))] + public bool Storno { get; protected set; } + + /// + /// The payment options used (eq. iDeal/creditcard) + /// + [JsonProperty("paymentOptionId")] + public int PaymentOptionId { get; protected set; } + + /// + /// The payment options sub id used (eq. the selected bank for iDeal) + /// + [JsonProperty("paymentOptionSubId")] + public int PaymentOptionSubId { get; protected set; } + + /// + /// For creditcard transactions + /// + [JsonProperty("secure")] + public Secure Secure { get; protected set; } + + /// + /// Returns the 3d secure status + /// + [JsonProperty("secureStatus")] + public string SecureStatus { get; protected set; } + + /// + /// Name of the consumer + /// + [JsonProperty("identifierName")] + public string IdentifierName { get; protected set; } + + /// + /// Payment identifier that can be displayed to the customer for reference + /// + [JsonProperty("identifierPublic")] + public string IdentifierPublic { get; protected set; } + + /// + /// Customer ID, a unique hash based upon the bankaccount/creditcard number of the customer + /// + [JsonProperty("identifierHash")] + public string IdentifierHash { get; protected set; } + + /// + /// ID of the service/website for which the transaction is started + /// + [JsonProperty("serviceId")] + public string ServiceId { get; protected set; } + + /// + /// Name of the service/website + /// + [JsonProperty("serviceName")] + public string ServiceName { get; protected set; } + + /// + /// Description of the service/website + /// + [JsonProperty("serviceDescription")] + public string ServiceDescription { get; protected set; } + + /// + /// Date time of the moment the transaction was started + /// + [JsonProperty("created")] + public string Created { get; protected set; } + + /// + /// Date time of the last status change of the transaction + /// + [JsonProperty("modified")] + public string Modified { get; protected set; } + + /// + /// ID of the type of the payment method + /// + [JsonProperty("paymentMethodId")] + public string PaymentMethodId { get; protected set; } + + /// + /// Name of the type of the payment method + /// + [JsonProperty("paymentMethodName")] + public string PaymentMethodName { get; protected set; } + + /// + /// Description of the type of the payment method + /// + [JsonProperty("paymentMethodDescription")] + public string PaymentMethodDescription { get; protected set; } + + /// + /// Name of the payment profile used to pay the transaction + /// + [JsonProperty("paymentProfileName")] + public string PaymentProfileName { get; protected set; } + + /// + /// Gets or sets the Order number of the transaction . + /// + /// The order number. + [JsonProperty("orderNumber")] public string OrderNumber { get; set; } + + /// + /// Name of the creditcard supplier + /// + [JsonProperty("cardBrand")] public string CardBrand { get; set; } + + /// + /// Debit or credit + /// + [JsonProperty("cardType")] public string CardType { get; set; } + + /// + /// Countrycode of the creditcards origin + /// + [JsonProperty("cardCountryCode")] public string CardCountryCode { get; set; } } diff --git a/PAYNLSDK/Objects/PaymentMethod.cs b/PAYNLSDK/Objects/PaymentMethod.cs index 76cc916..359ec94 100644 --- a/PAYNLSDK/Objects/PaymentMethod.cs +++ b/PAYNLSDK/Objects/PaymentMethod.cs @@ -1,30 +1,28 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Payment Method information +/// +public class PaymentMethod { /// - /// Payment Method information + /// Payment method ID /// - public class PaymentMethod - { - /// - /// Payment method ID - /// - [JsonProperty("id")] - public int Id { get; set; } + [JsonProperty("id")] + public int Id { get; set; } - /// - /// Payment method name - /// - [JsonProperty("name")] - public string Name { get; set; } + /// + /// Payment method name + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// Abbreviation for this payment method - /// - [JsonProperty("abbreviation")] - public string Abbreviation { get; set; } + /// + /// Abbreviation for this payment method + /// + [JsonProperty("abbreviation")] + public string Abbreviation { get; set; } - } } diff --git a/PAYNLSDK/Objects/PaymentOption.cs b/PAYNLSDK/Objects/PaymentOption.cs index 7c6045f..eadc288 100644 --- a/PAYNLSDK/Objects/PaymentOption.cs +++ b/PAYNLSDK/Objects/PaymentOption.cs @@ -1,90 +1,87 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; +using Newtonsoft.Json; +using PayNLSdk.Enums; using System.Collections.Generic; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Payment Option information base +/// +abstract public class PaymentOptionBase { /// - /// Payment Option information base + /// ID for this payment (sub)option /// - abstract public class PaymentOptionBase - { - /// - /// ID for this payment (sub)option - /// - [JsonProperty("id")] - public int ID { get; set; } - - /// - /// Name for this payment (sub)option - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// Visible name for this payment (sub)option - /// - [JsonProperty("visibleName")] - public string VisibleName { get; set; } + [JsonProperty("id")] + public int ID { get; set; } - /// - /// Image for this payment (sub)option - /// - [JsonProperty("img")] - public string Image { get; set; } - - /// - /// Path for the (sub)option icon. The full icon URL is a concatenation of $basePath, $path and $img. - /// - [JsonProperty("path")] - public string IconPath { get; set; } - - /// - /// Indicator whether or not the sub option is available - /// - [JsonProperty("state")] - public Availability State { get; set; } + /// + /// Name for this payment (sub)option + /// + [JsonProperty("name")] + public string Name { get; set; } - } + /// + /// Visible name for this payment (sub)option + /// + [JsonProperty("visibleName")] + public string VisibleName { get; set; } /// - /// Payment Suboption information + /// Image for this payment (sub)option /// - public class PaymentSubOption : PaymentOptionBase - { - } + [JsonProperty("img")] + public string Image { get; set; } /// - /// Payment Suboptions Dictionary + /// Path for the (sub)option icon. The full icon URL is a concatenation of $basePath, $path and $img. /// - public class PaymentSubOptions : Dictionary - { - } + [JsonProperty("path")] + public string IconPath { get; set; } /// - /// Payment Option information + /// Indicator whether or not the sub option is available /// - public class PaymentOption : PaymentOptionBase - { - /// - /// ID of the Payment Method this option belongs to - /// - [JsonProperty("paymentMethodId")] - public PaymentMethodId PaymentMethodId { get; set; } + [JsonProperty("state")] + public Availability State { get; set; } + +} - /// - /// Dictionary of payment sub options - /// - [JsonProperty("paymentOptionSubList")] - public PaymentSubOptions PaymentSubOptions { get; set; } - } +/// +/// Payment Suboption information +/// +public class PaymentSubOption : PaymentOptionBase +{ +} + +/// +/// Payment Suboptions Dictionary +/// +public class PaymentSubOptions : Dictionary +{ +} +/// +/// Payment Option information +/// +public class PaymentOption : PaymentOptionBase +{ /// - /// Payment Options Dictionary + /// ID of the Payment Method this option belongs to /// - public class PaymentOptions : Dictionary - { - } + [JsonProperty("paymentMethodId")] + public PaymentMethodId PaymentMethodId { get; set; } + /// + /// Dictionary of payment sub options + /// + [JsonProperty("paymentOptionSubList")] + public PaymentSubOptions PaymentSubOptions { get; set; } +} + +/// +/// Payment Options Dictionary +/// +public class PaymentOptions : Dictionary +{ } diff --git a/PAYNLSDK/Objects/PaymentProfile.cs b/PAYNLSDK/Objects/PaymentProfile.cs index e6cd087..1075dbc 100644 --- a/PAYNLSDK/Objects/PaymentProfile.cs +++ b/PAYNLSDK/Objects/PaymentProfile.cs @@ -1,62 +1,59 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; -using PAYNLSDK.Converters; +using Newtonsoft.Json; +using PayNLSdk.Converters; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Payment Profile information +/// +public class PaymentProfile { /// - /// Payment Profile information - /// - public class PaymentProfile - { - /// - /// Payment Profile ID - /// - [JsonProperty("id")] - public int Id { get; set; } - - /// - /// Payment Profile Name - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// Payment Profile Parent ID - /// - [JsonProperty("parent_id")] - public int ParentId { get; set; } - - /// - /// Indicator if this Payment Profile is publicly available - /// - [JsonProperty("public"), JsonConverter(typeof(BooleanConverter))] - public bool Public { get; set; } - - /// - /// Payment Method ID this profile belongs to - /// - [JsonProperty("payment_method_id")] - public int PaymentMethodId { get; set; } - - /// - /// Country ID this payment profile belongs to. - /// - [JsonProperty("country_id")] - public int CountryId { get; set; } - - /// - /// ID of the Payment Tariff - /// - [JsonProperty("payment_tariff_id")] - public int PaymentTariffId { get; set; } - - /// - /// The nature of address, mostly used for PayPerCall and PayPerMinute to indicate wether this the payment was done with a mobile phone (1) or not (0). - /// - [JsonProperty("noah_id")] - public int NoahId { get; set; } - - } + /// Payment Profile ID + /// + [JsonProperty("id")] + public int Id { get; set; } + + /// + /// Payment Profile Name + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// Payment Profile Parent ID + /// + [JsonProperty("parent_id")] + public int ParentId { get; set; } + + /// + /// Indicator if this Payment Profile is publicly available + /// + [JsonProperty("public"), JsonConverter(typeof(BooleanConverter))] + public bool Public { get; set; } + + /// + /// Payment Method ID this profile belongs to + /// + [JsonProperty("payment_method_id")] + public int PaymentMethodId { get; set; } + + /// + /// Country ID this payment profile belongs to. + /// + [JsonProperty("country_id")] + public int CountryId { get; set; } + + /// + /// ID of the Payment Tariff + /// + [JsonProperty("payment_tariff_id")] + public int PaymentTariffId { get; set; } + + /// + /// The nature of address, mostly used for PayPerCall and PayPerMinute to indicate wether this the payment was done with a mobile phone (1) or not (0). + /// + [JsonProperty("noah_id")] + public int NoahId { get; set; } + } diff --git a/PAYNLSDK/Objects/RefundInfo.cs b/PAYNLSDK/Objects/RefundInfo.cs index e6a342a..cf91b41 100644 --- a/PAYNLSDK/Objects/RefundInfo.cs +++ b/PAYNLSDK/Objects/RefundInfo.cs @@ -1,66 +1,65 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; +using System; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Refund Info Details +/// +public class RefundInfo { /// - /// Refund Info Details + /// payment session ID /// - public class RefundInfo - { - /// - /// payment session ID - /// - [JsonProperty("paymentSessionId")] - public long PaymentSessionId { get; set; } + [JsonProperty("paymentSessionId")] + public long PaymentSessionId { get; set; } - /// - /// Refund amount - /// - [JsonProperty("amount")] - public int Amount { get; set; } + /// + /// Refund amount + /// + [JsonProperty("amount")] + public int Amount { get; set; } - /// - /// description - /// - [JsonProperty("description")] - public string Description { get; set; } + /// + /// description + /// + [JsonProperty("description")] + public string Description { get; set; } - /// - /// The name of the customer. - /// - [JsonProperty("bankAccountHolder")] - public string BankAccountHolder { get; set; } + /// + /// The name of the customer. + /// + [JsonProperty("bankAccountHolder")] + public string BankAccountHolder { get; set; } - /// - /// The bankaccount number of the customer. - /// - [JsonProperty("bankAccountNumber")] - public string BankAccountNumber { get; set; } + /// + /// The bankaccount number of the customer. + /// + [JsonProperty("bankAccountNumber")] + public string BankAccountNumber { get; set; } - /// - /// The BIC of the bank. - /// - [JsonProperty("bankAccountBic")] - public string BankAccountBic { get; set; } + /// + /// The BIC of the bank. + /// + [JsonProperty("bankAccountBic")] + public string BankAccountBic { get; set; } - /// - /// status code - /// - [JsonProperty("statusCode")] - public int StatusCode { get; set; } + /// + /// status code + /// + [JsonProperty("statusCode")] + public int StatusCode { get; set; } - /// - /// status description - /// - [JsonProperty("statusName")] - public string StatusName { get; set; } + /// + /// status description + /// + [JsonProperty("statusName")] + public string StatusName { get; set; } - /// - /// The currency of the amount, default is EUR. - /// - [JsonProperty("processDate")] - public DateTime? ProcessDate { get; set; } + /// + /// The currency of the amount, default is EUR. + /// + [JsonProperty("processDate")] + public DateTime? ProcessDate { get; set; } - } } diff --git a/PAYNLSDK/Objects/SalesData.cs b/PAYNLSDK/Objects/SalesData.cs index f2ae30f..110041b 100644 --- a/PAYNLSDK/Objects/SalesData.cs +++ b/PAYNLSDK/Objects/SalesData.cs @@ -1,32 +1,30 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; -using PAYNLSDK.Converters; +using Newtonsoft.Json; +using PayNLSdk.Converters; +using System; using System.Collections.Generic; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Specification of sales data for a transaction +/// +public class SalesData { /// - /// Specification of sales data for a transaction + /// Invoice date /// - public class SalesData - { - /// - /// Invoice date - /// - [JsonProperty("invoiceDate"), JsonConverter(typeof(DMYConverter))] - public DateTime? InvoiceDate { get; set; } + [JsonProperty("invoiceDate"), JsonConverter(typeof(DMYConverter))] + public DateTime? InvoiceDate { get; set; } - /// - /// Delivery date - /// - [JsonProperty("deliveryDate"), JsonConverter(typeof(DMYConverter))] - public DateTime? DeliveryDate { get; set; } + /// + /// Delivery date + /// + [JsonProperty("deliveryDate"), JsonConverter(typeof(DMYConverter))] + public DateTime? DeliveryDate { get; set; } - /// - /// Ordered products specification - /// - [JsonProperty("orderData")] - public List OrderData { get; set; } - } -} + /// + /// Ordered products specification + /// + [JsonProperty("orderData")] + public List OrderData { get; set; } +} \ No newline at end of file diff --git a/PAYNLSDK/Objects/Service.cs b/PAYNLSDK/Objects/Service.cs index 8d3256c..1cf1ce9 100644 --- a/PAYNLSDK/Objects/Service.cs +++ b/PAYNLSDK/Objects/Service.cs @@ -1,74 +1,71 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; +using Newtonsoft.Json; +using PayNLSdk.Enums; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Service Details +/// +public class Service { /// - /// Service Details + /// Service ID /// - public class Service - { - /// - /// Service ID - /// - [JsonProperty("id")] - public string ID { get; set; } - - /// - /// Service Name - /// - [JsonProperty("name")] - public string Name { get; set; } + [JsonProperty("id")] + public string ID { get; set; } - /// - /// Service Description - /// - [JsonProperty("description")] - public string Description { get; set; } + /// + /// Service Name + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// The way the service is presented to the customer (eg. an URL or name of an advertisement) - /// - [JsonProperty("publication")] - public string Publication { get; set; } + /// + /// Service Description + /// + [JsonProperty("description")] + public string Description { get; set; } - /// - /// Base path of the images for the payment options - /// - [JsonProperty("basePath")] - public string BasePath { get; set; } + /// + /// The way the service is presented to the customer (eg. an URL or name of an advertisement) + /// + [JsonProperty("publication")] + public string Publication { get; set; } - /// - /// ID of the module - /// - [JsonProperty("module")] - public int Module { get; set; } + /// + /// Base path of the images for the payment options + /// + [JsonProperty("basePath")] + public string BasePath { get; set; } - /// - /// ID of the submodule - /// - [JsonProperty("subModule")] - public int SubModule { get; set; } + /// + /// ID of the module + /// + [JsonProperty("module")] + public int Module { get; set; } - /// - /// Active state for this Service - /// - [JsonProperty("state")] - public ActiveState State { get; set; } + /// + /// ID of the submodule + /// + [JsonProperty("subModule")] + public int SubModule { get; set; } - /// - /// Target url after a successfull payment - /// - [JsonProperty("successUrl")] - public string SuccessUrl { get; set; } + /// + /// Active state for this Service + /// + [JsonProperty("state")] + public ActiveState State { get; set; } - /// - /// Target url after a failed payment - /// - [JsonProperty("errorUrl")] - public string ErrorUrl { get; set; } + /// + /// Target url after a successfull payment + /// + [JsonProperty("successUrl")] + public string SuccessUrl { get; set; } - } + /// + /// Target url after a failed payment + /// + [JsonProperty("errorUrl")] + public string ErrorUrl { get; set; } } diff --git a/PAYNLSDK/Objects/ServiceCategory.cs b/PAYNLSDK/Objects/ServiceCategory.cs index a2249f7..444b2b2 100644 --- a/PAYNLSDK/Objects/ServiceCategory.cs +++ b/PAYNLSDK/Objects/ServiceCategory.cs @@ -1,23 +1,21 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Service Category information +/// +public class ServiceCategory { /// - /// Service Category information + /// ID of the Service Category /// - public class ServiceCategory - { - /// - /// ID of the Service Category - /// - [JsonProperty("id")] - public string Id { get; set; } + [JsonProperty("id")] + public string Id { get; set; } - /// - /// Name of the Service Category - /// - [JsonProperty("name")] - public string Name { get; set; } - } + /// + /// Name of the Service Category + /// + [JsonProperty("name")] + public string Name { get; set; } } diff --git a/PAYNLSDK/Objects/TransactionStartEnduser.cs b/PAYNLSDK/Objects/TransactionStartEnduser.cs index 504ce4f..5b7ca9a 100644 --- a/PAYNLSDK/Objects/TransactionStartEnduser.cs +++ b/PAYNLSDK/Objects/TransactionStartEnduser.cs @@ -1,20 +1,16 @@ using Newtonsoft.Json; -using PAYNLSDK.Converters; -using PAYNLSDK.Enums; -using System; +using PayNLSdk.Enums; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// +/// +public class TransactionStartEnduser { /// - /// + /// Indidicator whether or not the cusomer is blacklisted /// - public class TransactionStartEnduser - { - /// - /// Indidicator whether or not the cusomer is blacklisted - /// - [JsonProperty("blacklist")] - public Blacklist Blacklist {get; protected set;} - } - + [JsonProperty("blacklist")] + public Blacklist Blacklist { get; protected set; } } diff --git a/PAYNLSDK/Objects/TransactionStartInfo.cs b/PAYNLSDK/Objects/TransactionStartInfo.cs index 78c96b8..6437692 100644 --- a/PAYNLSDK/Objects/TransactionStartInfo.cs +++ b/PAYNLSDK/Objects/TransactionStartInfo.cs @@ -1,40 +1,37 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; -using PAYNLSDK.Converters; +using Newtonsoft.Json; +using PayNLSdk.Converters; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Transaction Start Information object. +/// This object is part of the response returned after a call to start a transaction and contains the +/// transaction ID and payment URL you should redirect the enduser to. +/// +public class TransactionStartInfo { /// - /// Transaction Start Information object. - /// This object is part of the response returned after a call to start a transaction and contains the - /// transaction ID and payment URL you should redirect the enduser to. + /// Transaction ID /// - public class TransactionStartInfo - { - /// - /// Transaction ID - /// - [JsonProperty("transactionId")] - public string TransactionId { get; protected set; } + [JsonProperty("transactionId")] + public string TransactionId { get; protected set; } - /// - /// The URL where the customer can be send to in order to finish the transaction. - /// - [JsonProperty("paymentURL")] - public string PaymentURL { get; protected set; } + /// + /// The URL where the customer can be send to in order to finish the transaction. + /// + [JsonProperty("paymentURL")] + public string PaymentURL { get; protected set; } - /// - /// Indicates whether the payment screen may be loaded in popup window - /// - [JsonProperty("popupAllowed"), JsonConverter(typeof(BooleanConverter))] - public bool? PopupAllowed { get; protected set; } + /// + /// Indicates whether the payment screen may be loaded in popup window + /// + [JsonProperty("popupAllowed"), JsonConverter(typeof(BooleanConverter))] + public bool? PopupAllowed { get; protected set; } - /// - /// Payment reference used to identify manual bank transfers - /// - [JsonProperty("paymentReference")] - public string PaymentReference { get; protected set; } + /// + /// Payment reference used to identify manual bank transfers + /// + [JsonProperty("paymentReference")] + public string PaymentReference { get; protected set; } - } -} +} \ No newline at end of file diff --git a/PAYNLSDK/Objects/TransactionStats.cs b/PAYNLSDK/Objects/TransactionStats.cs index 62cace1..ed33bd1 100644 --- a/PAYNLSDK/Objects/TransactionStats.cs +++ b/PAYNLSDK/Objects/TransactionStats.cs @@ -1,94 +1,91 @@ -using System; -using Newtonsoft.Json; -using PAYNLSDK.Enums; -using PAYNLSDK.Converters; +using Newtonsoft.Json; +using PayNLSdk.Converters; +using System; -namespace PAYNLSDK.Objects +namespace PayNLSdk.Objects; + +/// +/// Payment Transaction Information +/// +public class TransactionStats { /// - /// Payment Transaction Information + /// Transaction identifier. /// - public class TransactionStats - { - /// - /// Transaction identifier. - /// - [JsonProperty("id")] - public string Id { get; set; } + [JsonProperty("id")] + public string Id { get; set; } - /// - /// Name of the website used for the transaction - /// - [JsonProperty("websiteName")] - public string WebsiteName { get; set; } + /// + /// Name of the website used for the transaction + /// + [JsonProperty("websiteName")] + public string WebsiteName { get; set; } - /// - /// Name of the service used for the transaction - /// - [JsonProperty("serviceName")] - public string ServiceName { get; set; } + /// + /// Name of the service used for the transaction + /// + [JsonProperty("serviceName")] + public string ServiceName { get; set; } - /// - /// Code of the service used for the transaction - /// - [JsonProperty("serviceCode")] - public string ServiceCode { get; set; } + /// + /// Code of the service used for the transaction + /// + [JsonProperty("serviceCode")] + public string ServiceCode { get; set; } - /// - /// Amount in cents of euro - /// - [JsonProperty("orderAmount")] - public int OrderAmount { get; set; } + /// + /// Amount in cents of euro + /// + [JsonProperty("orderAmount")] + public int OrderAmount { get; set; } - /// - /// Date and time of the transaction. - /// - [JsonProperty("created"), JsonConverter(typeof(YMDHISConverter))] - public DateTime Created { get; set; } + /// + /// Date and time of the transaction. + /// + [JsonProperty("created"), JsonConverter(typeof(YMDHISConverter))] + public DateTime Created { get; set; } - // TODO: this should be paymentstatus - /// - /// Internal status of the transaction - /// - [JsonProperty("internalStatus")] - public int InternalStatus { get; set; } + // TODO: this should be paymentstatus + /// + /// Internal status of the transaction + /// + [JsonProperty("internalStatus")] + public int InternalStatus { get; set; } - /// - /// If Y mean that the payment was verified - /// - [JsonProperty("consumer3dsecure")] - public string Consumer3dSecure { get; set; } + /// + /// If Y mean that the payment was verified + /// + [JsonProperty("consumer3dsecure")] + public string Consumer3dSecure { get; set; } - /// - /// Consumer account number - /// - [JsonProperty("consumerAccountNumber")] - public string ConsumerAccountNumber { get; set; } + /// + /// Consumer account number + /// + [JsonProperty("consumerAccountNumber")] + public string ConsumerAccountNumber { get; set; } - /// - /// ID of the Payment Profile used for this transaction - /// - [JsonProperty("profileId")] - public int ProfileId { get; set; } + /// + /// ID of the Payment Profile used for this transaction + /// + [JsonProperty("profileId")] + public int ProfileId { get; set; } - /// - /// Name of the Payment Profile used for this transaction - /// - [JsonProperty("profileName")] - public string ProfileName { get; set; } + /// + /// Name of the Payment Profile used for this transaction + /// + [JsonProperty("profileName")] + public string ProfileName { get; set; } - } +} +/// +/// List of Transaction Statusses +/// +public class TransactionStatsList +{ /// - /// List of Transaction Statusses + /// Array containing the transactions stats /// - public class TransactionStatsList - { - /// - /// Array containing the transactions stats - /// - [JsonProperty("transations")] - public TransactionStats[] Transactions { get; set; } - } - + [JsonProperty("transations")] + public TransactionStats[] Transactions { get; set; } } diff --git a/PAYNLSDK/PayNLSdk.csproj b/PAYNLSDK/PayNLSdk.csproj index 1961501..f20d138 100644 --- a/PAYNLSDK/PayNLSdk.csproj +++ b/PAYNLSDK/PayNLSdk.csproj @@ -7,7 +7,7 @@ true RoodFluweel.PAYNLSDK - 1.7.6 + 2.0.0 paynl, dampee, Sebsoft dampee, paynl diff --git a/PAYNLSDK/PaymentMethod.cs b/PAYNLSDK/PaymentMethod.cs index 34e63ec..2ec92f6 100644 --- a/PAYNLSDK/PaymentMethod.cs +++ b/PAYNLSDK/PaymentMethod.cs @@ -1,50 +1,50 @@ -using PAYNLSDK.Net; -using PaymentMethodGet = PAYNLSDK.API.PaymentMethod.Get.Request; -using PaymentMethodGetAll = PAYNLSDK.API.PaymentMethod.GetAll.Request; +using PayNLSdk.Api.PaymentMethod.Get; +using PayNLSdk.Net; +using PaymentMethodGet = PayNLSdk.Api.PaymentMethod.Get.Request; +using PaymentMethodGetAll = PayNLSdk.Api.PaymentMethod.GetAll.Request; -namespace PAYNLSDK +namespace PayNLSdk; + +/// +/// Generic Payment Method service helper class. +/// Makes calling PAYNL Services easier and eliminates the need to fully initiate all Request objects. +/// +public class PaymentMethod { + private readonly IClient _webClient; + /// - /// Generic Payment Method service helper class. - /// Makes calling PAYNL Services easier and eliminates the need to fully initiate all Request objects. + /// Create a new PaymentMethod object /// - public class PaymentMethod + /// + public PaymentMethod(IClient webClient) { - private readonly IClient _webClient; - - /// - /// Create a new PaymentMethod object - /// - /// - public PaymentMethod(IClient webClient) - { - _webClient = webClient; - } + _webClient = webClient; + } - /// - /// Get information for the requested payment method. - /// - /// Payment Method ID - /// Response containing the payment method data - public PAYNLSDK.API.PaymentMethod.Get.Response Get(Enums.PaymentMethodId paymentMethodId) + /// + /// Get information for the requested payment method. + /// + /// Payment Method ID + /// Response containing the payment method data + public Response Get(Enums.PaymentMethodId paymentMethodId) + { + var request = new PaymentMethodGet { - var request = new PaymentMethodGet - { - PaymentMethodId = paymentMethodId - }; - _webClient.PerformRequest(request); - return request.Response; - } + PaymentMethodId = paymentMethodId + }; + _webClient.PerformRequest(request); + return request.Response; + } - /// - /// Get information for all payment methods. - /// - /// Response containing a list of information for all payment methods - public PAYNLSDK.API.PaymentMethod.GetAll.Response GetAll() - { - var request = new PaymentMethodGetAll(); - _webClient.PerformRequest(request); - return request.Response; - } + /// + /// Get information for all payment methods. + /// + /// Response containing a list of information for all payment methods + public Api.PaymentMethod.GetAll.Response GetAll() + { + var request = new PaymentMethodGetAll(); + _webClient.PerformRequest(request); + return request.Response; } } diff --git a/PAYNLSDK/PaymentProfile.cs b/PAYNLSDK/PaymentProfile.cs index c30ffe4..631720d 100644 --- a/PAYNLSDK/PaymentProfile.cs +++ b/PAYNLSDK/PaymentProfile.cs @@ -1,75 +1,75 @@ -using PAYNLSDK.Net; -using PaymentProfileGet = PAYNLSDK.API.PaymentProfile.Get.Request; -using PaymentProfileGetAll = PAYNLSDK.API.PaymentProfile.GetAll.Request; -using PaymentProfileGetAvailable = PAYNLSDK.API.PaymentProfile.GetAvailable.Request; +using PayNLSdk.Api.PaymentProfile.Get; +using PayNLSdk.Net; +using PaymentProfileGet = PayNLSdk.Api.PaymentProfile.Get.Request; +using PaymentProfileGetAll = PayNLSdk.Api.PaymentProfile.GetAll.Request; +using PaymentProfileGetAvailable = PayNLSdk.Api.PaymentProfile.GetAvailable.Request; -namespace PAYNLSDK +namespace PayNLSdk; + +/// +/// Provides retrieval for payment options +/// +public class PaymentProfile { + private readonly IClient _webClient; + /// - /// Provides retrieval for payment options + /// Create a new payment profile Sdk /// - public class PaymentProfile + /// + public PaymentProfile(IClient webClient) { - private readonly IClient _webClient; - - /// - /// Create a new payment profile Sdk - /// - /// - public PaymentProfile(IClient webClient) - { - _webClient = webClient; - } + _webClient = webClient; + } - /// - /// Get details for a specific payment profile - /// - /// Payment profile ID - /// Payment profile response - public PAYNLSDK.API.PaymentProfile.Get.Response Get(int paymentProfileId) + /// + /// Get details for a specific payment profile + /// + /// Payment profile ID + /// Payment profile response + public Response Get(int paymentProfileId) + { + var request = new PaymentProfileGet { - var request = new PaymentProfileGet - { - PaymentProfileId = paymentProfileId - }; + PaymentProfileId = paymentProfileId + }; - _webClient.PerformRequest(request); - return request.Response; - } + _webClient.PerformRequest(request); + return request.Response; + } - /// - /// Get details for all payment profiles - /// - /// List of payment profile info - public PAYNLSDK.API.PaymentProfile.GetAll.Response GetAll() - { - PaymentProfileGetAll request = new PaymentProfileGetAll(); - - _webClient.PerformRequest(request); - return request.Response; - } + /// + /// Get details for all payment profiles + /// + /// List of payment profile info + public Api.PaymentProfile.GetAll.Response GetAll() + { + PaymentProfileGetAll request = new PaymentProfileGetAll(); - /// - /// Get payment profile information for all your available profiles for the specified service category - /// - /// The ID of the category of the service the payment options are used for - /// ID of the program for which the payment options are used. (Only available if the program option is enabled!) - /// Payment Method ID - /// Indicator wether to show profiles that are initially not allowed on registration. - /// Response containing the list of payment profile information - public PAYNLSDK.API.PaymentProfile.GetAvailable.Response GetAvailable(int categoryId, int? programId = null, int? paymentMethodId = null, bool? showNotAllowedOnRegistration = null) - { - var request = new PaymentProfileGetAvailable - { - CategoryId = categoryId, - ProgramId = programId, - PaymentMethodId = paymentMethodId, - ShowNotAllowedOnRegistration = showNotAllowedOnRegistration - }; + _webClient.PerformRequest(request); + return request.Response; + } - _webClient.PerformRequest(request); - return request.Response; - } + /// + /// Get payment profile information for all your available profiles for the specified service category + /// + /// The ID of the category of the service the payment options are used for + /// ID of the program for which the payment options are used. (Only available if the program option is enabled!) + /// Payment Method ID + /// Indicator wether to show profiles that are initially not allowed on registration. + /// Response containing the list of payment profile information + public Api.PaymentProfile.GetAvailable.Response GetAvailable(int categoryId, int? programId = null, int? paymentMethodId = null, bool? showNotAllowedOnRegistration = null) + { + var request = new PaymentProfileGetAvailable + { + CategoryId = categoryId, + ProgramId = programId, + PaymentMethodId = paymentMethodId, + ShowNotAllowedOnRegistration = showNotAllowedOnRegistration + }; + _webClient.PerformRequest(request); + return request.Response; } -} + +} \ No newline at end of file diff --git a/PAYNLSDK/Service.cs b/PAYNLSDK/Service.cs index 26743f0..a33d629 100644 --- a/PAYNLSDK/Service.cs +++ b/PAYNLSDK/Service.cs @@ -1,38 +1,35 @@ -using PAYNLSDK.Enums; -using PAYNLSDK.Net; -using System; -using ServiceGetCategories = PAYNLSDK.API.Service.GetCategories.Request; +using PayNLSdk.Api.Service.GetCategories; +using PayNLSdk.Net; +using ServiceGetCategories = PayNLSdk.Api.Service.GetCategories.Request; -namespace PAYNLSDK +namespace PayNLSdk; + +/// +/// Generic Service service helper class. +/// Makes calling PAYNL Services easier and illiminates the need to fully initiate all Request objects. +/// +public class Service : IService { + private readonly IClient _webClient; + + public Service(IClient webClient) + { + _webClient = webClient; + } + /// - /// Generic Service service helper class. - /// Makes calling PAYNL Services easier and illiminates the need to fully initiate all Request objects. + /// Get Service Categories for a given payment option ID /// - public class Service : IService + /// Payment Option ID, if null return all + /// Response object containing service categories + public Response GetCategories(int? paymentOptionId = null) { - private readonly IClient _webClient; - - public Service(IClient webClient) - { - _webClient = webClient; - } + ServiceGetCategories request = new ServiceGetCategories(); + request.PaymentOptionId = paymentOptionId; - /// - /// Get Service Categories for a given payment option ID - /// - /// Payment Option ID, if null return all - /// Response object containing service categories - public PAYNLSDK.API.Service.GetCategories.Response GetCategories(int? paymentOptionId = null) - { - ServiceGetCategories request = new ServiceGetCategories(); - request.PaymentOptionId = paymentOptionId; - - _webClient.PerformRequest(request); - return request.Response; - } - - + _webClient.PerformRequest(request); + return request.Response; } + } diff --git a/PAYNLSDK/Statistics.cs b/PAYNLSDK/Statistics.cs index 71ecfae..dd8f792 100644 --- a/PAYNLSDK/Statistics.cs +++ b/PAYNLSDK/Statistics.cs @@ -1,82 +1,81 @@ using Newtonsoft.Json; -using PayNLSdk.API.Statistics.GetManagement; -using PAYNLSDK.Net; +using PayNLSdk.Api.Statistics.GetManagement; +using PayNLSdk.Net; using System.Collections.Generic; -namespace PAYNLSDK +namespace PayNLSdk; + +/// +/// This is a part of the alliance SDK +/// +/// +public class Statistics : IStatistics { - /// - /// This is a part of the alliance SDK - /// + private readonly IClient _webClient; + /// - public class Statistics : IStatistics + public Statistics(IClient webClient) { - private readonly IClient _webClient; - - /// - public Statistics(IClient webClient) - { - _webClient = webClient; - } + _webClient = webClient; + } - /// - /// Get management statistics from the RestApi - /// - /// - /// The fieldname on which the grouping has to take place - /// - public GetStatsResult GetStats(Request request, string groupByFieldName = "") - { - if (string.IsNullOrWhiteSpace(groupByFieldName)) { groupByFieldName = "company_id"; } - request.GroupByFieldNames.Clear(); - request.GroupByFieldNames.Add(groupByFieldName); + /// + /// Get management statistics from the RestApi + /// + /// + /// The fieldname on which the grouping has to take place + /// + public GetStatsResult GetStats(Request request, string groupByFieldName = "") + { + if (string.IsNullOrWhiteSpace(groupByFieldName)) { groupByFieldName = "company_id"; } + request.GroupByFieldNames.Clear(); + request.GroupByFieldNames.Add(groupByFieldName); - var response = _webClient.PerformRequest(request); - var jsonConverters = new List { new DecimalConverter() }; - return Newtonsoft.Json.JsonConvert.DeserializeObject(response, jsonConverters.ToArray()); - } + var response = _webClient.PerformRequest(request); + var jsonConverters = new List { new DecimalConverter() }; + return Newtonsoft.Json.JsonConvert.DeserializeObject(response, jsonConverters.ToArray()); + } - /// - /// Get management statistics from the Api using two group by fields - /// - /// - /// - /// - /// - public GetStatsMultiLevel GetMultiLevelStats(Request request, string groupByFieldName, string groupByFieldName2 = "day") - { - if (string.IsNullOrWhiteSpace(groupByFieldName)) { groupByFieldName = "company_id"; } - if (string.IsNullOrWhiteSpace(groupByFieldName2)) { groupByFieldName2 = "day"; } + /// + /// Get management statistics from the Api using two group by fields + /// + /// + /// + /// + /// + public GetStatsMultiLevel GetMultiLevelStats(Request request, string groupByFieldName, string groupByFieldName2 = "day") + { + if (string.IsNullOrWhiteSpace(groupByFieldName)) { groupByFieldName = "company_id"; } + if (string.IsNullOrWhiteSpace(groupByFieldName2)) { groupByFieldName2 = "day"; } - request.GroupByFieldNames.Clear(); - request.GroupByFieldNames.Add(groupByFieldName); - request.GroupByFieldNames.Add(groupByFieldName2); + request.GroupByFieldNames.Clear(); + request.GroupByFieldNames.Add(groupByFieldName); + request.GroupByFieldNames.Add(groupByFieldName2); - var response = _webClient.PerformRequest(request); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); - } + var response = _webClient.PerformRequest(request); + return Newtonsoft.Json.JsonConvert.DeserializeObject(response); } +} +/// +/// Get alliance statistics +/// +public interface IStatistics +{ /// - /// Get alliance statistics + /// Get management statistics from the RestApi /// - public interface IStatistics - { - /// - /// Get management statistics from the RestApi - /// - /// - /// The fieldname on which the grouping has to take place - /// - GetStatsResult GetStats(Request request, string groupByFieldName = ""); + /// + /// The fieldname on which the grouping has to take place + /// + GetStatsResult GetStats(Request request, string groupByFieldName = ""); - /// - /// Get management statistics from the Api using two group by fields - /// - /// - /// - /// - /// - GetStatsMultiLevel GetMultiLevelStats(Request request, string groupByFieldName, string groupByFieldName2 = "day"); - } + /// + /// Get management statistics from the Api using two group by fields + /// + /// + /// + /// + /// + GetStatsMultiLevel GetMultiLevelStats(Request request, string groupByFieldName, string groupByFieldName2 = "day"); } diff --git a/PAYNLSDK/Transaction.cs b/PAYNLSDK/Transaction.cs index befb6f4..42bdbc7 100644 --- a/PAYNLSDK/Transaction.cs +++ b/PAYNLSDK/Transaction.cs @@ -1,287 +1,288 @@ -using PAYNLSDK.Enums; -using PAYNLSDK.Exceptions; -using PAYNLSDK.Net; +using PayNLSdk.Api.Transaction.Info; +using PayNLSdk.Enums; +using PayNLSdk.Exceptions; +using PayNLSdk.Net; using System; -using TransactionGetService = PAYNLSDK.API.Transaction.GetService.Request; -using TransactionInfo = PAYNLSDK.API.Transaction.Info.Request; -using TransactionRefund = PAYNLSDK.API.Transaction.Refund.Request; -using TransactionApprove = PAYNLSDK.API.Transaction.Approve.Request; -using TransactionDecline = PAYNLSDK.API.Transaction.Decline.Request; - -namespace PAYNLSDK +using Request = PayNLSdk.Api.Transaction.Start.Request; +using TransactionApprove = PayNLSdk.Api.Transaction.Approve.Request; +using TransactionDecline = PayNLSdk.Api.Transaction.Decline.Request; +using TransactionGetService = PayNLSdk.Api.Transaction.GetService.Request; +using TransactionInfo = PayNLSdk.Api.Transaction.Info.Request; +using TransactionRefund = PayNLSdk.Api.Transaction.Refund.Request; + +namespace PayNLSdk; + +/// +/// Generic Transaction service helper class. +/// Makes calling PAYNL Services easier and illiminates the need to fully initiate all Request objects. +/// +public class Transaction : ITransaction { + + private readonly IClient _webClient; + /// - /// Generic Transaction service helper class. - /// Makes calling PAYNL Services easier and illiminates the need to fully initiate all Request objects. + /// Initializes a new transaction object /// - public class Transaction : ITransaction + /// + public Transaction(IClient webClient) { + _webClient = webClient; + } - private readonly IClient _webClient; - /// - /// Initializes a new transaction object - /// - /// - public Transaction(IClient webClient) + /// + /// Checks whether a transaction has a status of PAID + /// + /// Transaction Id + /// True if PAID, false otherwise + public bool IsPaid(string transactionId) + { + var request = new TransactionInfo { - _webClient = webClient; - } + TransactionId = transactionId + }; + _webClient.PerformRequest(request); + return (request.Response.PaymentDetails.State == Enums.PaymentStatus.PAID); + } - /// - /// Checks whether a transaction has a status of PAID - /// - /// Transaction Id - /// True if PAID, false otherwise - public bool IsPaid(string transactionId) - { - var request = new TransactionInfo - { - TransactionId = transactionId - }; + /// + /// Checks whether a transaction has a status of CANCELLED + /// + /// Transaction Id + /// True if CANCELLED, false otherwise + public bool IsCancelled(string transactionId) + { + try + { + TransactionInfo request = new TransactionInfo(); + request.TransactionId = transactionId; _webClient.PerformRequest(request); - return (request.Response.PaymentDetails.State == Enums.PaymentStatus.PAID); + return (request.Response.PaymentDetails.State == Enums.PaymentStatus.CANCEL); } - - - /// - /// Checks whether a transaction has a status of CANCELLED - /// - /// Transaction Id - /// True if CANCELLED, false otherwise - public bool IsCancelled(string transactionId) + catch (PayNlException e) { - try - { - TransactionInfo request = new TransactionInfo(); - request.TransactionId = transactionId; - _webClient.PerformRequest(request); - return (request.Response.PaymentDetails.State == Enums.PaymentStatus.CANCEL); - } - catch (PayNlException e) - { - return false; - } + return false; } + } - /// - /// Checks whether a transaction has a status of PENDING - /// - /// Transaction Id - /// True if PENDING, false otherwise - public bool IsPending(string transactionId) + /// + /// Checks whether a transaction has a status of PENDING + /// + /// Transaction Id + /// True if PENDING, false otherwise + public bool IsPending(string transactionId) + { + try { - try - { - TransactionInfo request = new TransactionInfo(); - request.TransactionId = transactionId; + TransactionInfo request = new TransactionInfo(); + request.TransactionId = transactionId; - _webClient.PerformRequest(request); - return ((request.Response.PaymentDetails.State == Enums.PaymentStatus.PENDING_1) || + _webClient.PerformRequest(request); + return ((request.Response.PaymentDetails.State == Enums.PaymentStatus.PENDING_1) || (request.Response.PaymentDetails.State == Enums.PaymentStatus.PENDING_2) || (request.Response.PaymentDetails.State == Enums.PaymentStatus.PENDING_3) || (request.Response.PaymentDetails.State == Enums.PaymentStatus.VERIFY) || (request.Response.PaymentDetails.StateName == "PENDING")); - } - catch (PayNlException e) - { - return false; - } } + catch (PayNlException e) + { + return false; + } + } - /// - /// Checks whether a transaction has a status of VERIFY - /// - /// Transaction Id - /// True if VERIFY, false otherwise - public bool IsVerify(string transactionId) + /// + /// Checks whether a transaction has a status of VERIFY + /// + /// Transaction Id + /// True if VERIFY, false otherwise + public bool IsVerify(string transactionId) + { + try { - try - { - TransactionInfo request = new TransactionInfo(); - request.TransactionId = transactionId; + TransactionInfo request = new TransactionInfo(); + request.TransactionId = transactionId; - _webClient.PerformRequest(request); - return ((request.Response.PaymentDetails.State == Enums.PaymentStatus.VERIFY) || + _webClient.PerformRequest(request); + return ((request.Response.PaymentDetails.State == Enums.PaymentStatus.VERIFY) || (request.Response.PaymentDetails.StateName == "VERIFY")); - } - catch (PayNlException e) - { - return false; - } } + catch (PayNlException e) + { + return false; + } + } - /// - /// Checks whether a status is a REFUND or REFUNDING status - /// - /// Transaction status - /// True if REFUND or REFUNDING, false otherwise - public static bool IsRefund(Enums.PaymentStatus status) + /// + /// Checks whether a status is a REFUND or REFUNDING status + /// + /// Transaction status + /// True if REFUND or REFUNDING, false otherwise + public static bool IsRefund(Enums.PaymentStatus status) + { + try { - try - { - return status == Enums.PaymentStatus.REFUND || status == Enums.PaymentStatus.REFUNDING; - } - catch (PayNlException e) - { - return false; - } + return status == Enums.PaymentStatus.REFUND || status == Enums.PaymentStatus.REFUNDING; } - - /// - /// Checks whether a status is a REFUNDING status, meaning a refund is currently being processed. - /// - /// Transaction status - /// True if REFUNDING, false otherwise - public static bool IsRefunding(Enums.PaymentStatus status) + catch (PayNlException e) { - try - { - return status == Enums.PaymentStatus.REFUNDING; - } - catch (PayNlException e) - { - return false; - } + return false; } + } - /// - /// Query the service for all (current status) information on a transaction - /// - /// Transaction ID - /// Full response object with all information available - public PAYNLSDK.API.Transaction.Info.Response Info(string transactionId) + /// + /// Checks whether a status is a REFUNDING status, meaning a refund is currently being processed. + /// + /// Transaction status + /// True if REFUNDING, false otherwise + public static bool IsRefunding(Enums.PaymentStatus status) + { + try { - TransactionInfo request = new TransactionInfo { TransactionId = transactionId }; - - _webClient.PerformRequest(request); - return request.Response; + return status == Enums.PaymentStatus.REFUNDING; } - - /// - /// Return service information. - /// This API returns merchant info and all the available payment options per country for a given service. - /// This is an important API if you want to build your own payment screens. - /// - /// Paymentmethod ID - /// FUll response with all service information - public PAYNLSDK.API.Transaction.GetService.Response GetService(PaymentMethodId? paymentMethodId) + catch (PayNlException e) { - TransactionGetService request = new TransactionGetService(); - request.PaymentMethodId = paymentMethodId; - - _webClient.PerformRequest(request); - return request.Response; + return false; } + } - /// - /// Return service information. - /// This API returns merchant info and all the available payment options per country for a given service. - /// This is an important API if you want to build your own payment screens. - /// - /// FUll response with all service information - public PAYNLSDK.API.Transaction.GetService.Response GetService() - { - return GetService(null); - } + /// + /// Query the service for all (current status) information on a transaction + /// + /// Transaction ID + /// Full response object with all information available + public Response Info(string transactionId) + { + TransactionInfo request = new TransactionInfo { TransactionId = transactionId }; - /// - /// Performs a (partial) refund call on an existing transaction - /// - /// Transaction ID - /// Reason for the refund. May be null. - /// Amount of the refund. If null is given, it will be the full amount of the transaction. - /// Date to process the refund. May be null. - /// Full response including the Refund ID - public PAYNLSDK.API.Transaction.Refund.Response Refund(string transactionId, string description = null, decimal? amount = null, DateTime? processDate = null) - { - var request = new TransactionRefund - { - TransactionId = transactionId, - Description = description, - Amount = amount, - ProcessDate = processDate - }; + _webClient.PerformRequest(request); + return request.Response; + } - _webClient.PerformRequest(request); - return request.Response; - } + /// + /// Return service information. + /// This API returns merchant info and all the available payment options per country for a given service. + /// This is an important API if you want to build your own payment screens. + /// + /// Paymentmethod ID + /// FUll response with all service information + public Api.Transaction.GetService.Response GetService(PaymentMethodId? paymentMethodId) + { + TransactionGetService request = new TransactionGetService(); + request.PaymentMethodId = paymentMethodId; - /// - /// function to approve a suspicious transaction - /// - /// Transaction ID - /// Full response including the message about the approvement - public PAYNLSDK.API.Transaction.Approve.Response Approve(string transactionId) - { - TransactionApprove request = new TransactionApprove(); - request.TransactionId = transactionId; + _webClient.PerformRequest(request); + return request.Response; + } - _webClient.PerformRequest(request); - return request.Response; - } + /// + /// Return service information. + /// This API returns merchant info and all the available payment options per country for a given service. + /// This is an important API if you want to build your own payment screens. + /// + /// FUll response with all service information + public Api.Transaction.GetService.Response GetService() + { + return GetService(null); + } - /// - /// function to decline a suspicious transaction - /// - /// Transaction ID - /// Full response including the message about the decline - public PAYNLSDK.API.Transaction.Decline.Response Decline(string transactionId) + /// + /// Performs a (partial) refund call on an existing transaction + /// + /// Transaction ID + /// Reason for the refund. May be null. + /// Amount of the refund. If null is given, it will be the full amount of the transaction. + /// Date to process the refund. May be null. + /// Full response including the Refund ID + public Api.Transaction.Refund.Response Refund(string transactionId, string description = null, decimal? amount = null, DateTime? processDate = null) + { + var request = new TransactionRefund { - TransactionDecline request = new TransactionDecline(); - request.TransactionId = transactionId; + TransactionId = transactionId, + Description = description, + Amount = amount, + ProcessDate = processDate + }; + + _webClient.PerformRequest(request); + return request.Response; + } - _webClient.PerformRequest(request); - return request.Response; - } + /// + /// function to approve a suspicious transaction + /// + /// Transaction ID + /// Full response including the message about the approvement + public Api.Transaction.Approve.Response Approve(string transactionId) + { + TransactionApprove request = new TransactionApprove(); + request.TransactionId = transactionId; + + _webClient.PerformRequest(request); + return request.Response; + } + /// + /// function to decline a suspicious transaction + /// + /// Transaction ID + /// Full response including the message about the decline + public Api.Transaction.Decline.Response Decline(string transactionId) + { + TransactionDecline request = new TransactionDecline(); + request.TransactionId = transactionId; - /// - /// Creates a transaction start request model - /// - /// The amount. Will be rounded at 2 digits after comma. - /// The IP address of the customer - /// The URL where the customer has to be send to after the payment. - /// The ID of the payment option (for iDEAL use 10). - /// In case of an iDEAL payment this is the ID of the bank (see the paymentOptionSubList in the getService function). - /// Whether or not we perform this call in test mode. - /// TransferType for this transaction (merchant/transaction) - /// TransferValue eg MerchantId (M-xxxx-xxxx) or orderId - /// Transaction Start Request - public static PAYNLSDK.API.Transaction.Start.Request CreateTransactionRequest(decimal amount, string ipAddress, string returnUrl, int? paymentOptionId = null, int? paymentSubOptionId = null, bool testMode = false, string transferType = null, string transferValue = null) - { - var request = new API.Transaction.Start.Request - { - Amount = (int)Math.Round(amount * 100), - IPAddress = ipAddress, - ReturnUrl = returnUrl, - PaymentOptionId = paymentOptionId, - PaymentOptionSubId = paymentSubOptionId, - TestMode = testMode, - TransferType = transferType, - TransferValue = transferValue - }; - return request; - } + _webClient.PerformRequest(request); + return request.Response; + } - /// - /// Performs a request to start a transaction. - /// - /// Full response object including Transaction ID - public PAYNLSDK.API.Transaction.Start.Response Start(PAYNLSDK.API.Transaction.Start.Request request) + /// + /// Creates a transaction start request model + /// + /// The amount. Will be rounded at 2 digits after comma. + /// The IP address of the customer + /// The URL where the customer has to be send to after the payment. + /// The ID of the payment option (for iDEAL use 10). + /// In case of an iDEAL payment this is the ID of the bank (see the paymentOptionSubList in the getService function). + /// Whether or not we perform this call in test mode. + /// TransferType for this transaction (merchant/transaction) + /// TransferValue eg MerchantId (M-xxxx-xxxx) or orderId + /// Transaction Start Request + public static Request CreateTransactionRequest(decimal amount, string ipAddress, string returnUrl, int? paymentOptionId = null, int? paymentSubOptionId = null, bool testMode = false, string transferType = null, string transferValue = null) + { + var request = new Request { + Amount = (int)Math.Round(amount * 100), + IPAddress = ipAddress, + ReturnUrl = returnUrl, + PaymentOptionId = paymentOptionId, + PaymentOptionSubId = paymentSubOptionId, + TestMode = testMode, + TransferType = transferType, + TransferValue = transferValue + }; + return request; + } - _webClient.PerformRequest(request); - return request.Response; - } + + /// + /// Performs a request to start a transaction. + /// + /// Full response object including Transaction ID + public Api.Transaction.Start.Response Start(Request request) + { + + _webClient.PerformRequest(request); + return request.Response; } } diff --git a/PAYNLSDK/Utilities/Reflection.cs b/PAYNLSDK/Utilities/Reflection.cs index 99ceaac..de0736e 100644 --- a/PAYNLSDK/Utilities/Reflection.cs +++ b/PAYNLSDK/Utilities/Reflection.cs @@ -1,21 +1,16 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace PAYNLSDK.Utilities +namespace PayNLSdk.Utilities; + +internal class Reflection { - internal class Reflection + public static bool IsNullable(Type t) { - public static bool IsNullable(Type t) + if (t == null) { - if (t == null) - { - throw new ArgumentNullException("t"); - } - - return (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)); + throw new ArgumentNullException("t"); } + + return (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)); } } diff --git a/PAYNLSDK/Utilities/Validators.cs b/PAYNLSDK/Utilities/Validators.cs index 07d7232..782aa54 100644 --- a/PAYNLSDK/Utilities/Validators.cs +++ b/PAYNLSDK/Utilities/Validators.cs @@ -2,40 +2,39 @@ // ReSharper disable ParameterOnlyUsedForPreconditionCheck.Global -namespace PAYNLSDK.Utilities +namespace PayNLSdk.Utilities; + +internal class ParameterValidator { - internal class ParameterValidator + internal static void IsNotEmpty(string param, string paramName) { - internal static void IsNotEmpty(string param, string paramName) + if (String.IsNullOrWhiteSpace(param)) { - if (String.IsNullOrWhiteSpace(param)) - { - throw new ArgumentException(string.Format("Invalid parameter {0}. Cannot be null, empty or consist of whitespace only", paramName), paramName); - } - } - - internal static void IsNotNull(object param, string paramName) - { - if (param == null) - { - throw new ArgumentException(string.Format("Invalid parameter '{0}'. Cannot be null", paramName), paramName); - } + throw new ArgumentException(string.Format("Invalid parameter {0}. Cannot be null, empty or consist of whitespace only", paramName), paramName); } + } - internal static bool IsEmpty(string param) + internal static void IsNotNull(object param, string paramName) + { + if (param == null) { - return String.IsNullOrWhiteSpace(param); + throw new ArgumentException(string.Format("Invalid parameter '{0}'. Cannot be null", paramName), paramName); } + } - internal static bool IsNull(object param) - { - return (param == null); - } + internal static bool IsEmpty(string param) + { + return String.IsNullOrWhiteSpace(param); + } - internal static bool IsNonEmptyInt(int? param) - { - return (param != null); - } + internal static bool IsNull(object param) + { + return (param == null); + } + internal static bool IsNonEmptyInt(int? param) + { + return (param != null); } + } diff --git a/PayNLSdk.Tests/Api/Alliance/AddInvoiceRequestTests.cs b/PayNLSdk.Tests/Api/Alliance/AddInvoiceRequestTests.cs index e0809ee..8c7a26f 100644 --- a/PayNLSdk.Tests/Api/Alliance/AddInvoiceRequestTests.cs +++ b/PayNLSdk.Tests/Api/Alliance/AddInvoiceRequestTests.cs @@ -1,94 +1,91 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using PayNLSdk.Api.Alliance.AddInvoice; -namespace PayNLSdk.Tests.Api.Alliance +namespace PayNLSdk.Tests.Api.Alliance; + +[TestClass] +public class AddInvoiceRequestTests { - [TestClass] - public class AddInvoiceRequestTests + private Request _sut; + + [TestInitialize] + public void TestInitialize() + { + _sut = new Request( + "Dummy", + "Dummy", + "Dummy", + "Dummy", + 12345 + ); + } + + [TestMethod] + public void GetParameters_ReturnMandatoryProperties_OnCalled() + { + // Arrange + + // Act + var parameters = _sut.GetParameters(); + + // Assert + Assert.IsNotNull(parameters["serviceId"]); + Assert.IsNotNull(parameters["merchantId"]); + Assert.IsNotNull(parameters["invoiceId"]); + Assert.IsNotNull(parameters["amount"]); + Assert.IsNotNull(parameters["description"]); + } + + #region Optional parameters + [TestMethod] + public void MakeYesterday_internalPropertySet_True() { - private PAYNLSDK.API.Alliance.AddInvoice.Request _sut; - - [TestInitialize] - public void TestInitialize() - { - _sut = new PAYNLSDK.API.Alliance.AddInvoice.Request( - "Dummy", - "Dummy", - "Dummy", - "Dummy", - 12345 - ); - } - - [TestMethod] - public void GetParameters_ReturnMandatoryProperties_OnCalled() - { - // Arrange - - // Act - var parameters = _sut.GetParameters(); - - // Assert - Assert.IsNotNull(parameters["serviceId"]); - Assert.IsNotNull(parameters["merchantId"]); - Assert.IsNotNull(parameters["invoiceId"]); - Assert.IsNotNull(parameters["amount"]); - Assert.IsNotNull(parameters["description"]); - } - - #region Optional parameters - [TestMethod] - public void MakeYesterday_internalPropertySet_True() - { - // Arrange - - // Act - _sut.MakeYesterday = true; - - // Assert - Assert.AreEqual("true", _sut.GetParameters()["makeYesterday"]); - } - - [TestMethod] - public void MakeYesterday_propertyNotAvailableInInParameters_PropertyIsNotSet() - { - // Arrange - //_sut.MakeYesterday = null; - - // Act - var parameter = _sut.GetParameters()["makeYesterday"]; - - // Assert - Assert.IsNull(parameter); - } - - [TestMethod] - public void InvoiceUrl_internalPropertySet_True() - { - // Arrange - var httpUrlToInvoice = "http://url.to/invoice"; - - // Act - _sut.InvoiceUrl = httpUrlToInvoice; - - // Assert - Assert.AreEqual(httpUrlToInvoice, _sut.GetParameters()["invoiceUrl"]); - } - - [TestMethod] - public void InvoiceUrl_propertyNotAvailableInInParameters_PropertyIsNotSet() - { - // Arrange - //_sut.MakeYesterday = null; - - // Act - var parameter = _sut.GetParameters()["invoiceUrl"]; - - // Assert - Assert.IsNull(parameter); - } - #endregion + // Arrange + + // Act + _sut.MakeYesterday = true; + + // Assert + Assert.AreEqual("true", _sut.GetParameters()["makeYesterday"]); + } + + [TestMethod] + public void MakeYesterday_propertyNotAvailableInInParameters_PropertyIsNotSet() + { + // Arrange + //_sut.MakeYesterday = null; + + // Act + var parameter = _sut.GetParameters()["makeYesterday"]; + + // Assert + Assert.IsNull(parameter); + } + + [TestMethod] + public void InvoiceUrl_internalPropertySet_True() + { + // Arrange + var httpUrlToInvoice = "http://url.to/invoice"; + + // Act + _sut.InvoiceUrl = httpUrlToInvoice; + + // Assert + Assert.AreEqual(httpUrlToInvoice, _sut.GetParameters()["invoiceUrl"]); + } + + [TestMethod] + public void InvoiceUrl_propertyNotAvailableInInParameters_PropertyIsNotSet() + { + // Arrange + //_sut.MakeYesterday = null; + + // Act + var parameter = _sut.GetParameters()["invoiceUrl"]; + + // Assert + Assert.IsNull(parameter); } + #endregion } diff --git a/PayNLSdk.Tests/Api/Statistics/GetStatsTests.cs b/PayNLSdk.Tests/Api/Statistics/GetStatsTests.cs index c14b57d..21747de 100644 --- a/PayNLSdk.Tests/Api/Statistics/GetStatsTests.cs +++ b/PayNLSdk.Tests/Api/Statistics/GetStatsTests.cs @@ -1,164 +1,163 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -using PayNLSdk.API.Statistics.GetManagement; +using PayNLSdk.Api.Statistics.GetManagement; +using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics.CodeAnalysis; using System.Linq; -namespace PayNLSdk.Tests.Api.Statistics +namespace PayNLSdk.Tests.Api.Statistics; + +[TestClass] +[SuppressMessage("ReSharper", "RedundantNameQualifier", Justification = "We need to be sure the correct object is called in the tests")] +public class GetStatsRequestTests { - [TestClass] - [SuppressMessage("ReSharper", "RedundantNameQualifier", Justification = "We need to be sure the correct object is called in the tests")] - public class GetStatsRequestTests + private Request _sut; + + [TestInitialize] + public void TestInitialize() { - private PayNLSdk.API.Statistics.GetManagement.Request _sut; + _sut = new Request(); + } - [TestInitialize] - public void TestInitialize() - { - _sut = new PayNLSdk.API.Statistics.GetManagement.Request(); - } + [TestMethod] + public void Ctor_FilterPropertyNotTempty_Always() + { + // Arrange - [TestMethod] - public void Ctor_FilterPropertyNotTempty_Always() - { - // Arrange + // Act - // Act + // Assert + Assert.IsNotNull(_sut.Filters); + Assert.AreEqual(0, _sut.Filters.Count); + } - // Assert - Assert.IsNotNull(_sut.Filters); - Assert.AreEqual(0, _sut.Filters.Count); - } + [TestMethod] + public void Ctor_GroupByPropertyNotTempty_Always() + { + // Arrange - [TestMethod] - public void Ctor_GroupByPropertyNotTempty_Always() - { - // Arrange + // Act - // Act + // Assert + Assert.IsNotNull(_sut.GroupByFieldNames); + Assert.AreEqual(0, _sut.GroupByFieldNames.Count); + } - // Assert - Assert.IsNotNull(_sut.GroupByFieldNames); - Assert.AreEqual(0, _sut.GroupByFieldNames.Count); - } + [TestMethod] + public void GetParameters_ContainsGroupBy_IfSortByFieldNamesPropertyIsUsed() + { + // Arrange + _sut.GroupByFieldNames.Add("ABC"); - [TestMethod] - public void GetParameters_ContainsGroupBy_IfSortByFieldNamesPropertyIsUsed() - { - // Arrange - _sut.GroupByFieldNames.Add("ABC"); + // Act + var result = _sut.GetParameters(); - // Act - var result = _sut.GetParameters(); + // Assert + Assert.AreEqual("ABC", result.Get("groupBy[0]")); - // Assert - Assert.AreEqual("ABC", result.Get("groupBy[0]")); + } - } + [TestMethod] + public void GetParameters_ContainsFilters_MultipleFiltersAdded() + { + // Arrange + _sut.Filters.Add(new Request.FilterItem { Key = "KEY1", Value = "VAL1" }); + _sut.Filters.Add(new Request.FilterItem { Key = "KEY2", Value = "VAL2" }); + + // Act + var result = _sut.GetParameters(); + + // Assert + Assert.IsTrue(GetWithPartialKey(result, "filterType[").Contains("KEY1")); + Assert.IsTrue(GetWithPartialKey(result, "filterType[").Contains("KEY2")); + Assert.IsTrue(GetWithPartialKey(result, "filterValue[").Contains("VAL1")); + Assert.IsTrue(GetWithPartialKey(result, "filterValue[").Contains("VAL2")); + } - [TestMethod] - public void GetParameters_ContainsFilters_MultipleFiltersAdded() - { - // Arrange - _sut.Filters.Add(new Request.FilterItem { Key = "KEY1", Value = "VAL1" }); - _sut.Filters.Add(new Request.FilterItem { Key = "KEY2", Value = "VAL2" }); - - // Act - var result = _sut.GetParameters(); - - // Assert - Assert.IsTrue(GetWithPartialKey(result, "filterType[").Contains("KEY1")); - Assert.IsTrue(GetWithPartialKey(result, "filterType[").Contains("KEY2")); - Assert.IsTrue(GetWithPartialKey(result, "filterValue[").Contains("VAL1")); - Assert.IsTrue(GetWithPartialKey(result, "filterValue[").Contains("VAL2")); - } + [TestMethod] + public void Create_CorrectStartEndDate_LastWeek() + { + // Arrange + var dateTime = new Mock(); + dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11)); - [TestMethod] - public void Create_CorrectStartEndDate_LastWeek() - { - // Arrange - var dateTime = new Mock(); - dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11)); + // Act + var result = Request.Create(dateTime.Object, Request.StatsPeriod.LastWeek); - // Act - var result = Request.Create(dateTime.Object, Request.StatsPeriod.LastWeek); + // Assert + Assert.AreEqual(new DateTime(2018, 12, 3), result.StartDate); + Assert.AreEqual(new DateTime(2018, 12, 9), result.EndDate); + } - // Assert - Assert.AreEqual(new DateTime(2018,12,3), result.StartDate); - Assert.AreEqual(new DateTime(2018,12,9), result.EndDate); - } + [TestMethod] + public void Create_CorrectStartEndDate_LastMonth() + { + // Arrange + var dateTime = new Mock(); + dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11)); - [TestMethod] - public void Create_CorrectStartEndDate_LastMonth() - { - // Arrange - var dateTime = new Mock(); - dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11)); + // Act + var result = Request.Create(dateTime.Object, Request.StatsPeriod.LastMonth); - // Act - var result = Request.Create(dateTime.Object, Request.StatsPeriod.LastMonth); + // Assert + Assert.AreEqual(new DateTime(2018, 11, 1), result.StartDate); + Assert.AreEqual(new DateTime(2018, 11, 30), result.EndDate); + } - // Assert - Assert.AreEqual(new DateTime(2018, 11, 1), result.StartDate); - Assert.AreEqual(new DateTime(2018, 11, 30), result.EndDate); - } + [TestMethod] + public void Create_CorrectStartEndDate_ThisWeek() + { + // Arrange + var dateTime = new Mock(); + dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11)); - [TestMethod] - public void Create_CorrectStartEndDate_ThisWeek() - { - // Arrange - var dateTime = new Mock(); - dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11)); + // Act + var result = Request.Create(dateTime.Object, Request.StatsPeriod.ThisWeek); - // Act - var result = Request.Create(dateTime.Object, Request.StatsPeriod.ThisWeek); + // Assert + Assert.AreEqual(new DateTime(2018, 12, 10), result.StartDate); + Assert.AreEqual(new DateTime(2018, 12, 16), result.EndDate); + } - // Assert - Assert.AreEqual(new DateTime(2018, 12, 10), result.StartDate); - Assert.AreEqual(new DateTime(2018, 12, 16), result.EndDate); - } + [TestMethod] + public void Create_CorrectStartEndDate_ThisMonth() + { + // Arrange + var dateTime = new Mock(); + dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11)); - [TestMethod] - public void Create_CorrectStartEndDate_ThisMonth() - { - // Arrange - var dateTime = new Mock(); - dateTime.SetupGet(p => p.Now).Returns(new DateTime(2018, 12, 11)); + // Act + var result = Request.Create(dateTime.Object, Request.StatsPeriod.ThisMonth); - // Act - var result = Request.Create(dateTime.Object, Request.StatsPeriod.ThisMonth); + // Assert + Assert.AreEqual(new DateTime(2018, 12, 1), result.StartDate); + Assert.AreEqual(new DateTime(2018, 12, 11), result.EndDate); + } - // Assert - Assert.AreEqual(new DateTime(2018, 12, 1), result.StartDate); - Assert.AreEqual(new DateTime(2018, 12, 11), result.EndDate); + /// + /// Loops all items in a and + /// return all values from all keys which start with the + /// + /// + /// + /// + private static IEnumerable GetWithPartialKey(NameValueCollection nvc, string keyStartsWith) + { + if (nvc == null) + { + yield break; } - /// - /// Loops all items in a and - /// return all values from all keys which start with the - /// - /// - /// - /// - private static IEnumerable GetWithPartialKey(NameValueCollection nvc, string keyStartsWith) + foreach (var s in nvc.AllKeys) { - if (nvc == null) - { - yield break; - } - - foreach (var s in nvc.AllKeys) + if (s.ToLower().StartsWith(keyStartsWith.ToLower())) { - if (s.ToLower().StartsWith(keyStartsWith.ToLower())) - { - yield return nvc.Get(s); - } + yield return nvc.Get(s); } } } -} +} \ No newline at end of file diff --git a/PayNLSdk.Tests/Api/Transaction/TransactionRefundTests.cs b/PayNLSdk.Tests/Api/Transaction/TransactionRefundTests.cs index ce28148..222f89e 100644 --- a/PayNLSdk.Tests/Api/Transaction/TransactionRefundTests.cs +++ b/PayNLSdk.Tests/Api/Transaction/TransactionRefundTests.cs @@ -1,47 +1,44 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using PayNLSdk.Api.Transaction.Refund; -namespace PayNLSdk.Tests.Api.Transaction +namespace PayNLSdk.Tests.Api.Transaction; + +[TestClass] +public class TransactionRefundTests { - [TestClass] - public class TransactionRefundTests + [TestMethod] + public void Request_AmountInCents_PassedInAsDecimal() { - [TestMethod] - public void Request_AmountInCents_PassedInAsDecimal() - { - // Arrange - var sut = new PAYNLSDK.API.Transaction.Refund.Request - { - TransactionId = "DUMMY", - Amount = 3.50m - }; - - // Act - var result = sut.GetParameters(); - - // Assert - Assert.AreEqual("350", result["amount"]); - } - - [TestMethod] - public void Request_NoAmountSupplied_NoParameterWithAmount() + // Arrange + var sut = new Request { - // Arrange - var sut = new PAYNLSDK.API.Transaction.Refund.Request - { - TransactionId = "DUMMY", - Amount = null - }; + TransactionId = "DUMMY", + Amount = 3.50m + }; - // Act - var result = sut.GetParameters(); + // Act + var result = sut.GetParameters(); + + // Assert + Assert.AreEqual("350", result["amount"]); + } - // Assert - Assert.IsNull(result["amount"]); - } + [TestMethod] + public void Request_NoAmountSupplied_NoParameterWithAmount() + { + // Arrange + var sut = new Request + { + TransactionId = "DUMMY", + Amount = null + }; + // Act + var result = sut.GetParameters(); + // Assert + Assert.IsNull(result["amount"]); } -} + + +} \ No newline at end of file diff --git a/PayNLSdk.Tests/ExtentionMethods/DateTimeTests.cs b/PayNLSdk.Tests/ExtentionMethods/DateTimeTests.cs index ac1e1f3..353a385 100644 --- a/PayNLSdk.Tests/ExtentionMethods/DateTimeTests.cs +++ b/PayNLSdk.Tests/ExtentionMethods/DateTimeTests.cs @@ -1,151 +1,148 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using PayNLSdk.ExtentionMethods; +using System; -namespace PayNLSdk.Tests.ExtentionMethods +namespace PayNLSdk.Tests.ExtentionMethods; + +[TestClass] +public class DateTimeTests { - [TestClass] - public class DateTimeTests + [TestInitialize] + public void TestInitialize() + { + + } + + [TestMethod] + public void LastMonthFirstDay_February_CurrentlyMarch() + { + // Arrange + var initialDate = new DateTime(2018, 2, 5); + + // Act + var result = initialDate.LastMonthFirstDay(); + + // Assert + Assert.AreEqual(2018, result.Year); + Assert.AreEqual(1, result.Month); + Assert.AreEqual(1, result.Day); + } + + [TestMethod] + public void LastMonthFirstDay_DecemberPreviousYear_CurrentlyFirstJanuary() + { + // Arrange + var initialDate = new DateTime(2018, 1, 1); + + // Act + var result = initialDate.LastMonthFirstDay(); + + // Assert + Assert.AreEqual(2017, result.Year); + Assert.AreEqual(12, result.Month); + Assert.AreEqual(1, result.Day); + } + + [TestMethod] + public void LastMonthFirstDay_PreviousMonth_LastDayOfTheMonth() + { + // Arrange + var initialDate = new DateTime(2018, 1, 31); + + // Act + var result = initialDate.LastMonthFirstDay(); + + // Assert + Assert.AreEqual(2017, result.Year); + Assert.AreEqual(12, result.Month); + Assert.AreEqual(1, result.Day); + } + + [TestMethod] + public void LastWeek_PreviousMonday_TodaySaturday() + { + // Arrange + var initialDate = new DateTime(2018, 10, 13); + + // Act + var result = initialDate.LastWeek(DayOfWeek.Monday); + + // Assert + Assert.AreEqual(new DateTime(2018, 10, 1), result); + Assert.AreEqual(DayOfWeek.Monday, result.DayOfWeek); + } + + [TestMethod] + public void LastWeek_PreviousMonday_TodayMonday() + { + // Arrange + var initialDate = new DateTime(2018, 12, 10); + + // Act + var result = initialDate.LastWeek(DayOfWeek.Monday); + + // Assert + Assert.AreEqual(new DateTime(2018, 12, 3), result); + Assert.AreEqual(DayOfWeek.Monday, result.DayOfWeek); + } + + [TestMethod] + public void LastWeek_PreviousMonday_TodaySunday() + { + // Arrange + var initialDate = new DateTime(2018, 12, 9); + + // Act + var result = initialDate.LastWeek(DayOfWeek.Monday); + + // Assert + Assert.AreEqual(new DateTime(2018, 11, 26), result); + Assert.AreEqual(DayOfWeek.Monday, result.DayOfWeek); + } + + [TestMethod] + public void LastMonthLastDay_Lastday_normalconditions() + { + // Arrange + var initialDate = new DateTime(2018, 7, 19); + + // Act + var result = initialDate.LastMonthLastDay(); + + // Assert + Assert.AreEqual(2018, result.Year); + Assert.AreEqual(6, result.Month); + Assert.AreEqual(30, result.Day); + } + + + [TestMethod] + public void LastMonthLastDay_31DecemberPreviousYear_CurrentlyFirstJanuary() + { + // Arrange + var initialDate = new DateTime(2018, 1, 1); + + // Act + var result = initialDate.LastMonthLastDay(); + + // Assert + Assert.AreEqual(2017, result.Year); + Assert.AreEqual(12, result.Month); + Assert.AreEqual(31, result.Day); + } + + [TestMethod] + public void LastMonthLastDay_1March_LeapYear() { - [TestInitialize] - public void TestInitialize() - { - - } - - [TestMethod] - public void LastMonthFirstDay_February_CurrentlyMarch() - { - // Arrange - var initialDate = new DateTime(2018,2,5); - - // Act - var result = initialDate.LastMonthFirstDay(); - - // Assert - Assert.AreEqual(2018, result.Year); - Assert.AreEqual(1, result.Month); - Assert.AreEqual(1, result.Day); - } - - [TestMethod] - public void LastMonthFirstDay_DecemberPreviousYear_CurrentlyFirstJanuary() - { - // Arrange - var initialDate = new DateTime(2018, 1, 1); - - // Act - var result = initialDate.LastMonthFirstDay(); - - // Assert - Assert.AreEqual(2017, result.Year); - Assert.AreEqual(12, result.Month); - Assert.AreEqual(1, result.Day); - } - - [TestMethod] - public void LastMonthFirstDay_PreviousMonth_LastDayOfTheMonth() - { - // Arrange - var initialDate = new DateTime(2018, 1, 31); - - // Act - var result = initialDate.LastMonthFirstDay(); - - // Assert - Assert.AreEqual(2017, result.Year); - Assert.AreEqual(12, result.Month); - Assert.AreEqual(1, result.Day); - } - - [TestMethod] - public void LastWeek_PreviousMonday_TodaySaturday() - { - // Arrange - var initialDate = new DateTime(2018,10,13); - - // Act - var result = initialDate.LastWeek(DayOfWeek.Monday); - - // Assert - Assert.AreEqual(new DateTime(2018,10,1), result); - Assert.AreEqual(DayOfWeek.Monday, result.DayOfWeek); - } - - [TestMethod] - public void LastWeek_PreviousMonday_TodayMonday() - { - // Arrange - var initialDate = new DateTime(2018, 12, 10); - - // Act - var result = initialDate.LastWeek(DayOfWeek.Monday); - - // Assert - Assert.AreEqual(new DateTime(2018, 12, 3), result); - Assert.AreEqual(DayOfWeek.Monday, result.DayOfWeek); - } - - [TestMethod] - public void LastWeek_PreviousMonday_TodaySunday() - { - // Arrange - var initialDate = new DateTime(2018, 12, 9); - - // Act - var result = initialDate.LastWeek(DayOfWeek.Monday); - - // Assert - Assert.AreEqual(new DateTime(2018, 11, 26), result); - Assert.AreEqual(DayOfWeek.Monday, result.DayOfWeek); - } - - [TestMethod] - public void LastMonthLastDay_Lastday_normalconditions() - { - // Arrange - var initialDate = new DateTime(2018, 7, 19); - - // Act - var result = initialDate.LastMonthLastDay(); - - // Assert - Assert.AreEqual(2018, result.Year); - Assert.AreEqual(6, result.Month); - Assert.AreEqual(30, result.Day); - } - - - [TestMethod] - public void LastMonthLastDay_31DecemberPreviousYear_CurrentlyFirstJanuary() - { - // Arrange - var initialDate = new DateTime(2018, 1, 1); - - // Act - var result = initialDate.LastMonthLastDay(); - - // Assert - Assert.AreEqual(2017, result.Year); - Assert.AreEqual(12, result.Month); - Assert.AreEqual(31, result.Day); - } - - [TestMethod] - public void LastMonthLastDay_1March_LeapYear() - { - // Arrange - var initialDate = new DateTime(2004, 3, 15); - - // Act - var result = initialDate.LastMonthLastDay(); - - // Assert - Assert.AreEqual(2004, result.Year); - Assert.AreEqual(2, result.Month); - Assert.AreEqual(29, result.Day); - } + // Arrange + var initialDate = new DateTime(2004, 3, 15); + + // Act + var result = initialDate.LastMonthLastDay(); + + // Assert + Assert.AreEqual(2004, result.Year); + Assert.AreEqual(2, result.Month); + Assert.AreEqual(29, result.Day); } } diff --git a/PayNLSdk.Tests/PayNLSdk.Tests.csproj b/PayNLSdk.Tests/PayNLSdk.Tests.csproj index a31c450..23b9a86 100644 --- a/PayNLSdk.Tests/PayNLSdk.Tests.csproj +++ b/PayNLSdk.Tests/PayNLSdk.Tests.csproj @@ -1,4 +1,4 @@ - + net8.0 false @@ -15,6 +15,6 @@ - + \ No newline at end of file diff --git a/PayNLSdk.Tests/ServiceTests.cs b/PayNLSdk.Tests/ServiceTests.cs index cd7dc04..bdd61e3 100644 --- a/PayNLSdk.Tests/ServiceTests.cs +++ b/PayNLSdk.Tests/ServiceTests.cs @@ -1,52 +1,51 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -using PAYNLSDK; -using PAYNLSDK.Net; +using PayNLSdk.Api.Service.GetCategories; +using PayNLSdk.Net; -namespace PayNLSdk.Tests +namespace PayNLSdk.Tests; + +[TestClass] +public class ServiceTests { - [TestClass] - public class ServiceTests + private Mock _iClientMock; + private Service _sut; + + [TestInitialize] + public void TestInitialize() + { + _iClientMock = new Mock(); + _sut = new Service(_iClientMock.Object); + } + + [TestMethod] + public void GetCategories_withoutParams() + { + // Arrange + + // Act + var result = _sut.GetCategories(); + + // Assert + _iClientMock.Verify( + o => o.PerformRequest(It.IsAny()), + Times.Once); + // Assert.IsNotNull(result); // UNTESTABLE CURRENTLY + } + + [TestMethod] + public void GetCategories_withParams() { - private Mock _iClientMock; - private Service _sut; - - [TestInitialize] - public void TestInitialize() - { - _iClientMock = new Mock(); - _sut = new Service(_iClientMock.Object); - } - - [TestMethod] - public void GetCategories_withoutParams() - { - // Arrange - - // Act - var result = _sut.GetCategories(); - - // Assert - _iClientMock.Verify( - o => o.PerformRequest(It.IsAny()), - Times.Once); - // Assert.IsNotNull(result); // UNTESTABLE CURRENTLY - } - - [TestMethod] - public void GetCategories_withParams() - { - // Arrange - int paymentOptionId = 1; - - // Act - var result = _sut.GetCategories(paymentOptionId); - - // Assert - _iClientMock.Verify( - o => o.PerformRequest(It.IsAny()), - Times.Once); - // Assert.IsNotNull(result); // UNTESTABLE CURRENTLY - } + // Arrange + int paymentOptionId = 1; + + // Act + var result = _sut.GetCategories(paymentOptionId); + + // Assert + _iClientMock.Verify( + o => o.PerformRequest(It.IsAny()), + Times.Once); + // Assert.IsNotNull(result); // UNTESTABLE CURRENTLY } } diff --git a/PayNLSdk.Tests/Utilities/ValidationTests.cs b/PayNLSdk.Tests/Utilities/ValidationTests.cs index d07422c..ef85058 100644 --- a/PayNLSdk.Tests/Utilities/ValidationTests.cs +++ b/PayNLSdk.Tests/Utilities/ValidationTests.cs @@ -1,68 +1,67 @@ -using System; using Microsoft.VisualStudio.TestTools.UnitTesting; -using PAYNLSDK.Utilities; +using PayNLSdk.Utilities; +using System; + +namespace PayNLSdk.Tests.Utilities; -namespace PayNLSdk.Tests.Utilities +[TestClass] +public class ValidationTests { - [TestClass] - public class ValidationTests + [TestMethod] + public void IsNotEmpty_DoesNotThrow_AbcInput() { - [TestMethod] - public void IsNotEmpty_DoesNotThrow_AbcInput() + // Arrange + var input = "abc"; + + // Act + try + { + ParameterValidator.IsNotEmpty(input, "someParamName"); + } + catch (ArgumentException) { - // Arrange - var input = "abc"; + Assert.Fail("should not throw"); + } - // Act - try - { - ParameterValidator.IsNotEmpty(input, "someParamName"); - } - catch (ArgumentException) - { - Assert.Fail("should not throw"); - } + // Assert + } - // Assert - } + [ExpectedException(typeof(ArgumentException), "We expected an exception")] + [TestMethod] + public void IsNotEmpty_ThrowsException_EmptyString() + { + // Arrange + var input = ""; - [ExpectedException(typeof(ArgumentException), "We expected an exception")] - [TestMethod] - public void IsNotEmpty_ThrowsException_EmptyString() - { - // Arrange - var input = ""; + // Act + ParameterValidator.IsNotEmpty(input, "someParamName"); - // Act - ParameterValidator.IsNotEmpty(input, "someParamName"); - - // Assert - } + // Assert + } - [TestMethod] - public void IsEmpty_False_AbcInput() - { - // Arrange - var input = "abc"; + [TestMethod] + public void IsEmpty_False_AbcInput() + { + // Arrange + var input = "abc"; - // Act - var result = ParameterValidator.IsEmpty(input); - - // Assert - Assert.IsFalse(result); - } + // Act + var result = ParameterValidator.IsEmpty(input); - [TestMethod] - public void IsEmpty_True_EmptyString() - { - // Arrange - var input = ""; + // Assert + Assert.IsFalse(result); + } - // Act - var result = ParameterValidator.IsEmpty(input); + [TestMethod] + public void IsEmpty_True_EmptyString() + { + // Arrange + var input = ""; - // Assert - Assert.IsTrue(result); - } + // Act + var result = ParameterValidator.IsEmpty(input); + + // Assert + Assert.IsTrue(result); } -} +} \ No newline at end of file From 372a2606be1313344453894f607f1f25f9278efd Mon Sep 17 00:00:00 2001 From: Damiaan Date: Wed, 15 Oct 2025 19:00:56 +0200 Subject: [PATCH 2/6] add comments --- PAYNLSDK/Enums/enums.cs | 6 +++- PAYNLSDK/ITransaction.cs | 60 ++++++++++++++++++++++++++++++++++++++-- PAYNLSDK/Transaction.cs | 11 -------- 3 files changed, 63 insertions(+), 14 deletions(-) diff --git a/PAYNLSDK/Enums/enums.cs b/PAYNLSDK/Enums/enums.cs index 6e9b722..445c0f2 100644 --- a/PAYNLSDK/Enums/enums.cs +++ b/PAYNLSDK/Enums/enums.cs @@ -251,6 +251,7 @@ public enum Blacklist /// public enum PaymentStatus { +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member [EnumMember(Value = "-90")] CANCEL = -90, [EnumMember(Value = "-60")] @@ -295,6 +296,7 @@ public enum PaymentStatus AUTHORIZE = 95, [EnumMember(Value = "-63")] DENIED = -63, +#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } /// @@ -302,6 +304,7 @@ public enum PaymentStatus /// public enum ProductType { +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member [EnumMember(Value = "ARTICLE")] ARTICLE, [EnumMember(Value = "SHIPPING")] @@ -338,4 +341,5 @@ public enum ProductType PAYMENT, [EnumMember(Value = "ROUNDING")] ROUNDING, -} \ No newline at end of file +#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member +} diff --git a/PAYNLSDK/ITransaction.cs b/PAYNLSDK/ITransaction.cs index 493303d..9a046a7 100644 --- a/PAYNLSDK/ITransaction.cs +++ b/PAYNLSDK/ITransaction.cs @@ -5,6 +5,9 @@ namespace PayNLSdk; +/// +/// All api calls against transactions +/// public interface ITransaction { /// @@ -12,15 +15,68 @@ public interface ITransaction /// /// The transaction id Response Approve(string transactionId); + + /// + /// Function to decline a suspicious transaction + /// + /// Transaction ID + /// Full response including the message about the decline Api.Transaction.Decline.Response Decline(string transactionId); - Api.Transaction.GetService.Response GetService(); - Api.Transaction.GetService.Response GetService(PaymentMethodId? paymentMethodId); + + /// + /// Return service information. + /// This API returns merchant info and all the available payment options per country for a given service. + /// This is an important API if you want to build your own payment screens. + /// + /// optional, the payment method ID + /// Full response with all service information + Api.Transaction.GetService.Response GetService(PaymentMethodId? paymentMethodId = null); + + /// + /// Query the service for all (current status) information on a transaction + /// + /// Transaction ID + /// Full response object with all information available Api.Transaction.Info.Response Info(string transactionId); + + /// + /// Checks whether a transaction has a status of CANCELLED + /// + /// Transaction Id + /// True if CANCELLED, false otherwise bool IsCancelled(string transactionId); + + /// + /// Checks whether a transaction has a status of PAID + /// + /// Transaction Id + /// True if PAID, false otherwise bool IsPaid(string transactionId); + + /// + /// Checks whether a transaction has a status of PENDING + /// + /// Transaction Id + /// True if PENDING, false otherwise bool IsPending(string transactionId); + + /// + /// Checks whether a transaction has a status of VERIFY + /// + /// Transaction Id + /// True if VERIFY, false otherwise bool IsVerify(string transactionId); + + /// + /// Performs a (partial) refund call on an existing transaction + /// + /// Transaction ID + /// Reason for the refund. May be null. + /// Amount of the refund. If null is given, it will be the full amount of the transaction. + /// Date to process the refund. May be null. + /// Full response including the Refund ID Api.Transaction.Refund.Response Refund(string transactionId, string description = null, decimal? amount = null, DateTime? processDate = null); + /// /// If a customer has chosen to pay per transaction this API needs to be called. /// diff --git a/PAYNLSDK/Transaction.cs b/PAYNLSDK/Transaction.cs index 42bdbc7..bea8425 100644 --- a/PAYNLSDK/Transaction.cs +++ b/PAYNLSDK/Transaction.cs @@ -184,17 +184,6 @@ public Api.Transaction.GetService.Response GetService(PaymentMethodId? paymentMe return request.Response; } - /// - /// Return service information. - /// This API returns merchant info and all the available payment options per country for a given service. - /// This is an important API if you want to build your own payment screens. - /// - /// FUll response with all service information - public Api.Transaction.GetService.Response GetService() - { - return GetService(null); - } - /// /// Performs a (partial) refund call on an existing transaction /// From 39ce3fbaa8b0275fcae97e9fc0ef953b3dfebc88 Mon Sep 17 00:00:00 2001 From: Damiaan Date: Wed, 15 Oct 2025 19:33:11 +0200 Subject: [PATCH 3/6] Preserve Windows line endings for WinForms and request files --- .gitattributes | 10 + PAYNLFormsApp/DebugForm.cs | 2 +- PAYNLFormsApp/Fixtures/RefundInfo.cs | 4 +- PAYNLFormsApp/Form1.cs | 26 +- PAYNLFormsApp/PAYNLFormsApp.csproj | 16 +- PAYNLFormsApp/packages.config | 2 +- .../Alliance/AddInvoice/AddInvoiceResult.cs | 5 +- .../Alliance/AddMerchant/AddMerchantResult.cs | 19 +- PAYNLSDK/API/Alliance/AddMerchant/Request.cs | 30 +-- .../Alliance/AddService/AddServiceResult.cs | 5 +- .../Alliance/GetMerchant/GetMerchantResult.cs | 75 +++--- PAYNLSDK/API/Alliance/GetMerchant/Request.cs | 2 +- PAYNLSDK/API/Banktransfer/Add/Request.cs | 5 +- PAYNLSDK/API/Banktransfer/Add/Response.cs | 5 +- PAYNLSDK/API/Document/Add/Request.cs | 5 +- PAYNLSDK/API/Document/Add/Response.cs | 9 +- PAYNLSDK/API/Merchant/Add/Request.cs | 37 +-- PAYNLSDK/API/Merchant/Add/Response.cs | 24 +- PAYNLSDK/API/Merchant/Clearing/Response.cs | 6 +- PAYNLSDK/API/Merchant/Info/Request.cs | 7 +- PAYNLSDK/API/Merchant/Info/Response.cs | 12 +- PAYNLSDK/API/PaymentMethod/Get/Request.cs | 7 +- PAYNLSDK/API/PaymentMethod/GetAll/Request.cs | 5 +- PAYNLSDK/API/PaymentProfile/Get/Request.cs | 7 +- PAYNLSDK/API/PaymentProfile/GetAll/Request.cs | 5 +- .../PaymentProfile/GetAvailable/Request.cs | 13 +- PAYNLSDK/API/Refund/Add/Request.cs | 7 +- PAYNLSDK/API/Refund/Add/Response.cs | 5 +- PAYNLSDK/API/Refund/Info/Request.cs | 5 +- PAYNLSDK/API/Refund/Info/Response.cs | 5 +- PAYNLSDK/API/Refund/Transaction/Request.cs | 19 +- PAYNLSDK/API/Refund/Transaction/Response.cs | 5 +- PAYNLSDK/API/RequestBase.cs | 6 +- PAYNLSDK/API/ResponseBase.cs | 8 +- PAYNLSDK/API/SMS/BulkMessage/Request.cs | 13 +- PAYNLSDK/API/SMS/BulkMessage/Response.cs | 5 +- PAYNLSDK/API/SMS/PremiumMessage/Request.cs | 11 +- PAYNLSDK/API/SMS/PremiumMessage/Response.cs | 5 +- PAYNLSDK/API/Service/GetCategories/Request.cs | 7 +- .../GetManagement/GetStatsMultiLevel.cs | 5 +- .../GetManagement/GetStatsResult.cs | 5 +- .../GetManagement/GetStatsResultBase.cs | 253 +++++++++--------- PAYNLSDK/API/Transaction/Approve/Request.cs | 9 +- PAYNLSDK/API/Transaction/Approve/Response.cs | 5 +- PAYNLSDK/API/Transaction/Decline/Request.cs | 9 +- PAYNLSDK/API/Transaction/Decline/Response.cs | 5 +- .../GetLastTransactions/Request.cs | 11 +- .../GetLastTransactions/Response.cs | 5 +- .../API/Transaction/GetService/Request.cs | 7 +- .../API/Transaction/GetService/Response.cs | 9 +- PAYNLSDK/API/Transaction/Info/Request.cs | 5 +- PAYNLSDK/API/Transaction/Info/Response.cs | 15 +- PAYNLSDK/API/Transaction/Refund/Request.cs | 17 +- PAYNLSDK/API/Transaction/Refund/Response.cs | 5 +- PAYNLSDK/API/Transaction/Start/Request.cs | 5 +- PAYNLSDK/API/Transaction/Start/Response.cs | 15 +- .../API/Validate/BankAccountNumber/Request.cs | 7 +- .../Validate/BankAccountNumber/Response.cs | 5 +- .../BankAccountNumberInternational/Request.cs | 7 +- .../Response.cs | 5 +- PAYNLSDK/API/Validate/GetServerIps/Request.cs | 5 +- PAYNLSDK/API/Validate/IBAN/Request.cs | 7 +- PAYNLSDK/API/Validate/IBAN/Response.cs | 5 +- .../API/Validate/IsPayServerIp/Request.cs | 7 +- .../API/Validate/IsPayServerIp/Response.cs | 5 +- PAYNLSDK/API/Validate/KVK/Request.cs | 7 +- PAYNLSDK/API/Validate/KVK/Response.cs | 5 +- PAYNLSDK/API/Validate/SOFI/Request.cs | 7 +- PAYNLSDK/API/Validate/SOFI/Response.cs | 5 +- PAYNLSDK/API/Validate/SWIFT/Request.cs | 7 +- PAYNLSDK/API/Validate/SWIFT/Response.cs | 5 +- PAYNLSDK/API/Validate/Util.cs | 3 +- PAYNLSDK/API/Validate/VAT/Request.cs | 7 +- PAYNLSDK/API/Validate/VAT/Response.cs | 5 +- PAYNLSDK/Alliance.cs | 9 +- PAYNLSDK/Api/Transaction/Enduser.cs | 45 ++-- .../Api/Transaction/Info/StornoDetails.cs | 21 +- .../Api/Transaction/Start/TransactionData.cs | 23 +- PAYNLSDK/Api/Transaction/StatsDetails.cs | 21 +- PAYNLSDK/Api/Validate/Util.cs.orig | 171 ------------ PAYNLSDK/Converters/BooleanConverter.cs | 68 +++-- PAYNLSDK/Converters/CountryOptionConverter.cs | 44 ++- PAYNLSDK/Converters/DMYConverter.cs | 112 ++++---- PAYNLSDK/Converters/EnumConversionBase.cs | 45 +++- PAYNLSDK/Converters/ErrorIdConverter.cs | 60 +++-- PAYNLSDK/Converters/GenderConverter.cs | 12 +- PAYNLSDK/Converters/ProductTypeConverter.cs | 7 +- PAYNLSDK/Converters/TaxClassConverter.cs | 12 +- PAYNLSDK/Converters/YMDConverter.cs | 105 ++++---- PAYNLSDK/Converters/YMDHISConverter.cs | 119 ++++---- PAYNLSDK/Language.cs | 3 +- PAYNLSDK/Net/Client.cs | 5 +- PAYNLSDK/Objects/Address.cs | 21 +- PAYNLSDK/Objects/Company.cs | 11 +- PAYNLSDK/Objects/Connection.cs | 29 +- PAYNLSDK/Objects/CountryOption.cs | 17 +- PAYNLSDK/Objects/Error.cs | 9 +- PAYNLSDK/Objects/Merchant.cs | 11 +- PAYNLSDK/Objects/OrderData.cs | 15 +- PAYNLSDK/Objects/PaymentDetails.cs | 77 +++--- PAYNLSDK/Objects/PaymentMethod.cs | 9 +- PAYNLSDK/Objects/PaymentOption.cs | 19 +- PAYNLSDK/Objects/PaymentProfile.cs | 19 +- PAYNLSDK/Objects/RefundInfo.cs | 21 +- PAYNLSDK/Objects/SalesData.cs | 9 +- PAYNLSDK/Objects/Service.cs | 23 +- PAYNLSDK/Objects/ServiceCategory.cs | 7 +- PAYNLSDK/Objects/TransactionStartEnduser.cs | 5 +- PAYNLSDK/Objects/TransactionStartInfo.cs | 11 +- PAYNLSDK/Objects/TransactionStats.cs | 27 +- PAYNLSDK/PayNLSdk.csproj | 2 +- PAYNLSDK/Statistics.cs | 8 +- PAYNLSDK/Utilities/JsonSerialization.cs | 74 +++++ 113 files changed, 1163 insertions(+), 1076 deletions(-) delete mode 100644 PAYNLSDK/Api/Validate/Util.cs.orig create mode 100644 PAYNLSDK/Utilities/JsonSerialization.cs diff --git a/.gitattributes b/.gitattributes index a664be3..10e87f2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -47,3 +47,13 @@ *.fsproj text=auto merge=union *.dbproj text=auto merge=union *.sln text=auto eol=crlf merge=union +PAYNLFormsApp/DebugForm.cs -text diff=csharp +PAYNLFormsApp/Form1.cs -text diff=csharp +PAYNLFormsApp/PAYNLFormsApp.csproj -text +PAYNLSDK/API/Banktransfer/Add/Request.cs -text diff=csharp +PAYNLSDK/API/Refund/Add/Request.cs -text diff=csharp +PAYNLSDK/API/Refund/Add/Response.cs -text diff=csharp +PAYNLSDK/API/Transaction/Approve/Request.cs -text diff=csharp +PAYNLSDK/API/Transaction/Approve/Response.cs -text diff=csharp +PAYNLSDK/API/Transaction/Decline/Request.cs -text diff=csharp +PAYNLSDK/API/Transaction/Decline/Response.cs -text diff=csharp diff --git a/PAYNLFormsApp/DebugForm.cs b/PAYNLFormsApp/DebugForm.cs index 0fc8ae9..bdc51b1 100644 --- a/PAYNLFormsApp/DebugForm.cs +++ b/PAYNLFormsApp/DebugForm.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using PayNLSdk.Utilities; using PAYNLFormsApp.Fixtures; using PAYNLSDK; using PAYNLSDK.API; diff --git a/PAYNLFormsApp/Fixtures/RefundInfo.cs b/PAYNLFormsApp/Fixtures/RefundInfo.cs index 6573c4b..616426c 100644 --- a/PAYNLFormsApp/Fixtures/RefundInfo.cs +++ b/PAYNLFormsApp/Fixtures/RefundInfo.cs @@ -2,7 +2,7 @@ using PAYNLSDK.Objects; using PAYNLSDK; using PAYNLSDK.Enums; -using Newtonsoft.Json; +using PayNLSdk.Utilities; namespace PAYNLFormsApp.Fixtures { @@ -11,7 +11,7 @@ public class TransactionRefundInfo static public PAYNLSDK.Objects.RefundInfo GetRefundInfoFixture() { String json = GetJsonFixture(); - PAYNLSDK.Objects.RefundInfo info = JsonConvert.DeserializeObject(json); + PAYNLSDK.Objects.RefundInfo info = JsonSerialization.Deserialize(json); return info; } diff --git a/PAYNLFormsApp/Form1.cs b/PAYNLFormsApp/Form1.cs index f8a8df5..368a211 100644 --- a/PAYNLFormsApp/Form1.cs +++ b/PAYNLFormsApp/Form1.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using PayNLSdk.Utilities; using PAYNLFormsApp.Fixtures; using PAYNLSDK.API; using PAYNLSDK.Exceptions; @@ -133,7 +133,7 @@ private void transactionStartproductsToolStripMenuItem_Click(object sender, Even //string qs = fixture.ToQueryString(); //AddDebug(qs); //NameValueCollection nvc = HttpUtility.ParseQueryString(qs); - //string json = JsonConvert.SerializeObject(NvcToDictionary(nvc, true)); + //string json = JsonSerialization.Serialize(NvcToDictionary(nvc, true)); AddDebug("-----"); //DumpNvc(nvc); AddDebug("-----"); @@ -249,8 +249,8 @@ private void Form1_Load(object sender, EventArgs e) AddDebug(PAYNLSDK.Enums.Util.ToEnumString(PAYNLSDK.Enums.TaxClass.High, typeof(PAYNLSDK.Enums.TaxClass))); string ser = @"{'gender':'m'}"; - X x = JsonConvert.DeserializeObject(ser); - AddDebug(JsonConvert.SerializeObject(x)); + X x = JsonSerialization.Deserialize(ser); + AddDebug(JsonSerialization.Serialize(x)); */ } @@ -379,7 +379,7 @@ private void testDateTimeConversionToolStripMenuItem_Click(object sender, EventA AddDebug("Can not test this use case"); // try // { - // TestYMD testObj = JsonConvert.DeserializeObject(dateString); + // TestYMD testObj = JsonSerialization.Deserialize(dateString); // AddDebug(String.Format("Converted '{0}' to {1}.", dateString, testObj.DT.ToString())); // } // catch (Exception e0) @@ -392,7 +392,7 @@ private void testDateTimeConversionToolStripMenuItem_Click(object sender, EventA //{ // try // { - // TestDMY testObj = JsonConvert.DeserializeObject(dateString); + // TestDMY testObj = JsonSerialization.Deserialize(dateString); // AddDebug(String.Format("Converted '{0}' to {1}.", dateString, testObj.DT.ToString())); // } // catch (Exception e1) @@ -405,7 +405,7 @@ private void testDateTimeConversionToolStripMenuItem_Click(object sender, EventA //{ // try // { - // TestYMDHIS testObj = JsonConvert.DeserializeObject(dateString); + // TestYMDHIS testObj = JsonSerialization.Deserialize(dateString); // AddDebug(String.Format("Converted '{0}' to {1}.", dateString, testObj.DT.ToString())); // } // catch (Exception e2) @@ -429,7 +429,7 @@ private void refundtransactionToolStripMenuItem_Click(object sender, EventArgs e //string qs = fixture.ToQueryString(); //AddDebug(qs); //NameValueCollection nvc = HttpUtility.ParseQueryString(qs); - //string json = JsonConvert.SerializeObject(NvcToDictionary(nvc, true)); + //string json = JsonSerialization.Serialize(NvcToDictionary(nvc, true)); AddDebug("-----"); //AddDebug("PARAMS AS JSON"); //AddDebug(json); @@ -450,7 +450,7 @@ private void refundTrasactionProductsToolStripMenuItem_Click(object sender, Even //string qs = fixture.ToQueryString(); //AddDebug(qs); //NameValueCollection nvc = HttpUtility.ParseQueryString(qs); - //string json = JsonConvert.SerializeObject(NvcToDictionary(nvc, true)); + //string json = JsonSerialization.Serialize(NvcToDictionary(nvc, true)); //AddDebug("-----"); ////AddDebug("PARAMS AS JSON"); ////AddDebug(json); @@ -481,7 +481,7 @@ private void refundInfoToolStripMenuItem_Click(object sender, EventArgs e) /* class X { - [JsonProperty("gender"), JsonConverter(typeof(PAYNLSDK.Converters.GenderConverter))] + [JsonPropertyName("gender"), JsonConverter(typeof(PAYNLSDK.Converters.GenderConverter))] public PAYNLSDK.Enums.Gender Gender { get; set; } } @@ -493,7 +493,7 @@ class X // /// // /// Merchant ID // /// - // [JsonProperty("dt"), JsonConverter(typeof(PAYNLSDK.Converters.YMDConverter))] + // [JsonPropertyName("dt"), JsonConverter(typeof(PAYNLSDK.Converters.YMDConverter))] // public DateTime? DT { get; set; } //} @@ -502,7 +502,7 @@ class X // /// // /// Merchant ID // /// - // [JsonProperty("dt"), JsonConverter(typeof(PAYNLSDK.Converters.DMYConverter))] + // [JsonPropertyName("dt"), JsonConverter(typeof(PAYNLSDK.Converters.DMYConverter))] // public DateTime? DT { get; set; } //} @@ -511,7 +511,7 @@ class X // /// // /// Merchant ID // /// - // [JsonProperty("dt"), JsonConverter(typeof(PAYNLSDK.Converters.YMDHISConverter))] + // [JsonPropertyName("dt"), JsonConverter(typeof(PAYNLSDK.Converters.YMDHISConverter))] // public DateTime? DT { get; set; } //} diff --git a/PAYNLFormsApp/PAYNLFormsApp.csproj b/PAYNLFormsApp/PAYNLFormsApp.csproj index 3ed6f81..863d0fc 100644 --- a/PAYNLFormsApp/PAYNLFormsApp.csproj +++ b/PAYNLFormsApp/PAYNLFormsApp.csproj @@ -65,8 +65,8 @@ ..\packages\LightInject.5.1.1\lib\netstandard1.1\LightInject.dll - - ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + + ..\packages\System.Text.Json.7.0.3\lib\netstandard2.0\System.Text.Json.dll @@ -226,11 +226,11 @@ - \ No newline at end of file diff --git a/PAYNLFormsApp/packages.config b/PAYNLFormsApp/packages.config index 1298228..af202a3 100644 --- a/PAYNLFormsApp/packages.config +++ b/PAYNLFormsApp/packages.config @@ -2,7 +2,7 @@ - + diff --git a/PAYNLSDK/API/Alliance/AddInvoice/AddInvoiceResult.cs b/PAYNLSDK/API/Alliance/AddInvoice/AddInvoiceResult.cs index 1009180..029295d 100644 --- a/PAYNLSDK/API/Alliance/AddInvoice/AddInvoiceResult.cs +++ b/PAYNLSDK/API/Alliance/AddInvoice/AddInvoiceResult.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Alliance.AddInvoice; @@ -13,7 +14,7 @@ public class AddInvoiceResult : ResponseBase /// Gets or sets the reference id for the payment. /// /// The reference identifier. - [JsonProperty("referenceId")] + [JsonPropertyName("referenceId")] public string ReferenceId { get; set; } /// diff --git a/PAYNLSDK/API/Alliance/AddMerchant/AddMerchantResult.cs b/PAYNLSDK/API/Alliance/AddMerchant/AddMerchantResult.cs index 1758d04..151536d 100644 --- a/PAYNLSDK/API/Alliance/AddMerchant/AddMerchantResult.cs +++ b/PAYNLSDK/API/Alliance/AddMerchant/AddMerchantResult.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Api.Alliance.AddMerchant; @@ -12,7 +13,7 @@ public class AddMerchantResult /// Gets or sets if it was success. /// /// whether we had a successful call or not. - [JsonProperty("success")] + [JsonPropertyName("success")] [JsonConverter(typeof(BooleanConverter))] public bool Success { get; set; } @@ -20,34 +21,34 @@ public class AddMerchantResult /// Gets or sets the error id /// /// The error field. - [JsonProperty("error_field")] + [JsonPropertyName("error_field")] public string ErrorField { get; set; } /// /// Gets or sets the error message. /// /// The error message. - [JsonProperty("error_message")] + [JsonPropertyName("error_message")] public string ErrorMessage { get; set; } /// /// Gets or sets the merchant identifier. /// /// The merchant identifier. - [JsonProperty("merchantId")] + [JsonPropertyName("merchantId")] public string MerchantId { get; set; } /// /// Gets or sets the merchant token. /// /// The merchant token. - [JsonProperty("merchantToken")] + [JsonPropertyName("merchantToken")] public string MerchantToken { get; set; } /// /// The created accounts for this merchant /// - [JsonProperty("accounts")] + [JsonPropertyName("accounts")] public Account[] Accounts { get; set; } /// @@ -59,14 +60,14 @@ public class Account /// Gets or sets the account identifier. /// /// The account identifier. - [JsonProperty("accountId")] + [JsonPropertyName("accountId")] public string AccountId { get; set; } /// /// Gets or sets the email. /// /// The email. - [JsonProperty("email")] + [JsonPropertyName("email")] public string Email { get; set; } } } diff --git a/PAYNLSDK/API/Alliance/AddMerchant/Request.cs b/PAYNLSDK/API/Alliance/AddMerchant/Request.cs index 329dc75..66ff205 100644 --- a/PAYNLSDK/API/Alliance/AddMerchant/Request.cs +++ b/PAYNLSDK/API/Alliance/AddMerchant/Request.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel.DataAnnotations; @@ -125,13 +125,13 @@ public override NameValueCollection GetParameters() /// Chamber of Commerce number of the company /// /// - [JsonProperty("coc")] + [JsonPropertyName("coc")] public string Coc { get; set; } /// /// Name of the company /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string FullName { get; set; } /// @@ -185,21 +185,21 @@ public class Account /// /// Email address /// - [JsonProperty("email")] + [JsonPropertyName("email")] [Required] public string Email { get; set; } /// /// Given name /// - [JsonProperty("firstname")] + [JsonPropertyName("firstname")] [Required] public string FirstName { get; set; } /// /// Family name /// - [JsonProperty("lastname")] + [JsonPropertyName("lastname")] [Required] public string LastName { get; set; } @@ -208,8 +208,8 @@ public class Account /// M: male /// F: female /// - [JsonProperty("gender")] - [JsonConverter(typeof(StringEnumConverter))] + [JsonPropertyName("gender")] + [JsonConverter(typeof(JsonStringEnumConverter))] [Required] public GenderEnum Gender { get; set; } @@ -217,7 +217,7 @@ public class Account /// Indicates if the user is authorised to sign /// 0 not authorised, 1 authorised independently, 2 shared authorized to sign /// - [JsonProperty("authorisedToSign")] + [JsonPropertyName("authorisedToSign")] [Required] public AuthorizedToSignEnum AuthorizedToSign { get; set; } @@ -225,14 +225,14 @@ public class Account /// Indicates if the user is ubo /// Ultimate beneficial owner (25% of more shares) /// - [JsonProperty("ubo")] + [JsonPropertyName("ubo")] [Required] public bool UltimateBeneficialOwner { get; set; } /// /// If the user is UBO, use this parameter to set the percentage of UBO. Eg. 25 for 25% /// - [JsonProperty("uboPercentage")] + [JsonPropertyName("uboPercentage")] [Required] public int UboPercentage { get; set; } @@ -240,7 +240,7 @@ public class Account /// Indicates if the user has company rights. Available options are 0 and 1 /// [Required] - [JsonProperty("useCompanyAuth")] + [JsonPropertyName("useCompanyAuth")] public bool UseCompanyAuth { get; set; } /// @@ -249,14 +249,14 @@ public class Account /// 0: No.Use this setting to add accounts that are only added to define the UBO's /// [Required] - [JsonProperty("hasAccess")] + [JsonPropertyName("hasAccess")] public bool HasAccess { get; set; } /// /// Preferred language of the registrant. See API_Langauge_v2::getAll() /// [Required] - [JsonProperty("language")] + [JsonPropertyName("language")] public string Language { get; set; } diff --git a/PAYNLSDK/API/Alliance/AddService/AddServiceResult.cs b/PAYNLSDK/API/Alliance/AddService/AddServiceResult.cs index fe671aa..e9c35a9 100644 --- a/PAYNLSDK/API/Alliance/AddService/AddServiceResult.cs +++ b/PAYNLSDK/API/Alliance/AddService/AddServiceResult.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Alliance.AddService; @@ -10,6 +11,6 @@ public class AddServiceResult : ResponseBase /// /// The newly created service identifier (SL-****-****) /// - [JsonProperty("serviceId")] + [JsonPropertyName("serviceId")] public string ServiceId { get; set; } } diff --git a/PAYNLSDK/API/Alliance/GetMerchant/GetMerchantResult.cs b/PAYNLSDK/API/Alliance/GetMerchant/GetMerchantResult.cs index 10bc675..aa69890 100644 --- a/PAYNLSDK/API/Alliance/GetMerchant/GetMerchantResult.cs +++ b/PAYNLSDK/API/Alliance/GetMerchant/GetMerchantResult.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -11,23 +12,23 @@ namespace PayNLSdk.Api.Alliance.GetMerchant; [SuppressMessage("ReSharper", "InconsistentNaming")] public class GetMerchantResult { - [JsonProperty("request")] public GetMerchantResult.Request request { get; set; } - [JsonProperty("merchantId")] public string merchantId { get; set; } - [JsonProperty("merchantName")] public string merchantName { get; set; } - [JsonProperty("services")] public Service[] services { get; set; } - [JsonProperty("balance")] public int BalanceInCents { get; set; } + [JsonPropertyName("request")] public GetMerchantResult.Request request { get; set; } + [JsonPropertyName("merchantId")] public string merchantId { get; set; } + [JsonPropertyName("merchantName")] public string merchantName { get; set; } + [JsonPropertyName("services")] public Service[] services { get; set; } + [JsonPropertyName("balance")] public int BalanceInCents { get; set; } [JsonIgnore] public decimal Balance => Math.Round(BalanceInCents / 100m); - [JsonProperty("documents")] public Document[] documents { get; set; } - [JsonProperty("accounts")] public Account[] accounts { get; set; } - [JsonProperty("bankaccounts")] public Bankaccount[] bankaccounts { get; set; } - [JsonProperty("public_info")] public PublicInfo public_info { get; set; } - [JsonProperty("contract")] public Contract contract { get; set; } + [JsonPropertyName("documents")] public Document[] documents { get; set; } + [JsonPropertyName("accounts")] public Account[] accounts { get; set; } + [JsonPropertyName("bankaccounts")] public Bankaccount[] bankaccounts { get; set; } + [JsonPropertyName("public_info")] public PublicInfo public_info { get; set; } + [JsonPropertyName("contract")] public Contract contract { get; set; } public class Request { - [JsonProperty("result")] public string result { get; set; } - [JsonProperty("errorId")] public string errorId { get; set; } - [JsonProperty("errorMessage")] public string errorMessage { get; set; } + [JsonPropertyName("result")] public string result { get; set; } + [JsonPropertyName("errorId")] public string errorId { get; set; } + [JsonPropertyName("errorMessage")] public string errorMessage { get; set; } } public class PublicInfo @@ -71,66 +72,66 @@ public class Service public class Document { - [JsonProperty("id")] + [JsonPropertyName("id")] public string id { get; set; } - [JsonProperty("type_id")] + [JsonPropertyName("type_id")] public string type_id { get; set; } - [JsonProperty("type_name")] + [JsonPropertyName("type_name")] public string type_name { get; set; } /// /// Can be one of these values: 1 (Requested), 2 (Uploaded), 3 (Approved), 4 (Rejected), 5 (Expired) /// - [JsonProperty("status_id")] + [JsonPropertyName("status_id")] public int status_id { get; set; } - [JsonProperty("status_name")] + [JsonPropertyName("status_name")] public string status_name { get; set; } - [JsonProperty("expires")] + [JsonPropertyName("expires")] public string expires { get; set; } } public class Account { - [JsonProperty("id")] + [JsonPropertyName("id")] public string id { get; set; } - [JsonProperty("account_id")] + [JsonPropertyName("account_id")] public string account_id { get; set; } - [JsonProperty("name")] + [JsonPropertyName("name")] public string name { get; set; } - [JsonProperty("accepted")] + [JsonPropertyName("accepted")] public string accepted { get; set; } - [JsonProperty("access")] + [JsonPropertyName("access")] public string access { get; set; } - [JsonProperty("ubo")] + [JsonPropertyName("ubo")] public string ubo { get; set; } - [JsonProperty("authorised_to_sign")] + [JsonPropertyName("authorised_to_sign")] public string authorised_to_sign { get; set; } - [JsonProperty("signature_label")] + [JsonPropertyName("signature_label")] public string signature_label { get; set; } - [JsonProperty("documents")] + [JsonPropertyName("documents")] public Document[] documents { get; set; } } public class Bankaccount { - [JsonProperty("id")] + [JsonPropertyName("id")] public string id { get; set; } - [JsonProperty("bankaccountHolder")] + [JsonPropertyName("bankaccountHolder")] public string bankaccountHolder { get; set; } - [JsonProperty("bankaccountNumber")] + [JsonPropertyName("bankaccountNumber")] public string bankaccountNumber { get; set; } - [JsonProperty("bic")] + [JsonPropertyName("bic")] public string bic { get; set; } - [JsonProperty("countryCode")] + [JsonPropertyName("countryCode")] public string countryCode { get; set; } } public class ContactData { - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } - [JsonProperty("value")] + [JsonPropertyName("value")] public string Value { get; set; } - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } } diff --git a/PAYNLSDK/API/Alliance/GetMerchant/Request.cs b/PAYNLSDK/API/Alliance/GetMerchant/Request.cs index 4c3b510..971f032 100644 --- a/PAYNLSDK/API/Alliance/GetMerchant/Request.cs +++ b/PAYNLSDK/API/Alliance/GetMerchant/Request.cs @@ -31,7 +31,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - // response = JsonConvert.DeserializeObject(RawResponse); + // response = JsonSerialization.Deserialize(RawResponse); } } \ No newline at end of file diff --git a/PAYNLSDK/API/Banktransfer/Add/Request.cs b/PAYNLSDK/API/Banktransfer/Add/Request.cs index df82868..24c37d8 100644 --- a/PAYNLSDK/API/Banktransfer/Add/Request.cs +++ b/PAYNLSDK/API/Banktransfer/Add/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System; @@ -187,7 +188,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); if (!Response.Request.Result) { // toss diff --git a/PAYNLSDK/API/Banktransfer/Add/Response.cs b/PAYNLSDK/API/Banktransfer/Add/Response.cs index 1c64ee2..ba7af53 100644 --- a/PAYNLSDK/API/Banktransfer/Add/Response.cs +++ b/PAYNLSDK/API/Banktransfer/Add/Response.cs @@ -1,9 +1,10 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Banktransfer.Add; public class Response : ResponseBase { - [JsonProperty("refundId")] + [JsonPropertyName("refundId")] public string RefundId { get; set; } } diff --git a/PAYNLSDK/API/Document/Add/Request.cs b/PAYNLSDK/API/Document/Add/Request.cs index f2f7362..3ab9d18 100644 --- a/PAYNLSDK/API/Document/Add/Request.cs +++ b/PAYNLSDK/API/Document/Add/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System; @@ -67,7 +68,7 @@ protected override void PrepareAndSetResponse() throw new PayNlException("rawResponse is empty!"); } - var r = JsonConvert.DeserializeObject(RawResponse); + var r = JsonSerialization.Deserialize(RawResponse); response = r; } } \ No newline at end of file diff --git a/PAYNLSDK/API/Document/Add/Response.cs b/PAYNLSDK/API/Document/Add/Response.cs index d1a760d..b021c71 100644 --- a/PAYNLSDK/API/Document/Add/Response.cs +++ b/PAYNLSDK/API/Document/Add/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Document.Add; @@ -10,15 +11,15 @@ public class Response : ResponseBase /// /// If true the call was successful /// - [JsonProperty("result")] public bool Result { get; set; } + [JsonPropertyName("result")] public bool Result { get; set; } /// /// ID of the error (if an error occurred) /// - [JsonProperty("errorId")] public string ErrorId { get; set; } + [JsonPropertyName("errorId")] public string ErrorId { get; set; } /// /// Description of the error (if an error occurred) /// - [JsonProperty("errorMessage")] public string ErrorMessage { get; set; } + [JsonPropertyName("errorMessage")] public string ErrorMessage { get; set; } } \ No newline at end of file diff --git a/PAYNLSDK/API/Merchant/Add/Request.cs b/PAYNLSDK/API/Merchant/Add/Request.cs index 09a16ce..438d705 100644 --- a/PAYNLSDK/API/Merchant/Add/Request.cs +++ b/PAYNLSDK/API/Merchant/Add/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Generic; @@ -82,28 +83,28 @@ public class Request : RequestBase /// 1 - The default registration email is sent /// 2 - The shortened alliance registration email is sent /// - [JsonProperty("sendEmail")] + [JsonPropertyName("sendEmail")] public int? SendEmail { get; set; } - [JsonProperty("countryCode")] + [JsonPropertyName("countryCode")] public string TwoLetterCountryCode { get; set; } - [JsonProperty("bankAccountOwner")] + [JsonPropertyName("bankAccountOwner")] public string BankAccountOwner { get; set; } - [JsonProperty("bankAccountNumber")] + [JsonPropertyName("bankAccountNumber")] public string BankAccountNumber { get; set; } - [JsonProperty("bankAccountBIC")] + [JsonPropertyName("bankAccountBIC")] public string BankAccountBic { get; set; } - [JsonProperty("vatNumber")] + [JsonPropertyName("vatNumber")] public string VatNumber { get; set; } /// /// Alliance or AlliancePlus /// - [JsonProperty("packageName")] + [JsonPropertyName("packageName")] public string PackageName { get; set; } /// /// settleBalance @@ -111,45 +112,45 @@ public class Request : RequestBase /// Your invoice will be subtracted from the merchants account. /// You will need to ask the merchant for permission before you can set this value to true /// - [JsonProperty("settleBalance")] + [JsonPropertyName("settleBalance")] public bool SettleBalance { get; set; } /// /// options are day, week or month /// - [JsonProperty("payoutInterval")] + [JsonPropertyName("payoutInterval")] public string PayoutInterval { get; set; } public class Account { - [JsonProperty("primary")] + [JsonPropertyName("primary")] public bool Primary { get; set; } - [JsonProperty("email")] + [JsonPropertyName("email")] public string Email { get; set; } - [JsonProperty("firstname")] + [JsonPropertyName("firstname")] public string FirstName { get; set; } - [JsonProperty("lastname")] + [JsonPropertyName("lastname")] public string LastName { get; set; } /// /// "male" or "female" /// - [JsonProperty("gender")] + [JsonPropertyName("gender")] public string Gender { get; set; } /// /// 0 not authorised, 1 authorised independently, 2 shared authorized to sign /// - [JsonProperty("authorisedToSign")] + [JsonPropertyName("authorisedToSign")] public int AuthorizedToSign { get; set; } /// /// Ultimate beneficial owner (25% of more shares) /// - [JsonProperty("ubo")] + [JsonPropertyName("ubo")] public bool UltimateBeneficialOwner { get; set; } } @@ -187,7 +188,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); if (!response.Request.Result) { // toss diff --git a/PAYNLSDK/API/Merchant/Add/Response.cs b/PAYNLSDK/API/Merchant/Add/Response.cs index 314ad58..ed74d33 100644 --- a/PAYNLSDK/API/Merchant/Add/Response.cs +++ b/PAYNLSDK/API/Merchant/Add/Response.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; +using PayNLSdk.Utilities; namespace PayNLSdk.Api.Merchant.Add; @@ -7,29 +9,29 @@ namespace PayNLSdk.Api.Merchant.Add; /// public class Response : ResponseBase { - [JsonProperty("merchantId")] + [JsonPropertyName("merchantId")] public string MerchantId { get; set; } /// /// The merchant name /// - [JsonProperty("merchantName")] public string MerchantName { get; set; } + [JsonPropertyName("merchantName")] public string MerchantName { get; set; } /// /// Alliance or AlliancePlus /// - [JsonProperty("packageName")] public string PackageName { get; set; } - [JsonProperty("invoiceAllowed")] public bool GetInvoiceAllowed { get; set; } - [JsonProperty("payoutInterval")] public string PayoutInterval { get; set; } + [JsonPropertyName("packageName")] public string PackageName { get; set; } + [JsonPropertyName("invoiceAllowed")] public bool GetInvoiceAllowed { get; set; } + [JsonPropertyName("payoutInterval")] public string PayoutInterval { get; set; } /// /// The date the contract has been created. /// - [JsonProperty("createdDate")] public string CreatedDate { get; set; } + [JsonPropertyName("createdDate")] public string CreatedDate { get; set; } /// /// The date when you can start using the services from PAY /// - [JsonProperty("acceptedDate")] public string AcceptedDate { get; set; } - [JsonProperty("deletedDate")] public string DeletedDate { get; set; } - [JsonProperty("services")] public string Services { get; set; } + [JsonPropertyName("acceptedDate")] public string AcceptedDate { get; set; } + [JsonPropertyName("deletedDate")] public string DeletedDate { get; set; } + [JsonPropertyName("services")] public string Services { get; set; } /// /// Convert a raw response to an object @@ -38,6 +40,6 @@ public class Response : ResponseBase /// public static Response FromRawResponse(string response) { - return JsonConvert.DeserializeObject(response); + return JsonSerialization.Deserialize(response); } } \ No newline at end of file diff --git a/PAYNLSDK/API/Merchant/Clearing/Response.cs b/PAYNLSDK/API/Merchant/Clearing/Response.cs index d2a1907..bb41a78 100644 --- a/PAYNLSDK/API/Merchant/Clearing/Response.cs +++ b/PAYNLSDK/API/Merchant/Clearing/Response.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; +using PayNLSdk.Utilities; namespace PayNLSdk.Api.Merchant.Clearing; @@ -16,6 +18,6 @@ public class Response : ResponseBase /// internal static Response FromRawResponse(string response) { - return JsonConvert.DeserializeObject(response); + return JsonSerialization.Deserialize(response); } } diff --git a/PAYNLSDK/API/Merchant/Info/Request.cs b/PAYNLSDK/API/Merchant/Info/Request.cs index 43769f3..fee599c 100644 --- a/PAYNLSDK/API/Merchant/Info/Request.cs +++ b/PAYNLSDK/API/Merchant/Info/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -7,7 +8,7 @@ namespace PayNLSdk.Api.Merchant.Info; public class Request : RequestBase { - [JsonProperty("merchantId")] + [JsonPropertyName("merchantId")] public string MerchantId { get; set; } /// @@ -33,7 +34,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); if (!response.Request.Result) { // toss diff --git a/PAYNLSDK/API/Merchant/Info/Response.cs b/PAYNLSDK/API/Merchant/Info/Response.cs index 0c2f296..9642eb2 100644 --- a/PAYNLSDK/API/Merchant/Info/Response.cs +++ b/PAYNLSDK/API/Merchant/Info/Response.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; +using PayNLSdk.Utilities; using System.ComponentModel.DataAnnotations; namespace PayNLSdk.Api.Merchant.Info; @@ -7,22 +9,22 @@ public class Response : ResponseBase { public static Response FromRawResponse(string response) { - return JsonConvert.DeserializeObject(response); + return JsonSerialization.Deserialize(response); } /// /// This array contains information whether the request was succesfull yes or no /// - [JsonProperty("request")] + [JsonPropertyName("request")] public ResultInfo request { get; set; } - [JsonProperty("merchant")] + [JsonPropertyName("merchant")] public Merchant merchant { get; set; } /// /// The different ways of contacting the merchant /// - [JsonProperty("contactData")] + [JsonPropertyName("contactData")] public Contact contactData { get; set; } #region Models (SubClasses) diff --git a/PAYNLSDK/API/PaymentMethod/Get/Request.cs b/PAYNLSDK/API/PaymentMethod/Get/Request.cs index 2522142..4fe5953 100644 --- a/PAYNLSDK/API/PaymentMethod/Get/Request.cs +++ b/PAYNLSDK/API/PaymentMethod/Get/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -13,7 +14,7 @@ public class Request : RequestBase /// /// The paymentMethod to be used /// - [JsonProperty("paymentMethodId")] + [JsonPropertyName("paymentMethodId")] public Enums.PaymentMethodId PaymentMethodId { get; set; } /// @@ -44,7 +45,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - Objects.PaymentMethod pm = JsonConvert.DeserializeObject(RawResponse); + Objects.PaymentMethod pm = JsonSerialization.Deserialize(RawResponse); Response r = new Response { PaymentMethod = pm diff --git a/PAYNLSDK/API/PaymentMethod/GetAll/Request.cs b/PAYNLSDK/API/PaymentMethod/GetAll/Request.cs index c4a1ae7..b8bfd8e 100644 --- a/PAYNLSDK/API/PaymentMethod/GetAll/Request.cs +++ b/PAYNLSDK/API/PaymentMethod/GetAll/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -35,7 +36,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - Objects.PaymentMethod[] pm = JsonConvert.DeserializeObject(RawResponse); + Objects.PaymentMethod[] pm = JsonSerialization.Deserialize(RawResponse); Response r = new Response { PaymentMethods = pm diff --git a/PAYNLSDK/API/PaymentProfile/Get/Request.cs b/PAYNLSDK/API/PaymentProfile/Get/Request.cs index d4ade8a..6c97a8c 100644 --- a/PAYNLSDK/API/PaymentProfile/Get/Request.cs +++ b/PAYNLSDK/API/PaymentProfile/Get/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -8,7 +9,7 @@ namespace PayNLSdk.Api.PaymentProfile.Get; public class Request : RequestBase { - [JsonProperty("paymentProfileId")] + [JsonPropertyName("paymentProfileId")] public int PaymentProfileId { get; set; } /// @@ -40,7 +41,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - Objects.PaymentProfile pm = JsonConvert.DeserializeObject(RawResponse); + Objects.PaymentProfile pm = JsonSerialization.Deserialize(RawResponse); Response r = new Response { PaymentProfile = pm diff --git a/PAYNLSDK/API/PaymentProfile/GetAll/Request.cs b/PAYNLSDK/API/PaymentProfile/GetAll/Request.cs index b52f02a..8db46d8 100644 --- a/PAYNLSDK/API/PaymentProfile/GetAll/Request.cs +++ b/PAYNLSDK/API/PaymentProfile/GetAll/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -29,7 +30,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - Objects.PaymentProfile[] pm = JsonConvert.DeserializeObject(RawResponse); + Objects.PaymentProfile[] pm = JsonSerialization.Deserialize(RawResponse); Response r = new Response { PaymentProfiles = pm diff --git a/PAYNLSDK/API/PaymentProfile/GetAvailable/Request.cs b/PAYNLSDK/API/PaymentProfile/GetAvailable/Request.cs index 3f759c1..ab70bd3 100644 --- a/PAYNLSDK/API/PaymentProfile/GetAvailable/Request.cs +++ b/PAYNLSDK/API/PaymentProfile/GetAvailable/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; @@ -12,25 +13,25 @@ public class Request : RequestBase /// The ID of the category of the service the payment options are used for. /// For a list of available categories, see /// - [JsonProperty("categoryId")] + [JsonPropertyName("categoryId")] public int CategoryId { get; set; } /// /// ID of the program for which the payment options are used. (Only available if the program option is enabled!) /// - [JsonProperty("programId")] + [JsonPropertyName("programId")] public int? ProgramId { get; set; } /// /// Optional ID of the payment method /// - [JsonProperty("paymentMethodId")] + [JsonPropertyName("paymentMethodId")] public int? PaymentMethodId { get; set; } /// /// Indicator wether to show profiles that are initially not allowed on registration. /// - [JsonProperty("showNotAllowedOnRegistration"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("showNotAllowedOnRegistration"), JsonConverter(typeof(BooleanConverter))] public bool? ShowNotAllowedOnRegistration { get; set; } /// @@ -77,7 +78,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - Objects.PaymentProfile[] pm = JsonConvert.DeserializeObject(RawResponse); + Objects.PaymentProfile[] pm = JsonSerialization.Deserialize(RawResponse); Response r = new Response(); r.PaymentProfiles = pm; response = r; diff --git a/PAYNLSDK/API/Refund/Add/Request.cs b/PAYNLSDK/API/Refund/Add/Request.cs index f882bc7..13c87a4 100644 --- a/PAYNLSDK/API/Refund/Add/Request.cs +++ b/PAYNLSDK/API/Refund/Add/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System; @@ -30,7 +31,7 @@ public Request(decimal amount, string bankAccountHolder, string bankAccountNumbe /// /// The amount to be paid should be given in cents. For example € 3.50 becomes 350. /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public int AmountInCents { get; set; } /// @@ -202,7 +203,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); if (!Response.Request.Result) { // toss diff --git a/PAYNLSDK/API/Refund/Add/Response.cs b/PAYNLSDK/API/Refund/Add/Response.cs index 83859cc..0609cc3 100644 --- a/PAYNLSDK/API/Refund/Add/Response.cs +++ b/PAYNLSDK/API/Refund/Add/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Refund.Add; @@ -7,6 +8,6 @@ public class Response : ResponseBase /// /// ID of the refund starting with 'RF-' (optional, emptyfor creditcard transactions) /// - [JsonProperty("refundId")] + [JsonPropertyName("refundId")] public string RefundId { get; set; } } diff --git a/PAYNLSDK/API/Refund/Info/Request.cs b/PAYNLSDK/API/Refund/Info/Request.cs index bff6c6f..6569807 100644 --- a/PAYNLSDK/API/Refund/Info/Request.cs +++ b/PAYNLSDK/API/Refund/Info/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -60,7 +61,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); if (!Response.Request.Result) { // toss diff --git a/PAYNLSDK/API/Refund/Info/Response.cs b/PAYNLSDK/API/Refund/Info/Response.cs index cdf47f1..43c8b36 100644 --- a/PAYNLSDK/API/Refund/Info/Response.cs +++ b/PAYNLSDK/API/Refund/Info/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Objects; namespace PayNLSdk.Api.Refund.Info; @@ -8,6 +9,6 @@ public class Response : ResponseBase /// /// Refund information /// - [JsonProperty("refund")] + [JsonPropertyName("refund")] public RefundInfo Refund { get; protected set; } } diff --git a/PAYNLSDK/API/Refund/Transaction/Request.cs b/PAYNLSDK/API/Refund/Transaction/Request.cs index 2ce3bdb..fe2057c 100644 --- a/PAYNLSDK/API/Refund/Transaction/Request.cs +++ b/PAYNLSDK/API/Refund/Transaction/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; @@ -26,37 +27,37 @@ public Request(string transactionId) /// /// The order ID or EX code of the transaction. /// - [JsonProperty("transactionId")] + [JsonPropertyName("transactionId")] public string TransactionId { get; set; } /// /// The amount to be paid should be given in cents. For example € 3.50 becomes 350. /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public int? Amount { get; set; } /// /// The description to include with the payment. /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } /// /// The description to include with the payment. /// - [JsonProperty("processDate"), JsonConverter(typeof(DMYConverter))] + [JsonPropertyName("processDate"), JsonConverter(typeof(DMYConverter))] public DateTime? ProcessDate { get; set; } /// /// Custom exchange URL overriding the defaultexchange URL. /// - [JsonProperty("exchangeUrl")] + [JsonPropertyName("exchangeUrl")] public string ExchangeUrl { get; set; } /// /// Product items that are refunded (key: product ID, value: quantity). /// - [JsonProperty("products")] + [JsonPropertyName("products")] public Dictionary Products { get; set; } /// @@ -122,7 +123,7 @@ public override System.Collections.Specialized.NameValueCollection GetParameters if (Products.Count > 0) { - nvc.Add("products", JsonConvert.SerializeObject(Products)); + nvc.Add("products", JsonSerialization.Serialize(Products)); } if (!ParameterValidator.IsEmpty(ExchangeUrl)) @@ -139,7 +140,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); if (!Response.Request.Result) { // toss diff --git a/PAYNLSDK/API/Refund/Transaction/Response.cs b/PAYNLSDK/API/Refund/Transaction/Response.cs index 89fc26a..e916701 100644 --- a/PAYNLSDK/API/Refund/Transaction/Response.cs +++ b/PAYNLSDK/API/Refund/Transaction/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Refund.Transaction; @@ -7,6 +8,6 @@ public class Response : ResponseBase /// /// ID of the refund starting with 'RF-' (optional, emptyfor creditcard transactions) /// - [JsonProperty("refundId")] + [JsonPropertyName("refundId")] public string RefundId { get; set; } } diff --git a/PAYNLSDK/API/RequestBase.cs b/PAYNLSDK/API/RequestBase.cs index a8df013..1c00bf7 100644 --- a/PAYNLSDK/API/RequestBase.cs +++ b/PAYNLSDK/API/RequestBase.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; +using PayNLSdk.Utilities; using System.Collections.Specialized; namespace PayNLSdk.Api; @@ -25,7 +27,7 @@ public abstract class RequestBase public override string ToString() { //return base.ToString(); - return JsonConvert.SerializeObject(this, Formatting.Indented); + return JsonSerialization.Serialize(this, JsonSerialization.CreateIndentedOptions()); } /// diff --git a/PAYNLSDK/API/ResponseBase.cs b/PAYNLSDK/API/ResponseBase.cs index 4d541f3..271dd7c 100644 --- a/PAYNLSDK/API/ResponseBase.cs +++ b/PAYNLSDK/API/ResponseBase.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; +using PayNLSdk.Utilities; using PayNLSdk.Objects; namespace PayNLSdk.Api; @@ -11,7 +13,7 @@ public abstract class ResponseBase /// /// The Error if the request led to a failed response /// - [JsonProperty("request")] + [JsonPropertyName("request")] public Error Request { get; protected set; } /// @@ -21,6 +23,6 @@ public abstract class ResponseBase public override string ToString() { //return base.ToString(); - return JsonConvert.SerializeObject(this, Formatting.Indented); + return JsonSerialization.Serialize(this, JsonSerialization.CreateIndentedOptions()); } } diff --git a/PAYNLSDK/API/SMS/BulkMessage/Request.cs b/PAYNLSDK/API/SMS/BulkMessage/Request.cs index c238d18..1d4ff77 100644 --- a/PAYNLSDK/API/SMS/BulkMessage/Request.cs +++ b/PAYNLSDK/API/SMS/BulkMessage/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -7,16 +8,16 @@ namespace PayNLSdk.Api.SMS.BulkMessage; public class Request : RequestBase { - [JsonProperty("org")] + [JsonPropertyName("org")] public string Sender { get; set; } - [JsonProperty("dest")] + [JsonPropertyName("dest")] public string Recipient { get; set; } - [JsonProperty("body")] + [JsonPropertyName("body")] public string Message { get; set; } - //[JsonProperty("starttime")] + //[JsonPropertyName("starttime")] //public int SendTime { get; set; } /// @@ -53,6 +54,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/SMS/BulkMessage/Response.cs b/PAYNLSDK/API/SMS/BulkMessage/Response.cs index 96c3e39..31d3580 100644 --- a/PAYNLSDK/API/SMS/BulkMessage/Response.cs +++ b/PAYNLSDK/API/SMS/BulkMessage/Response.cs @@ -1,10 +1,11 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Api.SMS.BulkMessage; public class Response : ResponseBase { - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] public bool result { get; protected set; } } diff --git a/PAYNLSDK/API/SMS/PremiumMessage/Request.cs b/PAYNLSDK/API/SMS/PremiumMessage/Request.cs index 30919d5..fee7b6a 100644 --- a/PAYNLSDK/API/SMS/PremiumMessage/Request.cs +++ b/PAYNLSDK/API/SMS/PremiumMessage/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -8,13 +9,13 @@ namespace PayNLSdk.Api.SMS.PremiumMessage; public class Request : RequestBase { - [JsonProperty("sms_id")] + [JsonPropertyName("sms_id")] public string SmsId { get; set; } - [JsonProperty("secret")] + [JsonPropertyName("secret")] public string Secret { get; set; } - [JsonProperty("message")] + [JsonPropertyName("message")] public string Message { get; set; } /// @@ -49,7 +50,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/SMS/PremiumMessage/Response.cs b/PAYNLSDK/API/SMS/PremiumMessage/Response.cs index 5967a29..442702f 100644 --- a/PAYNLSDK/API/SMS/PremiumMessage/Response.cs +++ b/PAYNLSDK/API/SMS/PremiumMessage/Response.cs @@ -1,10 +1,11 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Api.SMS.PremiumMessage; public class Response : ResponseBase { - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] public bool result { get; protected set; } } diff --git a/PAYNLSDK/API/Service/GetCategories/Request.cs b/PAYNLSDK/API/Service/GetCategories/Request.cs index 72e755e..4273d5c 100644 --- a/PAYNLSDK/API/Service/GetCategories/Request.cs +++ b/PAYNLSDK/API/Service/GetCategories/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Objects; using PayNLSdk.Utilities; @@ -15,7 +16,7 @@ public class Request : RequestBase /// /// The optional ID of the payment profile /// - [JsonProperty("paymentOptionId")] + [JsonPropertyName("paymentOptionId")] public int? PaymentOptionId { get; set; } /// @@ -47,7 +48,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - ServiceCategory[] pm = JsonConvert.DeserializeObject(RawResponse); + ServiceCategory[] pm = JsonSerialization.Deserialize(RawResponse); Response r = new Response { ServiceCategories = pm diff --git a/PAYNLSDK/API/Statistics/GetManagement/GetStatsMultiLevel.cs b/PAYNLSDK/API/Statistics/GetManagement/GetStatsMultiLevel.cs index 107650a..3a86445 100644 --- a/PAYNLSDK/API/Statistics/GetManagement/GetStatsMultiLevel.cs +++ b/PAYNLSDK/API/Statistics/GetManagement/GetStatsMultiLevel.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Statistics.GetManagement; @@ -8,7 +9,7 @@ namespace PayNLSdk.Api.Statistics.GetManagement; /// public class GetStatsMultiLevel : GetStatsResultBase { - [JsonProperty("arrStatsData")] + [JsonPropertyName("arrStatsData")] public TopLevelStatsData[] TopLevelGroup { get; set; } } diff --git a/PAYNLSDK/API/Statistics/GetManagement/GetStatsResult.cs b/PAYNLSDK/API/Statistics/GetManagement/GetStatsResult.cs index c08d5d3..fcf1e88 100644 --- a/PAYNLSDK/API/Statistics/GetManagement/GetStatsResult.cs +++ b/PAYNLSDK/API/Statistics/GetManagement/GetStatsResult.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Diagnostics.CodeAnalysis; namespace PayNLSdk.Api.Statistics.GetManagement; @@ -10,6 +11,6 @@ namespace PayNLSdk.Api.Statistics.GetManagement; [SuppressMessage("ReSharper", "InconsistentNaming")] public class GetStatsResult : GetStatsResultBase { - [JsonProperty("arrStatsData")] + [JsonPropertyName("arrStatsData")] public StatsData[] ArrStatsData { get; set; } } diff --git a/PAYNLSDK/API/Statistics/GetManagement/GetStatsResultBase.cs b/PAYNLSDK/API/Statistics/GetManagement/GetStatsResultBase.cs index e66ca14..317ecd1 100644 --- a/PAYNLSDK/API/Statistics/GetManagement/GetStatsResultBase.cs +++ b/PAYNLSDK/API/Statistics/GetManagement/GetStatsResultBase.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System; using System.Globalization; @@ -14,49 +14,49 @@ public abstract class GetStatsResultBase /// Gets or sets the login. /// /// The login. - [JsonProperty("login")] + [JsonPropertyName("login")] public string Login { get; set; } /// /// Gets or sets the arr label list. /// /// The arr label list. - [JsonProperty("arrLabelList")] + [JsonPropertyName("arrLabelList")] public LabelList ArrLabelList { get; set; } /// /// Gets or sets the total. /// /// The total. - [JsonProperty("totals")] + [JsonPropertyName("totals")] public Totals Total { get; set; } /// /// Gets or sets the total rows. /// /// The total rows. - [JsonProperty("totalRows")] + [JsonPropertyName("totalRows")] public int TotalRows { get; set; } /// /// Gets or sets the page. /// /// The page. - [JsonProperty("page")] + [JsonPropertyName("page")] public int Page { get; set; } /// /// Gets or sets the page data. /// /// The page data. - [JsonProperty("pageData")] + [JsonPropertyName("pageData")] public Pagedata PageData { get; set; } /// /// Gets or sets the currency symbol. /// /// The currency symbol. - [JsonProperty("currency_symbol")] + [JsonPropertyName("currency_symbol")] public string CurrencySymbol { get; set; } /// @@ -68,7 +68,7 @@ public class LabelList /// Gets or sets the 4. /// /// The 4. - [JsonProperty("4")] + [JsonPropertyName("4")] public _4 _4 { get; set; } } @@ -81,14 +81,14 @@ public class _4 /// Gets or sets the name. /// /// The name. - [JsonProperty("name")] + [JsonPropertyName("name")] public string name { get; set; } /// /// Gets or sets the cols. /// /// The cols. - [JsonProperty("cols")] + [JsonPropertyName("cols")] public ColumnLabels ColumnLabels { get; set; } } @@ -101,56 +101,56 @@ public class ColumnLabels /// Gets or sets the number. /// /// The number. - [JsonProperty("num")] + [JsonPropertyName("num")] public string num { get; set; } /// /// Gets or sets the average pay. /// /// The average pay. - [JsonProperty("avg_pay")] + [JsonPropertyName("avg_pay")] public string avg_pay { get; set; } /// /// Gets or sets the org. /// /// The org. - [JsonProperty("org")] + [JsonPropertyName("org")] public string org { get; set; } /// /// Gets or sets the org vat. /// /// The org vat. - [JsonProperty("org_vat")] + [JsonPropertyName("org_vat")] public string org_vat { get; set; } /// /// Gets or sets the org ext. /// /// The org ext. - [JsonProperty("org_ext")] + [JsonPropertyName("org_ext")] public string org_ext { get; set; } /// /// Gets or sets the org tot. /// /// The org tot. - [JsonProperty("org_tot")] + [JsonPropertyName("org_tot")] public string org_tot { get; set; } /// /// Gets or sets the CST. /// /// The CST. - [JsonProperty("cst")] + [JsonPropertyName("cst")] public string cst { get; set; } /// /// Gets or sets the pay. /// /// The pay. - [JsonProperty("pay")] + [JsonPropertyName("pay")] public string pay { get; set; } } @@ -163,56 +163,56 @@ public class ColumnValues /// Gets or sets the number. /// /// The number. - [JsonProperty("num")] + [JsonPropertyName("num")] public string num { get; set; } /// /// Gets or sets the average pay. /// /// The average pay. - [JsonProperty("avg_pay")] + [JsonPropertyName("avg_pay")] public string avg_pay { get; set; } /// /// Gets or sets the org. /// /// The org. - [JsonProperty("org")] + [JsonPropertyName("org")] public string org { get; set; } /// /// Gets or sets the org vat. /// /// The org vat. - [JsonProperty("org_vat")] + [JsonPropertyName("org_vat")] public string org_vat { get; set; } /// /// Gets or sets the org ext. /// /// The org ext. - [JsonProperty("org_ext")] + [JsonPropertyName("org_ext")] public string org_ext { get; set; } /// /// Gets or sets the org tot. /// /// The org tot. - [JsonProperty("org_tot")] + [JsonPropertyName("org_tot")] public string org_tot { get; set; } /// /// Gets or sets the CST. /// /// The CST. - [JsonProperty("cst")] + [JsonPropertyName("cst")] public string cst { get; set; } /// /// Gets or sets the pay. /// /// The pay. - [JsonProperty("pay")] + [JsonPropertyName("pay")] public string pay { get; set; } } @@ -225,7 +225,7 @@ public class Totals /// Gets or sets the sub data - which is oddly called "4" /// /// The 4. - [JsonProperty("4")] public Data _4 { get; set; } + [JsonPropertyName("4")] public Data _4 { get; set; } } /// @@ -237,7 +237,7 @@ public class Pagedata /// Gets or sets the colors. /// /// The colors. - [JsonProperty("pay")] public Colors colors { get; set; } + [JsonPropertyName("pay")] public Colors colors { get; set; } } /// @@ -249,182 +249,182 @@ public class Colors /// Gets or sets the color 1. /// /// The color 1. - [JsonProperty("COLOR_1")] public string COLOR_1 { get; set; } + [JsonPropertyName("COLOR_1")] public string COLOR_1 { get; set; } /// /// Gets or sets the color 2. /// /// The color 2. - [JsonProperty("COLOR_2")] public string COLOR_2 { get; set; } + [JsonPropertyName("COLOR_2")] public string COLOR_2 { get; set; } /// /// Gets or sets the color 3. /// /// The color 3. - [JsonProperty("COLOR_3")] public string COLOR_3 { get; set; } + [JsonPropertyName("COLOR_3")] public string COLOR_3 { get; set; } /// /// Gets or sets the color 4. /// /// The color 4. - [JsonProperty("COLOR_4")] public string COLOR_4 { get; set; } + [JsonPropertyName("COLOR_4")] public string COLOR_4 { get; set; } /// /// Gets or sets the color 5. /// /// The color 5. - [JsonProperty("COLOR_5")] public string COLOR_5 { get; set; } + [JsonPropertyName("COLOR_5")] public string COLOR_5 { get; set; } /// /// Gets or sets the color 6. /// /// The color 6. - [JsonProperty("COLOR_6")] public string COLOR_6 { get; set; } + [JsonPropertyName("COLOR_6")] public string COLOR_6 { get; set; } /// /// Gets or sets the color 7. /// /// The color 7. - [JsonProperty("COLOR_7")] public string COLOR_7 { get; set; } + [JsonPropertyName("COLOR_7")] public string COLOR_7 { get; set; } /// /// Gets or sets the color 8. /// /// The color 8. - [JsonProperty("COLOR_8")] public string COLOR_8 { get; set; } + [JsonPropertyName("COLOR_8")] public string COLOR_8 { get; set; } /// /// Gets or sets the color 9. /// /// The color 9. - [JsonProperty("COLOR_9")] public string COLOR_9 { get; set; } + [JsonPropertyName("COLOR_9")] public string COLOR_9 { get; set; } /// /// Gets or sets the color 10. /// /// The color 10. - [JsonProperty("COLOR_10")] public string COLOR_10 { get; set; } + [JsonPropertyName("COLOR_10")] public string COLOR_10 { get; set; } /// /// Gets or sets the color 11. /// /// The color 11. - [JsonProperty("COLOR_11")] public string COLOR_11 { get; set; } + [JsonPropertyName("COLOR_11")] public string COLOR_11 { get; set; } /// /// Gets or sets the color 12. /// /// The color 12. - [JsonProperty("COLOR_12")] public string COLOR_12 { get; set; } + [JsonPropertyName("COLOR_12")] public string COLOR_12 { get; set; } /// /// Gets or sets the color 13. /// /// The color 13. - [JsonProperty("COLOR_13")] public string COLOR_13 { get; set; } + [JsonPropertyName("COLOR_13")] public string COLOR_13 { get; set; } /// /// Gets or sets the color 14. /// /// The color 14. - [JsonProperty("COLOR_14")] public string COLOR_14 { get; set; } + [JsonPropertyName("COLOR_14")] public string COLOR_14 { get; set; } /// /// Gets or sets the color 15. /// /// The color 15. - [JsonProperty("COLOR_15")] public string COLOR_15 { get; set; } + [JsonPropertyName("COLOR_15")] public string COLOR_15 { get; set; } /// /// Gets or sets the color 16. /// /// The color 16. - [JsonProperty("COLOR_16")] public string COLOR_16 { get; set; } + [JsonPropertyName("COLOR_16")] public string COLOR_16 { get; set; } /// /// Gets or sets the color 17. /// /// The color 17. - [JsonProperty("COLOR_17")] public string COLOR_17 { get; set; } + [JsonPropertyName("COLOR_17")] public string COLOR_17 { get; set; } /// /// Gets or sets the color 18. /// /// The color 18. - [JsonProperty("COLOR_18")] public string COLOR_18 { get; set; } + [JsonPropertyName("COLOR_18")] public string COLOR_18 { get; set; } /// /// Gets or sets the color 19. /// /// The color 19. - [JsonProperty("COLOR_19")] public string COLOR_19 { get; set; } + [JsonPropertyName("COLOR_19")] public string COLOR_19 { get; set; } /// /// Gets or sets the color 20. /// /// The color 20. - [JsonProperty("COLOR_20")] public string COLOR_20 { get; set; } + [JsonPropertyName("COLOR_20")] public string COLOR_20 { get; set; } /// /// Gets or sets the color 21. /// /// The color 21. - [JsonProperty("COLOR_21")] public string COLOR_21 { get; set; } + [JsonPropertyName("COLOR_21")] public string COLOR_21 { get; set; } /// /// Gets or sets the color 22. /// /// The color 22. - [JsonProperty("COLOR_22")] public string COLOR_22 { get; set; } + [JsonPropertyName("COLOR_22")] public string COLOR_22 { get; set; } /// /// Gets or sets the color 23. /// /// The color 23. - [JsonProperty("COLOR_23")] public string COLOR_23 { get; set; } + [JsonPropertyName("COLOR_23")] public string COLOR_23 { get; set; } /// /// Gets or sets the color 24. /// /// The color 24. - [JsonProperty("COLOR_24")] public string COLOR_24 { get; set; } + [JsonPropertyName("COLOR_24")] public string COLOR_24 { get; set; } /// /// Gets or sets the color 25. /// /// The color 25. - [JsonProperty("COLOR_25")] public string COLOR_25 { get; set; } + [JsonPropertyName("COLOR_25")] public string COLOR_25 { get; set; } /// /// Gets or sets the color 26. /// /// The color 26. - [JsonProperty("COLOR_26")] public string COLOR_26 { get; set; } + [JsonPropertyName("COLOR_26")] public string COLOR_26 { get; set; } /// /// Gets or sets the color 27. /// /// The color 27. - [JsonProperty("COLOR_27")] public string COLOR_27 { get; set; } + [JsonPropertyName("COLOR_27")] public string COLOR_27 { get; set; } /// /// Gets or sets the color 28. /// /// The color 28. - [JsonProperty("COLOR_28")] public string COLOR_28 { get; set; } + [JsonPropertyName("COLOR_28")] public string COLOR_28 { get; set; } /// /// Gets or sets the color 29. /// /// The color 29. - [JsonProperty("COLOR_29")] public string COLOR_29 { get; set; } + [JsonPropertyName("COLOR_29")] public string COLOR_29 { get; set; } /// /// Gets or sets the color 30. /// /// The color 30. - [JsonProperty("COLOR_30")] public string COLOR_30 { get; set; } + [JsonPropertyName("COLOR_30")] public string COLOR_30 { get; set; } /// /// Gets or sets the color 31. /// /// The color 31. - [JsonProperty("COLOR_31")] public string COLOR_31 { get; set; } + [JsonPropertyName("COLOR_31")] public string COLOR_31 { get; set; } /// /// Gets or sets the color 32. /// /// The color 32. - [JsonProperty("COLOR_32")] public string COLOR_32 { get; set; } + [JsonPropertyName("COLOR_32")] public string COLOR_32 { get; set; } /// /// Gets or sets the color 33. /// /// The color 33. - [JsonProperty("COLOR_33")] public string COLOR_33 { get; set; } + [JsonPropertyName("COLOR_33")] public string COLOR_33 { get; set; } /// /// Gets or sets the color 34. /// /// The color 34. - [JsonProperty("COLOR_34")] public string COLOR_34 { get; set; } + [JsonPropertyName("COLOR_34")] public string COLOR_34 { get; set; } /// /// Gets or sets the color 35. /// /// The color 35. - [JsonProperty("COLOR_35")] public string COLOR_35 { get; set; } + [JsonPropertyName("COLOR_35")] public string COLOR_35 { get; set; } /// /// Gets or sets the color 36. /// /// The color 36. - [JsonProperty("COLOR_36")] public string COLOR_36 { get; set; } + [JsonPropertyName("COLOR_36")] public string COLOR_36 { get; set; } } /// @@ -436,21 +436,21 @@ public class StatsData /// Gets or sets the identifier. /// /// The identifier. - [JsonProperty("Id")] + [JsonPropertyName("Id")] public string Id { get; set; } /// /// Gets or sets the grouped by. /// /// The grouped by. - [JsonProperty("Label")] + [JsonPropertyName("Label")] public string GroupedBy { get; set; } /// /// Gets or sets the data. /// /// The data. - [JsonProperty("Data")] + [JsonPropertyName("Data")] public StatsLine[] Data { get; set; } } @@ -469,7 +469,7 @@ public class StatsLine /// Gets or sets the type. /// /// The type. - [JsonProperty("Label")] + [JsonPropertyName("Label")] public string Type { get; set; } /// @@ -488,70 +488,70 @@ public class Data /// Gets or sets the sum. /// /// The sum. - [JsonProperty("sum")] + [JsonPropertyName("sum")] public decimal sum { get; set; } /// /// Gets or sets the costs /// /// The CST. - [JsonProperty("cst")] + [JsonPropertyName("cst")] public decimal cst { get; set; } /// /// Gets or sets the number of transactions /// /// The number. - [JsonProperty("num")] + [JsonPropertyName("num")] public decimal num { get; set; } /// /// Gets or sets the average duration. Probably the average duration of seconds in a transaction. /// /// The average dur. - [JsonProperty("avg_dur")] + [JsonPropertyName("avg_dur")] public decimal avg_dur { get; set; } /// /// Gets or sets the average payout amount /// /// The average pay. - [JsonProperty("avg_pay")] + [JsonPropertyName("avg_pay")] public decimal avg_pay { get; set; } /// /// Gets or sets the paid costs. /// /// The pay. - [JsonProperty("pay")] + [JsonPropertyName("pay")] public decimal pay { get; set; } /// /// Gets or sets the organization total. Same as org_tot /// /// The org. - [JsonProperty("org")] + [JsonPropertyName("org")] public string org { get; set; } /// /// Gets or sets the org vat. /// /// The org vat. - [JsonProperty("org_vat")] + [JsonPropertyName("org_vat")] public string org_vat { get; set; } /// /// Gets or sets the org ext. /// /// The org ext. - [JsonProperty("org_ext")] + [JsonPropertyName("org_ext")] public string org_ext { get; set; } /// /// Gets or sets the org tot. /// /// The org tot. - [JsonProperty("org_tot")] + [JsonPropertyName("org_tot")] public decimal org_tot { get; set; } } } @@ -560,69 +560,64 @@ public class Data /// Class DecimalConverter. /// /// https://stackoverflow.com/q/24051206/97615 -/// +/// internal class DecimalConverter : JsonConverter { - /// - /// Determines whether this instance can convert the specified object type. - /// - /// Type of the object. - /// true if this instance can convert the specified object type; otherwise, false. - public override bool CanConvert(Type objectType) + public override bool CanConvert(Type typeToConvert) { - return objectType == typeof(decimal) || objectType == typeof(decimal?); + var targetType = Nullable.GetUnderlyingType(typeToConvert) ?? typeToConvert; + return targetType == typeof(decimal); } - /// - /// Reads the JSON representation of the object. - /// - /// The to read from. - /// Type of the object. - /// The existing value of object being read. - /// The calling serializer. - /// The object value. - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) + public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - var token = JToken.Load(reader); - switch (token.Type) + if (reader.TokenType == JsonTokenType.Null) { - case JTokenType.Float: - case JTokenType.Integer: - return token.ToObject(); - case JTokenType.String when decimal.TryParse( - token.ToString(), - NumberStyles.Any, - CultureInfo.InvariantCulture, - out var d): - return d; - case JTokenType.String: - case JTokenType.Null when objectType == typeof(decimal?): + if (Nullable.GetUnderlyingType(typeToConvert) != null) + { return null; - default: - throw new JsonSerializationException($"Unexpected token type: {token.Type}"); + } + + throw new JsonException("Cannot convert null to decimal."); } - } - /// - /// Writes the JSON representation of the object. - /// - /// The to write to. - /// The value. - /// The calling serializer. - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - var d = default(decimal?); - if (value != null) + if (reader.TokenType == JsonTokenType.Number) + { + return reader.GetDecimal(); + } + + if (reader.TokenType == JsonTokenType.String) { - d = value as decimal?; - if (d.HasValue) // If value was a decimal?, then this is possible + var raw = reader.GetString(); + if (string.IsNullOrWhiteSpace(raw)) { - d = new decimal( - decimal.ToDouble(d.Value)); // The ToDouble-conversion removes all unnecessary precision + return Nullable.GetUnderlyingType(typeToConvert) != null ? null : throw new JsonException("Cannot parse empty string to decimal."); } + + if (decimal.TryParse(raw, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) + { + return result; + } + + if (Nullable.GetUnderlyingType(typeToConvert) != null) + { + return null; + } + + throw new JsonException($"Unexpected value '{raw}' when parsing decimal."); + } + + throw new JsonException($"Unexpected token '{reader.TokenType}' when parsing decimal."); + } + + public override void Write(Utf8JsonWriter writer, object? value, JsonSerializerOptions options) + { + if (value == null) + { + writer.WriteNullValue(); + return; } - JToken.FromObject(d).WriteTo(writer); + writer.WriteNumberValue(Convert.ToDecimal(value, CultureInfo.InvariantCulture)); } } diff --git a/PAYNLSDK/API/Transaction/Approve/Request.cs b/PAYNLSDK/API/Transaction/Approve/Request.cs index ed32da7..bd09dc6 100644 --- a/PAYNLSDK/API/Transaction/Approve/Request.cs +++ b/PAYNLSDK/API/Transaction/Approve/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -13,14 +14,14 @@ public class Request : RequestBase /// /// /// - [JsonProperty("transactionId")] + [JsonPropertyName("transactionId")] public string TransactionId { get; set; } /// /// Entrance-code of transaction /// - [JsonProperty("entranceCode")] + [JsonPropertyName("entranceCode")] public string EntranceCode { get; set; } /// @@ -64,6 +65,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Transaction/Approve/Response.cs b/PAYNLSDK/API/Transaction/Approve/Response.cs index 72996ea..0361f9f 100644 --- a/PAYNLSDK/API/Transaction/Approve/Response.cs +++ b/PAYNLSDK/API/Transaction/Approve/Response.cs @@ -1,10 +1,11 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Transaction.Approve; public class Response : ResponseBase { - [JsonProperty("message")] + [JsonPropertyName("message")] public string Message { get; protected set; } } \ No newline at end of file diff --git a/PAYNLSDK/API/Transaction/Decline/Request.cs b/PAYNLSDK/API/Transaction/Decline/Request.cs index bad6e35..20075fc 100644 --- a/PAYNLSDK/API/Transaction/Decline/Request.cs +++ b/PAYNLSDK/API/Transaction/Decline/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -13,13 +14,13 @@ public class Request : RequestBase /// /// /// - [JsonProperty("transactionId")] + [JsonPropertyName("transactionId")] public string TransactionId { get; set; } /// /// not implemented /// - // [JsonProperty("entranceCode")] + // [JsonPropertyName("entranceCode")] // public string EntranceCode { get; set; } /* overrides */ @@ -65,6 +66,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Transaction/Decline/Response.cs b/PAYNLSDK/API/Transaction/Decline/Response.cs index dd0896d..e8a3f3c 100644 --- a/PAYNLSDK/API/Transaction/Decline/Response.cs +++ b/PAYNLSDK/API/Transaction/Decline/Response.cs @@ -1,9 +1,10 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Transaction.Decline; public class Response : ResponseBase { - [JsonProperty("message")] + [JsonPropertyName("message")] public string Message { get; protected set; } } diff --git a/PAYNLSDK/API/Transaction/GetLastTransactions/Request.cs b/PAYNLSDK/API/Transaction/GetLastTransactions/Request.cs index 310dea4..4cc8691 100644 --- a/PAYNLSDK/API/Transaction/GetLastTransactions/Request.cs +++ b/PAYNLSDK/API/Transaction/GetLastTransactions/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -7,13 +8,13 @@ namespace PayNLSdk.Api.Transaction.GetLastTransactions; public class Request : RequestBase { - [JsonProperty("merchantId")] + [JsonPropertyName("merchantId")] public string MerchantId { get; set; } - [JsonProperty("paid")] + [JsonPropertyName("paid")] public bool? Paid { get; set; } - [JsonProperty("limit")] + [JsonPropertyName("limit")] public int? Limit { get; set; } public override bool RequiresServiceId @@ -67,6 +68,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Transaction/GetLastTransactions/Response.cs b/PAYNLSDK/API/Transaction/GetLastTransactions/Response.cs index 91b8b94..dbd14c2 100644 --- a/PAYNLSDK/API/Transaction/GetLastTransactions/Response.cs +++ b/PAYNLSDK/API/Transaction/GetLastTransactions/Response.cs @@ -1,10 +1,11 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Objects; namespace PayNLSdk.Api.Transaction.GetLastTransactions; public class Response : ResponseBase { - [JsonProperty("arrStatsData")] + [JsonPropertyName("arrStatsData")] public TransactionStatsList TransactionStats { get; set; } } diff --git a/PAYNLSDK/API/Transaction/GetService/Request.cs b/PAYNLSDK/API/Transaction/GetService/Request.cs index a4fbf79..a04ced6 100644 --- a/PAYNLSDK/API/Transaction/GetService/Request.cs +++ b/PAYNLSDK/API/Transaction/GetService/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Enums; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; @@ -10,7 +11,7 @@ public class Request : RequestBase { public override bool RequiresServiceId => true; - [JsonProperty("paymentMethodId")] + [JsonPropertyName("paymentMethodId")] public PaymentMethodId? PaymentMethodId { get; set; } /// @@ -42,6 +43,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Transaction/GetService/Response.cs b/PAYNLSDK/API/Transaction/GetService/Response.cs index caed988..9bec6d3 100644 --- a/PAYNLSDK/API/Transaction/GetService/Response.cs +++ b/PAYNLSDK/API/Transaction/GetService/Response.cs @@ -1,16 +1,17 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Objects; namespace PayNLSdk.Api.Transaction.GetService; public class Response : ResponseBase { - [JsonProperty("merchant")] + [JsonPropertyName("merchant")] public Objects.Merchant Merchant { get; set; } - [JsonProperty("service")] + [JsonPropertyName("service")] public Objects.Service Service { get; set; } - [JsonProperty("countryOptionList")] + [JsonPropertyName("countryOptionList")] public CountryOptions CountryOptions { get; set; } } diff --git a/PAYNLSDK/API/Transaction/Info/Request.cs b/PAYNLSDK/API/Transaction/Info/Request.cs index 1cde020..4fe22be 100644 --- a/PAYNLSDK/API/Transaction/Info/Request.cs +++ b/PAYNLSDK/API/Transaction/Info/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -50,7 +51,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Transaction/Info/Response.cs b/PAYNLSDK/API/Transaction/Info/Response.cs index 47e75bb..18720ee 100644 --- a/PAYNLSDK/API/Transaction/Info/Response.cs +++ b/PAYNLSDK/API/Transaction/Info/Response.cs @@ -1,32 +1,33 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Objects; namespace PayNLSdk.Api.Transaction.Info; public class Response : ResponseBase { - [JsonProperty("connection")] + [JsonPropertyName("connection")] public Connection Connection { get; protected set; } - [JsonProperty("enduser")] + [JsonPropertyName("enduser")] public EndUser EndUser { get; protected set; } - //[JsonProperty("saledata")] + //[JsonPropertyName("saledata")] //public SalesData SalesData { get; protected set; } /// /// All details from the payment /// - [JsonProperty("paymentDetails")] + [JsonPropertyName("paymentDetails")] public PaymentDetails PaymentDetails { get; protected set; } /// /// Details regarding the refund (if any) /// - [JsonProperty("stornoDetails")] + [JsonPropertyName("stornoDetails")] public StornoDetails StornoDetails { get; protected set; } - [JsonProperty("statsDetails")] + [JsonPropertyName("statsDetails")] public StatsDetails StatsDetails { get; protected set; } } diff --git a/PAYNLSDK/API/Transaction/Refund/Request.cs b/PAYNLSDK/API/Transaction/Refund/Request.cs index a584f92..8a3d28f 100644 --- a/PAYNLSDK/API/Transaction/Refund/Request.cs +++ b/PAYNLSDK/API/Transaction/Refund/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; @@ -17,7 +18,7 @@ public class Request : RequestBase /// /// The order ID or EX code of the transaction. /// - [JsonProperty("transactionId")] + [JsonPropertyName("transactionId")] public string TransactionId { get; set; } /// @@ -25,20 +26,20 @@ public class Request : RequestBase /// For example € 3.50 becomes 350. /// If no amount is specified, the full amount is refunded and currency is not used. /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public decimal? Amount { get; set; } /// /// description to include with the payment. /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } /// /// The date on which the refund needs to be processed. Only works for IBAN refunds. /// /// Internal format should be dd-mm-yyyy(eg. 25-09-2016) - [JsonProperty("processDate"), JsonConverter(typeof(DMYConverter))] + [JsonPropertyName("processDate"), JsonConverter(typeof(DMYConverter))] public DateTime? ProcessDate { get; set; } /// @@ -84,13 +85,13 @@ public override NameValueCollection GetParameters() /// /// the vat percentage this refund applies to (AfterPay/Focum only) /// - [JsonProperty("vatPercentage")] + [JsonPropertyName("vatPercentage")] public decimal? VatPercentage { get; set; } /// /// Optional field. The currency in which the amount is specified. Standard in euro. /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Currency { get; set; } /// @@ -105,6 +106,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Transaction/Refund/Response.cs b/PAYNLSDK/API/Transaction/Refund/Response.cs index c5ff770..8e212e0 100644 --- a/PAYNLSDK/API/Transaction/Refund/Response.cs +++ b/PAYNLSDK/API/Transaction/Refund/Response.cs @@ -1,9 +1,10 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Transaction.Refund; public class Response : ResponseBase { - [JsonProperty("refundId")] + [JsonPropertyName("refundId")] public string RefundId { get; protected set; } } diff --git a/PAYNLSDK/API/Transaction/Start/Request.cs b/PAYNLSDK/API/Transaction/Start/Request.cs index cd6a67e..a2e95c5 100644 --- a/PAYNLSDK/API/Transaction/Start/Request.cs +++ b/PAYNLSDK/API/Transaction/Start/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Enums; using PayNLSdk.Exceptions; using PayNLSdk.Objects; @@ -421,7 +422,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); if (!Response.Request.Result) { // toss diff --git a/PAYNLSDK/API/Transaction/Start/Response.cs b/PAYNLSDK/API/Transaction/Start/Response.cs index 2155d5e..8890a57 100644 --- a/PAYNLSDK/API/Transaction/Start/Response.cs +++ b/PAYNLSDK/API/Transaction/Start/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Transaction.Start; @@ -7,12 +8,12 @@ public class Response : ResponseBase /// /// Information about the enduser /// - [JsonProperty("endUser")] + [JsonPropertyName("endUser")] public Enduser EndUser { get; set; } /// /// The for the started tranaction. Containing the url and transactionId /// - [JsonProperty("transaction")] + [JsonPropertyName("transaction")] public TransactionData Transaction { get; set; } public class Enduser @@ -22,10 +23,10 @@ public class Enduser public class TransactionData { - [JsonProperty("transactionId")] public string TransactionId { get; set; } - [JsonProperty("paymentURL")] public string PaymentUrl { get; set; } - [JsonProperty("popupAllowed")] public string PopupAllowed { get; set; } - [JsonProperty("paymentReference")] public string PaymentReference { get; set; } + [JsonPropertyName("transactionId")] public string TransactionId { get; set; } + [JsonPropertyName("paymentURL")] public string PaymentUrl { get; set; } + [JsonPropertyName("popupAllowed")] public string PopupAllowed { get; set; } + [JsonPropertyName("paymentReference")] public string PaymentReference { get; set; } } } diff --git a/PAYNLSDK/API/Validate/BankAccountNumber/Request.cs b/PAYNLSDK/API/Validate/BankAccountNumber/Request.cs index 3e7d1f5..cc4a6df 100644 --- a/PAYNLSDK/API/Validate/BankAccountNumber/Request.cs +++ b/PAYNLSDK/API/Validate/BankAccountNumber/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -13,7 +14,7 @@ public class Request : RequestBase /// /// The bank account number /// - [JsonProperty("bankAccountNumber")] + [JsonPropertyName("bankAccountNumber")] public string BankAccountNumber { get; set; } /// @@ -51,6 +52,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/BankAccountNumber/Response.cs b/PAYNLSDK/API/Validate/BankAccountNumber/Response.cs index ea58229..a16d234 100644 --- a/PAYNLSDK/API/Validate/BankAccountNumber/Response.cs +++ b/PAYNLSDK/API/Validate/BankAccountNumber/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using System.Diagnostics.CodeAnalysis; @@ -12,7 +13,7 @@ public class Response : ResponseBase /// /// the result from the bank account number validation /// - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] [SuppressMessage("ReSharper", "InconsistentNaming")] public bool result { get; protected set; } } diff --git a/PAYNLSDK/API/Validate/BankAccountNumberInternational/Request.cs b/PAYNLSDK/API/Validate/BankAccountNumberInternational/Request.cs index d752168..4158b04 100644 --- a/PAYNLSDK/API/Validate/BankAccountNumberInternational/Request.cs +++ b/PAYNLSDK/API/Validate/BankAccountNumberInternational/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -14,7 +15,7 @@ public class Request : RequestBase /// /// Bank account number /// - [JsonProperty("bankAccountNumber")] + [JsonPropertyName("bankAccountNumber")] public string BankAccountNumber { get; set; } /// @@ -51,6 +52,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/BankAccountNumberInternational/Response.cs b/PAYNLSDK/API/Validate/BankAccountNumberInternational/Response.cs index 7da7bb6..455e4fb 100644 --- a/PAYNLSDK/API/Validate/BankAccountNumberInternational/Response.cs +++ b/PAYNLSDK/API/Validate/BankAccountNumberInternational/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Api.Validate.BankAccountNumberInternational; @@ -11,6 +12,6 @@ public class Response : ResponseBase /// Gets or sets a value indicating whether this is succesful. /// /// true if succesful; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] public bool Result { get; protected set; } } \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/GetServerIps/Request.cs b/PAYNLSDK/API/Validate/GetServerIps/Request.cs index dddd192..c868e15 100644 --- a/PAYNLSDK/API/Validate/GetServerIps/Request.cs +++ b/PAYNLSDK/API/Validate/GetServerIps/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -41,7 +42,7 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - string[] ips = JsonConvert.DeserializeObject(RawResponse); + string[] ips = JsonSerialization.Deserialize(RawResponse); Response r = new Response { IPAddresses = ips diff --git a/PAYNLSDK/API/Validate/IBAN/Request.cs b/PAYNLSDK/API/Validate/IBAN/Request.cs index e01485b..624aa89 100644 --- a/PAYNLSDK/API/Validate/IBAN/Request.cs +++ b/PAYNLSDK/API/Validate/IBAN/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -18,7 +19,7 @@ public class Request : RequestBase /// Gets or sets the iban. /// /// The iban. - [JsonProperty("iban")] + [JsonPropertyName("iban")] [SuppressMessage("ReSharper", "InconsistentNaming")] public string IBAN { get; set; } @@ -58,6 +59,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/IBAN/Response.cs b/PAYNLSDK/API/Validate/IBAN/Response.cs index 7ea2073..209724e 100644 --- a/PAYNLSDK/API/Validate/IBAN/Response.cs +++ b/PAYNLSDK/API/Validate/IBAN/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Api.Validate.IBAN; @@ -14,6 +15,6 @@ public class Response : ResponseBase /// Gets or sets a value indicating whether this is succesful. /// /// true if succesful; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] public bool result { get; protected set; } } \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/IsPayServerIp/Request.cs b/PAYNLSDK/API/Validate/IsPayServerIp/Request.cs index 116b113..d4fc872 100644 --- a/PAYNLSDK/API/Validate/IsPayServerIp/Request.cs +++ b/PAYNLSDK/API/Validate/IsPayServerIp/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -17,7 +18,7 @@ public class Request : RequestBase /// Gets or sets the ip address. /// /// The ip address. - [JsonProperty("ipAddress")] + [JsonPropertyName("ipAddress")] public string IpAddress { get; set; } /// @@ -56,6 +57,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/IsPayServerIp/Response.cs b/PAYNLSDK/API/Validate/IsPayServerIp/Response.cs index 7e40776..e090e8f 100644 --- a/PAYNLSDK/API/Validate/IsPayServerIp/Response.cs +++ b/PAYNLSDK/API/Validate/IsPayServerIp/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Api.Validate.IsPayServerIp; @@ -14,6 +15,6 @@ public class Response : ResponseBase /// Gets or sets a value indicating whether this is succesful. /// /// true if succesful; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] public bool result { get; protected set; } } \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/KVK/Request.cs b/PAYNLSDK/API/Validate/KVK/Request.cs index 553a027..431bbe5 100644 --- a/PAYNLSDK/API/Validate/KVK/Request.cs +++ b/PAYNLSDK/API/Validate/KVK/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -18,7 +19,7 @@ public class Request : RequestBase /// Gets or sets the "kamer van koophandel" number. /// /// The KVK. - [JsonProperty("kvk")] + [JsonPropertyName("kvk")] [SuppressMessage("ReSharper", "InconsistentNaming")] public string KVK { get; set; } @@ -58,6 +59,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/KVK/Response.cs b/PAYNLSDK/API/Validate/KVK/Response.cs index eda489e..3544be3 100644 --- a/PAYNLSDK/API/Validate/KVK/Response.cs +++ b/PAYNLSDK/API/Validate/KVK/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Api.Validate.KVK; @@ -15,6 +16,6 @@ public class Response : ResponseBase /// Gets or sets a value indicating whether this is result. /// /// true if result; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] public bool result { get; protected set; } } diff --git a/PAYNLSDK/API/Validate/SOFI/Request.cs b/PAYNLSDK/API/Validate/SOFI/Request.cs index 0ad05da..077bfae 100644 --- a/PAYNLSDK/API/Validate/SOFI/Request.cs +++ b/PAYNLSDK/API/Validate/SOFI/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -7,7 +8,7 @@ namespace PayNLSdk.Api.Validate.SOFI; public class Request : RequestBase { - [JsonProperty("sofi")] + [JsonPropertyName("sofi")] public string SOFI { get; set; } public override bool RequiresApiToken @@ -47,6 +48,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/SOFI/Response.cs b/PAYNLSDK/API/Validate/SOFI/Response.cs index b24e22a..0108f12 100644 --- a/PAYNLSDK/API/Validate/SOFI/Response.cs +++ b/PAYNLSDK/API/Validate/SOFI/Response.cs @@ -1,10 +1,11 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Api.Validate.SOFI; public class Response : ResponseBase { - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] public bool result { get; protected set; } } diff --git a/PAYNLSDK/API/Validate/SWIFT/Request.cs b/PAYNLSDK/API/Validate/SWIFT/Request.cs index a3cc985..581c19e 100644 --- a/PAYNLSDK/API/Validate/SWIFT/Request.cs +++ b/PAYNLSDK/API/Validate/SWIFT/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -18,7 +19,7 @@ public class Request : RequestBase /// Gets or sets the SWIFT number. /// /// The swift. - [JsonProperty("swift")] + [JsonPropertyName("swift")] [SuppressMessage("ReSharper", "InconsistentNaming")] public string SWIFT { get; set; } @@ -58,6 +59,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } diff --git a/PAYNLSDK/API/Validate/SWIFT/Response.cs b/PAYNLSDK/API/Validate/SWIFT/Response.cs index 36ad2bb..3322ea5 100644 --- a/PAYNLSDK/API/Validate/SWIFT/Response.cs +++ b/PAYNLSDK/API/Validate/SWIFT/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Api.Validate.SWIFT; @@ -14,6 +15,6 @@ public class Response : ResponseBase /// Gets or sets a value indicating whether this is successful. /// /// true if successful; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] public bool result { get; protected set; } } \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/Util.cs b/PAYNLSDK/API/Validate/Util.cs index 68093f8..c6fc814 100644 --- a/PAYNLSDK/API/Validate/Util.cs +++ b/PAYNLSDK/API/Validate/Util.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Net; namespace PayNLSdk.Api.Validate; diff --git a/PAYNLSDK/API/Validate/VAT/Request.cs b/PAYNLSDK/API/Validate/VAT/Request.cs index 05f36b7..eb46e4c 100644 --- a/PAYNLSDK/API/Validate/VAT/Request.cs +++ b/PAYNLSDK/API/Validate/VAT/Request.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Exceptions; using PayNLSdk.Utilities; using System.Collections.Specialized; @@ -18,7 +19,7 @@ public class Request : RequestBase /// Gets or sets the vat. /// /// The vat. - [JsonProperty("vat")] + [JsonPropertyName("vat")] [SuppressMessage("ReSharper", "InconsistentNaming")] public string VAT { get; set; } @@ -58,6 +59,6 @@ protected override void PrepareAndSetResponse() { throw new PayNlException("rawResponse is empty!"); } - response = JsonConvert.DeserializeObject(RawResponse); + response = JsonSerialization.Deserialize(RawResponse); } } \ No newline at end of file diff --git a/PAYNLSDK/API/Validate/VAT/Response.cs b/PAYNLSDK/API/Validate/VAT/Response.cs index 09861ed..5f95170 100644 --- a/PAYNLSDK/API/Validate/VAT/Response.cs +++ b/PAYNLSDK/API/Validate/VAT/Response.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Api.Validate.VAT; @@ -14,6 +15,6 @@ public class Response : ResponseBase /// Gets or sets a value indicating whether this is succesful. /// /// true if succesful; otherwise, false. - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] public bool result { get; protected set; } } diff --git a/PAYNLSDK/Alliance.cs b/PAYNLSDK/Alliance.cs index 66ce4e2..3537d9a 100644 --- a/PAYNLSDK/Alliance.cs +++ b/PAYNLSDK/Alliance.cs @@ -5,6 +5,7 @@ using PayNLSdk.Net; using System.Diagnostics.CodeAnalysis; using Request = PayNLSdk.Api.Alliance.GetMerchant.Request; +using PayNLSdk.Utilities; namespace PayNLSdk; @@ -29,27 +30,27 @@ public Alliance(IClient webClient) public GetMerchantResult GetMerchant(Request request) { var response = _webClient.PerformRequest(request); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); + return JsonSerialization.Deserialize(response); } /// public AddMerchantResult AddMerchant(Api.Alliance.AddMerchant.Request request) { var response = _webClient.PerformRequest(request); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); + return JsonSerialization.Deserialize(response); } /// public AddServiceResult AddService(Api.Alliance.AddService.Request request) { var response = _webClient.PerformRequest(request); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); + return JsonSerialization.Deserialize(response); } /// public AddInvoiceResult AddInvoice(Api.Alliance.AddInvoice.Request request) { var response = _webClient.PerformRequest(request); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); + return JsonSerialization.Deserialize(response); } } \ No newline at end of file diff --git a/PAYNLSDK/Api/Transaction/Enduser.cs b/PAYNLSDK/Api/Transaction/Enduser.cs index e24c67e..4dd0478 100644 --- a/PAYNLSDK/Api/Transaction/Enduser.cs +++ b/PAYNLSDK/Api/Transaction/Enduser.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Api.Transaction.Info; using PayNLSdk.Converters; using PayNLSdk.Enums; @@ -13,119 +14,119 @@ namespace PayNLSdk.Api.Transaction; public class EndUser { // @DISABLED@ - //[JsonProperty("accessCode")] + //[JsonPropertyName("accessCode")] //public string AccessCode { get; set; } /// /// Unique reference of customer /// - [JsonProperty("customerReference")] + [JsonPropertyName("customerReference")] public string CustomerReference { get; set; } /// /// End User's Language /// - [JsonProperty("language")] + [JsonPropertyName("language")] public string Language { get; set; } /// /// End User's Initials /// - [JsonProperty("initials")] + [JsonPropertyName("initials")] public string Initials { get; set; } /// /// End User's Gender /// - [JsonProperty("gender"), JsonConverter(typeof(GenderConverter))] + [JsonPropertyName("gender"), JsonConverter(typeof(GenderConverter))] public Gender? Gender { get; set; } /// /// End User's Last Name /// - [JsonProperty("lastName")] + [JsonPropertyName("lastName")] public string Lastname { get; set; } /// /// End User's Date of Birth /// - [JsonProperty("dob"), JsonConverter(typeof(DMYConverter))] + [JsonPropertyName("dob"), JsonConverter(typeof(DMYConverter))] public DateTime? BirthDate { get; set; } /// /// End User's Phone Number /// - [JsonProperty("phoneNumber")] + [JsonPropertyName("phoneNumber")] public string PhoneNumber { get; set; } /// /// End User's Email Address /// - [JsonProperty("emailAddress")] + [JsonPropertyName("emailAddress")] public string EmailAddress { get; set; } /// /// End User's Bank Account Number. /// Note in most cases the IBAN will be used. /// - [JsonProperty("bankAccount")] + [JsonPropertyName("bankAccount")] public string BankAccount { get; set; } /// /// End User's IBAN /// - [JsonProperty("iban")] + [JsonPropertyName("iban")] public string IBAN { get; set; } /// /// End User's BIC /// - [JsonProperty("bic")] + [JsonPropertyName("bic")] public string BIC { get; set; } - [JsonProperty("sendConfirmMail")] + [JsonPropertyName("sendConfirmMail")] public bool? SendConfirmMail { get; set; } - //[JsonProperty("confirmMailTemplate")] + //[JsonPropertyName("confirmMailTemplate")] //public string ConfirmMailTemplate { get; set; } /// /// End User's Address /// - [JsonProperty("address")] + [JsonPropertyName("address")] public Address Address { get; set; } /// /// End User's Invoice Address /// - [JsonProperty("invoiceAddress")] + [JsonPropertyName("invoiceAddress")] public Address InvoiceAddress { get; set; } - //[JsonProperty("saleData")] + //[JsonPropertyName("saleData")] //public SaleData? SalesData { get; protected set; } /// /// End User's Payment Details /// - [JsonProperty("paymentDetails")] + [JsonPropertyName("paymentDetails")] public PaymentDetails PaymentDetails { get; set; } /// /// End User's Storno Details if applicable /// - [JsonProperty("stornoDetails")] + [JsonPropertyName("stornoDetails")] public StornoDetails StornoDetails { get; set; } /// /// End User's Stats Details if applicable /// - [JsonProperty("statsDetails")] + [JsonPropertyName("statsDetails")] public StatsDetails StatsDetails { get; set; } /// /// Company information of the EndUser /// - [JsonProperty("company")] + [JsonPropertyName("company")] public Company Company { get; set; } } diff --git a/PAYNLSDK/Api/Transaction/Info/StornoDetails.cs b/PAYNLSDK/Api/Transaction/Info/StornoDetails.cs index 19e5221..df63e59 100644 --- a/PAYNLSDK/Api/Transaction/Info/StornoDetails.cs +++ b/PAYNLSDK/Api/Transaction/Info/StornoDetails.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Transaction.Info; @@ -10,55 +11,55 @@ public class StornoDetails /// /// ID of the refund /// - [JsonProperty("stornoId")] + [JsonPropertyName("stornoId")] public int? StornoId { get; protected set; } /// /// Refund amount /// - [JsonProperty("stornoAmount")] + [JsonPropertyName("stornoAmount")] public int? StornoAmount { get; protected set; } /// /// Number of the bankaccount the refund is deposited to /// - [JsonProperty("bankAccount")] + [JsonPropertyName("bankAccount")] public string BankAccount { get; protected set; } /// /// IBAN of the bankaccount the refund is deposited to /// - [JsonProperty("iban")] + [JsonPropertyName("iban")] public string IBAN { get; protected set; } /// /// BIC of the bankaccount the refund is deposited to /// - [JsonProperty("bic")] + [JsonPropertyName("bic")] public string bic { get; protected set; } /// /// City of the bankaccount owner /// - [JsonProperty("city")] + [JsonPropertyName("city")] public string City { get; protected set; } /// /// Date and time the payment is refunded /// - [JsonProperty("datetime")] + [JsonPropertyName("datetime")] public string Date { get; protected set; } /// /// Reason of the refund /// - [JsonProperty("reason")] + [JsonPropertyName("reason")] public string Reason { get; protected set; } /// /// The email address the refund confirmation is sent to /// - [JsonProperty("emailAdress")] + [JsonPropertyName("emailAdress")] public string EmailAddress { get; protected set; } } diff --git a/PAYNLSDK/Api/Transaction/Start/TransactionData.cs b/PAYNLSDK/Api/Transaction/Start/TransactionData.cs index 1cd42ba..c0f1ec6 100644 --- a/PAYNLSDK/Api/Transaction/Start/TransactionData.cs +++ b/PAYNLSDK/Api/Transaction/Start/TransactionData.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using System; @@ -12,59 +13,59 @@ public class TransactionData /// /// The currency of the transaction. If omitted, EUR is used. /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Currency { get; set; } /// /// Cost for VAT /// - [JsonProperty("costsVat")] + [JsonPropertyName("costsVat")] public int? CostsVat { get; set; } // No documentation is available to implement this - //[JsonProperty("excludeCosts")] + //[JsonPropertyName("excludeCosts")] //public Array ExcludeCosts { get; set; } /// /// The URL of the exchange file that needs to be called /// - [JsonProperty("orderExchangeUrl")] + [JsonPropertyName("orderExchangeUrl")] public string OrderExchangeUrl { get; set; } /// /// Description belonging to the order /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } /// /// Expire date of the transaction /// - [JsonProperty("expireDate")] + [JsonPropertyName("expireDate")] public DateTime? ExpireDate { get; set; } /// /// The number belonging to the order /// - [JsonProperty("orderNumber")] + [JsonPropertyName("orderNumber")] public string OrderNumber { get; set; } /// /// Unique id of the enduser /// - [JsonProperty("enduserId")] + [JsonPropertyName("enduserId")] public int? EnduserId { get; set; } /// /// Whether to sent a confimation email /// - [JsonProperty("sendReminderEmail"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("sendReminderEmail"), JsonConverter(typeof(BooleanConverter))] public bool SendReminderEmail { get; set; } /// /// The id of mailtemplate in case a confirmation mail needs to be sent /// - [JsonProperty("reminderMailTemplateId")] + [JsonPropertyName("reminderMailTemplateId")] public int? ReminderMailTemplateId { get; set; } diff --git a/PAYNLSDK/Api/Transaction/StatsDetails.cs b/PAYNLSDK/Api/Transaction/StatsDetails.cs index 233cc20..f8e3966 100644 --- a/PAYNLSDK/Api/Transaction/StatsDetails.cs +++ b/PAYNLSDK/Api/Transaction/StatsDetails.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Api.Transaction; @@ -11,52 +12,52 @@ public class StatsDetails /// /// ID for the Payment session these details belong to /// - [JsonProperty("paymentSessionId")] + [JsonPropertyName("paymentSessionId")] public long PaymentSessionId { get; set; } /// /// The used tool code which can be tracked in the stats /// - [JsonProperty("tool")] + [JsonPropertyName("tool")] public string Tool { get; set; } /// /// The used info code which can be tracked in the stats /// - [JsonProperty("info")] + [JsonPropertyName("info")] public string Info { get; set; } /// /// The id of a promotor / affiliate. /// In general, you won't use this unless you know the ID's of your affiliate's /// - [JsonProperty("promotorId")] + [JsonPropertyName("promotorId")] public int? PromotorId { get; set; } /// /// The first free value which can be tracked in the stats /// - [JsonProperty("extra1")] + [JsonPropertyName("extra1")] public string Extra1 { get; set; } /// /// The second free value which can be tracked in the stats /// - [JsonProperty("extra2")] + [JsonPropertyName("extra2")] public string Extra2 { get; set; } /// /// The third free value which can be tracked in the stats /// - [JsonProperty("extra3")] + [JsonPropertyName("extra3")] public string Extra3 { get; set; } /// /// Option to send multiple values via an array which can be tracked in the stats /// - [JsonProperty("transferData")] + [JsonPropertyName("transferData")] public string[] TransferData { get; set; } - [JsonProperty("object")] + [JsonPropertyName("object")] public object Object { get; set; } } diff --git a/PAYNLSDK/Api/Validate/Util.cs.orig b/PAYNLSDK/Api/Validate/Util.cs.orig deleted file mode 100644 index b48f2f2..0000000 --- a/PAYNLSDK/Api/Validate/Util.cs.orig +++ /dev/null @@ -1,171 +0,0 @@ -using Newtonsoft.Json; -using PayNLSdk.Net; -using System; -using System.Diagnostics.Contracts; - -namespace PayNLSdk.API.Validate -{ - /// -<<<<<<< HEAD - /// Utility methods which you can use to validate your input data -======= - /// Internal utilities ->>>>>>> origin/main - /// - public class Util - { - private readonly IClient _client; - - private JsonSerializerSettings serializerSettings; - - /// - /// settings for the JSON serializer - /// - public JsonSerializerSettings SerializerSettings - { - get - { - if (serializerSettings != null) - { - return serializerSettings; - } - - serializerSettings = new JsonSerializerSettings - { - NullValueHandling = NullValueHandling.Ignore - }; - return serializerSettings; - } - set => serializerSettings = value; - } - - /// - /// Creates a new instance from the Utility class - /// - /// - public Util(IClient client) : this(client, null) - { - } - - /// - /// Creates a new instance from the Utility class - /// - /// - /// - public Util(IClient client, JsonSerializerSettings serializerSettings) - { - _client = client; - SerializerSettings = serializerSettings; - } - - /// - /// use the payNl service to validate the ipaddress which called you - /// - /// an input string - /// true if it matches - public bool ValidatePayIP(string ipAddress) - { - IsPayServerIp.Request request = new IsPayServerIp.Request(); - request.IpAddress = ipAddress; - _client.PerformRequest(request); - return request.Response.result; - } - - /// - /// use the payNl service to validate the bank account - /// - /// an input string - /// true if it is an international number - /// true if it matches - public bool ValidateBankAccountNumber(string bankAccountNumber, bool international) - { - if (international) - { - BankAccountNumberInternational.Request request = new BankAccountNumberInternational.Request(); - request.BankAccountNumber = bankAccountNumber; - _client.PerformRequest(request); - return request.Response.Result; - } - else - { - BankAccountNumber.Request request = new BankAccountNumber.Request(); - request.BankAccountNumber = bankAccountNumber; - _client.PerformRequest(request); - return request.Response.result; - } - } - - /// -<<<<<<< HEAD - /// use the payNl service to validate the IBAN number - /// - /// an input string - /// true if it matches -======= - /// Validates an iban number - /// - /// - /// ->>>>>>> origin/main - public bool ValidateIBAN(string iban) - { - IBAN.Request request = new IBAN.Request(); - request.IBAN = iban; - _client.PerformRequest(request); - return request.Response.result; - } - - /// - /// use the payNl service to validate the SWIFT number - /// - /// an input string - /// true if it matches - public bool ValidateSWIFT(string swift) - { - SWIFT.Request request = new SWIFT.Request(); - request.SWIFT = swift; - _client.PerformRequest(request); - return request.Response.result; - } - - /// - /// use the payNl service to validate the KVK number - /// - /// an input string - /// true if it matches - public bool ValidateKVK(string kvk) - { - KVK.Request request = new KVK.Request(); - request.KVK = kvk; - _client.PerformRequest(request); - return request.Response.result; - } - - /// - /// use the payNl service to validate the VAT number - /// - /// an input string - /// true if it matches - public bool ValidateVAT(string vat) - { - VAT.Request request = new VAT.Request(); - request.VAT = vat; - _client.PerformRequest(request); - return request.Response.result; - } - - /// - /// use the payNl service to validate the SOFI number - /// - /// an input string - /// true if it matches - public bool ValidateSOFI(string sofi) - { - SOFI.Request request = new SOFI.Request(); - request.SOFI = sofi; - _client.PerformRequest(request); - return request.Response.result; - } - - } -} diff --git a/PAYNLSDK/Converters/BooleanConverter.cs b/PAYNLSDK/Converters/BooleanConverter.cs index 2f2621a..2d54dce 100644 --- a/PAYNLSDK/Converters/BooleanConverter.cs +++ b/PAYNLSDK/Converters/BooleanConverter.cs @@ -1,35 +1,73 @@ -using Newtonsoft.Json; using System; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Converters; /// -/// A boolean json converter for newtonsoft +/// A boolean json converter for System.Text.Json that supports numeric and string payloads. /// internal class BooleanConverter : JsonConverter { - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override bool CanConvert(Type typeToConvert) { - try + var targetType = Nullable.GetUnderlyingType(typeToConvert) ?? typeToConvert; + return targetType == typeof(bool); + } + + public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + bool? value = reader.TokenType switch + { + JsonTokenType.True => true, + JsonTokenType.False => false, + JsonTokenType.Number => reader.GetDouble() != 0d, + JsonTokenType.String => ParseString(reader.GetString()), + JsonTokenType.Null => null, + _ => throw new JsonException($"Unexpected token '{reader.TokenType}' when parsing boolean.") + }; + + if (Nullable.GetUnderlyingType(typeToConvert) != null) { - var result = serializer.Deserialize(reader); - return (result == 1); + return value; } - catch (Exception) + + if (!value.HasValue) { - return Boolean.Parse(serializer.Deserialize(reader)); + throw new JsonException("Cannot convert null to non-nullable boolean."); } + + return value.Value; } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void Write(Utf8JsonWriter writer, object? value, JsonSerializerOptions options) { - bool result = Convert.ToBoolean(value); - writer.WriteValue(result); - return; + if (value == null) + { + writer.WriteNullValue(); + return; + } + + writer.WriteBooleanValue(Convert.ToBoolean(value)); } - public override bool CanConvert(Type objectType) + private static bool? ParseString(string? value) { - return typeof(Boolean).IsAssignableFrom(objectType); + if (string.IsNullOrWhiteSpace(value)) + { + return null; + } + + if (bool.TryParse(value, out var boolResult)) + { + return boolResult; + } + + if (int.TryParse(value, out var intResult)) + { + return intResult != 0; + } + + throw new JsonException($"Unexpected value '{value}' when parsing boolean."); } -} \ No newline at end of file +} diff --git a/PAYNLSDK/Converters/CountryOptionConverter.cs b/PAYNLSDK/Converters/CountryOptionConverter.cs index ecd4a0f..4796086 100644 --- a/PAYNLSDK/Converters/CountryOptionConverter.cs +++ b/PAYNLSDK/Converters/CountryOptionConverter.cs @@ -1,30 +1,48 @@ -using Newtonsoft.Json; -using PayNLSdk.Objects; using System; using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; +using PayNLSdk.Objects; namespace PayNLSdk.Converters; internal class CountryOptionConverter : JsonConverter { - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override bool CanConvert(Type typeToConvert) + { + return typeof(CountryOptions).IsAssignableFrom(typeToConvert); + } + + public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if (reader.TokenType == JsonToken.StartObject) + if (reader.TokenType != JsonTokenType.StartObject) { - var dict = serializer.Deserialize>(reader); - return dict; + throw new JsonException($"Unexpected token '{reader.TokenType}' when parsing country options."); } - throw new JsonSerializationException(String.Format("Unexpected token '{0}' when parsing country options.", reader.TokenType)); - } + var data = JsonSerializer.Deserialize>(ref reader, options); + if (data == null) + { + return new CountryOptions(); + } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - //throw new NotImplementedException(); + var result = new CountryOptions(); + foreach (var pair in data) + { + result[pair.Key] = pair.Value; + } + + return result; } - public override bool CanConvert(Type objectType) + public override void Write(Utf8JsonWriter writer, object? value, JsonSerializerOptions options) { - return typeof(CountryOptions).IsAssignableFrom(objectType); + if (value is CountryOptions countryOptions) + { + JsonSerializer.Serialize(writer, new Dictionary(countryOptions), options); + return; + } + + writer.WriteNullValue(); } } diff --git a/PAYNLSDK/Converters/DMYConverter.cs b/PAYNLSDK/Converters/DMYConverter.cs index 05893d0..b9d8594 100644 --- a/PAYNLSDK/Converters/DMYConverter.cs +++ b/PAYNLSDK/Converters/DMYConverter.cs @@ -1,80 +1,86 @@ -using Newtonsoft.Json; -using PayNLSdk.Utilities; using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; +using PayNLSdk.Utilities; namespace PayNLSdk.Converters; internal class DMYConverter : JsonConverter { private const string Format = "dd-MM-yyyy"; - private static readonly string[] ParseFormats = { - // - argument. + private static readonly string[] ParseFormats = + { "d-M-yyyy", "dd-MM-yyyy", - // Slash argument. "d/M/yyyy", "dd/MM/yyyy" }; - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + + public override bool CanConvert(Type typeToConvert) + { + var targetType = Nullable.GetUnderlyingType(typeToConvert) ?? typeToConvert; + return targetType == typeof(DateTime); + } + + public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if (!(value is DateTime dateTime)) + if (reader.TokenType == JsonTokenType.Null) { - throw new JsonSerializationException("Expected value of type 'DateTime'."); + if (Nullable.GetUnderlyingType(typeToConvert) != null) + { + return null; + } + + throw new JsonException("Cannot convert null to DateTime."); } - if (dateTime.Kind == DateTimeKind.Unspecified) + if (reader.TokenType == JsonTokenType.String) { - throw new JsonSerializationException("Cannot convert date time with an unspecified kind"); + if (reader.TryGetDateTime(out var parsed)) + { + EnsureSpecified(parsed); + return parsed; + } + + var raw = reader.GetString(); + if (ParameterValidator.IsEmpty(raw)) + { + return null; + } + + if (DateTime.TryParseExact(raw, ParseFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTime)) + { + return dateTime; + } + + return null; } - var convertedDateTime = dateTime.ToString(Format); - writer.WriteValue(convertedDateTime); + + throw new JsonException($"Unexpected token '{reader.TokenType}' when parsing date."); } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override void Write(Utf8JsonWriter writer, object? value, JsonSerializerOptions options) { - switch (reader.TokenType) + if (value == null) { - case JsonToken.Null: - return null; - case JsonToken.Date: - { - var dateTime = (DateTime)reader.Value; - if (dateTime.Kind == DateTimeKind.Unspecified) - { - throw new JsonSerializationException("Parsed date time is not in the expected RFC3339 format"); - } - return dateTime; - } - case JsonToken.String: - { - DateTime dateTime; - /*string[] formats = { "d/M/yyyy", "dd/MM/yyyy", "d-M-yyyy", "dd-MM-yyyy" };*/ - string timeString = (string)reader.Value; - if (!ParameterValidator.IsEmpty(timeString)) - { - if (DateTime.TryParseExact(timeString, ParseFormats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime)) - { - // Gelukt we kunnen doorgaan - return dateTime; - } - else - { - // De opgegeven timeString is niet juist. - return null; - } + writer.WriteNullValue(); + return; + } - } - return null; - } - default: - throw new JsonSerializationException($"Unexpected token '{reader.TokenType}' when parsing date."); + if (value is DateTime dateTime) + { + EnsureSpecified(dateTime); + writer.WriteStringValue(dateTime.ToString(Format, CultureInfo.InvariantCulture)); + return; } + + throw new JsonException("Expected value of type 'DateTime'."); } - public override bool CanConvert(Type objectType) + private static void EnsureSpecified(DateTime dateTime) { - Type t = (Reflection.IsNullable(objectType)) - ? Nullable.GetUnderlyingType(objectType) - : objectType; - - return t == typeof(DateTime); + if (dateTime.Kind == DateTimeKind.Unspecified) + { + throw new JsonException("Cannot convert date time with an unspecified kind"); + } } } diff --git a/PAYNLSDK/Converters/EnumConversionBase.cs b/PAYNLSDK/Converters/EnumConversionBase.cs index 889c5f6..195b805 100644 --- a/PAYNLSDK/Converters/EnumConversionBase.cs +++ b/PAYNLSDK/Converters/EnumConversionBase.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json; using System; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Converters; @@ -7,14 +8,46 @@ internal abstract class EnumConversionBase : JsonConverter { public abstract Type EnumType { get; } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override bool CanConvert(Type typeToConvert) { - return Enums.EnumUtil.ToEnum(serializer.Deserialize(reader), EnumType); + var targetType = Nullable.GetUnderlyingType(typeToConvert) ?? typeToConvert; + return EnumType == targetType; } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - string result = Enums.EnumUtil.ToEnumString(value, EnumType); - writer.WriteValue(result); + if (reader.TokenType == JsonTokenType.Null) + { + if (Nullable.GetUnderlyingType(typeToConvert) != null) + { + return null; + } + + throw new JsonException("Cannot convert null to enum."); + } + + if (reader.TokenType != JsonTokenType.String) + { + throw new JsonException($"Unexpected token '{reader.TokenType}' when parsing enum."); + } + + var value = reader.GetString(); + if (string.IsNullOrEmpty(value)) + { + return Nullable.GetUnderlyingType(typeToConvert) != null ? null : Activator.CreateInstance(EnumType); + } + + return Enums.EnumUtil.ToEnum(value, EnumType); + } + + public override void Write(Utf8JsonWriter writer, object? value, JsonSerializerOptions options) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStringValue(Enums.EnumUtil.ToEnumString(value, EnumType)); } } diff --git a/PAYNLSDK/Converters/ErrorIdConverter.cs b/PAYNLSDK/Converters/ErrorIdConverter.cs index 5b52c9d..3d5652d 100644 --- a/PAYNLSDK/Converters/ErrorIdConverter.cs +++ b/PAYNLSDK/Converters/ErrorIdConverter.cs @@ -1,43 +1,61 @@ -using Newtonsoft.Json; using System; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Converters; internal class ErrorIdConverter : JsonConverter { - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override bool CanConvert(Type typeToConvert) { - string result = serializer.Deserialize(reader); - if (result == String.Empty) + var targetType = Nullable.GetUnderlyingType(typeToConvert) ?? typeToConvert; + return targetType == typeof(int); + } + + public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType == JsonTokenType.Null) { - return 0; + if (Nullable.GetUnderlyingType(typeToConvert) != null) + { + return null; + } + + throw new JsonException("Cannot convert null to Int32."); } - try + + if (reader.TokenType == JsonTokenType.Number) { - return Int32.Parse(result); + return reader.GetInt32(); } - catch (Exception e) + + if (reader.TokenType == JsonTokenType.String) { - throw new JsonSerializationException(String.Format("Unexpected conversion '{0}' when parsing errorId.", result), e); + var value = reader.GetString(); + if (string.IsNullOrEmpty(value)) + { + return 0; + } + + if (int.TryParse(value, out var parsed)) + { + return parsed; + } + + throw new JsonException($"Unexpected conversion '{value}' when parsing errorId."); } + + throw new JsonException($"Unexpected token '{reader.TokenType}' when parsing errorId."); } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void Write(Utf8JsonWriter writer, object? value, JsonSerializerOptions options) { if (value == null) { - writer.WriteNull(); + writer.WriteNullValue(); return; } - //if (CanConvert(value.GetType())) - //{ - serializer.Serialize(writer, value); - //} - //throw new JsonSerializationException(String.Format("Can't serialize type {0} to Integer.", value.GetType())); - } - public override bool CanConvert(Type objectType) - { - return typeof(int).IsAssignableFrom(objectType); + writer.WriteNumberValue(Convert.ToInt32(value)); } -} \ No newline at end of file +} diff --git a/PAYNLSDK/Converters/GenderConverter.cs b/PAYNLSDK/Converters/GenderConverter.cs index eb22ba0..b6fa81f 100644 --- a/PAYNLSDK/Converters/GenderConverter.cs +++ b/PAYNLSDK/Converters/GenderConverter.cs @@ -1,16 +1,8 @@ -using System; +using System; namespace PayNLSdk.Converters; internal class GenderConverter : EnumConversionBase { - public override Type EnumType - { - get { return typeof(Enums.Gender); } - } - - public override bool CanConvert(Type objectType) - { - throw new NotImplementedException(); - } + public override Type EnumType => typeof(Enums.Gender); } diff --git a/PAYNLSDK/Converters/ProductTypeConverter.cs b/PAYNLSDK/Converters/ProductTypeConverter.cs index 2b35e58..fbe6ce9 100644 --- a/PAYNLSDK/Converters/ProductTypeConverter.cs +++ b/PAYNLSDK/Converters/ProductTypeConverter.cs @@ -1,13 +1,8 @@ -using System; +using System; namespace PayNLSdk.Converters; internal class ProductTypeConverter : EnumConversionBase { public override Type EnumType => typeof(Enums.ProductType); - - public override bool CanConvert(Type objectType) - { - throw new NotImplementedException(); - } } diff --git a/PAYNLSDK/Converters/TaxClassConverter.cs b/PAYNLSDK/Converters/TaxClassConverter.cs index 87bbdeb..edb8783 100644 --- a/PAYNLSDK/Converters/TaxClassConverter.cs +++ b/PAYNLSDK/Converters/TaxClassConverter.cs @@ -1,16 +1,8 @@ -using System; +using System; namespace PayNLSdk.Converters; internal class TaxClassConverter : EnumConversionBase { - public override Type EnumType - { - get { return typeof(Enums.TaxClass); } - } - - public override bool CanConvert(Type objectType) - { - throw new NotImplementedException(); - } + public override Type EnumType => typeof(Enums.TaxClass); } diff --git a/PAYNLSDK/Converters/YMDConverter.cs b/PAYNLSDK/Converters/YMDConverter.cs index dbc5f2d..0cf7e82 100644 --- a/PAYNLSDK/Converters/YMDConverter.cs +++ b/PAYNLSDK/Converters/YMDConverter.cs @@ -1,83 +1,86 @@ -using Newtonsoft.Json; -using PayNLSdk.Utilities; using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; +using PayNLSdk.Utilities; namespace PayNLSdk.Converters; internal class YMDConverter : JsonConverter { private const string Format = "yyyy-MM-dd"; - private static string[] ParseFormats = { - // - argument. + private static readonly string[] ParseFormats = + { "yyyy-M-d", "yyyy-MM-dd", - // Slash argument. "yyyy/M/d", "yyyy/MM/dd" }; - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + + public override bool CanConvert(Type typeToConvert) { - if (value is DateTime) - { - var dateTime = (DateTime)value; - if (dateTime.Kind == DateTimeKind.Unspecified) - { - throw new JsonSerializationException("Cannot convert date time with an unspecified kind"); - } - string convertedDateTime = dateTime.ToString(Format); - writer.WriteValue(convertedDateTime); - } - else - { - throw new JsonSerializationException("Expected value of type 'DateTime'."); - } + var targetType = Nullable.GetUnderlyingType(typeToConvert) ?? typeToConvert; + return targetType == typeof(DateTime); } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if (reader.TokenType == JsonToken.Null) + if (reader.TokenType == JsonTokenType.Null) { - return null; + if (Nullable.GetUnderlyingType(typeToConvert) != null) + { + return null; + } + + throw new JsonException("Cannot convert null to DateTime."); } - if (reader.TokenType == JsonToken.Date) + if (reader.TokenType == JsonTokenType.String) { - var dateTime = (DateTime)reader.Value; - if (dateTime.Kind == DateTimeKind.Unspecified) + if (reader.TryGetDateTime(out var parsed)) { - throw new JsonSerializationException("Parsed date time is not in the expected RFC3339 format"); + EnsureSpecified(parsed); + return parsed; } - return dateTime; - } - if (reader.TokenType == JsonToken.String) - { - DateTime dateTime; - /*string[] formats = { "yyyy/M/d", "yyyy/MM/dd", "yyyy-M-d", "yyyy-MM-dd" };*/ - string timeString = (string)reader.Value; - if (!ParameterValidator.IsEmpty(timeString)) + var raw = reader.GetString(); + if (ParameterValidator.IsEmpty(raw)) { - if (DateTime.TryParseExact(timeString, ParseFormats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime)) - { - // Gelukt we kunnen doorgaan - return dateTime; - } - else - { - // De opgegeven timeString is niet juist. - return null; - } + return null; + } + if (DateTime.TryParseExact(raw, ParseFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTime)) + { + return dateTime; } + return null; } - throw new JsonSerializationException(String.Format("Unexpected token '{0}' when parsing date.", reader.TokenType)); + + throw new JsonException($"Unexpected token '{reader.TokenType}' when parsing date."); } - public override bool CanConvert(Type objectType) + public override void Write(Utf8JsonWriter writer, object? value, JsonSerializerOptions options) { - Type t = (Reflection.IsNullable(objectType)) - ? Nullable.GetUnderlyingType(objectType) - : objectType; + if (value == null) + { + writer.WriteNullValue(); + return; + } - return t == typeof(DateTime); + if (value is DateTime dateTime) + { + EnsureSpecified(dateTime); + writer.WriteStringValue(dateTime.ToString(Format, CultureInfo.InvariantCulture)); + return; + } + + throw new JsonException("Expected value of type 'DateTime'."); + } + + private static void EnsureSpecified(DateTime dateTime) + { + if (dateTime.Kind == DateTimeKind.Unspecified) + { + throw new JsonException("Cannot convert date time with an unspecified kind"); + } } } diff --git a/PAYNLSDK/Converters/YMDHISConverter.cs b/PAYNLSDK/Converters/YMDHISConverter.cs index 852864c..c046de9 100644 --- a/PAYNLSDK/Converters/YMDHISConverter.cs +++ b/PAYNLSDK/Converters/YMDHISConverter.cs @@ -1,20 +1,21 @@ -using Newtonsoft.Json; -using PayNLSdk.Utilities; using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; +using PayNLSdk.Utilities; namespace PayNLSdk.Converters; internal class YMDHISConverter : JsonConverter { private const string Format = "yyyy-MM-dd HH:ii:ss"; - private static string[] ParseFormats = { - // - argument. + private static readonly string[] ParseFormats = + { "yyyy-M-d h:mm:ss tt", "yyyy-M-d h:mm tt", "yyyy-MM-dd hh:mm:ss", "yyyy-M-d h:mm:ss", "yyyy-M-d hh:mm tt", "yyyy-M-d hh tt", "yyyy-M-d h:mm", "yyyy-M-d h:mm", "yyyy-MM-dd hh:mm", "yyyy-M-dd hh:mm", - // Slash argument. "yyyy/M/d h:mm:ss tt", "yyyy/M/d h:mm tt", "yyyy/MM/dd hh:mm:ss", "yyyy/M/d h:mm:ss", "yyyy/M/d hh:mm tt", "yyyy/M/d hh tt", @@ -22,86 +23,72 @@ internal class YMDHISConverter : JsonConverter "yyyy/MM/dd hh:mm", "yyyy/M/dd hh:mm" }; - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override bool CanConvert(Type typeToConvert) { - if (value is DateTime) - { - var dateTime = (DateTime)value; - if (dateTime.Kind == DateTimeKind.Unspecified) - { - throw new JsonSerializationException("Cannot convert date time with an unspecified kind"); - } - string convertedDateTime = dateTime.ToString(Format); - writer.WriteValue(convertedDateTime); - } - else - { - throw new JsonSerializationException("Expected value of type 'DateTime'."); - } + var targetType = Nullable.GetUnderlyingType(typeToConvert) ?? typeToConvert; + return targetType == typeof(DateTime); } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if (reader.TokenType == JsonToken.Null) + if (reader.TokenType == JsonTokenType.Null) { - return null; + if (Nullable.GetUnderlyingType(typeToConvert) != null) + { + return null; + } + + throw new JsonException("Cannot convert null to DateTime."); } - if (reader.TokenType == JsonToken.Date) + if (reader.TokenType == JsonTokenType.String) { - var dateTime = (DateTime)reader.Value; - if (dateTime.Kind == DateTimeKind.Unspecified) + if (reader.TryGetDateTime(out var parsed)) { - throw new JsonSerializationException("Parsed date time is not in the expected RFC3339 format"); + EnsureSpecified(parsed); + return parsed; } - return dateTime; - } - if (reader.TokenType == JsonToken.String) - { - DateTime dateTime; - /* - string[] formats = { - // - argument. - "yyyy-M-d h:mm:ss tt", "yyyy-M-d h:mm tt", - "yyyy-MM-dd hh:mm:ss", "yyyy-M-d h:mm:ss", - "yyyy-M-d hh:mm tt", "yyyy-M-d hh tt", - "yyyy-M-d h:mm", "yyyy-M-d h:mm", - "yyyy-MM-dd hh:mm", "yyyy-M-dd hh:mm", - // Slash argument. - "yyyy/M/d h:mm:ss tt", "yyyy/M/d h:mm tt", - "yyyy/MM/dd hh:mm:ss", "yyyy/M/d h:mm:ss", - "yyyy/M/d hh:mm tt", "yyyy/M/d hh tt", - "yyyy/M/d h:mm", "yyyy/M/d h:mm", - "yyyy/MM/dd hh:mm", "yyyy/M/dd hh:mm" - }; - */ - string timeString = (string)reader.Value; - if (!ParameterValidator.IsEmpty(timeString)) + var raw = reader.GetString(); + if (ParameterValidator.IsEmpty(raw)) { - if (DateTime.TryParseExact(timeString, ParseFormats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime)) - { - // Gelukt we kunnen doorgaan - return dateTime; - } - else - { - // De opgegeven timeString is niet juist. - return null; - } + return null; + } + if (DateTime.TryParseExact(raw, ParseFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTime)) + { + return dateTime; } + return null; } - throw new JsonSerializationException(String.Format("Unexpected token '{0}' when parsing date.", reader.TokenType)); + + throw new JsonException($"Unexpected token '{reader.TokenType}' when parsing date."); } - public override bool CanConvert(Type objectType) + public override void Write(Utf8JsonWriter writer, object? value, JsonSerializerOptions options) { - Type t = (Reflection.IsNullable(objectType)) - ? Nullable.GetUnderlyingType(objectType) - : objectType; + if (value == null) + { + writer.WriteNullValue(); + return; + } + + if (value is DateTime dateTime) + { + EnsureSpecified(dateTime); + writer.WriteStringValue(dateTime.ToString(Format, CultureInfo.InvariantCulture)); + return; + } + + throw new JsonException("Expected value of type 'DateTime'."); + } - return t == typeof(DateTime); + private static void EnsureSpecified(DateTime dateTime) + { + if (dateTime.Kind == DateTimeKind.Unspecified) + { + throw new JsonException("Cannot convert date time with an unspecified kind"); + } } } diff --git a/PAYNLSDK/Language.cs b/PAYNLSDK/Language.cs index bc3f00b..0f953ee 100644 --- a/PAYNLSDK/Language.cs +++ b/PAYNLSDK/Language.cs @@ -1,6 +1,7 @@ using PayNLSdk.Api.Alliance.GetMerchant; using PayNLSdk.Api.Language; using PayNLSdk.Net; +using PayNLSdk.Utilities; namespace PayNLSdk; @@ -21,7 +22,7 @@ public Language(IClient webClient) public GetMerchantResult GetAll() { var response = _webClient.PerformRequest(new GetAllRequest()); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); + return JsonSerialization.Deserialize(response); } } diff --git a/PAYNLSDK/Net/Client.cs b/PAYNLSDK/Net/Client.cs index 6b1dbd1..8e83158 100644 --- a/PAYNLSDK/Net/Client.cs +++ b/PAYNLSDK/Net/Client.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Api; using PayNLSdk.Exceptions; using PayNLSdk.Net.ProxyConfigurationInjector; @@ -252,7 +253,7 @@ private PayNlException ErrorExceptionFromWebException(WebException e) // Try JSON parsing. try { - Dictionary errors = JsonConvert.DeserializeObject>(rawResponse); + Dictionary errors = JsonSerialization.Deserialize>(rawResponse); string errMessage = ""; if (errors.ContainsKey("error")) { diff --git a/PAYNLSDK/Objects/Address.cs b/PAYNLSDK/Objects/Address.cs index 9a22e04..a4aee2f 100644 --- a/PAYNLSDK/Objects/Address.cs +++ b/PAYNLSDK/Objects/Address.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using PayNLSdk.Enums; @@ -12,54 +13,54 @@ public class Address /// /// Initials for Address /// - [JsonProperty("initials")] + [JsonPropertyName("initials")] public string Initials { get; set; } /// /// Lastname of receiver /// - [JsonProperty("lastName")] + [JsonPropertyName("lastName")] public string LastName { get; set; } /// /// Gender of receiver /// - [JsonProperty("gender"), JsonConverter(typeof(GenderConverter))] + [JsonPropertyName("gender"), JsonConverter(typeof(GenderConverter))] public Gender? Gender { get; set; } /// /// Street name /// - [JsonProperty("streetName")] + [JsonPropertyName("streetName")] public string StreetName { get; set; } /// /// Street number /// - [JsonProperty("streetNumber")] + [JsonPropertyName("streetNumber")] public string StreetNumber { get; set; } /// /// Street number /// - [JsonProperty("streetNumberExtension")] + [JsonPropertyName("streetNumberExtension")] public string StreetNumberExtension { get; set; } /// /// Zipcode /// - [JsonProperty("zipCode")] + [JsonPropertyName("zipCode")] public string ZipCode { get; set; } /// /// City /// - [JsonProperty("city")] + [JsonPropertyName("city")] public string City { get; set; } /// /// ISO2 Country code /// - [JsonProperty("countryCode")] + [JsonPropertyName("countryCode")] public string CountryCode { get; set; } } \ No newline at end of file diff --git a/PAYNLSDK/Objects/Company.cs b/PAYNLSDK/Objects/Company.cs index d8d4908..592923c 100644 --- a/PAYNLSDK/Objects/Company.cs +++ b/PAYNLSDK/Objects/Company.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Objects; @@ -10,24 +11,24 @@ public class Company /// /// The name of the company /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } /// /// The COC number of the company /// - [JsonProperty("cocNumber")] + [JsonPropertyName("cocNumber")] public string CocNumber { get; set; } /// /// The VAT number of the company /// - [JsonProperty("vatNumber")] + [JsonPropertyName("vatNumber")] public string VatNumber { get; set; } /// /// ID of the country (2 char country code) /// - [JsonProperty("countryCode")] + [JsonPropertyName("countryCode")] public string CountryCode { get; set; } } diff --git a/PAYNLSDK/Objects/Connection.cs b/PAYNLSDK/Objects/Connection.cs index 67f4b25..32c8d6e 100644 --- a/PAYNLSDK/Objects/Connection.cs +++ b/PAYNLSDK/Objects/Connection.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Enums; namespace PayNLSdk.Objects; @@ -11,78 +12,78 @@ public class Connection /// /// Trust indicator, from -10 to 10 /// - [JsonProperty("trust")] + [JsonPropertyName("trust")] public int? Trust { get; protected set; } /// /// Country code fo the customer /// - [JsonProperty("country")] + [JsonPropertyName("country")] public string Country { get; protected set; } /// /// name of the city of the customer /// - [JsonProperty("city")] + [JsonPropertyName("city")] public string City { get; protected set; } /// /// Customer location, latitude /// - [JsonProperty("locationLat")] + [JsonPropertyName("locationLat")] public string LocationLat { get; protected set; } /// /// Customer location, longitude /// - [JsonProperty("locationLon")] + [JsonPropertyName("locationLon")] public string LocationLon { get; protected set; } /// /// Details of the cusomers browser. Specified on transaction start /// - [JsonProperty("browserData")] + [JsonPropertyName("browserData")] public string BrowserData { get; protected set; } /// /// IP address of the customer (during payment) /// - [JsonProperty("ipAddress")] + [JsonPropertyName("ipAddress")] public string IP { get; protected set; } /// /// Indicator whether or not the cusomer is blacklisted /// - [JsonProperty("blacklist")] + [JsonPropertyName("blacklist")] public Blacklist? Blacklist { get; protected set; } /// /// Hostaddress of the customer /// - [JsonProperty("host")] + [JsonPropertyName("host")] public string Host { get; protected set; } /// /// Ip used in the order /// - [JsonProperty("orderIpAddress")] + [JsonPropertyName("orderIpAddress")] public string OrderIP { get; protected set; } /// /// Used return URl in request /// - [JsonProperty("orderReturnUrl")] + [JsonPropertyName("orderReturnUrl")] public string OrderReturnUrl { get; protected set; } /// /// The corresponding merchant-code of the merchant /// - [JsonProperty("merchantCode")] + [JsonPropertyName("merchantCode")] public string MerchantCode { get; protected set; } /// /// The corresponding name of the merchant /// - [JsonProperty("merchantName")] + [JsonPropertyName("merchantName")] public string MerchantName { get; protected set; } } diff --git a/PAYNLSDK/Objects/CountryOption.cs b/PAYNLSDK/Objects/CountryOption.cs index febb581..e0dd2cb 100644 --- a/PAYNLSDK/Objects/CountryOption.cs +++ b/PAYNLSDK/Objects/CountryOption.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using System.Collections.Generic; @@ -12,43 +13,43 @@ public class CountryOption /// /// Country option ID /// - [JsonProperty("id")] + [JsonPropertyName("id")] public string ID { get; set; } /// /// Country name /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Country visible name /// - [JsonProperty("visibleName")] + [JsonPropertyName("visibleName")] public string VisibleName { get; set; } /// /// Filename of the country icon /// - [JsonProperty("img")] + [JsonPropertyName("img")] public string Image { get; set; } /// /// Path for the country icon. The full icon URL is a concatenation of $basePath, $path and $img. /// - [JsonProperty("path")] + [JsonPropertyName("path")] public string IconPath { get; set; } /// /// Indicator whether or not the country is located in the EU. /// - [JsonProperty("in_eu"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("in_eu"), JsonConverter(typeof(BooleanConverter))] public bool InEU { get; protected set; } /// /// List of available payment options for this country /// - [JsonProperty("paymentOptionList")] + [JsonPropertyName("paymentOptionList")] public PaymentOptions PaymentOptions { get; set; } } diff --git a/PAYNLSDK/Objects/Error.cs b/PAYNLSDK/Objects/Error.cs index 2166eed..45d4729 100644 --- a/PAYNLSDK/Objects/Error.cs +++ b/PAYNLSDK/Objects/Error.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Objects; @@ -11,18 +12,18 @@ public class Error /// /// Result of a call. In case of a real error, this SHOULD always be false. /// - [JsonProperty("result"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("result"), JsonConverter(typeof(BooleanConverter))] public bool Result { get; protected set; } /// /// Error code /// - [JsonProperty("errorId")] + [JsonPropertyName("errorId")] public string Code { get; protected set; } /// /// Error message /// - [JsonProperty("errorMessage")] + [JsonPropertyName("errorMessage")] public string Message { get; protected set; } } diff --git a/PAYNLSDK/Objects/Merchant.cs b/PAYNLSDK/Objects/Merchant.cs index edaf055..45c77da 100644 --- a/PAYNLSDK/Objects/Merchant.cs +++ b/PAYNLSDK/Objects/Merchant.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Enums; namespace PayNLSdk.Objects; @@ -11,25 +12,25 @@ public class Merchant /// /// Merchant ID /// - [JsonProperty("id")] + [JsonPropertyName("id")] public string ID { get; set; } /// /// Merchant Name /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Merchant Public Name /// - [JsonProperty("publicName")] + [JsonPropertyName("publicName")] public string PublicName { get; set; } /// /// Active State of the merchant /// - [JsonProperty("state")] + [JsonPropertyName("state")] public ActiveState State { get; set; } } \ No newline at end of file diff --git a/PAYNLSDK/Objects/OrderData.cs b/PAYNLSDK/Objects/OrderData.cs index d1cf760..fae13e1 100644 --- a/PAYNLSDK/Objects/OrderData.cs +++ b/PAYNLSDK/Objects/OrderData.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using PayNLSdk.Enums; @@ -12,37 +13,37 @@ public class OrderData /// /// Your systems product ID /// - [JsonProperty("productId")] + [JsonPropertyName("productId")] public string ProductId { get; set; } /// /// Description of the product (max 45 characters) /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } /// /// Amount in cents of the product (amount incl. vat) /// - [JsonProperty("price")] + [JsonPropertyName("price")] public int Price { get; set; } /// /// Quantity of products with this product id /// - [JsonProperty("quantity")] + [JsonPropertyName("quantity")] public int Quantity { get; set; } /// /// The vat code /// - [JsonProperty("vatCode"), JsonConverter(typeof(TaxClassConverter))] + [JsonPropertyName("vatCode"), JsonConverter(typeof(TaxClassConverter))] public TaxClass VatCode { get; set; } /// /// Type of the order line. Possible values: ARTICLE, SHIPPING, HANDLING, DISCOUNT /// - [JsonProperty("productType"), JsonConverter(typeof(ProductTypeConverter))] + [JsonPropertyName("productType"), JsonConverter(typeof(ProductTypeConverter))] public ProductType ProductType { get; set; } /// diff --git a/PAYNLSDK/Objects/PaymentDetails.cs b/PAYNLSDK/Objects/PaymentDetails.cs index 9e24e86..757739e 100644 --- a/PAYNLSDK/Objects/PaymentDetails.cs +++ b/PAYNLSDK/Objects/PaymentDetails.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using PayNLSdk.Enums; @@ -12,220 +13,220 @@ public class PaymentDetails /// /// Amount of the session (in cents, eg. 1235) /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public int Amount { get; protected set; } /// /// Currency Amount of the session (in cents, eg. 1235) /// - [JsonProperty("currencyAmount")] + [JsonPropertyName("currencyAmount")] public int CurrencyAmount { get; protected set; } /// /// The total amount paid for this transaction /// - [JsonProperty("paidAmount")] + [JsonPropertyName("paidAmount")] public string PaidAmount { get; protected set; } /// /// The total currency amount paid for this transaction /// - [JsonProperty("paidCurrencyAmount")] + [JsonPropertyName("paidCurrencyAmount")] public string PaidCurrencyAmount { get; protected set; } /// /// Basic amount without the cost /// - [JsonProperty("paidBase")] + [JsonPropertyName("paidBase")] public string PaidBase { get; protected set; } /// /// Payment costs paid by the customer (ex. VAT) /// - [JsonProperty("paidCosts")] + [JsonPropertyName("paidCosts")] public string PaidCosts { get; protected set; } /// /// VAT rate for costs /// - [JsonProperty("paidCostsVat")] + [JsonPropertyName("paidCostsVat")] public string PaidCostsVat { get; protected set; } /// /// Currency of the payment /// - [JsonProperty("PaidCurreny")] + [JsonPropertyName("PaidCurreny")] public string PaidCurrency { get; protected set; } /// /// Number of payment attempts /// - [JsonProperty("paidAttemps")] + [JsonPropertyName("paidAttemps")] public string PaidAttemps { get; protected set; } /// /// Duration of the phonecall (only for phone payments) /// - [JsonProperty("paidDuration")] + [JsonPropertyName("paidDuration")] public string PaidDuration { get; protected set; } /// /// Order description /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; protected set; } /// /// Time passed from payment start to payment finish /// - [JsonProperty("processTime")] + [JsonPropertyName("processTime")] public string ProcessTime { get; protected set; } /// /// Payment Status indicator /// - [JsonProperty("state")] + [JsonPropertyName("state")] public PaymentStatus State { get; protected set; } /// /// Payment status name /// - [JsonProperty("stateName")] + [JsonPropertyName("stateName")] public string StateName { get; protected set; } /// /// Payment status description /// - [JsonProperty("stateDescription")] + [JsonPropertyName("stateDescription")] public string StateDescription { get; protected set; } /// /// Indicator whether or not the exchange URL has been called succesfully /// - [JsonProperty("exchange")] + [JsonPropertyName("exchange")] //public ExchangeState Exchange { get; protected set; } public string Exchange { get; protected set; } /// /// Indicator whether or not the transaction is refunded /// - [JsonProperty("storno"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("storno"), JsonConverter(typeof(BooleanConverter))] public bool Storno { get; protected set; } /// /// The payment options used (eq. iDeal/creditcard) /// - [JsonProperty("paymentOptionId")] + [JsonPropertyName("paymentOptionId")] public int PaymentOptionId { get; protected set; } /// /// The payment options sub id used (eq. the selected bank for iDeal) /// - [JsonProperty("paymentOptionSubId")] + [JsonPropertyName("paymentOptionSubId")] public int PaymentOptionSubId { get; protected set; } /// /// For creditcard transactions /// - [JsonProperty("secure")] + [JsonPropertyName("secure")] public Secure Secure { get; protected set; } /// /// Returns the 3d secure status /// - [JsonProperty("secureStatus")] + [JsonPropertyName("secureStatus")] public string SecureStatus { get; protected set; } /// /// Name of the consumer /// - [JsonProperty("identifierName")] + [JsonPropertyName("identifierName")] public string IdentifierName { get; protected set; } /// /// Payment identifier that can be displayed to the customer for reference /// - [JsonProperty("identifierPublic")] + [JsonPropertyName("identifierPublic")] public string IdentifierPublic { get; protected set; } /// /// Customer ID, a unique hash based upon the bankaccount/creditcard number of the customer /// - [JsonProperty("identifierHash")] + [JsonPropertyName("identifierHash")] public string IdentifierHash { get; protected set; } /// /// ID of the service/website for which the transaction is started /// - [JsonProperty("serviceId")] + [JsonPropertyName("serviceId")] public string ServiceId { get; protected set; } /// /// Name of the service/website /// - [JsonProperty("serviceName")] + [JsonPropertyName("serviceName")] public string ServiceName { get; protected set; } /// /// Description of the service/website /// - [JsonProperty("serviceDescription")] + [JsonPropertyName("serviceDescription")] public string ServiceDescription { get; protected set; } /// /// Date time of the moment the transaction was started /// - [JsonProperty("created")] + [JsonPropertyName("created")] public string Created { get; protected set; } /// /// Date time of the last status change of the transaction /// - [JsonProperty("modified")] + [JsonPropertyName("modified")] public string Modified { get; protected set; } /// /// ID of the type of the payment method /// - [JsonProperty("paymentMethodId")] + [JsonPropertyName("paymentMethodId")] public string PaymentMethodId { get; protected set; } /// /// Name of the type of the payment method /// - [JsonProperty("paymentMethodName")] + [JsonPropertyName("paymentMethodName")] public string PaymentMethodName { get; protected set; } /// /// Description of the type of the payment method /// - [JsonProperty("paymentMethodDescription")] + [JsonPropertyName("paymentMethodDescription")] public string PaymentMethodDescription { get; protected set; } /// /// Name of the payment profile used to pay the transaction /// - [JsonProperty("paymentProfileName")] + [JsonPropertyName("paymentProfileName")] public string PaymentProfileName { get; protected set; } /// /// Gets or sets the Order number of the transaction . /// /// The order number. - [JsonProperty("orderNumber")] public string OrderNumber { get; set; } + [JsonPropertyName("orderNumber")] public string OrderNumber { get; set; } /// /// Name of the creditcard supplier /// - [JsonProperty("cardBrand")] public string CardBrand { get; set; } + [JsonPropertyName("cardBrand")] public string CardBrand { get; set; } /// /// Debit or credit /// - [JsonProperty("cardType")] public string CardType { get; set; } + [JsonPropertyName("cardType")] public string CardType { get; set; } /// /// Countrycode of the creditcards origin /// - [JsonProperty("cardCountryCode")] public string CardCountryCode { get; set; } + [JsonPropertyName("cardCountryCode")] public string CardCountryCode { get; set; } } diff --git a/PAYNLSDK/Objects/PaymentMethod.cs b/PAYNLSDK/Objects/PaymentMethod.cs index 359ec94..f1c1320 100644 --- a/PAYNLSDK/Objects/PaymentMethod.cs +++ b/PAYNLSDK/Objects/PaymentMethod.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Objects; @@ -10,19 +11,19 @@ public class PaymentMethod /// /// Payment method ID /// - [JsonProperty("id")] + [JsonPropertyName("id")] public int Id { get; set; } /// /// Payment method name /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Abbreviation for this payment method /// - [JsonProperty("abbreviation")] + [JsonPropertyName("abbreviation")] public string Abbreviation { get; set; } } diff --git a/PAYNLSDK/Objects/PaymentOption.cs b/PAYNLSDK/Objects/PaymentOption.cs index eadc288..6ea8d3e 100644 --- a/PAYNLSDK/Objects/PaymentOption.cs +++ b/PAYNLSDK/Objects/PaymentOption.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Enums; using System.Collections.Generic; @@ -12,37 +13,37 @@ abstract public class PaymentOptionBase /// /// ID for this payment (sub)option /// - [JsonProperty("id")] + [JsonPropertyName("id")] public int ID { get; set; } /// /// Name for this payment (sub)option /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Visible name for this payment (sub)option /// - [JsonProperty("visibleName")] + [JsonPropertyName("visibleName")] public string VisibleName { get; set; } /// /// Image for this payment (sub)option /// - [JsonProperty("img")] + [JsonPropertyName("img")] public string Image { get; set; } /// /// Path for the (sub)option icon. The full icon URL is a concatenation of $basePath, $path and $img. /// - [JsonProperty("path")] + [JsonPropertyName("path")] public string IconPath { get; set; } /// /// Indicator whether or not the sub option is available /// - [JsonProperty("state")] + [JsonPropertyName("state")] public Availability State { get; set; } } @@ -69,13 +70,13 @@ public class PaymentOption : PaymentOptionBase /// /// ID of the Payment Method this option belongs to /// - [JsonProperty("paymentMethodId")] + [JsonPropertyName("paymentMethodId")] public PaymentMethodId PaymentMethodId { get; set; } /// /// Dictionary of payment sub options /// - [JsonProperty("paymentOptionSubList")] + [JsonPropertyName("paymentOptionSubList")] public PaymentSubOptions PaymentSubOptions { get; set; } } diff --git a/PAYNLSDK/Objects/PaymentProfile.cs b/PAYNLSDK/Objects/PaymentProfile.cs index 1075dbc..6804ff7 100644 --- a/PAYNLSDK/Objects/PaymentProfile.cs +++ b/PAYNLSDK/Objects/PaymentProfile.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Objects; @@ -11,49 +12,49 @@ public class PaymentProfile /// /// Payment Profile ID /// - [JsonProperty("id")] + [JsonPropertyName("id")] public int Id { get; set; } /// /// Payment Profile Name /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Payment Profile Parent ID /// - [JsonProperty("parent_id")] + [JsonPropertyName("parent_id")] public int ParentId { get; set; } /// /// Indicator if this Payment Profile is publicly available /// - [JsonProperty("public"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("public"), JsonConverter(typeof(BooleanConverter))] public bool Public { get; set; } /// /// Payment Method ID this profile belongs to /// - [JsonProperty("payment_method_id")] + [JsonPropertyName("payment_method_id")] public int PaymentMethodId { get; set; } /// /// Country ID this payment profile belongs to. /// - [JsonProperty("country_id")] + [JsonPropertyName("country_id")] public int CountryId { get; set; } /// /// ID of the Payment Tariff /// - [JsonProperty("payment_tariff_id")] + [JsonPropertyName("payment_tariff_id")] public int PaymentTariffId { get; set; } /// /// The nature of address, mostly used for PayPerCall and PayPerMinute to indicate wether this the payment was done with a mobile phone (1) or not (0). /// - [JsonProperty("noah_id")] + [JsonPropertyName("noah_id")] public int NoahId { get; set; } } diff --git a/PAYNLSDK/Objects/RefundInfo.cs b/PAYNLSDK/Objects/RefundInfo.cs index cf91b41..2aabefe 100644 --- a/PAYNLSDK/Objects/RefundInfo.cs +++ b/PAYNLSDK/Objects/RefundInfo.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using System; namespace PayNLSdk.Objects; @@ -11,55 +12,55 @@ public class RefundInfo /// /// payment session ID /// - [JsonProperty("paymentSessionId")] + [JsonPropertyName("paymentSessionId")] public long PaymentSessionId { get; set; } /// /// Refund amount /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public int Amount { get; set; } /// /// description /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } /// /// The name of the customer. /// - [JsonProperty("bankAccountHolder")] + [JsonPropertyName("bankAccountHolder")] public string BankAccountHolder { get; set; } /// /// The bankaccount number of the customer. /// - [JsonProperty("bankAccountNumber")] + [JsonPropertyName("bankAccountNumber")] public string BankAccountNumber { get; set; } /// /// The BIC of the bank. /// - [JsonProperty("bankAccountBic")] + [JsonPropertyName("bankAccountBic")] public string BankAccountBic { get; set; } /// /// status code /// - [JsonProperty("statusCode")] + [JsonPropertyName("statusCode")] public int StatusCode { get; set; } /// /// status description /// - [JsonProperty("statusName")] + [JsonPropertyName("statusName")] public string StatusName { get; set; } /// /// The currency of the amount, default is EUR. /// - [JsonProperty("processDate")] + [JsonPropertyName("processDate")] public DateTime? ProcessDate { get; set; } } diff --git a/PAYNLSDK/Objects/SalesData.cs b/PAYNLSDK/Objects/SalesData.cs index 110041b..01ab4c0 100644 --- a/PAYNLSDK/Objects/SalesData.cs +++ b/PAYNLSDK/Objects/SalesData.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using System; using System.Collections.Generic; @@ -13,18 +14,18 @@ public class SalesData /// /// Invoice date /// - [JsonProperty("invoiceDate"), JsonConverter(typeof(DMYConverter))] + [JsonPropertyName("invoiceDate"), JsonConverter(typeof(DMYConverter))] public DateTime? InvoiceDate { get; set; } /// /// Delivery date /// - [JsonProperty("deliveryDate"), JsonConverter(typeof(DMYConverter))] + [JsonPropertyName("deliveryDate"), JsonConverter(typeof(DMYConverter))] public DateTime? DeliveryDate { get; set; } /// /// Ordered products specification /// - [JsonProperty("orderData")] + [JsonPropertyName("orderData")] public List OrderData { get; set; } } \ No newline at end of file diff --git a/PAYNLSDK/Objects/Service.cs b/PAYNLSDK/Objects/Service.cs index 1cf1ce9..473e5a9 100644 --- a/PAYNLSDK/Objects/Service.cs +++ b/PAYNLSDK/Objects/Service.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Enums; namespace PayNLSdk.Objects; @@ -11,61 +12,61 @@ public class Service /// /// Service ID /// - [JsonProperty("id")] + [JsonPropertyName("id")] public string ID { get; set; } /// /// Service Name /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Service Description /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } /// /// The way the service is presented to the customer (eg. an URL or name of an advertisement) /// - [JsonProperty("publication")] + [JsonPropertyName("publication")] public string Publication { get; set; } /// /// Base path of the images for the payment options /// - [JsonProperty("basePath")] + [JsonPropertyName("basePath")] public string BasePath { get; set; } /// /// ID of the module /// - [JsonProperty("module")] + [JsonPropertyName("module")] public int Module { get; set; } /// /// ID of the submodule /// - [JsonProperty("subModule")] + [JsonPropertyName("subModule")] public int SubModule { get; set; } /// /// Active state for this Service /// - [JsonProperty("state")] + [JsonPropertyName("state")] public ActiveState State { get; set; } /// /// Target url after a successfull payment /// - [JsonProperty("successUrl")] + [JsonPropertyName("successUrl")] public string SuccessUrl { get; set; } /// /// Target url after a failed payment /// - [JsonProperty("errorUrl")] + [JsonPropertyName("errorUrl")] public string ErrorUrl { get; set; } } diff --git a/PAYNLSDK/Objects/ServiceCategory.cs b/PAYNLSDK/Objects/ServiceCategory.cs index 444b2b2..9515bd8 100644 --- a/PAYNLSDK/Objects/ServiceCategory.cs +++ b/PAYNLSDK/Objects/ServiceCategory.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PayNLSdk.Objects; @@ -10,12 +11,12 @@ public class ServiceCategory /// /// ID of the Service Category /// - [JsonProperty("id")] + [JsonPropertyName("id")] public string Id { get; set; } /// /// Name of the Service Category /// - [JsonProperty("name")] + [JsonPropertyName("name")] public string Name { get; set; } } diff --git a/PAYNLSDK/Objects/TransactionStartEnduser.cs b/PAYNLSDK/Objects/TransactionStartEnduser.cs index 5b7ca9a..914f6d5 100644 --- a/PAYNLSDK/Objects/TransactionStartEnduser.cs +++ b/PAYNLSDK/Objects/TransactionStartEnduser.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Enums; namespace PayNLSdk.Objects; @@ -11,6 +12,6 @@ public class TransactionStartEnduser /// /// Indidicator whether or not the cusomer is blacklisted /// - [JsonProperty("blacklist")] + [JsonPropertyName("blacklist")] public Blacklist Blacklist { get; protected set; } } diff --git a/PAYNLSDK/Objects/TransactionStartInfo.cs b/PAYNLSDK/Objects/TransactionStartInfo.cs index 6437692..8244c41 100644 --- a/PAYNLSDK/Objects/TransactionStartInfo.cs +++ b/PAYNLSDK/Objects/TransactionStartInfo.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; namespace PayNLSdk.Objects; @@ -13,25 +14,25 @@ public class TransactionStartInfo /// /// Transaction ID /// - [JsonProperty("transactionId")] + [JsonPropertyName("transactionId")] public string TransactionId { get; protected set; } /// /// The URL where the customer can be send to in order to finish the transaction. /// - [JsonProperty("paymentURL")] + [JsonPropertyName("paymentURL")] public string PaymentURL { get; protected set; } /// /// Indicates whether the payment screen may be loaded in popup window /// - [JsonProperty("popupAllowed"), JsonConverter(typeof(BooleanConverter))] + [JsonPropertyName("popupAllowed"), JsonConverter(typeof(BooleanConverter))] public bool? PopupAllowed { get; protected set; } /// /// Payment reference used to identify manual bank transfers /// - [JsonProperty("paymentReference")] + [JsonPropertyName("paymentReference")] public string PaymentReference { get; protected set; } } \ No newline at end of file diff --git a/PAYNLSDK/Objects/TransactionStats.cs b/PAYNLSDK/Objects/TransactionStats.cs index ed33bd1..b5c1ead 100644 --- a/PAYNLSDK/Objects/TransactionStats.cs +++ b/PAYNLSDK/Objects/TransactionStats.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Converters; using System; @@ -12,68 +13,68 @@ public class TransactionStats /// /// Transaction identifier. /// - [JsonProperty("id")] + [JsonPropertyName("id")] public string Id { get; set; } /// /// Name of the website used for the transaction /// - [JsonProperty("websiteName")] + [JsonPropertyName("websiteName")] public string WebsiteName { get; set; } /// /// Name of the service used for the transaction /// - [JsonProperty("serviceName")] + [JsonPropertyName("serviceName")] public string ServiceName { get; set; } /// /// Code of the service used for the transaction /// - [JsonProperty("serviceCode")] + [JsonPropertyName("serviceCode")] public string ServiceCode { get; set; } /// /// Amount in cents of euro /// - [JsonProperty("orderAmount")] + [JsonPropertyName("orderAmount")] public int OrderAmount { get; set; } /// /// Date and time of the transaction. /// - [JsonProperty("created"), JsonConverter(typeof(YMDHISConverter))] + [JsonPropertyName("created"), JsonConverter(typeof(YMDHISConverter))] public DateTime Created { get; set; } // TODO: this should be paymentstatus /// /// Internal status of the transaction /// - [JsonProperty("internalStatus")] + [JsonPropertyName("internalStatus")] public int InternalStatus { get; set; } /// /// If Y mean that the payment was verified /// - [JsonProperty("consumer3dsecure")] + [JsonPropertyName("consumer3dsecure")] public string Consumer3dSecure { get; set; } /// /// Consumer account number /// - [JsonProperty("consumerAccountNumber")] + [JsonPropertyName("consumerAccountNumber")] public string ConsumerAccountNumber { get; set; } /// /// ID of the Payment Profile used for this transaction /// - [JsonProperty("profileId")] + [JsonPropertyName("profileId")] public int ProfileId { get; set; } /// /// Name of the Payment Profile used for this transaction /// - [JsonProperty("profileName")] + [JsonPropertyName("profileName")] public string ProfileName { get; set; } } @@ -86,6 +87,6 @@ public class TransactionStatsList /// /// Array containing the transactions stats /// - [JsonProperty("transations")] + [JsonPropertyName("transations")] public TransactionStats[] Transactions { get; set; } } diff --git a/PAYNLSDK/PayNLSdk.csproj b/PAYNLSDK/PayNLSdk.csproj index f20d138..6c3f35f 100644 --- a/PAYNLSDK/PayNLSdk.csproj +++ b/PAYNLSDK/PayNLSdk.csproj @@ -34,7 +34,7 @@ Targeting netstandard2.0 - + diff --git a/PAYNLSDK/Statistics.cs b/PAYNLSDK/Statistics.cs index dd8f792..64a8eb1 100644 --- a/PAYNLSDK/Statistics.cs +++ b/PAYNLSDK/Statistics.cs @@ -1,7 +1,9 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using PayNLSdk.Api.Statistics.GetManagement; using PayNLSdk.Net; using System.Collections.Generic; +using PayNLSdk.Utilities; namespace PayNLSdk; @@ -33,7 +35,7 @@ public GetStatsResult GetStats(Request request, string groupByFieldName = "") var response = _webClient.PerformRequest(request); var jsonConverters = new List { new DecimalConverter() }; - return Newtonsoft.Json.JsonConvert.DeserializeObject(response, jsonConverters.ToArray()); + return JsonSerialization.Deserialize(response, jsonConverters.ToArray()); } /// @@ -53,7 +55,7 @@ public GetStatsMultiLevel GetMultiLevelStats(Request request, string groupByFiel request.GroupByFieldNames.Add(groupByFieldName2); var response = _webClient.PerformRequest(request); - return Newtonsoft.Json.JsonConvert.DeserializeObject(response); + return JsonSerialization.Deserialize(response); } } diff --git a/PAYNLSDK/Utilities/JsonSerialization.cs b/PAYNLSDK/Utilities/JsonSerialization.cs new file mode 100644 index 0000000..19fdc8b --- /dev/null +++ b/PAYNLSDK/Utilities/JsonSerialization.cs @@ -0,0 +1,74 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using PayNLSdk.Converters; + +namespace PayNLSdk.Utilities; + +internal static class JsonSerialization +{ + public static JsonSerializerOptions DefaultOptions { get; } = CreateDefaultOptions(); + + public static JsonSerializerOptions CreateOptionsWith(params JsonConverter[] converters) + { + if (converters == null || converters.Length == 0) + { + return DefaultOptions; + } + + var options = new JsonSerializerOptions(DefaultOptions); + foreach (var converter in converters) + { + options.Converters.Add(converter); + } + + return options; + } + + public static JsonSerializerOptions CreateIndentedOptions() + { + var options = new JsonSerializerOptions(DefaultOptions) + { + WriteIndented = true + }; + return options; + } + + public static T? Deserialize(string json, JsonSerializerOptions? options = null) + { + if (string.IsNullOrWhiteSpace(json)) + { + return default; + } + + return JsonSerializer.Deserialize(json, options ?? DefaultOptions); + } + + public static T? Deserialize(string json, params JsonConverter[] converters) + { + return Deserialize(json, CreateOptionsWith(converters)); + } + + public static string Serialize(T value, JsonSerializerOptions? options = null) + { + return JsonSerializer.Serialize(value, options ?? DefaultOptions); + } + + private static JsonSerializerOptions CreateDefaultOptions() + { + var options = new JsonSerializerOptions + { + NumberHandling = JsonNumberHandling.AllowReadingFromString + }; + + options.Converters.Add(new BooleanConverter()); + options.Converters.Add(new DMYConverter()); + options.Converters.Add(new YMDConverter()); + options.Converters.Add(new YMDHISConverter()); + options.Converters.Add(new ErrorIdConverter()); + options.Converters.Add(new CountryOptionConverter()); + options.Converters.Add(new JsonStringEnumConverter()); + + return options; + } +} From a697a4f0419b239a9468ecd53d673bbcd98fb1a8 Mon Sep 17 00:00:00 2001 From: Damiaan Date: Wed, 15 Oct 2025 19:14:27 +0200 Subject: [PATCH 4/6] Add dependency injection helper --- PAYNLSDK/DependencyInjection.cs | 26 ++++++++++++++++++++++++++ PAYNLSDK/PayNLSdk.csproj | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 PAYNLSDK/DependencyInjection.cs diff --git a/PAYNLSDK/DependencyInjection.cs b/PAYNLSDK/DependencyInjection.cs new file mode 100644 index 0000000..12e64c3 --- /dev/null +++ b/PAYNLSDK/DependencyInjection.cs @@ -0,0 +1,26 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace PayNLSdk; +/// +/// Extension services for Pay.nl SDK +/// +public static class DependencyInjection +{ + /// + /// Register Pay. services + /// + /// + /// + public static IServiceCollection AddPayNl(this IServiceCollection services) + { + // Register your services here + services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); + return services; + } +} diff --git a/PAYNLSDK/PayNLSdk.csproj b/PAYNLSDK/PayNLSdk.csproj index 6c3f35f..0364ed4 100644 --- a/PAYNLSDK/PayNLSdk.csproj +++ b/PAYNLSDK/PayNLSdk.csproj @@ -35,6 +35,8 @@ Targeting netstandard2.0 + + From 27ef479c4bebe7d472df9ec750d4b98f42591946 Mon Sep 17 00:00:00 2001 From: Damiaan Date: Thu, 16 Oct 2025 00:14:01 +0200 Subject: [PATCH 5/6] adding simple logging in client --- PAYNLSDK/Net/Client.cs | 39 ++++++++++++++------------------------- PAYNLSDK/PayNLSdk.csproj | 3 ++- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/PAYNLSDK/Net/Client.cs b/PAYNLSDK/Net/Client.cs index 8e83158..11c735f 100644 --- a/PAYNLSDK/Net/Client.cs +++ b/PAYNLSDK/Net/Client.cs @@ -1,4 +1,5 @@ -using System.Text.Json; +using Microsoft.Extensions.Logging; +using System.Text.Json; using System.Text.Json.Serialization; using PayNLSdk.Api; using PayNLSdk.Exceptions; @@ -30,18 +31,23 @@ public class Client : IClient /// protected readonly IPayNlConfiguration SecurityConfiguration; + private readonly ILogger _logger; + /// [SuppressMessage("ReSharper", "MemberCanBeProtected.Global")] - public Client(IPayNlConfiguration securityConfiguration, IProxyConfigurationInjector proxyConfigurationInjector = null) + public Client(IPayNlConfiguration securityConfiguration, + ILogger logger, + IProxyConfigurationInjector proxyConfigurationInjector) { SecurityConfiguration = securityConfiguration; + _logger = logger; ProxyConfigurationInjector = proxyConfigurationInjector; } private const string Endpoint = "https://rest-api.pay.nl"; /// - public string ClientVersion => "1.1.0.0"; + public string ClientVersion => "2"; /// public string UserAgent => $"PAYNL/SDK/{ClientVersion} DotNet/{Environment.Version.Major}"; @@ -53,35 +59,18 @@ public Client(IPayNlConfiguration securityConfiguration, IProxyConfigurationInje /// raw response string public string PerformRequest(RequestBase request) { + _logger.LogInformation("Preparing request to {Url} with {@Parameters}", request.Url, request.GetParameters()); var webRequest = PrepareRequest(request.Url, "POST"); var rawResponse = PerformRoundTrip2(webRequest, HttpStatusCode.OK, () => { - using (var requestWriter = new StreamWriter(webRequest.GetRequestStream())) - { - //string serializedResource = resource.Serialize(); - string serializedResource = ToQueryString(request); - requestWriter.Write(serializedResource); - } + using var requestWriter = new StreamWriter(webRequest.GetRequestStream()); + + var serializedResource = ToQueryString(request); + requestWriter.Write(serializedResource); } ); request.RawResponse = rawResponse; return rawResponse; - - - //var webClient = new WebClient(); - //// we are not using the client.Credentials for the reason stated here: https://stackoverflow.com/a/26016919/97615 - ////string credentials = Convert.ToBase64String( - //// Encoding.ASCII.GetBytes("token:" + _securityConfiguration.ApiToken)); - ////webClient.Headers[HttpRequestHeader.Authorization] = $"Basic {credentials}"; - //webClient.Credentials = new NetworkCredential("token", _securityConfiguration.ApiToken); - //webClient.Headers[HttpRequestHeader.UserAgent] = this.UserAgent; - //webClient.QueryString = GetParameters(request); - //webClient.BaseAddress = Endpoint; - - //// download data - //var rawResponse = webClient.DownloadString(request.Url); - - return rawResponse; } /// diff --git a/PAYNLSDK/PayNLSdk.csproj b/PAYNLSDK/PayNLSdk.csproj index 0364ed4..cb61694 100644 --- a/PAYNLSDK/PayNLSdk.csproj +++ b/PAYNLSDK/PayNLSdk.csproj @@ -7,7 +7,7 @@ true RoodFluweel.PAYNLSDK - 2.0.0 + 2.0.0-beta001 paynl, dampee, Sebsoft dampee, paynl @@ -36,6 +36,7 @@ Targeting netstandard2.0 + From 38673b5683ebf5875f4536e8c70c3135f9ddce75 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Oct 2025 22:19:44 +0000 Subject: [PATCH 6/6] Bump System.Text.Json from 7.0.3 to 8.0.5 --- updated-dependencies: - dependency-name: System.Text.Json dependency-version: 8.0.5 dependency-type: direct:production - dependency-name: System.Text.Json dependency-version: 8.0.5 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- PAYNLFormsApp/App.config | 10 +++++++- PAYNLFormsApp/PAYNLFormsApp.csproj | 37 ++++++++++++++++++++++++++++-- PAYNLFormsApp/packages.config | 12 ++++++++-- PAYNLSDK/PayNLSdk.csproj | 2 +- 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/PAYNLFormsApp/App.config b/PAYNLFormsApp/App.config index 8d23437..3afd7af 100644 --- a/PAYNLFormsApp/App.config +++ b/PAYNLFormsApp/App.config @@ -1,6 +1,14 @@ - + + + + + + + + + diff --git a/PAYNLFormsApp/PAYNLFormsApp.csproj b/PAYNLFormsApp/PAYNLFormsApp.csproj index 863d0fc..ae9cacd 100644 --- a/PAYNLFormsApp/PAYNLFormsApp.csproj +++ b/PAYNLFormsApp/PAYNLFormsApp.csproj @@ -65,18 +65,51 @@ ..\packages\LightInject.5.1.1\lib\netstandard1.1\LightInject.dll - - ..\packages\System.Text.Json.7.0.3\lib\netstandard2.0\System.Text.Json.dll + + ..\packages\Microsoft.Bcl.AsyncInterfaces.9.0.10\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + True + + ..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll + True + + + ..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll + True + + + ..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll + True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + True + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + + ..\packages\System.Text.Encodings.Web.9.0.10\lib\net462\System.Text.Encodings.Web.dll + True + + + ..\packages\System.Text.Json.8.0.5\lib\net462\System.Text.Json.dll + True + + + ..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll + True + + + ..\packages\System.ValueTuple.4.6.1\lib\net462\System.ValueTuple.dll + True + diff --git a/PAYNLFormsApp/packages.config b/PAYNLFormsApp/packages.config index af202a3..e580d18 100644 --- a/PAYNLFormsApp/packages.config +++ b/PAYNLFormsApp/packages.config @@ -1,8 +1,9 @@  + - + @@ -13,23 +14,30 @@ + + + + + + + - + \ No newline at end of file diff --git a/PAYNLSDK/PayNLSdk.csproj b/PAYNLSDK/PayNLSdk.csproj index cb61694..1911080 100644 --- a/PAYNLSDK/PayNLSdk.csproj +++ b/PAYNLSDK/PayNLSdk.csproj @@ -34,7 +34,7 @@ Targeting netstandard2.0 - +