mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Enable better error when invoice cannot be created on crowdfund (#575)
Closes #572
This commit is contained in:
committed by
Nicolas Dorier
parent
4f4d05b8cd
commit
f09f23e570
@@ -176,30 +176,38 @@ namespace BTCPayServer.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
store.AdditionalClaims.Add(new Claim(Policies.CanCreateInvoice.Key, store.Id));
|
store.AdditionalClaims.Add(new Claim(Policies.CanCreateInvoice.Key, store.Id));
|
||||||
var invoice = await _InvoiceController.CreateInvoiceCore(new Invoice()
|
try
|
||||||
{
|
{
|
||||||
OrderId = $"{CrowdfundHubStreamer.CrowdfundInvoiceOrderIdPrefix}{appId}",
|
var invoice = await _InvoiceController.CreateInvoiceCore(new Invoice()
|
||||||
Currency = settings.TargetCurrency,
|
{
|
||||||
ItemCode = request.ChoiceKey ?? string.Empty,
|
OrderId = $"{CrowdfundHubStreamer.CrowdfundInvoiceOrderIdPrefix}{appId}",
|
||||||
ItemDesc = title,
|
Currency = settings.TargetCurrency,
|
||||||
BuyerEmail = request.Email,
|
ItemCode = request.ChoiceKey ?? string.Empty,
|
||||||
Price = price,
|
ItemDesc = title,
|
||||||
NotificationURL = settings.NotificationUrl,
|
BuyerEmail = request.Email,
|
||||||
FullNotifications = true,
|
Price = price,
|
||||||
ExtendedNotifications = true,
|
NotificationURL = settings.NotificationUrl,
|
||||||
RedirectURL = request.RedirectUrl ?? Request.GetDisplayUrl(),
|
FullNotifications = true,
|
||||||
|
ExtendedNotifications = true,
|
||||||
|
RedirectURL = request.RedirectUrl ?? Request.GetDisplayUrl(),
|
||||||
|
|
||||||
|
|
||||||
}, store, HttpContext.Request.GetAbsoluteRoot());
|
}, store, HttpContext.Request.GetAbsoluteRoot());
|
||||||
if (request.RedirectToCheckout)
|
if (request.RedirectToCheckout)
|
||||||
{
|
{
|
||||||
return RedirectToAction(nameof(InvoiceController.Checkout), "Invoice",
|
return RedirectToAction(nameof(InvoiceController.Checkout), "Invoice",
|
||||||
new {invoiceId = invoice.Data.Id});
|
new {invoiceId = invoice.Data.Id});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Ok(invoice.Data.Id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (BitpayHttpException e)
|
||||||
{
|
{
|
||||||
return Ok(invoice.Data.Id);
|
return BadRequest(e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user