Add contribution payment options to registries

- Added support for single and amount-specific QR codes.
- Updated `RegistrySettings` model and database schema.
- Enhanced `RegistryAdmin` to configure payment options.
- Introduced `RegistryContributionAmount` for partial fulfillment.
- Updated `RegistryPublic` to display contribution progress.
- Added new models for payment methods and QR code handling.
- Improved privacy by limiting contributor visibility.
This commit is contained in:
Arne Moerman
2026-05-18 23:33:06 +02:00
parent 7dd7b0342f
commit c36e04029b
14 changed files with 1211 additions and 21 deletions
@@ -247,6 +247,50 @@ else
</div>
</div>
<div class="mt-3">
<h3>Contribution Payment Options</h3>
<div class="row g-3 mt-2">
<div class="col-md-12">
<label class="form-label">Single QR code URL</label>
<InputText class="form-control" @bind-Value="SettingsModel.ContributionQrCodeUrl" />
<small class="form-text text-muted">Optional: one QR code that donors can scan for any amount.</small>
</div>
</div>
<div class="mt-3">
<div class="d-flex justify-content-between align-items-center">
<h4 class="mb-0">Amount-specific QR codes</h4>
<button type="button" class="btn btn-outline-secondary btn-sm" @onclick="AddContributionAmountQrCode">Add QR amount</button>
</div>
@if (SettingsModel.ContributionAmountQrCodes.Count == 0)
{
<p class="text-muted mt-2 mb-0">No amount-specific QR codes configured.</p>
}
else
{
<div class="mt-2 d-flex flex-column gap-2">
@foreach (var amountQr in SettingsModel.ContributionAmountQrCodes)
{
<div class="row g-2 align-items-end">
<div class="col-md-3">
<label class="form-label">Amount</label>
<InputNumber class="form-control" @bind-Value="amountQr.Amount" />
</div>
<div class="col-md-7">
<label class="form-label">QR code URL</label>
<InputText class="form-control" @bind-Value="amountQr.QrCodeUrl" />
</div>
<div class="col-md-2">
<button type="button" class="btn btn-outline-danger w-100" @onclick="() => RemoveContributionAmountQrCode(amountQr)">Remove</button>
</div>
</div>
}
</div>
}
</div>
</div>
<button class="btn btn-primary mt-4" type="submit">Save settings</button>
</EditForm>
</section>
@@ -39,6 +39,9 @@ public partial class RegistryAdmin : ComponentBase
builder.AddMarkupContent(3, "<span class='ql-formats'><button class='ql-link'></button><button class='ql-clean'></button></span>");
};
private bool _pendingEditorLoad;
private string? _lastLoadedHeaderContentHtml;
protected override async Task OnParametersSetAsync()
{
var userId = await RegistryUserContext.GetUserIdAsync(CancellationToken.None).ConfigureAwait(false);
@@ -60,14 +63,16 @@ public partial class RegistryAdmin : ComponentBase
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender || TextEditor is null || string.IsNullOrWhiteSpace(SettingsModel.HeaderContentHtml))
if (TextEditor is null || !_pendingEditorLoad)
{
return;
}
try
{
await TextEditor.LoadHTMLContent(SettingsModel.HeaderContentHtml).ConfigureAwait(false);
await TextEditor.LoadHTMLContent(SettingsModel.HeaderContentHtml ?? string.Empty).ConfigureAwait(false);
_lastLoadedHeaderContentHtml = SettingsModel.HeaderContentHtml ?? string.Empty;
_pendingEditorLoad = false;
}
catch (JSException)
{
@@ -229,6 +234,17 @@ public partial class RegistryAdmin : ComponentBase
Admins = await RegistryService.GetRegistryAdminsAsync(RegistryId, CancellationToken.None).ConfigureAwait(false);
}
protected void AddContributionAmountQrCode()
{
SettingsModel.ContributionAmountQrCodes.Add(new ContributionAmountQrCodeModel());
}
protected void RemoveContributionAmountQrCode(ContributionAmountQrCodeModel model)
{
ArgumentNullException.ThrowIfNull(model);
SettingsModel.ContributionAmountQrCodes.Remove(model);
}
private async Task LoadAsync()
{
var settings = await RegistryService.GetRegistrySettingsAsync(RegistryId, CancellationToken.None).ConfigureAwait(false);
@@ -244,6 +260,11 @@ public partial class RegistryAdmin : ComponentBase
SettingsModel.BankAccountIban = settings.BankAccountIban;
SettingsModel.BankAccountBic = settings.BankAccountBic;
SettingsModel.ShowBankAccountName = settings.ShowBankAccountName;
SettingsModel.ContributionQrCodeUrl = settings.ContributionQrCodeUrl;
SettingsModel.ContributionAmountQrCodes = settings.ContributionAmountQrCodes;
var currentHeaderContent = SettingsModel.HeaderContentHtml ?? string.Empty;
_pendingEditorLoad = currentHeaderContent != _lastLoadedHeaderContentHtml;
}
Admins = await RegistryService.GetRegistryAdminsAsync(RegistryId, CancellationToken.None).ConfigureAwait(false);
@@ -0,0 +1,75 @@
@page "/registry/{Code}/item/{ItemId:guid}/contribution-amount"
@rendermode InteractiveServer
@using BirthList.Web.Features.Registries
<PageTitle>Contribution Amount</PageTitle>
@if (Registry is null || Item is null)
{
<p>Item not found.</p>
}
else if (!IsAuthenticated)
{
<p>Please log in first.</p>
}
else
{
<div class="registry-shell @RegistryThemeService.GetCssClass(Registry.RegistryType, Registry.ThemeKey)">
<h1>Partially fulfill: @Item.Name</h1>
<div class="card p-3">
@if (RepresentableAmounts.Count == 0)
{
<p class="text-muted mb-0">No representable amount can be formed from configured QR codes up to €200.</p>
}
else
{
<label class="form-label">Select amount: €@SelectedAmount</label>
<input type="range"
class="form-range"
min="0"
max="@(RepresentableAmounts.Count - 1)"
step="1"
@bind="SliderIndex"
@bind:after="RecalculateSuggestions" />
}
@if (Suggestions.Count == 0)
{
<p class="text-muted mt-2">No QR combination available for this amount.</p>
}
else
{
<p class="mt-3 mb-2"><strong>Suggested QR combination:</strong></p>
<ul class="mb-3">
@foreach (var suggestion in Suggestions)
{
<li>@suggestion.RepeatCount x €@suggestion.Amount</li>
}
</ul>
<div class="d-flex flex-column gap-3">
@foreach (var suggestion in Suggestions)
{
@for (var i = 0; i < suggestion.RepeatCount; i++)
{
<div>
<div class="small mb-1">€@suggestion.Amount</div>
<img src="@BuildQrImageUrl(suggestion.QrCodeUrl)" alt="QR code @suggestion.Amount" class="img-fluid" style="max-height: 220px;" />
<div class="small text-muted text-break">
<a href="@suggestion.QrCodeUrl" target="_blank" rel="noopener noreferrer">Open payment link</a>
</div>
</div>
}
}
</div>
}
<div class="d-flex gap-2 mt-3">
<button class="btn btn-success" @onclick="ConfirmAsync" disabled="@(SelectedAmount <= 0)">I transferred this amount</button>
<button class="btn btn-outline-secondary" @onclick="BackToRegistry">Back</button>
</div>
</div>
</div>
}
@@ -0,0 +1,210 @@
using BirthList.Web.Features.Registries;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components;
namespace BirthList.Web.Components.Pages;
[Authorize]
public partial class RegistryContributionAmount : ComponentBase
{
[Parameter] public string Code { get; set; } = string.Empty;
[Parameter] public Guid ItemId { get; set; }
[Inject] private RegistryService RegistryService { get; set; } = null!;
[Inject] private RegistryUserContext RegistryUserContext { get; set; } = null!;
[Inject] private RegistryThemeService RegistryThemeService { get; set; } = null!;
[Inject] private NavigationManager NavigationManager { get; set; } = null!;
protected RegistryPublicViewModel? Registry { get; private set; }
protected RegistryPublicItemViewModel? Item { get; private set; }
protected bool IsAuthenticated { get; private set; }
protected int SelectedAmount { get; private set; }
protected int SliderMin { get; private set; } = 1;
protected int SliderIndex { get; set; }
protected IReadOnlyList<int> RepresentableAmounts { get; private set; } = [];
protected List<QrCombinationSuggestion> Suggestions { get; private set; } = [];
protected override async Task OnParametersSetAsync()
{
var userId = await RegistryUserContext.GetUserIdAsync(CancellationToken.None).ConfigureAwait(false);
IsAuthenticated = !string.IsNullOrWhiteSpace(userId);
if (!IsAuthenticated)
{
return;
}
Registry = await RegistryService.GetPublicRegistryByCodeAsync(Code, userId, CancellationToken.None).ConfigureAwait(false);
Item = Registry?.Items.FirstOrDefault(x => x.Id == ItemId);
if (Registry is null || Item is null)
{
return;
}
var configuredAmounts = Registry.ContributionAmountQrCodes
.Select(x => (int)Math.Round(x.Amount, MidpointRounding.AwayFromZero))
.Where(x => x > 0)
.Distinct()
.OrderBy(x => x)
.ToList();
SliderMin = configuredAmounts.Count > 0 ? configuredAmounts[0] : 1;
RepresentableAmounts = Enumerable.Range(SliderMin, 201 - SliderMin)
.Where(x => BuildSuggestions(x).Count > 0)
.ToList();
if (RepresentableAmounts.Count == 0)
{
SelectedAmount = 0;
SliderIndex = 0;
Suggestions = [];
return;
}
SliderIndex = 0;
SelectedAmount = RepresentableAmounts[SliderIndex];
RecalculateSuggestions();
}
protected void RecalculateSuggestions()
{
if (RepresentableAmounts.Count == 0)
{
Suggestions = [];
SelectedAmount = 0;
return;
}
var maxIndex = RepresentableAmounts.Count - 1;
if (SliderIndex < 0)
{
SliderIndex = 0;
}
else if (SliderIndex > maxIndex)
{
SliderIndex = maxIndex;
}
SelectedAmount = RepresentableAmounts[SliderIndex];
Suggestions = BuildSuggestions(SelectedAmount);
}
protected async Task ConfirmAsync()
{
var userId = await RegistryUserContext.GetUserIdAsync(CancellationToken.None).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(userId) || Item is null || SelectedAmount <= 0)
{
return;
}
await RegistryService.AddContributionAsync(Item.Id, userId, SelectedAmount, $"Participation for item: {Item.Name}", CancellationToken.None).ConfigureAwait(false);
BackToRegistry();
}
protected void BackToRegistry()
{
NavigationManager.NavigateTo($"/registry/{Code}");
}
private List<QrCombinationSuggestion> BuildSuggestions(decimal requestedAmount)
{
if (Registry is null || requestedAmount <= 0)
{
return [];
}
var target = (int)Math.Round(requestedAmount, MidpointRounding.AwayFromZero);
var options = Registry.ContributionAmountQrCodes
.Where(x => x.Amount > 0 && !string.IsNullOrWhiteSpace(x.QrCodeUrl))
.Select(x => new
{
Amount = (int)Math.Round(x.Amount, MidpointRounding.AwayFromZero),
QrCodeUrl = x.QrCodeUrl.Trim()
})
.Where(x => x.Amount > 0)
.DistinctBy(x => x.Amount)
.OrderByDescending(x => x.Amount)
.ToList();
if (options.Count == 0 || target <= 0)
{
return [];
}
var max = int.MaxValue / 4;
var minCoins = Enumerable.Repeat(max, target + 1).ToArray();
var choice = Enumerable.Repeat(-1, target + 1).ToArray();
minCoins[0] = 0;
for (var amount = 1; amount <= target; amount++)
{
for (var i = 0; i < options.Count; i++)
{
var option = options[i];
if (option.Amount > amount)
{
continue;
}
var candidate = minCoins[amount - option.Amount];
if (candidate == max)
{
continue;
}
candidate += 1;
if (candidate < minCoins[amount])
{
minCoins[amount] = candidate;
choice[amount] = i;
}
}
}
if (minCoins[target] == max)
{
return [];
}
var counts = new Dictionary<int, int>();
var current = target;
while (current > 0)
{
var optionIndex = choice[current];
if (optionIndex < 0)
{
return [];
}
var optionAmount = options[optionIndex].Amount;
counts[optionIndex] = counts.TryGetValue(optionIndex, out var count) ? count + 1 : 1;
current -= optionAmount;
}
return counts
.Select(x => new QrCombinationSuggestion
{
Amount = options[x.Key].Amount,
QrCodeUrl = options[x.Key].QrCodeUrl,
RepeatCount = x.Value
})
.OrderBy(x => x.Amount)
.ToList();
}
protected static string BuildQrImageUrl(string paymentLink)
{
ArgumentException.ThrowIfNullOrWhiteSpace(paymentLink);
return $"https://api.qrserver.com/v1/create-qr-code/?size=320x320&data={Uri.EscapeDataString(paymentLink)}";
}
protected sealed class QrCombinationSuggestion
{
public int Amount { get; init; }
public string QrCodeUrl { get; init; } = string.Empty;
public int RepeatCount { get; init; }
}
}
@@ -64,14 +64,17 @@ else
{
<p class="card-text item-description-text">@item.Description</p>
}
<p class="mb-1"><strong>Qty:</strong> @item.PurchasedQuantity/@item.DesiredQuantity purchased</p>
@if (item.DesiredQuantity > 1)
{
<p class="mb-1"><strong>Qty:</strong> @item.PurchasedQuantity/@item.DesiredQuantity purchased</p>
}
@if (item.PriceAmount.HasValue)
{
<p class="mb-1"><strong>Price:</strong> @item.PriceAmount.Value.ToString("0.00") @item.CurrencyCode</p>
}
@if (item.ParticipationAllowed && item.ParticipationTargetAmount.HasValue)
@if (item.ParticipationAllowed && GetParticipationTotalAmount(item).HasValue)
{
<p class="mb-2"><strong>Participation:</strong> @item.MoneyFulfilledAmount.ToString("0.00") / @item.ParticipationTargetAmount.Value.ToString("0.00") @item.CurrencyCode</p>
<p class="mb-2"><strong>Participation:</strong> @item.MoneyFulfilledAmount.ToString("0.00") out of €@GetParticipationTotalAmount(item)!.Value.ToString("0.00") fulfilled</p>
}
@if (item.Purchasers.Count > 0 || item.Contributors.Count > 0)
@@ -110,13 +113,39 @@ else
@if (item.Contributors.Count > 0)
{
<div class="mb-2">
<strong class="text-sm">Contributed by:</strong>
<div class="contributor-list">
@foreach (var contributor in item.Contributors)
@if (Registry.IsAdmin)
{
<strong class="text-sm">Contributed by:</strong>
<div class="contributor-list">
@foreach (var contributor in item.Contributors)
{
<span class="contributor-badge">@contributor.DisplayName (@contributor.Amount.ToString("0.00") @item.CurrencyCode)</span>
}
</div>
}
else if (!string.IsNullOrWhiteSpace(Registry.CurrentUserId))
{
var currentUserContribution = item.Contributors.FirstOrDefault(x => x.UserId == Registry.CurrentUserId);
if (currentUserContribution is not null)
{
<span class="contributor-badge">@contributor.DisplayName (@contributor.Amount.ToString("0.00") @item.CurrencyCode)</span>
<strong class="text-sm">Contributed by:</strong>
<div class="contributor-list">
<span class="contributor-badge">@currentUserContribution.DisplayName (@currentUserContribution.Amount.ToString("0.00") @item.CurrencyCode)</span>
@if (item.Contributors.Count > 1)
{
<span class="contributor-badge">and others</span>
}
</div>
}
</div>
else
{
<span class="text-muted small">Contributed</span>
}
}
else
{
<span class="text-muted small">Contributed</span>
}
</div>
}
</div>
@@ -147,7 +176,7 @@ else
}
@if (item.ParticipationAllowed)
{
<button class="btn btn-secondary btn-sm" @onclick="() => OpenContributionPrompt(item.Id)">I transferred money</button>
<button class="btn btn-secondary btn-sm" @onclick="() => OpenContributionPrompt(item.Id)">Partially fulfill</button>
}
</div>
}
@@ -219,3 +248,91 @@ else
</div>
</div>
}
@if (ShowPartialFulfillWizard)
{
<div class="prompt-overlay">
<div class="prompt-card">
<h3>Partially fulfill item</h3>
@if (PartialFulfillStep == 1)
{
<p>Select how you want to donate:</p>
<div class="d-flex flex-column gap-2">
@if (HasIbanPaymentOption())
{
<button class="btn btn-outline-primary text-start" @onclick="() => SelectPaymentMethod(ContributionPaymentMethodType.Iban)">
IBAN transfer
</button>
}
@if (HasSingleQrPaymentOption())
{
<button class="btn btn-outline-primary text-start" @onclick="() => SelectPaymentMethod(ContributionPaymentMethodType.SingleQrCode)">
Single QR code
</button>
}
@if (HasAmountSpecificQrPaymentOption())
{
<button class="btn btn-outline-primary text-start" @onclick="() => SelectPaymentMethod(ContributionPaymentMethodType.AmountSpecificQrCode)">
QR code per amount
</button>
}
</div>
@if (SelectedPaymentMethod == ContributionPaymentMethodType.Iban && !string.IsNullOrWhiteSpace(Registry?.BankAccountIban))
{
<div class="alert alert-secondary mt-3 mb-0">
<strong>IBAN:</strong> @Registry.BankAccountIban
@if (!string.IsNullOrWhiteSpace(Registry.BankAccountBic))
{
<span> | <strong>BIC:</strong> @Registry.BankAccountBic</span>
}
</div>
}
@if (!string.IsNullOrWhiteSpace(SelectedPaymentQrCodeUrl))
{
<div class="mt-3 text-center">
<img src="@BuildQrImageUrl(SelectedPaymentQrCodeUrl)" alt="Payment QR code" class="img-fluid" style="max-height: 240px;" />
<div class="mt-2">
<a href="@SelectedPaymentQrCodeUrl" target="_blank" rel="noopener noreferrer">Open payment link</a>
</div>
</div>
}
<div class="d-flex gap-2 mt-3">
<button class="btn btn-primary" @onclick="ContinueContributionWizard" disabled="@(SelectedPaymentMethod is null)">Next</button>
<button class="btn btn-outline-secondary" @onclick="CloseContributionPrompt">Cancel</button>
</div>
}
else if (PartialFulfillStep == 2)
{
<p>How much did you add for this item?</p>
<InputNumber class="form-control" @bind-Value="ContributionAmount" @bind-Value:after="OnContributionAmountChanged" />
<p class="mt-2">Message: @ContributionMessage</p>
@if (SelectedPaymentMethod == ContributionPaymentMethodType.AmountSpecificQrCode && ContributionAmount > 0 && string.IsNullOrWhiteSpace(SelectedPaymentQrCodeUrl))
{
<p class="text-muted mt-2 mb-0">No QR code configured for this exact amount.</p>
}
@if (!string.IsNullOrWhiteSpace(SelectedPaymentQrCodeUrl))
{
<div class="mt-3 text-center">
<img src="@BuildQrImageUrl(SelectedPaymentQrCodeUrl)" alt="Payment QR code" class="img-fluid" style="max-height: 240px;" />
<div class="mt-2">
<a href="@SelectedPaymentQrCodeUrl" target="_blank" rel="noopener noreferrer">Open payment link</a>
</div>
</div>
}
<div class="d-flex gap-2 mt-3">
<button class="btn btn-success" @onclick="ConfirmContributionAsync">Confirm</button>
<button class="btn btn-outline-secondary" @onclick="BackContributionWizard">Back</button>
<button class="btn btn-outline-secondary" @onclick="CloseContributionPrompt">Cancel</button>
</div>
}
</div>
</div>
}
@@ -27,6 +27,11 @@ public partial class RegistryPublic : ComponentBase
protected string? PurchaseItemUrl { get; private set; }
protected IReadOnlyList<ItemContributorViewModel> PurchasersToUnmark { get; private set; } = [];
protected bool ShowPartialFulfillWizard { get; private set; }
protected int PartialFulfillStep { get; private set; } = 1;
protected ContributionPaymentMethodType? SelectedPaymentMethod { get; set; }
protected string? SelectedPaymentQrCodeUrl { get; private set; }
protected override async Task OnParametersSetAsync()
{
var userId = await RegistryUserContext.GetUserIdAsync(CancellationToken.None).ConfigureAwait(false);
@@ -97,27 +102,95 @@ public partial class RegistryPublic : ComponentBase
ContributionMessage = Registry?.Items.FirstOrDefault(x => x.Id == itemId) is { } item
? $"Participation for item: {item.Name}"
: string.Empty;
ShowContributionPrompt = true;
ShowPartialFulfillWizard = true;
PartialFulfillStep = 1;
SelectedPaymentMethod = null;
SelectedPaymentQrCodeUrl = null;
}
protected void CloseContributionPrompt()
{
ShowContributionPrompt = false;
ShowPartialFulfillWizard = false;
PartialFulfillStep = 1;
SelectedPaymentMethod = null;
SelectedPaymentQrCodeUrl = null;
ActiveItemId = Guid.Empty;
ContributionMessage = string.Empty;
}
protected async Task ConfirmContributionAsync()
protected bool HasIbanPaymentOption()
{
var userId = await RegistryUserContext.GetUserIdAsync(CancellationToken.None).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(userId) || ActiveItemId == Guid.Empty || ContributionAmount <= 0)
return Registry is not null && !string.IsNullOrWhiteSpace(Registry.BankAccountIban);
}
protected bool HasSingleQrPaymentOption()
{
return Registry is not null && !string.IsNullOrWhiteSpace(Registry.ContributionQrCodeUrl);
}
protected bool HasAmountSpecificQrPaymentOption()
{
return Registry is not null && Registry.ContributionAmountQrCodes.Count > 0;
}
protected void SelectPaymentMethod(ContributionPaymentMethodType method)
{
SelectedPaymentMethod = method;
SelectedPaymentQrCodeUrl = method switch
{
return;
ContributionPaymentMethodType.SingleQrCode => Registry?.ContributionQrCodeUrl,
ContributionPaymentMethodType.AmountSpecificQrCode => FindAmountSpecificQrCode(ContributionAmount),
_ => null
};
}
protected void ContinueContributionWizard()
{
if (PartialFulfillStep == 1)
{
if (SelectedPaymentMethod is null)
{
return;
}
if (SelectedPaymentMethod == ContributionPaymentMethodType.AmountSpecificQrCode && ActiveItemId != Guid.Empty)
{
ShowPartialFulfillWizard = false;
NavigationManager.NavigateTo($"/registry/{Code}/item/{ActiveItemId}/contribution-amount");
return;
}
PartialFulfillStep = 2;
}
}
protected void BackContributionWizard()
{
if (PartialFulfillStep > 1)
{
PartialFulfillStep--;
}
}
protected void OnContributionAmountChanged()
{
if (SelectedPaymentMethod == ContributionPaymentMethodType.AmountSpecificQrCode)
{
SelectedPaymentQrCodeUrl = FindAmountSpecificQrCode(ContributionAmount);
}
}
private string? FindAmountSpecificQrCode(decimal amount)
{
if (Registry is null || amount <= 0)
{
return null;
}
await RegistryService.AddContributionAsync(ActiveItemId, userId, ContributionAmount, ContributionMessage, CancellationToken.None).ConfigureAwait(false);
ShowContributionPrompt = false;
Registry = await RegistryService.GetPublicRegistryByCodeAsync(Code, userId, CancellationToken.None).ConfigureAwait(false);
var match = Registry.ContributionAmountQrCodes
.FirstOrDefault(x => x.Amount == amount);
return match?.QrCodeUrl;
}
protected async Task UnmarkPurchaseAsync(Guid itemId)
@@ -184,4 +257,32 @@ public partial class RegistryPublic : ComponentBase
ShowPurchaserSelectionPrompt = false;
Registry = await RegistryService.GetPublicRegistryByCodeAsync(Code, userId, CancellationToken.None).ConfigureAwait(false);
}
protected async Task ConfirmContributionAsync()
{
var userId = await RegistryUserContext.GetUserIdAsync(CancellationToken.None).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(userId) || ActiveItemId == Guid.Empty || ContributionAmount <= 0)
{
return;
}
await RegistryService.AddContributionAsync(ActiveItemId, userId, ContributionAmount, ContributionMessage, CancellationToken.None).ConfigureAwait(false);
ShowPartialFulfillWizard = false;
PartialFulfillStep = 1;
SelectedPaymentMethod = null;
SelectedPaymentQrCodeUrl = null;
Registry = await RegistryService.GetPublicRegistryByCodeAsync(Code, userId, CancellationToken.None).ConfigureAwait(false);
}
protected static decimal? GetParticipationTotalAmount(RegistryPublicItemViewModel item)
{
ArgumentNullException.ThrowIfNull(item);
return item.ParticipationTargetAmount ?? item.PriceAmount;
}
protected static string BuildQrImageUrl(string paymentLink)
{
ArgumentException.ThrowIfNullOrWhiteSpace(paymentLink);
return $"https://api.qrserver.com/v1/create-qr-code/?size=320x320&data={Uri.EscapeDataString(paymentLink)}";
}
}