mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-10 09:19:24 +01:00
Add better error message if v1 routes are used.
This commit is contained in:
parent
443a350bad
commit
b5590a38fe
2 changed files with 46 additions and 0 deletions
|
@ -97,6 +97,9 @@ namespace BTCPayServer.Tests
|
|||
Assert.NotNull(e.APIError.Message);
|
||||
GreenfieldPermissionAPIError permissionError = Assert.IsType<GreenfieldPermissionAPIError>(e.APIError);
|
||||
Assert.Equal(Policies.CanModifyStoreSettings, permissionError.MissingPermission);
|
||||
|
||||
var client = await user.CreateClient(Policies.CanViewStoreSettings);
|
||||
await AssertAPIError("unsupported-in-v2", () => client.SendHttpRequest<object>($"api/v1/stores/{user.StoreId}/payment-methods/LightningNetwork"));
|
||||
}
|
||||
|
||||
[Fact(Timeout = TestTimeout)]
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
using BTCPayServer.Abstractions.Constants;
|
||||
using BTCPayServer.Abstractions.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BTCPayServer.Controllers.GreenField
|
||||
{
|
||||
[ApiController]
|
||||
[EnableCors(CorsPolicies.All)]
|
||||
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
public class GreenfieldObsoleteController : ControllerBase
|
||||
{
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/LNURL")]
|
||||
public IActionResult Obsolete1(string storeId)
|
||||
{
|
||||
return Obsolete();
|
||||
}
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/LNURLPay/{cryptoCode}")]
|
||||
[HttpDelete("~/api/v1/stores/{storeId}/payment-methods/LNURLPay/{cryptoCode}")]
|
||||
[HttpPut("~/api/v1/stores/{storeId}/payment-methods/LNURLPay/{cryptoCode}")]
|
||||
public IActionResult Obsolete2(string storeId, string cryptoCode)
|
||||
{
|
||||
return Obsolete();
|
||||
}
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/LightningNetwork")]
|
||||
public IActionResult Obsolete3(string storeId)
|
||||
{
|
||||
return Obsolete();
|
||||
}
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/LightningNetwork/{cryptoCode}")]
|
||||
[HttpDelete("~/api/v1/stores/{storeId}/payment-methods/LightningNetwork/{cryptoCode}")]
|
||||
[HttpPut("~/api/v1/stores/{storeId}/payment-methods/LightningNetwork/{cryptoCode}")]
|
||||
public IActionResult Obsolete4(string storeId, string cryptoCode)
|
||||
{
|
||||
return Obsolete();
|
||||
}
|
||||
private IActionResult Obsolete()
|
||||
{
|
||||
return this.CreateAPIError(410, "unsupported-in-v2", "This route isn't supported by BTCPay Server 2.0 and newer. Please update your integration.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue