Skip to content

Commit

Permalink
Fixing null issue
Browse files Browse the repository at this point in the history
  • Loading branch information
wAsnk committed Oct 31, 2024
1 parent 7225adb commit babd6ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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; }
}

0 comments on commit babd6ec

Please sign in to comment.