diff --git a/src/Modules/OrchardCore.Commerce.Payment/Endpoints/Api/PaymentEndpoint.cs b/src/Modules/OrchardCore.Commerce.Payment/Endpoints/Api/PaymentEndpoint.cs index 5f3bf0ad..5bbf0814 100644 --- a/src/Modules/OrchardCore.Commerce.Payment/Endpoints/Api/PaymentEndpoint.cs +++ b/src/Modules/OrchardCore.Commerce.Payment/Endpoints/Api/PaymentEndpoint.cs @@ -60,14 +60,14 @@ [FromServices] IPaymentService paymentService return httpContext.ChallengeOrForbidApi(); } - if (viewModel.PaymentProviderName.EqualsOrdinalIgnoreCase("Stripe")) + if (viewModel.PaymentProviderName == null) { - return TypedResults.BadRequest("Stripe payment uses ~/checkout/stripe/middleware, not ~/checkout/callback/Stripe."); + return TypedResults.BadRequest($"${nameof(AddCallbackViewModel.PaymentProviderName)} is required."); } - if (string.IsNullOrWhiteSpace(viewModel.OrderId)) + if (viewModel.PaymentProviderName.EqualsOrdinalIgnoreCase("Stripe")) { - viewModel.OrderId = null; + return TypedResults.BadRequest("Stripe payment uses ~/checkout/stripe/middleware, not ~/checkout/callback/Stripe."); } if (await paymentService.CallBackAsync( diff --git a/src/Modules/OrchardCore.Commerce.Payment/Endpoints/Models/AddCallbackViewModel.cs b/src/Modules/OrchardCore.Commerce.Payment/Endpoints/Models/AddCallbackViewModel.cs index 6012c453..53db0b5e 100644 --- a/src/Modules/OrchardCore.Commerce.Payment/Endpoints/Models/AddCallbackViewModel.cs +++ b/src/Modules/OrchardCore.Commerce.Payment/Endpoints/Models/AddCallbackViewModel.cs @@ -1,8 +1,11 @@ -namespace OrchardCore.Commerce.Payment.Endpoints.Models; +using System.ComponentModel.DataAnnotations; + +namespace OrchardCore.Commerce.Payment.Endpoints.Models; public class AddCallbackViewModel { - public string PaymentProviderName { get; set; } + [Required] + public string? PaymentProviderName { get; set; } public string? OrderId { get; set; } public string? ShoppingCartId { get; set; } }