diff --git a/README.md b/README.md index c2fe13bb..8dec75c8 100644 --- a/README.md +++ b/README.md @@ -49,21 +49,21 @@ Source: https://docs.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-s ## Supported API's This library currently supports the following API's: -- Payments API +- Payment API - PaymentMethod API - PaymentLink API -- Customers API -- Mandates API -- Subscriptions API +- Customer API +- Mandate API +- Subscription API - Refund API - Connect API -- Chargebacks API -- Invoices API +- Chargeback API +- Invoice API - Permissions API -- Profiles API +- Profile API - Organizations API - Order API -- Captures API +- Capture API - Onboarding API - Balances API - Terminal API diff --git a/samples/Mollie.WebApplication.Blazor/Framework/StaticStringListBuilder.cs b/samples/Mollie.WebApplication.Blazor/Framework/StaticStringListBuilder.cs index caebd758..8caf81c7 100644 --- a/samples/Mollie.WebApplication.Blazor/Framework/StaticStringListBuilder.cs +++ b/samples/Mollie.WebApplication.Blazor/Framework/StaticStringListBuilder.cs @@ -1,12 +1,14 @@ using System.Reflection; -namespace Mollie.WebApplication.Blazor.Framework; +namespace Mollie.WebApplication.Blazor.Framework; public static class StaticStringListBuilder { public static IEnumerable GetStaticStringList(Type type) { foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.Static | BindingFlags.Public)) { - string value = fieldInfo.GetValue(null).ToString(); - yield return value; + string? value = fieldInfo.GetValue(null)?.ToString(); + if (value != null) { + yield return value; + } } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Framework/Validators/DecimalPlacesAttribute.cs b/samples/Mollie.WebApplication.Blazor/Framework/Validators/DecimalPlacesAttribute.cs index 1ce3abfc..38a1ec80 100644 --- a/samples/Mollie.WebApplication.Blazor/Framework/Validators/DecimalPlacesAttribute.cs +++ b/samples/Mollie.WebApplication.Blazor/Framework/Validators/DecimalPlacesAttribute.cs @@ -1,27 +1,31 @@ using System.ComponentModel.DataAnnotations; using System.Globalization; -namespace Mollie.WebApplication.Blazor.Framework.Validators; +namespace Mollie.WebApplication.Blazor.Framework.Validators; public class DecimalPlacesAttribute : ValidationAttribute { - public int DecimalPlaces { get; } + private int _decimalPlaces { get; } public DecimalPlacesAttribute(int decimalPlaces) { - DecimalPlaces = decimalPlaces; + _decimalPlaces = decimalPlaces; } - protected override ValidationResult IsValid(object value, ValidationContext validationContext) { + protected override ValidationResult? IsValid(object? value, ValidationContext validationContext) { + if (value == null) { + return new ValidationResult("Value is null"); + } + decimal amount = (decimal)value; string text = amount.ToString(CultureInfo.InvariantCulture); int dotIndex = text.IndexOf('.'); var decimals = text.Length - dotIndex - 1; - var places = DecimalPlaces switch + var places = _decimalPlaces switch { 0 => "without decimal places", 1 => "with one decimal place", - _ => $"with {DecimalPlaces} decimal places" + _ => $"with {_decimalPlaces} decimal places" }; - return dotIndex < 0 || dotIndex != text.LastIndexOf('.') || decimals != DecimalPlaces + return dotIndex < 0 || dotIndex != text.LastIndexOf('.') || decimals != _decimalPlaces ? new ValidationResult(ErrorMessage ?? $"Please enter an amount {places}") : ValidationResult.Success; } diff --git a/samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs b/samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs index c0eebf77..6adce01a 100644 --- a/samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs +++ b/samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs @@ -1,24 +1,24 @@ using System.ComponentModel.DataAnnotations; using System.Reflection; -namespace Mollie.WebApplication.Blazor.Framework.Validators; +namespace Mollie.WebApplication.Blazor.Framework.Validators; public class StaticStringListAttribute : ValidationAttribute { private readonly Type _staticClass; public StaticStringListAttribute(Type staticClass) { - this._staticClass = staticClass; + _staticClass = staticClass; } - protected override ValidationResult IsValid(object value, ValidationContext validationContext) { - IEnumerable validValues = this._staticClass + protected override ValidationResult? IsValid(object? value, ValidationContext validationContext) { + IEnumerable validValues = _staticClass .GetFields(BindingFlags.Static | BindingFlags.Public) - .Select(x => x.GetValue(null).ToString()); + .Select(x => x.GetValue(null)?.ToString()); if (validValues.Contains(value)) { return ValidationResult.Success; } - + return new ValidationResult($"The value \"{value}\" is invalid"); } } diff --git a/samples/Mollie.WebApplication.Blazor/Models/Customer/CreateCustomerModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Customer/CreateCustomerModel.cs index 135f9db5..1f037fc1 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Customer/CreateCustomerModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Customer/CreateCustomerModel.cs @@ -4,8 +4,8 @@ namespace Mollie.WebApplication.Blazor.Models.Customer; public class CreateCustomerModel { [Required] - public string Name { get; set; } + public required string Name { get; set; } [EmailAddress] - public string Email { get; set; } + public required string Email { get; set; } } diff --git a/samples/Mollie.WebApplication.Blazor/Models/Mandate/CreateMandateModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Mandate/CreateMandateModel.cs index f93ca90b..c897bedd 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Mandate/CreateMandateModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Mandate/CreateMandateModel.cs @@ -1,11 +1,11 @@ using System.ComponentModel.DataAnnotations; -namespace Mollie.WebApplication.Blazor.Models.Mandate; +namespace Mollie.WebApplication.Blazor.Models.Mandate; public class CreateMandateModel { [Required] - public string ConsumerName { get; set; } - + public required string ConsumerName { get; set; } + [Required] - public string ConsumerAccount { get; set; } -} \ No newline at end of file + public required string ConsumerAccount { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderBillingAddressModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderBillingAddressModel.cs index 716c2ad7..a882e15c 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderBillingAddressModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderBillingAddressModel.cs @@ -1,28 +1,28 @@ using System.ComponentModel.DataAnnotations; -namespace Mollie.WebApplication.Blazor.Models.Order; +namespace Mollie.WebApplication.Blazor.Models.Order; public class CreateOrderBillingAddressModel { [Required] - public string GivenName { get; set; } - + public required string GivenName { get; set; } + [Required] - public string FamilyName { get; set; } - + public required string FamilyName { get; set; } + [Required] [EmailAddress] - public string Email { get; set; } - + public required string Email { get; set; } + [Required] - public string StreetAndNumber { get; set; } - + public required string StreetAndNumber { get; set; } + [Required] - public string City { get; set; } - + public required string City { get; set; } + [Required] [MaxLength(2)] - public string Country { get; set; } - + public required string Country { get; set; } + [Required] - public string PostalCode { get; set; } -} \ No newline at end of file + public required string PostalCode { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderLineModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderLineModel.cs index 4dcf8170..309c1630 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderLineModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderLineModel.cs @@ -1,25 +1,25 @@ using System.ComponentModel.DataAnnotations; using Mollie.WebApplication.Blazor.Framework.Validators; -namespace Mollie.WebApplication.Blazor.Models.Order; +namespace Mollie.WebApplication.Blazor.Models.Order; public class CreateOrderLineModel { [Required] - public string Name { get; set; } + public string Name { get; set; } = string.Empty; [Required] [Range(1, 100, ErrorMessage = "Please enter a quantity between 0.01 and 1000")] public int Quantity { get; set; } - + [Required] [Range(0.01, 10000, ErrorMessage = "Please enter a unit price between 0.01 and 10000")] [DecimalPlaces(2)] public decimal UnitPrice { get; set; } - + public decimal TotalAmount { get; set; } - + [Range(0.01, 100, ErrorMessage = "Please enter a vat rate between 0.01 and 100")] [DecimalPlaces(2)] public decimal VatRate { get; set; } public decimal VatAmount { get; set; } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderModel.cs index 16d36cf7..6ea22639 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderModel.cs @@ -2,25 +2,27 @@ using Mollie.Api.Models; using Mollie.WebApplication.Blazor.Framework.Validators; -namespace Mollie.WebApplication.Blazor.Models.Order; +namespace Mollie.WebApplication.Blazor.Models.Order; public class CreateOrderModel { [Required] - public string OrderNumber { get; set; } - + public string? OrderNumber { get; set; } + + [Required] + public string? Locale { get; set; } + [Required] - public string Locale { get; set; } - public decimal Amount { get; set; } + public decimal? Amount { get; set; } [Required] [StaticStringList(typeof(Currency))] - public string Currency { get; set; } - + public required string Currency { get; set; } + [Required] [Url] - public string RedirectUrl { get; set; } - - public List Lines { get; set; } - - public CreateOrderBillingAddressModel BillingAddress { get; set; } -} \ No newline at end of file + public required string RedirectUrl { get; set; } + + public List? Lines { get; set; } = new(); + + public required CreateOrderBillingAddressModel BillingAddress { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs index 272b2c7d..5ec687ef 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs @@ -2,22 +2,22 @@ using Mollie.Api.Models; using Mollie.WebApplication.Blazor.Framework.Validators; -namespace Mollie.WebApplication.Blazor.Models.Payment; +namespace Mollie.WebApplication.Blazor.Models.Payment; public class CreatePaymentModel { [Required] [Range(0.01, 1000, ErrorMessage = "Please enter an amount between 0.01 and 1000")] [DecimalPlaces(2)] - public decimal Amount { get; set; } + public required decimal Amount { get; set; } [Required] [StaticStringList(typeof(Currency))] - public string Currency { get; set; } - + public required string Currency { get; set; } + [Required] [Url] - public string RedirectUrl { get; set; } + public required string RedirectUrl { get; set; } [Required] - public string Description { get; set; } -} \ No newline at end of file + public required string Description { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Subscription/CreateSubscriptionModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Subscription/CreateSubscriptionModel.cs index 43fab675..e16f4a8a 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Subscription/CreateSubscriptionModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Subscription/CreateSubscriptionModel.cs @@ -2,18 +2,17 @@ using Mollie.Api.Models; using Mollie.WebApplication.Blazor.Framework.Validators; -namespace Mollie.WebApplication.Blazor.Models.Subscription; - +namespace Mollie.WebApplication.Blazor.Models.Subscription; public class CreateSubscriptionModel { [Required] [Range(0.01, 1000, ErrorMessage = "Please enter an amount between 0.01 and 1000")] [DecimalPlaces(2)] - public decimal Amount { get; set; } = default!; + public required decimal Amount { get; set; } [Required] [StaticStringList(typeof(Currency))] - public string Currency { get; set; } + public required string Currency { get; set; } [Range(1, 10)] public int? Times { get; set; } @@ -25,8 +24,8 @@ public class CreateSubscriptionModel { [Required] [Display(Name = "Interval period")] - public IntervalPeriod IntervalPeriod { get; set; } + public required IntervalPeriod IntervalPeriod { get; set; } [Required] - public string Description { get; set; } -} \ No newline at end of file + public required string Description { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Mollie.WebApplication.Blazor.csproj b/samples/Mollie.WebApplication.Blazor/Mollie.WebApplication.Blazor.csproj index 30f359cb..3f922832 100644 --- a/samples/Mollie.WebApplication.Blazor/Mollie.WebApplication.Blazor.csproj +++ b/samples/Mollie.WebApplication.Blazor/Mollie.WebApplication.Blazor.csproj @@ -2,7 +2,7 @@ net8.0 - disable + enable enable 51758f49-d7ec-4044-8cd9-95cf49d0f3cf diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Customer/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Customer/Create.razor index b5ebdbf1..1c63a118 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Customer/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Customer/Create.razor @@ -2,6 +2,7 @@ @using Mollie.WebApplication.Blazor.Models.Customer @using Mollie.Api.Client +@using Mollie.Api.Models.Customer.Request @inject ICustomerClient CustomerClient @inject NavigationManager NavigationManager @@ -36,17 +37,17 @@ @code { - private MollieApiException _apiException = null; - + private MollieApiException? _apiException; + private CreateCustomerModel _customer = new() { Name = "Customer name", Email = "customer@customer.customer" }; - + private async Task OnSave() { try { _apiException = null; - + await CustomerClient.CreateCustomerAsync(new CustomerRequest() { Name = _customer.Name, Email = _customer.Email @@ -58,4 +59,4 @@ _apiException = e; } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Customer/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Customer/Overview.razor index 116d4d0b..41247f07 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Customer/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Customer/Overview.razor @@ -1,4 +1,6 @@ @page "/customer/overview" +@using Mollie.Api.Models.Customer.Response +@using Mollie.Api.Models.List.Response @inject ICustomerClient CustomerClient @@ -11,7 +13,7 @@ else { - + @@ -39,7 +41,7 @@ else { }
- + @@ -49,9 +51,9 @@ else { @code { [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse _customers = null; + public string? Url { get; set; } + + private ListResponse? _customers; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -63,8 +65,9 @@ else { } else { _customers = await CustomerClient.GetCustomerListAsync(new UrlObjectLink>() { - Href = Url + Href = Url, + Type = "application/json" }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Error.cshtml.cs b/samples/Mollie.WebApplication.Blazor/Pages/Error.cshtml.cs index 46aa84c7..b9d9c3ee 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Error.cshtml.cs +++ b/samples/Mollie.WebApplication.Blazor/Pages/Error.cshtml.cs @@ -7,17 +7,11 @@ namespace Mollie.WebApplication.Blazor.Pages; [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [IgnoreAntiforgeryToken] public class ErrorModel : PageModel { - public string RequestId { get; set; } + public string? RequestId { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - private readonly ILogger _logger; - - public ErrorModel(ILogger logger) { - _logger = logger; - } - public void OnGet() { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Create.razor index ce543b6d..6ba72115 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Create.razor @@ -1,6 +1,8 @@ @page "/customer/{customerId}/mandate/create" @using Mollie.WebApplication.Blazor.Models.Mandate @using Mollie.Api.Client +@using Mollie.Api.Models.Mandate.Request +@using Mollie.Api.Models.Mandate.Request.PaymentSpecificParameters @inject IMandateClient MandateClient @inject NavigationManager NavigationManager @@ -45,11 +47,11 @@ @code { - private MollieApiException _apiException = null; - + private MollieApiException? _apiException; + [Parameter] - public string CustomerId { get; set; } - + public required string CustomerId { get; set; } + private CreateMandateModel _mandate = new() { ConsumerName = "Consumer name", ConsumerAccount = "" @@ -58,7 +60,7 @@ private async Task OnSave() { try { _apiException = null; - + await MandateClient.CreateMandateAsync(CustomerId, new SepaDirectDebitMandateRequest { Method = PaymentMethod.DirectDebit, ConsumerName = _mandate.ConsumerName, @@ -71,4 +73,4 @@ _apiException = e; } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Overview.razor index 18ce3cb0..53c11715 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Overview.razor @@ -1,4 +1,6 @@ @page "/customer/{customerId}/mandate/overview" +@using Mollie.Api.Models.List.Response +@using Mollie.Api.Models.Mandate.Response @inject IMandateClient MandateClient @@ -11,7 +13,7 @@ else { - + @@ -32,7 +34,7 @@ else { }
- + @@ -41,13 +43,13 @@ else { @code { [Parameter] - public string CustomerId { get; set; } - + public required string CustomerId { get; set; } + [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse _mandates = null; + public string? Url { get; set; } + + private ListResponse? _mandates; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -59,8 +61,9 @@ else { } else { _mandates = await MandateClient.GetMandateListAsync(new UrlObjectLink>() { - Href = Url + Href = Url, + Type = "application/json" }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderAddressEditor.razor b/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderAddressEditor.razor index d6d02993..31407025 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderAddressEditor.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderAddressEditor.razor @@ -66,5 +66,5 @@ @code { [Parameter, EditorRequired] - public CreateOrderBillingAddressModel Address { get; set; } -} \ No newline at end of file + public required CreateOrderBillingAddressModel Address { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderLineEditor.razor b/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderLineEditor.razor index c50dde41..52363324 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderLineEditor.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderLineEditor.razor @@ -3,7 +3,7 @@ - + @@ -81,9 +81,9 @@ @code { [Parameter, EditorRequired] - public IList OrderLines { get; set; } + public required IList OrderLines { get; set; } - private CreateOrderLineModel _newOrderLineModel = new CreateOrderLineModel(); + private CreateOrderLineModel _newOrderLineModel = new (); private void OnAddOrderLine() { decimal totalAmount = _newOrderLineModel.Quantity * _newOrderLineModel.UnitPrice; @@ -98,4 +98,4 @@ private void OnRemoveOrderLine(CreateOrderLineModel orderLine) { OrderLines.Remove(orderLine); } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Order/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Order/Create.razor index 7aafee89..aa8d9910 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Order/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Order/Create.razor @@ -4,6 +4,7 @@ @using Mollie.WebApplication.Blazor.Models.Order @using System.Globalization @using Mollie.Api.Client +@using Mollie.Api.Models.Order.Request @inject IOrderClient OrderClient @inject NavigationManager NavigationManager @@ -15,7 +16,7 @@ - +
- +
- +
Billing address
- +
Order lines
@@ -68,15 +69,16 @@
@code { - private MollieApiException _apiException = null; - - private CreateOrderModel _order = new() { + private MollieApiException? _apiException; + + private readonly CreateOrderModel _order = new() { OrderNumber = "Order number", Locale = Locale.nl_NL, + Amount = 100m, Currency = "EUR", RedirectUrl = "https://www.mollie.com/", Lines = new List { - new CreateOrderLineModel { + new() { Name = "Chocolates", UnitPrice = 100.00m, Quantity = 1, @@ -95,15 +97,15 @@ StreetAndNumber = "Keizersgracht 126" } }; - + private async Task OnSave() { try { _apiException = null; - + await OrderClient.CreateOrderAsync(new OrderRequest { - OrderNumber = _order.OrderNumber, - Locale = _order.Locale, - Amount = new Amount(_order.Currency, _order.Lines.Sum(lines => lines.TotalAmount)), + OrderNumber = _order.OrderNumber!, + Locale = _order.Locale!, + Amount = new Amount(_order.Currency, _order.Lines!.Sum(lines => lines.TotalAmount)), RedirectUrl = _order.RedirectUrl, BillingAddress = new OrderAddressDetails { GivenName = _order.BillingAddress.GivenName, @@ -114,7 +116,7 @@ City = _order.BillingAddress.City, Country = _order.BillingAddress.Country }, - Lines = _order.Lines.Select(line => new OrderLineRequest { + Lines = _order.Lines!.Select(line => new OrderLineRequest { Name = line.Name, Quantity = line.Quantity, UnitPrice = new Amount(_order.Currency, line.UnitPrice), @@ -130,4 +132,4 @@ _apiException = e; } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Order/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Order/Overview.razor index b50b2716..0ce7fad5 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Order/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Order/Overview.razor @@ -1,4 +1,6 @@ @page "/order/overview" +@using Mollie.Api.Models.Order.Response +@using Mollie.Api.Models.List.Response @inject IOrderClient OrderClient @@ -11,7 +13,7 @@ else { - +
@@ -34,7 +36,7 @@ else { @@ -42,7 +44,7 @@ else { }
@order.Method @order.Metadata - @if (order.Status == OrderStatus.Created) { + @if (order.Status == OrderStatus.Created && order.Links.Checkout != null) { Pay }
- + @@ -52,9 +54,9 @@ else { @code { [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse _orders = null; + public string? Url { get; set; } + + private ListResponse? _orders; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -66,8 +68,9 @@ else { } else { _orders = await OrderClient.GetOrderListAsync(new UrlObjectLink>() { - Href = Url + Href = Url, + Type = "application/json" }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor index 2be18417..42e00b6c 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor @@ -11,16 +11,16 @@ - + - +
+ @bind-Value="_model.Amount">
@@ -29,7 +29,7 @@ + @bind-Value="_model.Currency"> @foreach (string currency in StaticStringListBuilder.GetStaticStringList(typeof(Currency))) { } @@ -41,7 +41,7 @@ + @bind-Value="_model.RedirectUrl"> @@ -50,7 +50,7 @@ + @bind-Value="_model.Description"> @@ -58,23 +58,23 @@
@code { - private MollieApiException _apiException = null; - - private CreatePaymentModel model = new() { + private MollieApiException? _apiException; + + private CreatePaymentModel _model = new() { Amount = 10.00m, Currency = "EUR", RedirectUrl = "https://www.mollie.com/", Description = "A payment from the example application" }; - + private async Task OnSave() { try { _apiException = null; - + await PaymentClient.CreatePaymentAsync(new PaymentRequest { - Amount = new Amount(model.Currency, model.Amount), - RedirectUrl = model.RedirectUrl, - Description = model.Description + Amount = new Amount(_model.Currency, _model.Amount), + RedirectUrl = _model.RedirectUrl, + Description = _model.Description }); NavigationManager.NavigateTo("/payment/overview"); @@ -83,4 +83,4 @@ _apiException = e; } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Payment/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Payment/Overview.razor index 380914b0..8c08ac75 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Payment/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Payment/Overview.razor @@ -1,4 +1,5 @@ @page "/payment/overview" +@using Mollie.Api.Models.List.Response @inject IPaymentClient PaymentClient @@ -11,7 +12,7 @@ else { - + @@ -34,7 +35,7 @@ else { @@ -42,7 +43,7 @@ else { }
@payment.Method @payment.Metadata - @if (payment.Status == PaymentStatus.Open && @payment.Links?.Checkout != null) { + @if (payment.Status == PaymentStatus.Open && @payment.Links.Checkout != null) { Pay }
- + @@ -52,9 +53,9 @@ else { @code { [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse _payments = null; + public string? Url { get; set; } + + private ListResponse? _payments; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -66,8 +67,9 @@ else { } else { _payments = await PaymentClient.GetPaymentListAsync(new UrlObjectLink>() { - Href = Url + Href = Url, + Type = "application/json" }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/PaymentMethod/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/PaymentMethod/Overview.razor index 225777b1..2e6652b8 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/PaymentMethod/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/PaymentMethod/Overview.razor @@ -1,4 +1,6 @@ @page "/payment-method/overview" +@using Mollie.Api.Models.List.Response +@using Mollie.Api.Models.PaymentMethod.Response @inject IPaymentMethodClient PaymentMethodClient @@ -32,9 +34,9 @@ else { @code { - private ListResponse _paymentMethods = null; + private ListResponse? _paymentMethods; protected override async Task OnInitializedAsync() { _paymentMethods = await PaymentMethodClient.GetPaymentMethodListAsync(); } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Create.razor index 2235900b..975c061a 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Create.razor @@ -2,6 +2,7 @@ @using Mollie.WebApplication.Blazor.Models.Subscription @using Mollie.Api.Client +@using Mollie.Api.Models.Subscription.Request @inject ISubscriptionClient SubscriptionClient @inject NavigationManager NavigationManager @@ -10,7 +11,7 @@ - + @@ -19,7 +20,7 @@ + @bind-Value="_model.Amount"> @@ -28,53 +29,53 @@ + @bind-Value="_model.Currency"> @foreach (string currency in StaticStringListBuilder.GetStaticStringList(typeof(Currency))) { } - +
+ @bind-Value="_model.Times">
- +
+ @bind-Value="_model.IntervalAmount">
- +
+ @bind-Value="_model.IntervalPeriod"> @foreach (string intervalPeriod in Enum.GetNames(typeof(IntervalPeriod))) { }
- +
@code { - private MollieApiException _apiException = null; - + private MollieApiException? _apiException; + [Parameter] - public string CustomerId { get; set; } - - private CreateSubscriptionModel model = new() { + public required string CustomerId { get; set; } + + private CreateSubscriptionModel _model = new() { Amount = 10.00m, Currency = Currency.EUR, IntervalPeriod = IntervalPeriod.Days, @@ -82,16 +83,16 @@ IntervalAmount = 2, Description = "A subscription created by the example application" }; - + private async Task OnSave() { try { _apiException = null; - + await SubscriptionClient.CreateSubscriptionAsync(CustomerId, new SubscriptionRequest { - Amount = new Amount(model.Currency, model.Amount), - Interval = $"{model.IntervalAmount} {model.IntervalPeriod.ToString().ToLower()}", - Times = model.Times, - Description = model.Description + Amount = new Amount(_model.Currency, _model.Amount), + Interval = $"{_model.IntervalAmount} {_model.IntervalPeriod.ToString().ToLower()}", + Times = _model.Times, + Description = _model.Description }); NavigationManager.NavigateTo($"/customer/{CustomerId}/subscription/overview"); @@ -100,4 +101,4 @@ _apiException = e; } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Overview.razor index ab71a70b..18831712 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Overview.razor @@ -1,17 +1,19 @@ @page "/customer/{customerId}/subscription/overview" +@using Mollie.Api.Models.List.Response +@using Mollie.Api.Models.Subscription.Response @inject ISubscriptionClient SubscriptionClient

Subscriptions

-@if (subscriptions == null) { +@if (_subscriptions == null) {

Loading...

} else { - + @@ -23,7 +25,7 @@ else { - @foreach (SubscriptionResponse subscription in subscriptions.Items) { + @foreach (SubscriptionResponse subscription in _subscriptions.Items) { @@ -34,22 +36,22 @@ else { }
@subscription.Id @subscription.CreatedAt
- + + Previous="_subscriptions.Links.Previous" + Next="_subscriptions.Links.Next"> } @code { [Parameter] - public string CustomerId { get; set; } - + public required string CustomerId { get; set; } + [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse subscriptions = null; + public string? Url { get; set; } + + private ListResponse? _subscriptions; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -57,12 +59,13 @@ else { private async Task LoadData() { if (string.IsNullOrEmpty(Url)) { - subscriptions = await SubscriptionClient.GetSubscriptionListAsync(CustomerId); + _subscriptions = await SubscriptionClient.GetSubscriptionListAsync(CustomerId); } else { - subscriptions = await SubscriptionClient.GetSubscriptionListAsync(new UrlObjectLink>() { - Href = Url + _subscriptions = await SubscriptionClient.GetSubscriptionListAsync(new UrlObjectLink>() { + Href = Url, + Type = "application/json" }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Terminal/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Terminal/Overview.razor index b67cd362..9b187db9 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Terminal/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Terminal/Overview.razor @@ -1,4 +1,6 @@ @page "/terminal/overview" +@using Mollie.Api.Models.List.Response +@using Mollie.Api.Models.Terminal.Response @inject ITerminalClient TerminalClient @@ -18,7 +20,6 @@ else { Model Serialnumber Currency - Locale @@ -31,12 +32,11 @@ else { @terminal.Model @terminal.SerialNumber @terminal.Currency - @terminal.Locale } - + @@ -46,9 +46,9 @@ else { @code { [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse _terminals = null; + public string? Url { get; set; } + + private ListResponse? _terminals; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -60,8 +60,9 @@ else { } else { _terminals = await TerminalClient.GetTerminalListAsync(new UrlObjectLink>() { - Href = Url + Href = Url, + Type = "application/json" }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/_Host.cshtml b/samples/Mollie.WebApplication.Blazor/Pages/_Host.cshtml index 4a2f28f3..6857d582 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/_Host.cshtml +++ b/samples/Mollie.WebApplication.Blazor/Pages/_Host.cshtml @@ -31,4 +31,4 @@ - \ No newline at end of file + diff --git a/samples/Mollie.WebApplication.Blazor/Program.cs b/samples/Mollie.WebApplication.Blazor/Program.cs index 39c587b6..0f336766 100644 --- a/samples/Mollie.WebApplication.Blazor/Program.cs +++ b/samples/Mollie.WebApplication.Blazor/Program.cs @@ -7,7 +7,7 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddMollieApi(options => { - options.ApiKey = builder.Configuration["Mollie:ApiKey"]; + options.ApiKey = builder.Configuration["Mollie:ApiKey"]!; options.RetryPolicy = MollieHttpRetryPolicies.TransientHttpErrorRetryPolicy(); }); @@ -29,4 +29,4 @@ app.MapBlazorHub(); app.MapFallbackToPage("/_Host"); -app.Run(); \ No newline at end of file +app.Run(); diff --git a/samples/Mollie.WebApplication.Blazor/Shared/ApiExceptionDisplay.razor b/samples/Mollie.WebApplication.Blazor/Shared/ApiExceptionDisplay.razor index 6619b4a7..d7b0d54e 100644 --- a/samples/Mollie.WebApplication.Blazor/Shared/ApiExceptionDisplay.razor +++ b/samples/Mollie.WebApplication.Blazor/Shared/ApiExceptionDisplay.razor @@ -8,5 +8,5 @@ @code { [Parameter, EditorRequired] - public MollieApiException Exception { get; set; } -} \ No newline at end of file + public MollieApiException? Exception { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Shared/NavMenu.razor b/samples/Mollie.WebApplication.Blazor/Shared/NavMenu.razor index e9b4e9e6..79c3c2cc 100644 --- a/samples/Mollie.WebApplication.Blazor/Shared/NavMenu.razor +++ b/samples/Mollie.WebApplication.Blazor/Shared/NavMenu.razor @@ -19,25 +19,25 @@ Payments - + - + - + - +