mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-19 13:14:21 +01:00
Fix possible null reference exception when creating a pull payment (#3162)
Co-authored-by: Andrew Camilleri <evilkukka@gmail.com>
This commit is contained in:
@@ -95,9 +95,13 @@ namespace BTCPayServer.Controllers
|
||||
model.PaymentMethodItems =
|
||||
paymentMethodOptions.Select(id => new SelectListItem(id.ToPrettyString(), id.ToString(), true));
|
||||
model.Name ??= string.Empty;
|
||||
model.Currency = model.Currency.ToUpperInvariant().Trim();
|
||||
model.Currency = model.Currency?.ToUpperInvariant()?.Trim() ?? String.Empty;
|
||||
model.PaymentMethods ??= new List<string>();
|
||||
if (!model.PaymentMethods.Any())
|
||||
{
|
||||
// Since we assign all payment methods to be selected by default above we need to update
|
||||
// them here to reflect user's selection so that they can correct their mistake
|
||||
model.PaymentMethodItems = paymentMethodOptions.Select(id => new SelectListItem(id.ToPrettyString(), id.ToString(), false));
|
||||
ModelState.AddModelError(nameof(model.PaymentMethods), "You need at least one payment method");
|
||||
}
|
||||
if (_currencyNameTable.GetCurrencyData(model.Currency, false) is null)
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
</label>
|
||||
</div>
|
||||
}
|
||||
<span asp-validation-for="PaymentMethods" class="text-danger mt-0"></span>
|
||||
</div>
|
||||
|
||||
<h5 class="mt-4 mb-2">Additional Options</h5>
|
||||
|
||||
Reference in New Issue
Block a user