mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 23:54:26 +01:00
make prism support opensats
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Abstractions.Constants;
|
||||
using BTCPayServer.Abstractions.Contracts;
|
||||
using BTCPayServer.Abstractions.Custodians;
|
||||
using BTCPayServer.Abstractions.Extensions;
|
||||
using BTCPayServer.Abstractions.Models;
|
||||
using BTCPayServer.Forms;
|
||||
using BTCPayServer.Abstractions.Services;
|
||||
using BTCPayServer.Client;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace BTCPayServer.Plugins.Bringin;
|
||||
|
||||
@@ -17,10 +21,50 @@ public class BringinPlugin : BaseBTCPayServerPlugin
|
||||
|
||||
public override void Execute(IServiceCollection applicationBuilder)
|
||||
{
|
||||
applicationBuilder.AddStartupTask<CustodianEnablerTask>();
|
||||
applicationBuilder.AddSingleton<ICustodian, BringinCustodian>();
|
||||
applicationBuilder.AddSingleton<IFormComponentProvider, BringinApiKeyFormComponentProvider>();
|
||||
|
||||
applicationBuilder.AddSingleton<BringinService>();
|
||||
applicationBuilder.AddSingleton<IHostedService, BringinService>(s => s.GetService<BringinService>());
|
||||
applicationBuilder.AddSingleton<IUIExtension>(new UIExtension("Bringin/BringinDashboardWidget", "dashboard"));
|
||||
applicationBuilder.AddSingleton<IUIExtension>(new UIExtension("Bringin/Nav",
|
||||
"store-integrations-nav"));
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
[Route("plugins/{storeId}/Bringin")]
|
||||
public class BringinController : Controller
|
||||
{
|
||||
private readonly BringinService _bringinService;
|
||||
|
||||
public BringinController(BringinService bringinService)
|
||||
{
|
||||
_bringinService = bringinService;
|
||||
}
|
||||
|
||||
[HttpGet("")]
|
||||
public async Task<IActionResult> Edit()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet("callback")]
|
||||
public async Task<IActionResult> Callback(string storeId, string apiKey)
|
||||
{
|
||||
//truncate with showing only first 3 letters on start ond end
|
||||
|
||||
var truncatedApikey = apiKey.Substring(0, 3) + "***" + apiKey.Substring(apiKey.Length - 3);
|
||||
|
||||
return View("Confirm",
|
||||
new ConfirmModel("Confirm Bringin API Key",
|
||||
$"You are about to set your Bringin API key to {truncatedApikey}", "Set", "btn-primary"));
|
||||
}
|
||||
|
||||
[HttpPost("callback")]
|
||||
public async Task<IActionResult> CallbackConfirm(string storeId, string apiKey)
|
||||
{
|
||||
var vm = await _bringinService.Update(storeId);
|
||||
vm.ApiKey = apiKey;
|
||||
await _bringinService.Update(storeId, vm);
|
||||
return RedirectToAction("Edit", new {storeId});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user