Skip to content

Commit

Permalink
Version 4.0.0 (#366)
Browse files Browse the repository at this point in the history
* Remove the optional retryPolicy parameter from AddMollieApi (#356)

* Enable nullable references in Mollie.Api project  (#346)

* Upgrade language version to 12
* Enable nullable references
* Add PolySharp so we can use required and init keyword
* Change all models from class to record

* Increase version number to 4.0.0

* Remove empty IResponseObject interface, as we don't need it

* Fix editorconfig warnings (#358)

* Fix editorconfig errors

* Fix build warnings

* Remove "this." from codebase

* Fixing build editor suggestions

* Enable nullable references in Blazor project

* Fix more editor config issues

* WIP: Use ModelName -> Request/Response namespaces everywhere

* Use ModelName -> Request/Response namespaces everywhere

* Remove unused using statements

* Fix null reference issues

* 11 warnings to go

* Add more XML comments and fix all editorconfig warnings

* Fix unit test

* Standardize client and method names (#359)

* Rename DeletePayment to CancelPayment in PaymentClient

* Move the "Create order refund" method and the "List order refunds" methods from the OrderClient to the RefundClient

* Rename GetChargebacksListAsync to GetChargebackListAsync for consistency

* Rename GetCapturesListAsync to GetCaptureListAsync

* Rename GetShipmentsListAsync to GetShipmentListAsync

* Rename GetOrganizationsListAsync to GetOrganizationListAsync

* Rename ListBalanceTransactionsAsync to GetBalanceTransactionListAsync
Rename ListPrimaryBalanceTransactionsAsync to GetPrimaryBalanceTransactionListAsync
Rename ListBalancesAsync to GetBalanceListAsync

* Standardize method names in ISettlementsClient

* Standardize client names, all clientnames are now singular

* Standardize API names in readme

* Allow null values for the Amount property in PaymentLinkRequest (#360)

* Replace init with set in all models (#363)

* Use { get; set; } everywhere instead of { get; init; } so we can continue to support lower C# language versions

* Create payment specific mandate response types (#364)

* Add payment specific response methods in mandate api

* Create Json converter to parse mandate payment specific responses

* Generate a new PaypalBillingAgreementId every time the CanCreatePayPalMandate integration test runs

* Remove PayPal integration test, it is not supported on our account

* Update GetBalanceTransactionListAsync and GetPrimaryBalanceTransactionListAsync methods to use a ListResponse instead of a custom type (#365)

* #362 Update GetBalanceTransactionListAsync and GetPrimaryBalanceTransactionListAsync methods to use a ListResponse instead of a custom type

* #362 Add GetBalanceTransactionListAsync method to retrieve a list of balance transactions by URL

* Fix CanCreateSpecificPaymentType integration test

* Fix issue where Links property of PaymentResponse would be null for BankTransferPaymentResponse

---------

Co-authored-by: Gerard Gunnewijk <gerard.gunnewijk@live.nl>
  • Loading branch information
Viincenttt and synercoder committed Jun 7, 2024
1 parent 25d4459 commit 2417d09
Show file tree
Hide file tree
Showing 350 changed files with 4,554 additions and 4,226 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System.Reflection;

namespace Mollie.WebApplication.Blazor.Framework;
namespace Mollie.WebApplication.Blazor.Framework;

public static class StaticStringListBuilder {
public static IEnumerable<string> 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;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<string> validValues = this._staticClass
protected override ValidationResult? IsValid(object? value, ValidationContext validationContext) {
IEnumerable<string?> 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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Original file line number Diff line number Diff line change
@@ -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; }
}
public required string ConsumerAccount { get; set; }
}
Original file line number Diff line number Diff line change
@@ -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; }
}
public required string PostalCode { get; set; }
}
Original file line number Diff line number Diff line change
@@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<CreateOrderLineModel> Lines { get; set; }
public CreateOrderBillingAddressModel BillingAddress { get; set; }
}
public required string RedirectUrl { get; set; }

public List<CreateOrderLineModel>? Lines { get; set; } = new();

public required CreateOrderBillingAddressModel BillingAddress { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
public required string Description { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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; }
}
public required string Description { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>disable</Nullable>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>51758f49-d7ec-4044-8cd9-95cf49d0f3cf</UserSecretsId>
</PropertyGroup>
Expand Down
11 changes: 6 additions & 5 deletions samples/Mollie.WebApplication.Blazor/Pages/Customer/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -36,17 +37,17 @@
</EditForm>

@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
Expand All @@ -58,4 +59,4 @@
_apiException = e;
}
}
}
}
Loading

0 comments on commit 2417d09

Please sign in to comment.