diff --git a/MidrandBookshop/Components/Pages/PaymentFailed.razor.cs b/MidrandBookshop/Components/Pages/PaymentFailed.razor.cs index fe5d385..b6638f1 100644 --- a/MidrandBookshop/Components/Pages/PaymentFailed.razor.cs +++ b/MidrandBookshop/Components/Pages/PaymentFailed.razor.cs @@ -29,10 +29,13 @@ public partial class PaymentFailed User = authState!.User; if (User?.Identity?.IsAuthenticated == false) Navigation.NavigateTo("/login"); + } - if (string.IsNullOrWhiteSpace(PaymentReference)) return; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (!firstRender) return; - long orderId = HashService.DecodeLongIdHash(PaymentReference).Value; + long orderId = HashService.DecodeLongIdHash(PaymentReference!).Value; var customerEmail = User!.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)!.Value!; diff --git a/MidrandBookshop/Components/Pages/PaymentSuccess.razor.cs b/MidrandBookshop/Components/Pages/PaymentSuccess.razor.cs index a1668ff..51b567f 100644 --- a/MidrandBookshop/Components/Pages/PaymentSuccess.razor.cs +++ b/MidrandBookshop/Components/Pages/PaymentSuccess.razor.cs @@ -1,7 +1,6 @@ using LiteCharms.Features; using LiteCharms.Features.Hasher; using LiteCharms.Features.MidrandBooks.Customers; -using LiteCharms.Features.MidrandBooks.Orders; using LiteCharms.Features.MidrandBooks.Payments; using LiteCharms.Features.MidrandBooks.Payments.Models; @@ -10,7 +9,6 @@ namespace MidrandBookshop.Components.Pages; public partial class PaymentSuccess { [Inject] private CartService CartService { get; set; } = default!; - [Inject] private OrderService OrderService { get; set; } = default!; [Inject] private CustomerService CustomerService { get; set; } = default!; [Inject] private PaymentService PaymentService { get; set; } = default!; [Inject] private HashService HashService { get; set; } = default!; @@ -31,6 +29,11 @@ public partial class PaymentSuccess User = authState!.User; if (User?.Identity?.IsAuthenticated == false) Navigation.NavigateTo("/login"); + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (!firstRender) return; long orderId = HashService.DecodeLongIdHash(PaymentReference!).Value; string orderHash = HashService.HashEncodeLongId(orderId).Value;