From 1ce47e951e5465033cdef9753a68baf7b367a451 Mon Sep 17 00:00:00 2001 From: arifm Date: Wed, 9 Oct 2024 17:35:04 +0100 Subject: [PATCH 01/14] WIP - Cancel payrun --- src/NoFrixion.MoneyMoov/Enums/PayrunEventTypeEnum.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/NoFrixion.MoneyMoov/Enums/PayrunEventTypeEnum.cs b/src/NoFrixion.MoneyMoov/Enums/PayrunEventTypeEnum.cs index 6a6ceb2c..56279183 100755 --- a/src/NoFrixion.MoneyMoov/Enums/PayrunEventTypeEnum.cs +++ b/src/NoFrixion.MoneyMoov/Enums/PayrunEventTypeEnum.cs @@ -40,5 +40,7 @@ public enum PayrunEventTypeEnum Archived = 10, - Unarchived = 11 + Unarchived = 11, + + Cancelled = 12, } \ No newline at end of file From 50447820c38d7a8a4f509078c1fdc4b88a324c4e Mon Sep 17 00:00:00 2001 From: sauravmaiti22 Date: Thu, 10 Oct 2024 12:55:58 +0100 Subject: [PATCH 02/14] Encrypt decrypt tribe calls --- .../RestClient/RestApiClient.cs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/NoFrixion.MoneyMoov/RestClient/RestApiClient.cs b/src/NoFrixion.MoneyMoov/RestClient/RestApiClient.cs index 4981fbb0..1f0e4d3c 100755 --- a/src/NoFrixion.MoneyMoov/RestClient/RestApiClient.cs +++ b/src/NoFrixion.MoneyMoov/RestClient/RestApiClient.cs @@ -33,6 +33,9 @@ public interface IRestApiClient Task> PostAsync(string path, HttpContent content); + Task> PostAsync(string path, HttpContent content, Dictionary headers, + MediaTypeWithQualityHeaderValue acceptHeader); + Task PostAsync(string path, string accessToken, HttpContent content); Task> PostAsync(string path, string accessToken, HttpContent content); @@ -104,6 +107,10 @@ public Task PostAsync(string path, HttpContent content) public Task> PostAsync(string path, HttpContent content) => ExecAsync(BuildRequest(HttpMethod.Post, path, string.Empty, content)); + public Task> PostAsync(string path, HttpContent content, Dictionary headers, + MediaTypeWithQualityHeaderValue acceptHeader) + => ExecAsync(BuildRequest(HttpMethod.Post, path, string.Empty, content, null, headers, acceptHeader)); + public Task PostAsync(string path, string accessToken, HttpContent content) => ExecAsync(BuildRequest(HttpMethod.Post, path, accessToken, content)); @@ -151,11 +158,13 @@ private HttpRequestMessage BuildRequest( string path, string accessToken, Option httpContent, - string? rowVersion = null) + string? rowVersion = null, + Dictionary? headers = null, + MediaTypeWithQualityHeaderValue? acceptHeader = null) { HttpRequestMessage request = new HttpRequestMessage(method, path); - request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + request.Headers.Accept.Add(acceptHeader ?? new MediaTypeWithQualityHeaderValue("application/json")); if (!string.IsNullOrEmpty(accessToken)) { @@ -166,6 +175,14 @@ private HttpRequestMessage BuildRequest( { request.Headers.TryAddWithoutValidation("If-Match", rowVersion); } + + if (headers != null) + { + foreach (var header in headers) + { + request.Headers.TryAddWithoutValidation(header.Key, header.Value); + } + } if(httpContent.IsSome) { From 9deaaa68b01554f3c90e7425a78cd4a26148f70b Mon Sep 17 00:00:00 2001 From: Aaron Clauson Date: Thu, 10 Oct 2024 22:31:33 +0100 Subject: [PATCH 03/14] Add JSON serialisation placeholder unit test. (#429) --- .../Json/PayoutSerialisationTests.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 test/MoneyMoov.UnitTests/Json/PayoutSerialisationTests.cs diff --git a/test/MoneyMoov.UnitTests/Json/PayoutSerialisationTests.cs b/test/MoneyMoov.UnitTests/Json/PayoutSerialisationTests.cs new file mode 100755 index 00000000..3a4fe340 --- /dev/null +++ b/test/MoneyMoov.UnitTests/Json/PayoutSerialisationTests.cs @@ -0,0 +1,48 @@ +//----------------------------------------------------------------------------- +// Filename: PayoutSerialisationTests.cs +// +// Description: Unit tests for serialising a Payout model to JSON. +// +// Author(s): +// Aaron Clauson (aaron@nofrixion.com) +// +// History: +// 10 Oct 2024 Aaron Clauson Created, Stillorgan Wood, Dublin, Ireland. +// +// License: +// MIT. +//----------------------------------------------------------------------------- + +using Microsoft.Extensions.Logging; +using NoFrixion.MoneyMoov.Models; +using System.Text; +using Xunit; +using Xunit.Abstractions; + +namespace NoFrixion.MoneyMoov.UnitTests.Json; + +public class PayoutSerialisationTests : MoneyMoovUnitTestBase +{ + public PayoutSerialisationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { } + + [Fact] + public async Task Serialize_Payout_Success() + { + Logger.LogDebug($"--> {TypeExtensions.GetCaller()}."); + + var payout = new Payout + { + Amount = 42.42m, + Currency = CurrencyTypeEnum.EUR, + TheirReference = "123 456", + Status = PayoutStatus.PROCESSED + }; + + var json = payout.ToJsonFlat(); + var content = new StringContent(json, Encoding.UTF8, "application/json"); + + Logger.LogDebug($"json: {json}"); + Logger.LogDebug($"content: {await content.ReadAsStringAsync()}"); + } +} \ No newline at end of file From 6142dd602dd03b194511e159c48c9e44e7ef5261 Mon Sep 17 00:00:00 2001 From: Axel Granillo Date: Fri, 11 Oct 2024 16:11:01 -0600 Subject: [PATCH 04/14] =?UTF-8?q?=E2=9C=A8=20MOOV-3764:=20Add=20DD=20Accou?= =?UTF-8?q?ntID=20to=20payment=20request=20features?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/PaymentRequests/IPaymentRequest.cs | 2 ++ .../Models/PaymentRequests/PaymentRequest.cs | 6 ++++++ .../Models/PaymentRequests/PaymentRequestCreate.cs | 7 +++++++ .../Models/PaymentRequests/PaymentRequestUpdate.cs | 6 ++++++ 4 files changed, 21 insertions(+) diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs index 268220bf..b6628d84 100644 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs @@ -62,4 +62,6 @@ public interface IPaymentRequest public string? Title { get; set; } public string? PartialPaymentSteps { get; set; } + + public Guid? DirectDebitAccountID { get; set; } } diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs index 1a397cbb..91933431 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs @@ -341,6 +341,12 @@ public class PaymentRequest : IPaymentRequest, IWebhookPayload /// public DateTimeOffset? LightningInvoiceExpiresAt { get; set; } + /// + /// The payment account ID to use to receive Direct Debit payments. This must match one of your + /// NoFrixion payment account IDs. This can be left blank to use your default payment account. + /// + public Guid? DirectDebitAccountID { get; set; } + public string CustomerName => Addresses.Any() ? $"{Addresses.First().FirstName} {Addresses.First().LastName}" : string.Empty; diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs index 534515a1..364e0d7b 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs @@ -333,6 +333,12 @@ public string? OriginUrl /// public List? Tags { get; set; } + /// + /// The payment account ID to use to receive Direct Debit payments. This must match one of your + /// NoFrixion payment account IDs. This can be left blank to use your default payment account. + /// + public Guid? DirectDebitAccountID { get; set; } + public NoFrixionProblem Validate() { var context = new ValidationContext(this, serviceProvider: null, items: null); @@ -406,6 +412,7 @@ public Dictionary ToDictionary() dict.Add(nameof(Title), Title ?? string.Empty); dict.Add(nameof(PartialPaymentSteps), PartialPaymentSteps ?? string.Empty); dict.Add(nameof(NotificationEmailAddresses), NotificationEmailAddresses ?? string.Empty); + dict.Add(nameof(DirectDebitAccountID), DirectDebitAccountID?.ToString() ?? string.Empty); if (TagIds?.Count() > 0) { diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs index e4fc6cac..62e68ef4 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs @@ -233,6 +233,12 @@ public class PaymentRequestUpdate /// Date and time of expiration of the lightning invoice. /// public DateTimeOffset? LightningInvoiceExpiresAt { get; set; } + + /// + /// The payment account ID to use to receive Direct Debit payments. This must match one of your + /// NoFrixion payment account IDs. This can be left blank to use your default payment account. + /// + public Guid? DirectDebitAccountID { get; set; } /// /// Places all the payment request's properties into a dictionary. Useful for testing From bc61b676dd712079a665bddb208617dabc9da7c6 Mon Sep 17 00:00:00 2001 From: Axel Granillo Date: Fri, 11 Oct 2024 16:11:45 -0600 Subject: [PATCH 05/14] =?UTF-8?q?=E2=9C=A8=20MOOV-3764:=20Update=20payment?= =?UTF-8?q?=20request=20DD=20status=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/PaymentRequestExtensions.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/NoFrixion.MoneyMoov/Extensions/PaymentRequestExtensions.cs b/src/NoFrixion.MoneyMoov/Extensions/PaymentRequestExtensions.cs index 86179090..150081f9 100755 --- a/src/NoFrixion.MoneyMoov/Extensions/PaymentRequestExtensions.cs +++ b/src/NoFrixion.MoneyMoov/Extensions/PaymentRequestExtensions.cs @@ -410,7 +410,9 @@ PaymentRequestEventTypesEnum.direct_debit_failed or PaymentMethod = PaymentMethodTypeEnum.directDebit, Currency = createEvent.Currency, AttemptedAmount = createEvent.Amount, - PaymentProcessor = createEvent.PaymentProcessorName + PaymentProcessor = createEvent.PaymentProcessorName, + AuthorisedAt = createEvent.Inserted, + AuthorisedAmount = createEvent.Amount }; if (attempt.Any(x => @@ -418,9 +420,9 @@ PaymentRequestEventTypesEnum.direct_debit_failed or { var paidEvent = attempt.First(x => x.EventType is PaymentRequestEventTypesEnum.direct_debit_paid); - - paymentAttempt.AuthorisedAt = paidEvent.Inserted; - paymentAttempt.AuthorisedAmount = paidEvent.Amount; + + paymentAttempt.SettledAt = paidEvent.Inserted; + paymentAttempt.SettledAmount = paidEvent.Amount; } else if (attempt.Any(x => x.EventType is PaymentRequestEventTypesEnum.direct_debit_failed)) From 4e9bc7f5e9ec9a2e7619a2190443337e190d4942 Mon Sep 17 00:00:00 2001 From: Axel Granillo Date: Mon, 14 Oct 2024 13:12:52 -0600 Subject: [PATCH 06/14] =?UTF-8?q?=F0=9F=94=A5=20MOOV-3764:=20Remove=20Dire?= =?UTF-8?q?ctDebitAccountID=20payment=20request=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/PaymentRequests/IPaymentRequest.cs | 2 -- .../Models/PaymentRequests/PaymentRequest.cs | 6 ------ .../Models/PaymentRequests/PaymentRequestCreate.cs | 7 ------- .../Models/PaymentRequests/PaymentRequestUpdate.cs | 6 ------ 4 files changed, 21 deletions(-) diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs index b6628d84..268220bf 100644 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs @@ -62,6 +62,4 @@ public interface IPaymentRequest public string? Title { get; set; } public string? PartialPaymentSteps { get; set; } - - public Guid? DirectDebitAccountID { get; set; } } diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs index 91933431..1a397cbb 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs @@ -341,12 +341,6 @@ public class PaymentRequest : IPaymentRequest, IWebhookPayload /// public DateTimeOffset? LightningInvoiceExpiresAt { get; set; } - /// - /// The payment account ID to use to receive Direct Debit payments. This must match one of your - /// NoFrixion payment account IDs. This can be left blank to use your default payment account. - /// - public Guid? DirectDebitAccountID { get; set; } - public string CustomerName => Addresses.Any() ? $"{Addresses.First().FirstName} {Addresses.First().LastName}" : string.Empty; diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs index 364e0d7b..534515a1 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs @@ -333,12 +333,6 @@ public string? OriginUrl /// public List? Tags { get; set; } - /// - /// The payment account ID to use to receive Direct Debit payments. This must match one of your - /// NoFrixion payment account IDs. This can be left blank to use your default payment account. - /// - public Guid? DirectDebitAccountID { get; set; } - public NoFrixionProblem Validate() { var context = new ValidationContext(this, serviceProvider: null, items: null); @@ -412,7 +406,6 @@ public Dictionary ToDictionary() dict.Add(nameof(Title), Title ?? string.Empty); dict.Add(nameof(PartialPaymentSteps), PartialPaymentSteps ?? string.Empty); dict.Add(nameof(NotificationEmailAddresses), NotificationEmailAddresses ?? string.Empty); - dict.Add(nameof(DirectDebitAccountID), DirectDebitAccountID?.ToString() ?? string.Empty); if (TagIds?.Count() > 0) { diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs index 62e68ef4..e4fc6cac 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs @@ -233,12 +233,6 @@ public class PaymentRequestUpdate /// Date and time of expiration of the lightning invoice. /// public DateTimeOffset? LightningInvoiceExpiresAt { get; set; } - - /// - /// The payment account ID to use to receive Direct Debit payments. This must match one of your - /// NoFrixion payment account IDs. This can be left blank to use your default payment account. - /// - public Guid? DirectDebitAccountID { get; set; } /// /// Places all the payment request's properties into a dictionary. Useful for testing From 57bdd5e9cdc03fababd854e93505a455bc5cf6cc Mon Sep 17 00:00:00 2001 From: Aaron Clauson Date: Tue, 15 Oct 2024 16:48:40 +0100 Subject: [PATCH 07/14] Deprecates the PaymentMethodTypes flag enum property in favour of a List (#432) * Repalce use of flag enums on public payment request models with list for openapi generator compatibility. * Simplified use of old and new payment method types properties. * Add ulong handler to flag enum extenions methods. --- .../Extensions/EnumExtensions.cs | 85 +++++++++++++++++++ .../JsonConverters/NumericConverter.cs | 1 - .../Models/PaymentRequests/IPaymentRequest.cs | 5 +- .../Models/PaymentRequests/PaymentRequest.cs | 12 ++- .../PaymentRequests/PaymentRequestCreate.cs | 35 +++++++- .../PaymentRequests/PaymentRequestMinimal.cs | 12 ++- .../PaymentRequests/PaymentRequestUpdate.cs | 43 +++++++++- .../PaymentRequestValidator.cs | 3 + .../Mapping/CsvMapperTests.cs | 4 + .../Models/PaymentRequestCreateTests.cs | 16 ++-- .../PaymentRequestEmailNotificationTests.cs | 4 +- .../Models/PaymentRequestResultTests.cs | 4 +- 12 files changed, 204 insertions(+), 20 deletions(-) create mode 100644 src/NoFrixion.MoneyMoov/Extensions/EnumExtensions.cs diff --git a/src/NoFrixion.MoneyMoov/Extensions/EnumExtensions.cs b/src/NoFrixion.MoneyMoov/Extensions/EnumExtensions.cs new file mode 100644 index 00000000..c9d7cdd8 --- /dev/null +++ b/src/NoFrixion.MoneyMoov/Extensions/EnumExtensions.cs @@ -0,0 +1,85 @@ +//----------------------------------------------------------------------------- +// Filename: GuidExtensions.cs +// +// Description: Contains extension methods for Guid types: +// +// Author(s): +// Aaron Clauson (aaron@nofrixion.com) +// +// History: +// 15 Oct 2024 Aaron Clauson Created, Carne, Wexford, Ireland. +// +// License: +// Proprietary NoFrixion. +//----------------------------------------------------------------------------- + +namespace NoFrixion.MoneyMoov; + +public static class EnumExtensions +{ + /// + /// This method converts an Enum with the Flags attribute to a list of Enums. + /// + public static List ToList(this T flags) where T : Enum + { + if (!typeof(T).IsDefined(typeof(FlagsAttribute), false)) + { + throw new ArgumentException("The type parameter T must have the Flags attribute.", nameof(flags)); + } + + // Check if the enum underlying type is ulong + var underlyingType = Enum.GetUnderlyingType(typeof(T)); + + if (underlyingType == typeof(ulong)) + { + return Enum.GetValues(typeof(T)) + .Cast() + .Where(value => flags.HasFlag(value) && Convert.ToUInt64(value) != 0) // Exclude None or 0 + .ToList(); + } + else + { + return Enum.GetValues(typeof(T)) + .Cast() + .Where(value => flags.HasFlag(value) && Convert.ToInt32(value) != 0) // Exclude None or 0 + .ToList(); + } + } + + /// + /// This method converts list of flag enum values to a single flag enum. + /// + public static T ToFlagEnum(this IEnumerable enumValues) where T : Enum + { + if (!typeof(T).IsDefined(typeof(FlagsAttribute), false)) + { + throw new ArgumentException("The type parameter T must have the Flags attribute.", nameof(enumValues)); + } + + // Check if the enum underlying type is ulong + var underlyingType = Enum.GetUnderlyingType(typeof(T)); + + if (underlyingType == typeof(ulong)) + { + ulong result = 0UL; + + foreach (var value in enumValues) + { + result |= Convert.ToUInt64(value); + } + + return (T)Enum.ToObject(typeof(T), result); + } + else + { + int result = 0; + + foreach (var value in enumValues) + { + result |= Convert.ToInt32(value); + } + + return (T)Enum.ToObject(typeof(T), result); + } + } +} \ No newline at end of file diff --git a/src/NoFrixion.MoneyMoov/JsonConverters/NumericConverter.cs b/src/NoFrixion.MoneyMoov/JsonConverters/NumericConverter.cs index 12f25a1a..91fd5f0c 100755 --- a/src/NoFrixion.MoneyMoov/JsonConverters/NumericConverter.cs +++ b/src/NoFrixion.MoneyMoov/JsonConverters/NumericConverter.cs @@ -14,7 +14,6 @@ // MIT. //----------------------------------------------------------------------------- -using LanguageExt; using System.ComponentModel; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs index 268220bf..7bda8e23 100644 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/IPaymentRequest.cs @@ -26,7 +26,10 @@ public interface IPaymentRequest public string? OrderID { get; set; } - public PaymentMethodTypeEnum PaymentMethodTypes { get; set; } + [Obsolete("This field has been deprecated. Please use PaymentMethods instead.")] + public PaymentMethodTypeEnum PaymentMethodTypes { get; } + + public List PaymentMethods { get; set; } public string? Description { get; set; } diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs index 1a397cbb..4740912a 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs @@ -57,7 +57,17 @@ public class PaymentRequest : IPaymentRequest, IWebhookPayload /// The payment methods that the payment request supports. When setting using form data /// should be supplied as a comma separated list, for example "card, pisp, lightning". /// - public PaymentMethodTypeEnum PaymentMethodTypes { get; set; } = PaymentMethodTypeEnum.card; + [Obsolete("This field has been deprecated. Please use PaymentMethods instead.")] + public PaymentMethodTypeEnum PaymentMethodTypes + { + get => + PaymentMethods.Any() ? PaymentMethods.ToFlagEnum() : PaymentMethodTypeEnum.None; + } + + /// + /// The payment methods that the payment request supports. + /// + public List PaymentMethods { get; set; } = new List(); /// /// An optional description for the payment request. If set this field will appear diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs index 534515a1..16042ef9 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs @@ -14,6 +14,7 @@ //----------------------------------------------------------------------------- using NoFrixion.MoneyMoov.Attributes; +using NoFrixion.MoneyMoov.Json; using System.ComponentModel.DataAnnotations; namespace NoFrixion.MoneyMoov.Models; @@ -62,7 +63,28 @@ public class PaymentRequestCreate : IValidatableObject, IPaymentRequest /// The payment methods that the payment request supports. When setting using form data /// should be supplied as a comma separated list, for example "card, pisp, lightning". /// - public PaymentMethodTypeEnum PaymentMethodTypes { get; set; } = PaymentMethodTypeEnum.card; + [Obsolete("This field has been deprecated. Please use PaymentMethods instead.")] + public PaymentMethodTypeEnum PaymentMethodTypes { + get => + PaymentMethods.Any() ? PaymentMethods.ToFlagEnum() : PaymentMethodTypeEnum.None; + + init + { + if(value == PaymentMethodTypeEnum.None) + { + PaymentMethods.Clear(); + } + else + { + PaymentMethods = value.ToList(); + } + } + } + + /// + /// The payment methods that the payment request supports. + /// + public List PaymentMethods { get; set; } = new() { PaymentMethodTypeEnum.card }; /// /// An optional description for the payment request. If set this field will appear @@ -376,7 +398,6 @@ public Dictionary ToDictionary() dict.Add(nameof(Currency), Currency.ToString()); dict.Add(nameof(CustomerID), CustomerID ?? string.Empty); dict.Add(nameof(OrderID), OrderID ?? string.Empty); - dict.Add(nameof(PaymentMethodTypes), PaymentMethodTypes.ToString()); dict.Add(nameof(Description), Description ?? string.Empty); dict.Add(nameof(BaseOriginUrl), BaseOriginUrl!); dict.Add(nameof(CallbackUrl), CallbackUrl!); @@ -407,6 +428,16 @@ public Dictionary ToDictionary() dict.Add(nameof(PartialPaymentSteps), PartialPaymentSteps ?? string.Empty); dict.Add(nameof(NotificationEmailAddresses), NotificationEmailAddresses ?? string.Empty); + if (PaymentMethods?.Count() > 0) + { + int paymentMethodNumber = 0; + foreach (var paymentMethod in PaymentMethods) + { + dict.Add($"{nameof(PaymentMethods)}[{paymentMethodNumber}]", paymentMethod.ToString()); + paymentMethodNumber++; + } + } + if (TagIds?.Count() > 0) { int tagIdNumber = 0; diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestMinimal.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestMinimal.cs index 99a676bf..bb236bfb 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestMinimal.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestMinimal.cs @@ -69,7 +69,17 @@ public class PaymentRequestMinimal /// The payment methods that the payment request supports. When setting using form data /// should be supplied as a comma separated list, for example "card, pisp, lightning, applePay". /// - public PaymentMethodTypeEnum PaymentMethods { get; set; } + [Obsolete("This field has been deprecated. Please use PaymentMethodsList instead.")] + public PaymentMethodTypeEnum PaymentMethods + { + get => + PaymentMethodsList.Aggregate(PaymentMethodTypeEnum.None, (current, method) => current | method); + } + + /// + /// The payment methods that the payment request supports. + /// + public List PaymentMethodsList { get; set; } = new List(); /// /// This is the error returned from the bank which is recorded in payment request events. diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs index e4fc6cac..48bd6b05 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestUpdate.cs @@ -45,7 +45,37 @@ public class PaymentRequestUpdate /// The payment methods that the payment request supports. When setting using form data /// should be supplied as a comma separated list, for example "card, pisp, lightning". /// - public PaymentMethodTypeEnum? PaymentMethodTypes { get; set; } + [Obsolete("This field has been deprecated. Please use PaymentMethods instead.")] + public PaymentMethodTypeEnum? PaymentMethodTypes + { + get => + PaymentMethods != null && PaymentMethods.Any() ? PaymentMethods.ToFlagEnum() : PaymentMethodTypeEnum.None; + + init + { + if (value != null) + { + if (PaymentMethods == null) + { + PaymentMethods = new(); + } + + if (value == PaymentMethodTypeEnum.None) + { + PaymentMethods.Clear(); + } + else + { + PaymentMethods = value.Value.ToList(); + } + } + } + } + + /// + /// The payment methods that the payment request supports. + /// + public List? PaymentMethods { get; set; } /// /// An optional description for the payment request. If set this field will appear @@ -248,7 +278,6 @@ public Dictionary ToDictionary() if (Currency != null) dict.Add(nameof(Currency), Currency.Value.ToString()); if (CustomerID != null) dict.Add(nameof(CustomerID), CustomerID); if (OrderID != null) dict.Add(nameof(OrderID), OrderID); - if (PaymentMethodTypes != null) dict.Add(nameof(PaymentMethodTypes), PaymentMethodTypes.Value.ToString()); if (Description != null) dict.Add(nameof(Description), Description); if (PispAccountID != null) dict.Add(nameof(PispAccountID), PispAccountID.GetValueOrDefault().ToString()); if (ShippingFirstName != null) dict.Add(nameof(ShippingFirstName), ShippingFirstName); @@ -274,6 +303,16 @@ public Dictionary ToDictionary() if (Title != null) dict.Add(nameof(Title), Title); if (PartialPaymentSteps != null) dict.Add(nameof(PartialPaymentSteps), PartialPaymentSteps); + if (PaymentMethods?.Count() > 0) + { + int paymentMethodNumber = 0; + foreach (var paymentMethod in PaymentMethods) + { + dict.Add($"{nameof(PaymentMethods)}[{paymentMethodNumber}]", paymentMethod.ToString()); + paymentMethodNumber++; + } + } + return dict; } } \ No newline at end of file diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestValidator.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestValidator.cs index 2195e3de..b276082f 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestValidator.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestValidator.cs @@ -30,10 +30,12 @@ public static IEnumerable Validate( IPaymentRequest paymentRequest, ValidationContext validationContext) { +#pragma warning disable CS0618 // Type or member is obsolete if (paymentRequest.PaymentMethodTypes == PaymentMethodTypeEnum.None) { yield return new ValidationResult($"At least one payment method type must be specified.", new string[] { nameof(paymentRequest.PaymentMethodTypes) }); } + if (paymentRequest.PaymentMethodTypes.HasFlag(PaymentMethodTypeEnum.pisp) && paymentRequest.Currency == CurrencyTypeEnum.EUR && !ValidateAmount(paymentRequest.Amount, paymentRequest.PaymentMethodTypes, paymentRequest.Currency)) @@ -66,6 +68,7 @@ public static IEnumerable Validate( yield return new ValidationResult($"The amount can only be set to 0 when the payment methods are set to a single option of card.", new string[] { nameof(paymentRequest.Amount) }); } +#pragma warning restore CS0618 // Type or member is obsolete if (!string.IsNullOrEmpty(paymentRequest.BaseOriginUrl)) { diff --git a/test/MoneyMoov.UnitTests/Mapping/CsvMapperTests.cs b/test/MoneyMoov.UnitTests/Mapping/CsvMapperTests.cs index a8e44092..831dece3 100755 --- a/test/MoneyMoov.UnitTests/Mapping/CsvMapperTests.cs +++ b/test/MoneyMoov.UnitTests/Mapping/CsvMapperTests.cs @@ -104,7 +104,9 @@ public void CarDealer_Payment_Request_Create_Success() Assert.Equal(39400M, results[0].Model.Amount); Assert.Equal(CurrencyTypeEnum.EUR, results[0].Model.Currency); Assert.Equal("5001834", results[0].Model.OrderID); +#pragma warning disable CS0618 // Type or member is obsolete Assert.Equal(PaymentMethodTypeEnum.pisp, results[0].Model.PaymentMethodTypes); +#pragma warning restore CS0618 // Type or member is obsolete Assert.Equal("RANGE ROVER TDV8", results[0].Model.Description); Assert.Equal("Jane", results[0].Model.ShippingFirstName); Assert.Equal("Doe", results[0].Model.ShippingLastName); @@ -160,7 +162,9 @@ public void CarDealer_UpdateSep2023_Payment_Request_Create_Success() Assert.Equal(10000M, results[0].Model.Amount); Assert.Equal(CurrencyTypeEnum.EUR, results[0].Model.Currency); Assert.Equal("5002027", results[0].Model.OrderID); +#pragma warning disable CS0618 // Type or member is obsolete Assert.Equal(PaymentMethodTypeEnum.pisp, results[0].Model.PaymentMethodTypes); +#pragma warning restore CS0618 // Type or member is obsolete Assert.Equal("Order for car XXX", results[0].Model.Description); Assert.Equal(string.Empty, results[0].Model.ShippingFirstName); Assert.Equal(string.Empty, results[0].Model.ShippingLastName); diff --git a/test/MoneyMoov.UnitTests/Models/PaymentRequestCreateTests.cs b/test/MoneyMoov.UnitTests/Models/PaymentRequestCreateTests.cs index 092dbc69..ac0e448c 100755 --- a/test/MoneyMoov.UnitTests/Models/PaymentRequestCreateTests.cs +++ b/test/MoneyMoov.UnitTests/Models/PaymentRequestCreateTests.cs @@ -161,7 +161,7 @@ public void Create_PaymentRequest_Zero_Amount_Failure() Currency = CurrencyTypeEnum.EUR, CallbackUrl = "https://localhost/good", BaseOriginUrl = "https://localhost", - PaymentMethodTypes = PaymentMethodTypeEnum.card | PaymentMethodTypeEnum.lightning + PaymentMethods = new() { PaymentMethodTypeEnum.card, PaymentMethodTypeEnum.lightning } }; var context = new ValidationContext(this, serviceProvider: null, items: null); @@ -231,7 +231,7 @@ public void Create_PaymentRequestCreate_Amount_Too_Low_EUR_PIS() Amount = 0.99M, Currency = CurrencyTypeEnum.EUR, CallbackUrl = "https://localhost/callback", - PaymentMethodTypes = PaymentMethodTypeEnum.pisp + PaymentMethods = new() { PaymentMethodTypeEnum.pisp } }; var validationProb = paymentRequest.Validate(); @@ -251,7 +251,7 @@ public void Create_PaymentRequestCreate_EUR_PIS() Amount = 1.00M, Currency = CurrencyTypeEnum.EUR, CallbackUrl = "https://localhost/callback", - PaymentMethodTypes = PaymentMethodTypeEnum.pisp + PaymentMethods = new() { PaymentMethodTypeEnum.pisp } }; var validationProb = paymentRequest.Validate(); @@ -271,7 +271,7 @@ public void Create_PaymentRequestCreate_Amount_Too_Low_GBP_PIS() Amount = 1.99M, Currency = CurrencyTypeEnum.GBP, CallbackUrl = "https://localhost/callback", - PaymentMethodTypes = PaymentMethodTypeEnum.pisp + PaymentMethods = new() { PaymentMethodTypeEnum.pisp } }; var validationProb = paymentRequest.Validate(); @@ -291,7 +291,7 @@ public void Create_PaymentRequestCreate_GBP_PIS() Amount = 2.00M, Currency = CurrencyTypeEnum.GBP, CallbackUrl = "https://localhost/callback", - PaymentMethodTypes = PaymentMethodTypeEnum.pisp + PaymentMethods = new() { PaymentMethodTypeEnum.pisp } }; var validationProb = paymentRequest.Validate(); @@ -312,7 +312,7 @@ public void Create_PaymentRequestCreate_Card_Token_With_Customer_Email() Currency = CurrencyTypeEnum.EUR, CallbackUrl = "https://localhost/callback", BaseOriginUrl = "https://localhost", - PaymentMethodTypes = PaymentMethodTypeEnum.card, + PaymentMethods = new() { PaymentMethodTypeEnum.card }, CardCreateToken = true, CardCreateTokenMode = CardTokenCreateModes.ConsentNotRequired, CustomerEmailAddress = "qa@nofrixion.com" @@ -336,7 +336,7 @@ public void Create_PaymentRequestCreate_Card_Token_But_No_Customer_Email() Currency = CurrencyTypeEnum.GBP, CallbackUrl = "https://localhost/callback", BaseOriginUrl = "https://localhost", - PaymentMethodTypes = PaymentMethodTypeEnum.card, + PaymentMethods = new() { PaymentMethodTypeEnum.card }, CardCreateToken = true }; @@ -359,7 +359,7 @@ public void Create_PaymentRequestCreate_Card_Token_With_Invalid_Customer_Email() Currency = CurrencyTypeEnum.EUR, CallbackUrl = "https://localhost/callback", BaseOriginUrl = "https://localhost", - PaymentMethodTypes = PaymentMethodTypeEnum.card, + PaymentMethods = new() { PaymentMethodTypeEnum.card }, CardCreateToken = true, CustomerEmailAddress = "qa-nofrixion.com" }; diff --git a/test/MoneyMoov.UnitTests/Models/PaymentRequestEmailNotificationTests.cs b/test/MoneyMoov.UnitTests/Models/PaymentRequestEmailNotificationTests.cs index 0754abce..b9e88b58 100644 --- a/test/MoneyMoov.UnitTests/Models/PaymentRequestEmailNotificationTests.cs +++ b/test/MoneyMoov.UnitTests/Models/PaymentRequestEmailNotificationTests.cs @@ -54,7 +54,7 @@ public void Substitute_Test() { ID = Guid.NewGuid(), Currency = CurrencyTypeEnum.EUR, - PaymentMethodTypes = PaymentMethodTypeEnum.card | PaymentMethodTypeEnum.pisp, + PaymentMethods = new List { PaymentMethodTypeEnum.card, PaymentMethodTypeEnum.pisp }, CustomerEmailAddress = "jane.doe@nofrixion.com", Amount = 10001.99M, Title = "Super Title", @@ -117,7 +117,7 @@ public void Substitute_With_PaymentRequest_And_Dictionary_Test() { ID = Guid.NewGuid(), Currency = CurrencyTypeEnum.EUR, - PaymentMethodTypes = PaymentMethodTypeEnum.card | PaymentMethodTypeEnum.pisp, + PaymentMethods = new List { PaymentMethodTypeEnum.card, PaymentMethodTypeEnum.pisp }, CustomerEmailAddress = "jane.doe@nofrixion.com", Amount = 10001.99M, Title = "Super Title", diff --git a/test/MoneyMoov.UnitTests/Models/PaymentRequestResultTests.cs b/test/MoneyMoov.UnitTests/Models/PaymentRequestResultTests.cs index c23a1a5e..1c6ba45c 100755 --- a/test/MoneyMoov.UnitTests/Models/PaymentRequestResultTests.cs +++ b/test/MoneyMoov.UnitTests/Models/PaymentRequestResultTests.cs @@ -378,7 +378,7 @@ private PaymentRequest GetTestPaymentRequest() var merchantID = Guid.NewGuid(); var amount = 0.42M; var currency = CurrencyTypeEnum.EUR; - var paymentMethods = PaymentMethodTypeEnum.card | PaymentMethodTypeEnum.lightning; + var paymentMethods = new List { PaymentMethodTypeEnum.card, PaymentMethodTypeEnum.lightning }; var description = "desc"; var customerID = "cid"; var orderID = "oid"; @@ -392,7 +392,7 @@ private PaymentRequest GetTestPaymentRequest() MerchantID = merchantID, Amount = amount, Currency = currency, - PaymentMethodTypes = paymentMethods, + PaymentMethods = paymentMethods, Description = description, CustomerID = customerID, OrderID = orderID, From 44d76881c5c004f25fd0c873bca5089586a8d944 Mon Sep 17 00:00:00 2001 From: Aaron Clauson Date: Tue, 15 Oct 2024 18:57:55 +0100 Subject: [PATCH 08/14] Return the merchant supported payment methods as a list. (#433) --- src/NoFrixion.MoneyMoov/Models/Merchant/Merchant.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/NoFrixion.MoneyMoov/Models/Merchant/Merchant.cs b/src/NoFrixion.MoneyMoov/Models/Merchant/Merchant.cs index ceae698a..81c9284f 100755 --- a/src/NoFrixion.MoneyMoov/Models/Merchant/Merchant.cs +++ b/src/NoFrixion.MoneyMoov/Models/Merchant/Merchant.cs @@ -101,13 +101,19 @@ public class Merchant /// For internal use only. /// public string? ModulrCustomerID { get; set; } - + /// /// The payment methods that are configured and supported for this merchant. /// Returned as a comma-separated list of PaymentMethodTypeEnum values. /// + [Obsolete("Please usse SupportedPaymentMethodsList instead.")] public PaymentMethodTypeEnum SupportedPaymentMethods { get; set; } + /// + /// The payment methods that are configured and supported for this merchant. + /// + public List SupportedPaymentMethodsList { get; set; } = new List(); + /// /// The role of the identity that loaded the merchant record. /// From 972fa4f87ea26e580e6e45d833cd03fe7f92d89b Mon Sep 17 00:00:00 2001 From: sauravmaiti22 Date: Wed, 16 Oct 2024 09:59:37 +0100 Subject: [PATCH 09/14] Send tribe load failure webhook --- .../Enums/WebhookResourceTypesEnum.cs | 7 +++- .../Models/Tribe/TribeLoad.cs | 40 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/NoFrixion.MoneyMoov/Models/Tribe/TribeLoad.cs diff --git a/src/NoFrixion.MoneyMoov/Enums/WebhookResourceTypesEnum.cs b/src/NoFrixion.MoneyMoov/Enums/WebhookResourceTypesEnum.cs index 391df602..fba2d76c 100755 --- a/src/NoFrixion.MoneyMoov/Enums/WebhookResourceTypesEnum.cs +++ b/src/NoFrixion.MoneyMoov/Enums/WebhookResourceTypesEnum.cs @@ -67,6 +67,11 @@ public enum WebhookResourceTypesEnum /// /// Will trigger notifications for report, including account statement, related events. /// - Report = 64 + Report = 64, + + /// + /// Will trigger notifications for tribe load event + /// + TribeLoad = 128, } diff --git a/src/NoFrixion.MoneyMoov/Models/Tribe/TribeLoad.cs b/src/NoFrixion.MoneyMoov/Models/Tribe/TribeLoad.cs new file mode 100644 index 00000000..b504ffeb --- /dev/null +++ b/src/NoFrixion.MoneyMoov/Models/Tribe/TribeLoad.cs @@ -0,0 +1,40 @@ +//----------------------------------------------------------------------------- +// Filename: TribeLoad.cs +// +// Description: Represents a load into a tribe account. +// +// Author(s): +// Saurav Maiti (saurav@nofrixion.com) +// +// History: +// 15 Oct 2024 Saurav Maiti Created, Harcourt street, Dublin, Ireland. +// +// License: +// Proprietary NoFrixion. +// ----------------------------------------------------------------------------- + +namespace NoFrixion.MoneyMoov.Models; + +public class TribeLoad: IWebhookPayload +{ + /// + /// Represents the transaction that was attempted to + /// be loaded into the tribe account. + /// + public required Transaction Transaction { get; set; } + + /// + /// Represents the problem that occurred when attempting to + /// load the transaction into the tribe account. + /// + public string? FailureReason { get; set; } + + public Guid ID { get; set; } + + /// + /// The ID of the merchant that the tribe account belongs to. + /// + public Guid MerchantID { get; set; } + + public DateTimeOffset Inserted { get; set; } +} \ No newline at end of file From bf11fa849f001ee07602eb76a63315713c52f385 Mon Sep 17 00:00:00 2001 From: sauravmaiti22 Date: Wed, 16 Oct 2024 10:27:02 +0100 Subject: [PATCH 10/14] Changed license to MIT --- src/NoFrixion.MoneyMoov/Models/Tribe/TribeLoad.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NoFrixion.MoneyMoov/Models/Tribe/TribeLoad.cs b/src/NoFrixion.MoneyMoov/Models/Tribe/TribeLoad.cs index b504ffeb..c94e48e5 100644 --- a/src/NoFrixion.MoneyMoov/Models/Tribe/TribeLoad.cs +++ b/src/NoFrixion.MoneyMoov/Models/Tribe/TribeLoad.cs @@ -10,7 +10,7 @@ // 15 Oct 2024 Saurav Maiti Created, Harcourt street, Dublin, Ireland. // // License: -// Proprietary NoFrixion. +// MIT // ----------------------------------------------------------------------------- namespace NoFrixion.MoneyMoov.Models; From 95a06392a2a53e73dc2531f7c310595ac456140c Mon Sep 17 00:00:00 2001 From: Aaron Clauson Date: Wed, 16 Oct 2024 14:26:43 +0100 Subject: [PATCH 11/14] Removes teh DD mandate amount from the public model. Not currently being used and causes confusion. (#435) --- src/NoFrixion.MoneyMoov/Models/Mandates/Mandate.cs | 9 ++++++--- src/NoFrixion.MoneyMoov/Models/Mandates/MandateCreate.cs | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/NoFrixion.MoneyMoov/Models/Mandates/Mandate.cs b/src/NoFrixion.MoneyMoov/Models/Mandates/Mandate.cs index 0c15ffc0..1ff11af5 100755 --- a/src/NoFrixion.MoneyMoov/Models/Mandates/Mandate.cs +++ b/src/NoFrixion.MoneyMoov/Models/Mandates/Mandate.cs @@ -112,11 +112,14 @@ public class Mandate /// /// Currency of this mandate. /// - public CurrencyTypeEnum Currency { get; set; } - + public CurrencyTypeEnum Currency { get; set; } + /// - /// Amount of this mandate. + /// This is an optional field that with mandates created via Account Information Services can be + /// used to do a balance check on the payer's account. We don't currenlty support the AIS workflow. /// + [System.Text.Json.Serialization.JsonIgnore] + [Newtonsoft.Json.JsonProperty] public decimal Amount { get; set; } /// diff --git a/src/NoFrixion.MoneyMoov/Models/Mandates/MandateCreate.cs b/src/NoFrixion.MoneyMoov/Models/Mandates/MandateCreate.cs index 4deac1d3..416a2133 100644 --- a/src/NoFrixion.MoneyMoov/Models/Mandates/MandateCreate.cs +++ b/src/NoFrixion.MoneyMoov/Models/Mandates/MandateCreate.cs @@ -124,10 +124,11 @@ public class MandateCreate public CurrencyTypeEnum Currency { get; set; } /// - /// Amount of the mandate. + /// This is an optional field that with mandates created via Account Information Services can be + /// used to do a balance check on the payer's account. We don't currenlty support the AIS workflow. /// - [Required(ErrorMessage = "Please, specify an amount.")] - [Range(0.00001, double.MaxValue, ErrorMessage = "Minimum value of 0.00001 is required for Amount")] + [System.Text.Json.Serialization.JsonIgnore] + [Newtonsoft.Json.JsonProperty] public decimal Amount { get; set; } /// From f2a633661f9550cd0ed7f6838c4d4111822a2048 Mon Sep 17 00:00:00 2001 From: Aaron Clauson Date: Wed, 16 Oct 2024 20:31:38 +0100 Subject: [PATCH 12/14] Add DD mandate ID to payreq evt model. Fix bug where jsonproperty was being used instead of jsonignore. (#436) --- src/NoFrixion.MoneyMoov/Models/Mandates/Mandate.cs | 2 +- .../Models/Mandates/MandateCreate.cs | 4 ++-- .../Models/PaymentRequests/PaymentRequest.cs | 4 ++-- .../Models/PaymentRequests/PaymentRequestCreate.cs | 6 +++--- .../Models/PaymentRequests/PaymentRequestEvent.cs | 14 +++++++++----- src/NoFrixion.MoneyMoov/Models/Payouts/Payout.cs | 12 ++++++------ src/NoFrixion.MoneyMoov/NoFrixionProblem.cs | 4 ++-- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/NoFrixion.MoneyMoov/Models/Mandates/Mandate.cs b/src/NoFrixion.MoneyMoov/Models/Mandates/Mandate.cs index 1ff11af5..9888d866 100755 --- a/src/NoFrixion.MoneyMoov/Models/Mandates/Mandate.cs +++ b/src/NoFrixion.MoneyMoov/Models/Mandates/Mandate.cs @@ -119,7 +119,7 @@ public class Mandate /// used to do a balance check on the payer's account. We don't currenlty support the AIS workflow. /// [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public decimal Amount { get; set; } /// diff --git a/src/NoFrixion.MoneyMoov/Models/Mandates/MandateCreate.cs b/src/NoFrixion.MoneyMoov/Models/Mandates/MandateCreate.cs index 416a2133..0bad495b 100644 --- a/src/NoFrixion.MoneyMoov/Models/Mandates/MandateCreate.cs +++ b/src/NoFrixion.MoneyMoov/Models/Mandates/MandateCreate.cs @@ -127,8 +127,8 @@ public class MandateCreate /// This is an optional field that with mandates created via Account Information Services can be /// used to do a balance check on the payer's account. We don't currenlty support the AIS workflow. /// - [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [System.Text.Json.Serialization.JsonIgnore] + [Newtonsoft.Json.JsonIgnore] public decimal Amount { get; set; } /// diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs index 4740912a..f2c41752 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequest.cs @@ -236,7 +236,7 @@ public PaymentMethodTypeEnum PaymentMethodTypes public string? CardStripePaymentIntentSecret { get; set; } [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public Merchant? Merchant { get; set; } public List Addresses { get; set; } = new List(); @@ -287,7 +287,7 @@ public PaymentMethodTypeEnum PaymentMethodTypes /// /// The billing address or null if it's not set. [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public PaymentRequestAddress? BillingAddress => Addresses?.Where(x => x.AddressType == AddressTypesEnum.Billing).FirstOrDefault(); diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs index 16042ef9..e664477b 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestCreate.cs @@ -308,15 +308,15 @@ public string? OriginUrl public string? CustomerEmailAddress { get; set; } [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public PaymentProcessorsEnum PaymentProcessor { get; set; } [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public string? LightningInvoice { get; set; } [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public DateTimeOffset? LightningInvoiceExpiresAt { get; set; } [EmailAddressMultiple(ErrorMessage = PaymentRequestConstants.NOTIFICATION_EMAIL_ADDRESSES_ERROR_MESSAGE)] diff --git a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestEvent.cs b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestEvent.cs index 7daa1c5e..30228c41 100755 --- a/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestEvent.cs +++ b/src/NoFrixion.MoneyMoov/Models/PaymentRequests/PaymentRequestEvent.cs @@ -17,7 +17,6 @@ // MIT. //----------------------------------------------------------------------------- -using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; namespace NoFrixion.MoneyMoov.Models; @@ -44,11 +43,11 @@ public class PaymentRequestEvent public string? ErrorMessage { get; set; } [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public string? RawResponse { get; set; } [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public string? RawResponseHash { get; set; } public string? CardRequestID { get; set; } @@ -101,7 +100,7 @@ public class PaymentRequestEvent /// between submitting and finalising a payment initiation attempt. /// [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public string? PispToken { get; set; } /// @@ -139,7 +138,7 @@ public class PaymentRequestEvent /// of the tokenised card record that can be used with the pay with card token method. /// [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public Guid? TokenisedCardID { get; set; } /// @@ -164,6 +163,11 @@ public class PaymentRequestEvent /// public string? DirectDebitPaymentReference { get; set; } + /// + /// The ID of the mandate that was used wehn requesting payment. + /// + public Guid? DrirectDebitMandateID { get; set; } + /// /// Gets the amount to display with the correct number of decimal places based on the currency type. /// diff --git a/src/NoFrixion.MoneyMoov/Models/Payouts/Payout.cs b/src/NoFrixion.MoneyMoov/Models/Payouts/Payout.cs index 26dafe03..50f4cbd1 100755 --- a/src/NoFrixion.MoneyMoov/Models/Payouts/Payout.cs +++ b/src/NoFrixion.MoneyMoov/Models/Payouts/Payout.cs @@ -102,7 +102,7 @@ public class Payout : IValidatableObject, IWebhookPayload [Obsolete("Please use Destination.")] [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public Guid? DestinationAccountID { get => Destination?.AccountID; @@ -115,7 +115,7 @@ public Guid? DestinationAccountID [Obsolete("Please use Destination.")] [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public string? DestinationIBAN { get => Destination?.Identifier?.IBAN; @@ -129,7 +129,7 @@ public string? DestinationIBAN [Obsolete("Please use Destination.")] [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public string? DestinationAccountNumber { get => Destination?.Identifier?.AccountNumber; @@ -143,7 +143,7 @@ public string? DestinationAccountNumber [Obsolete("Please use Destination.")] [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public string? DestinationSortCode { get => Destination?.Identifier?.SortCode; @@ -157,7 +157,7 @@ public string? DestinationSortCode [Obsolete("Please use Destination.")] [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public string? DestinationAccountName { get => Destination?.Name; @@ -265,7 +265,7 @@ public AccountIdentifier? SourceAccountIdentifier [Obsolete("Please use Destination.")] [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] public Counterparty? DestinationAccount { get => Destination; diff --git a/src/NoFrixion.MoneyMoov/NoFrixionProblem.cs b/src/NoFrixion.MoneyMoov/NoFrixionProblem.cs index 1db1558e..27b10864 100755 --- a/src/NoFrixion.MoneyMoov/NoFrixionProblem.cs +++ b/src/NoFrixion.MoneyMoov/NoFrixionProblem.cs @@ -212,12 +212,12 @@ public static NoFrixionProblem Empty /// unknown, on non-JSON, format. /// [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] [IgnoreDataMember] public string RawError { get; set; } = string.Empty; [System.Text.Json.Serialization.JsonIgnore] - [Newtonsoft.Json.JsonProperty] + [Newtonsoft.Json.JsonIgnore] [IgnoreDataMember] public bool IsEmpty => _isEmpty; From 22d494ae5e89f72815f5f7331fb04002a96f7b83 Mon Sep 17 00:00:00 2001 From: Aaron Clauson Date: Wed, 16 Oct 2024 21:37:41 +0100 Subject: [PATCH 13/14] Add merchant token permissions (#437) * Add DD mandate ID to payreq evt model. Fix bug where jsonproperty was being used instead of jsonignore. * Add DD permissions to merchant token. --- .../Enums/MerchantTokenPermissionsEnum.cs | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/NoFrixion.MoneyMoov/Enums/MerchantTokenPermissionsEnum.cs b/src/NoFrixion.MoneyMoov/Enums/MerchantTokenPermissionsEnum.cs index 2c840cfb..b7454487 100755 --- a/src/NoFrixion.MoneyMoov/Enums/MerchantTokenPermissionsEnum.cs +++ b/src/NoFrixion.MoneyMoov/Enums/MerchantTokenPermissionsEnum.cs @@ -34,80 +34,90 @@ public enum MerchantTokenPermissionsEnum /// /// Permission to edit a payment request /// - EditPaymentRequest = 2, + EditPaymentRequest = 1 << 1, /// /// Permission to delete a payment request /// - DeletePaymentRequest = 4, + DeletePaymentRequest = 1 << 2, /// /// Permission to create a rule /// - CreateRule = 8, + CreateRule = 1 << 3, /// /// Permission to edit a rule /// - EditRule = 16, + EditRule = 1 << 4, /// /// Permission to delete a rule /// - DeleteRule = 32, + DeleteRule = 1 << 5, /// /// Permission to create a payout /// - CreatePayout = 64, + CreatePayout = 1 << 6, /// /// Permission to edit a payout /// - EditPayout = 128, + EditPayout = 1 << 7, /// /// Permission to delete a payout /// - DeletePayout = 256, + DeletePayout = 1 << 8, /// /// Permission to create a report. /// - CreateReport = 512, + CreateReport = 1 << 9, /// /// Permission to edit, retrieve and initiate a report. /// - EditReport = 1024, + EditReport = 1 << 10, /// /// Permission to delete a report. /// - DeleteReport = 2048, + DeleteReport = 1 << 11, /// /// Permission to execute and get report results. /// - ExecuteReport = 4096, + ExecuteReport = 1 << 12, /// /// Permission to create a new payment account. /// - CreatePaymentAccount = 8192, + CreatePaymentAccount = 1 << 13, /// /// Permission to edit details on a payment account. /// - EditPaymentAccount = 16384, + EditPaymentAccount = 1 << 14, /// /// Permission to create and submit a payout from a trusted source. /// - TrustedSubmitPayout = 32768, + TrustedSubmitPayout = 1 << 15, /// - /// Permission to perfrom open banking account information actions. + /// Permission to perform open banking account information actions. /// - OpenBankingAccountInformation = 65536 + OpenBankingAccountInformation = 1 << 16, + + /// + /// Permission to create a direct debit mandate. + /// + CreateDirectDebitMandate = 1 << 17, + + /// + /// Permission to submit a direct debit payment attempt. + /// + SubmitDirectDebitPayment = 1 << 18 } \ No newline at end of file From 5188c2e1a105de57d399c89f081a5c0ee2215394 Mon Sep 17 00:00:00 2001 From: Release Manager Date: Wed, 16 Oct 2024 21:00:10 +0000 Subject: [PATCH 14/14] =?UTF-8?q?=F0=9F=94=96=20Bumped=20to=20moov-1.8.25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/NoFrixion.MoneyMoov/NoFrixion.MoneyMoov.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NoFrixion.MoneyMoov/NoFrixion.MoneyMoov.csproj b/src/NoFrixion.MoneyMoov/NoFrixion.MoneyMoov.csproj index d360c76f..0715b4c0 100755 --- a/src/NoFrixion.MoneyMoov/NoFrixion.MoneyMoov.csproj +++ b/src/NoFrixion.MoneyMoov/NoFrixion.MoneyMoov.csproj @@ -4,8 +4,8 @@ net8.0 enable enable - 1.8.24.0 - 1.8.24.0 + 1.8.25.0 + 1.8.25.0 True True $(NoWarn);1591