mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
committed by
Andrew Camilleri
parent
b7b2f16925
commit
17e6179fec
@@ -45,14 +45,12 @@ namespace BTCPayServer.Controllers.GreenField
|
|||||||
_cssThemeManager = cssThemeManager;
|
_cssThemeManager = cssThemeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
public static IEnumerable<LightningNetworkPaymentMethodData> GetLightningPaymentMethods(StoreData store, BTCPayNetworkProvider networkProvider, bool enabledOnly = false)
|
||||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/LightningNetwork")]
|
|
||||||
public ActionResult<IEnumerable<LightningNetworkPaymentMethodData>> GetLightningPaymentMethods(
|
|
||||||
[FromQuery] bool enabledOnly = false)
|
|
||||||
{
|
{
|
||||||
var blob = Store.GetStoreBlob();
|
var blob = store.GetStoreBlob();
|
||||||
var excludedPaymentMethods = blob.GetExcludedPaymentMethods();
|
var excludedPaymentMethods = blob.GetExcludedPaymentMethods();
|
||||||
return Ok(Store.GetSupportedPaymentMethods(_btcPayNetworkProvider)
|
|
||||||
|
return store.GetSupportedPaymentMethods(networkProvider)
|
||||||
.Where((method) => method.PaymentId.PaymentType == PaymentTypes.LightningLike)
|
.Where((method) => method.PaymentId.PaymentType == PaymentTypes.LightningLike)
|
||||||
.OfType<LightningSupportedPaymentMethod>()
|
.OfType<LightningSupportedPaymentMethod>()
|
||||||
.Select(paymentMethod =>
|
.Select(paymentMethod =>
|
||||||
@@ -63,8 +61,15 @@ namespace BTCPayServer.Controllers.GreenField
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.Where((result) => !enabledOnly || result.Enabled)
|
.Where((result) => !enabledOnly || result.Enabled)
|
||||||
.ToList()
|
.ToList();
|
||||||
);
|
}
|
||||||
|
|
||||||
|
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||||
|
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/LightningNetwork")]
|
||||||
|
public ActionResult<IEnumerable<LightningNetworkPaymentMethodData>> GetLightningPaymentMethods(
|
||||||
|
[FromQuery] bool enabledOnly = false)
|
||||||
|
{
|
||||||
|
return Ok(GetLightningPaymentMethods(Store, _btcPayNetworkProvider, enabledOnly));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||||
|
|||||||
@@ -36,22 +36,27 @@ namespace BTCPayServer.Controllers.GreenField
|
|||||||
_walletProvider = walletProvider;
|
_walletProvider = walletProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
public static IEnumerable<OnChainPaymentMethodData> GetOnChainPaymentMethods(StoreData store, BTCPayNetworkProvider networkProvider, bool enabledOnly = false)
|
||||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain")]
|
|
||||||
public ActionResult<IEnumerable<OnChainPaymentMethodData>> GetOnChainPaymentMethods(
|
|
||||||
[FromQuery] bool enabledOnly = false)
|
|
||||||
{
|
{
|
||||||
var blob = Store.GetStoreBlob();
|
var blob = store.GetStoreBlob();
|
||||||
var excludedPaymentMethods = blob.GetExcludedPaymentMethods();
|
var excludedPaymentMethods = blob.GetExcludedPaymentMethods();
|
||||||
return Ok(Store.GetSupportedPaymentMethods(_btcPayNetworkProvider)
|
|
||||||
|
return store.GetSupportedPaymentMethods(networkProvider)
|
||||||
.Where((method) => method.PaymentId.PaymentType == PaymentTypes.BTCLike)
|
.Where((method) => method.PaymentId.PaymentType == PaymentTypes.BTCLike)
|
||||||
.OfType<DerivationSchemeSettings>()
|
.OfType<DerivationSchemeSettings>()
|
||||||
.Select(strategy =>
|
.Select(strategy =>
|
||||||
new OnChainPaymentMethodData(strategy.PaymentId.CryptoCode,
|
new OnChainPaymentMethodData(strategy.PaymentId.CryptoCode,
|
||||||
strategy.AccountDerivation.ToString(), !excludedPaymentMethods.Match(strategy.PaymentId)))
|
strategy.AccountDerivation.ToString(), !excludedPaymentMethods.Match(strategy.PaymentId)))
|
||||||
.Where((result) => !enabledOnly || result.Enabled)
|
.Where((result) => !enabledOnly || result.Enabled)
|
||||||
.ToList()
|
.ToList();
|
||||||
);
|
}
|
||||||
|
|
||||||
|
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||||
|
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain")]
|
||||||
|
public ActionResult<IEnumerable<OnChainPaymentMethodData>> GetOnChainPaymentMethods(
|
||||||
|
[FromQuery] bool enabledOnly = false)
|
||||||
|
{
|
||||||
|
return Ok(GetOnChainPaymentMethods(Store, _btcPayNetworkProvider, enabledOnly));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#nullable enable
|
||||||
|
using BTCPayServer.Abstractions.Constants;
|
||||||
|
using BTCPayServer.Client;
|
||||||
|
using BTCPayServer.Client.Models;
|
||||||
|
using BTCPayServer.Data;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using StoreData = BTCPayServer.Data.StoreData;
|
||||||
|
|
||||||
|
namespace BTCPayServer.Controllers.GreenField
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||||
|
public class StorePaymentMethodsController : ControllerBase
|
||||||
|
{
|
||||||
|
private StoreData Store => HttpContext.GetStoreData();
|
||||||
|
private readonly BTCPayNetworkProvider _btcPayNetworkProvider;
|
||||||
|
|
||||||
|
public StorePaymentMethodsController(BTCPayNetworkProvider btcPayNetworkProvider)
|
||||||
|
{
|
||||||
|
_btcPayNetworkProvider = btcPayNetworkProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||||
|
[HttpGet("~/api/v1/stores/{storeId}/payment-methods")]
|
||||||
|
public ActionResult<LightningNetworkPaymentMethodData> GetPaymentMethods(
|
||||||
|
[FromQuery] bool enabledOnly = false
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var storeBlob = Store.GetStoreBlob();
|
||||||
|
var excludedPaymentMethods = storeBlob.GetExcludedPaymentMethods();
|
||||||
|
|
||||||
|
return Ok(new {
|
||||||
|
onchain = StoreOnChainPaymentMethodsController.GetOnChainPaymentMethods(Store, _btcPayNetworkProvider, enabledOnly),
|
||||||
|
lightning = StoreLightningNetworkPaymentMethodsController.GetLightningPaymentMethods(Store, _btcPayNetworkProvider, enabledOnly)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user