mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-10 17:26:05 +01:00
do not have report name conflict with old plugin (#5826)
* do not have report name conflict with old plugin * tryadd instead of add * Apply #5816 to crowdfund too
This commit is contained in:
parent
dcc6f17c9c
commit
a60072a431
3 changed files with 46 additions and 23 deletions
|
@ -132,26 +132,9 @@ namespace BTCPayServer.Plugins.Crowdfund.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
JObject formResponseJObject = null;
|
JObject formResponseJObject = null;
|
||||||
|
|
||||||
if (settings.FormId is not null)
|
|
||||||
{
|
|
||||||
var formData = await FormDataService.GetForm(settings.FormId);
|
|
||||||
if (formData is not null)
|
|
||||||
{
|
|
||||||
formResponseJObject = TryParseJObject(formResponse) ?? new JObject();
|
|
||||||
var form = Form.Parse(formData.Config);
|
|
||||||
FormDataService.SetValues(form, formResponseJObject);
|
|
||||||
if (!FormDataService.Validate(form, ModelState))
|
|
||||||
{
|
|
||||||
// someone tried to bypass validation
|
|
||||||
return RedirectToAction(nameof(ViewCrowdfund), new { appId });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var store = await _appService.GetStore(app);
|
var store = await _appService.GetStore(app);
|
||||||
var title = settings.Title;
|
|
||||||
decimal? price = request.Amount;
|
decimal? price = request.Amount;
|
||||||
|
var title = settings.Title;
|
||||||
Dictionary<string, InvoiceSupportedTransactionCurrency> paymentMethods = null;
|
Dictionary<string, InvoiceSupportedTransactionCurrency> paymentMethods = null;
|
||||||
ViewPointOfSaleViewModel.Item choice = null;
|
ViewPointOfSaleViewModel.Item choice = null;
|
||||||
if (!string.IsNullOrEmpty(request.ChoiceKey))
|
if (!string.IsNullOrEmpty(request.ChoiceKey))
|
||||||
|
@ -195,6 +178,48 @@ namespace BTCPayServer.Plugins.Crowdfund.Controllers
|
||||||
price = request.Amount;
|
price = request.Amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.FormId is not null)
|
||||||
|
{
|
||||||
|
var formData = await FormDataService.GetForm(settings.FormId);
|
||||||
|
if (formData is not null)
|
||||||
|
{
|
||||||
|
formResponseJObject = TryParseJObject(formResponse) ?? new JObject();
|
||||||
|
var form = Form.Parse(formData.Config);
|
||||||
|
FormDataService.SetValues(form, formResponseJObject);
|
||||||
|
if (!FormDataService.Validate(form, ModelState))
|
||||||
|
{
|
||||||
|
// someone tried to bypass validation
|
||||||
|
return RedirectToAction(nameof(ViewCrowdfund), new { appId });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var amtField = form.GetFieldByFullName($"{FormDataService.InvoiceParameterPrefix}amount");
|
||||||
|
if (amtField is null)
|
||||||
|
{
|
||||||
|
form.Fields.Add(new Field
|
||||||
|
{
|
||||||
|
Name = $"{FormDataService.InvoiceParameterPrefix}amount",
|
||||||
|
Type = "hidden",
|
||||||
|
Value = price?.ToString(),
|
||||||
|
Constant = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
amtField.Value = price?.ToString();
|
||||||
|
}
|
||||||
|
formResponseJObject = FormDataService.GetValues(form);
|
||||||
|
|
||||||
|
var invoiceRequest = FormDataService.GenerateInvoiceParametersFromForm(form);
|
||||||
|
if (invoiceRequest.Amount is not null)
|
||||||
|
{
|
||||||
|
price = invoiceRequest.Amount.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!isAdmin && (settings.EnforceTargetAmount && info.TargetAmount.HasValue && price >
|
if (!isAdmin && (settings.EnforceTargetAmount && info.TargetAmount.HasValue && price >
|
||||||
(info.TargetAmount - (info.Info.CurrentAmount + info.Info.CurrentPendingAmount))))
|
(info.TargetAmount - (info.Info.CurrentAmount + info.Info.CurrentPendingAmount))))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using BTCPayServer.Client.Models;
|
|
||||||
using BTCPayServer.Services.Reporting;
|
using BTCPayServer.Services.Reporting;
|
||||||
|
|
||||||
namespace BTCPayServer.Services
|
namespace BTCPayServer.Services
|
||||||
|
@ -11,10 +9,10 @@ namespace BTCPayServer.Services
|
||||||
{
|
{
|
||||||
foreach (var r in reportProviders)
|
foreach (var r in reportProviders)
|
||||||
{
|
{
|
||||||
ReportProviders.Add(r.Name, r);
|
ReportProviders.TryAdd(r.Name, r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, ReportProvider> ReportProviders { get; } = new Dictionary<string, ReportProvider>();
|
public Dictionary<string, ReportProvider> ReportProviders { get; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class LegacyInvoiceExportReportProvider : ReportProvider
|
||||||
private readonly InvoiceRepository _invoiceRepository;
|
private readonly InvoiceRepository _invoiceRepository;
|
||||||
|
|
||||||
|
|
||||||
public override string Name { get; } = "Invoice Export (legacy)";
|
public override string Name { get; } = "Legacy Invoice Export";
|
||||||
|
|
||||||
public override async Task Query(QueryContext queryContext, CancellationToken cancellation)
|
public override async Task Query(QueryContext queryContext, CancellationToken cancellation)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue