Skip to content

Commit ee8fd38

Browse files
authored
VCST-2612: Add validation for inactive payment methods (#19)
1 parent b1b4c8c commit ee8fd38

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/VirtoCommerce.XOrder.Core/Validators/OrderErrorDescriber.cs

+5
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,10 @@ public static string PaymentMethodUnavailable(string code)
3838
{
3939
return $"The payment method code:{code} unavailable";
4040
}
41+
42+
public static string PaymentMethodInactive(string gatewayCode)
43+
{
44+
return $"Payment method {gatewayCode} is inactive";
45+
}
4146
}
4247
}

src/VirtoCommerce.XOrder.Core/Validators/PaymentRequestValidator.cs

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public PaymentRequestValidator()
2525
.WithMessage(x => OrderErrorDescriber.PaymentMethodNotFound(x.Payment.GatewayCode))
2626
.When(x => x.Payment != null);
2727

28+
RuleFor(x => x.Payment.PaymentMethod.IsActive)
29+
.Equal(true)
30+
.WithMessage(x => OrderErrorDescriber.PaymentMethodInactive(x.Payment.GatewayCode))
31+
.When(x => x.Payment?.PaymentMethod != null);
32+
2833
RuleFor(x => x.Store)
2934
.NotNull()
3035
.WithMessage(OrderErrorDescriber.StoreNotFound());

0 commit comments

Comments
 (0)