mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 05:54:26 +01:00
The Big Cleanup: Refactor BTCPay internals (#5809)
This commit is contained in:
@@ -26,12 +26,15 @@ namespace BTCPayServer.Controllers
|
||||
public class BitpayInvoiceController : Controller
|
||||
{
|
||||
private readonly UIInvoiceController _InvoiceController;
|
||||
private readonly Dictionary<PaymentMethodId, IPaymentMethodBitpayAPIExtension> _bitpayExtensions;
|
||||
private readonly InvoiceRepository _InvoiceRepository;
|
||||
|
||||
public BitpayInvoiceController(UIInvoiceController invoiceController,
|
||||
Dictionary<PaymentMethodId, IPaymentMethodBitpayAPIExtension> bitpayExtensions,
|
||||
InvoiceRepository invoiceRepository)
|
||||
{
|
||||
_InvoiceController = invoiceController;
|
||||
_bitpayExtensions = bitpayExtensions;
|
||||
_InvoiceRepository = invoiceRepository;
|
||||
}
|
||||
|
||||
@@ -56,7 +59,7 @@ namespace BTCPayServer.Controllers
|
||||
})).FirstOrDefault();
|
||||
if (invoice == null)
|
||||
throw new BitpayHttpException(404, "Object not found");
|
||||
return new DataWrapper<InvoiceResponse>(invoice.EntityToDTO());
|
||||
return new DataWrapper<InvoiceResponse>(invoice.EntityToDTO(_bitpayExtensions, Url));
|
||||
}
|
||||
[HttpGet]
|
||||
[Route("invoices")]
|
||||
@@ -90,7 +93,7 @@ namespace BTCPayServer.Controllers
|
||||
};
|
||||
|
||||
var entities = (await _InvoiceRepository.GetInvoices(query))
|
||||
.Select((o) => o.EntityToDTO()).ToArray();
|
||||
.Select((o) => o.EntityToDTO(_bitpayExtensions, Url)).ToArray();
|
||||
|
||||
return Json(DataWrapper.Create(entities));
|
||||
}
|
||||
@@ -100,7 +103,7 @@ namespace BTCPayServer.Controllers
|
||||
CancellationToken cancellationToken = default, Action<InvoiceEntity> entityManipulator = null)
|
||||
{
|
||||
var entity = await CreateInvoiceCoreRaw(invoice, store, serverUrl, additionalTags, cancellationToken, entityManipulator);
|
||||
var resp = entity.EntityToDTO();
|
||||
var resp = entity.EntityToDTO(_bitpayExtensions, Url);
|
||||
return new DataWrapper<InvoiceResponse>(resp) { Facade = "pos/invoice" };
|
||||
}
|
||||
|
||||
@@ -178,7 +181,10 @@ namespace BTCPayServer.Controllers
|
||||
excludeFilter = PaymentFilter.Where(p => !supportedTransactionCurrencies.Contains(p));
|
||||
}
|
||||
entity.PaymentTolerance = storeBlob.PaymentTolerance;
|
||||
entity.DefaultPaymentMethod = invoice.DefaultPaymentMethod;
|
||||
if (invoice.DefaultPaymentMethod is not null && PaymentMethodId.TryParse(invoice.DefaultPaymentMethod, out var defaultPaymentMethod))
|
||||
{
|
||||
entity.DefaultPaymentMethod = defaultPaymentMethod;
|
||||
}
|
||||
entity.RequiresRefundEmail = invoice.RequiresRefundEmail;
|
||||
|
||||
return await _InvoiceController.CreateInvoiceCoreRaw(entity, store, excludeFilter, null, cancellationToken, entityManipulator);
|
||||
|
||||
Reference in New Issue
Block a user