mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 21:48:12 -05:00
stripe webhook key from billing settings
This commit is contained in:
parent
91af4e12c7
commit
398a4d8e46
7
src/Billing/BillingSettings.cs
Normal file
7
src/Billing/BillingSettings.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace Bit.Billing
|
||||||
|
{
|
||||||
|
public class BillingSettings
|
||||||
|
{
|
||||||
|
public virtual string StripeWebhookKey { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,27 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Bit.Billing.Controllers
|
namespace Bit.Billing.Controllers
|
||||||
{
|
{
|
||||||
[Route("stripe")]
|
[Route("stripe")]
|
||||||
public class StripeController : Controller
|
public class StripeController : Controller
|
||||||
{
|
{
|
||||||
[HttpPost("webhook")]
|
private readonly BillingSettings _billingSettings;
|
||||||
public void PostWebhook([FromBody]dynamic body, [FromQuery] string key)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
public StripeController(IOptions<BillingSettings> billingSettings)
|
||||||
|
{
|
||||||
|
_billingSettings = billingSettings?.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("webhook")]
|
||||||
|
public IActionResult PostWebhook([FromBody]dynamic body, [FromQuery] string key)
|
||||||
|
{
|
||||||
|
if(key != _billingSettings.StripeWebhookKey)
|
||||||
|
{
|
||||||
|
return new BadRequestResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new OkResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Hosting;
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Bit.Core;
|
||||||
|
|
||||||
namespace Bit.Billing
|
namespace Bit.Billing
|
||||||
{
|
{
|
||||||
@ -33,6 +34,15 @@ namespace Bit.Billing
|
|||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
// Options
|
||||||
|
services.AddOptions();
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
//var globalSettings = new GlobalSettings();
|
||||||
|
//ConfigurationBinder.Bind(Configuration.GetSection("GlobalSettings"), globalSettings);
|
||||||
|
//services.AddSingleton(s => globalSettings);
|
||||||
|
services.Configure<BillingSettings>(Configuration.GetSection("BillingSettings"));
|
||||||
|
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,5 +4,11 @@
|
|||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Warning"
|
"Default": "Warning"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"globalSettings": {
|
||||||
|
|
||||||
|
},
|
||||||
|
"billingSettings": {
|
||||||
|
"stripeWebhookKey": "SECRET"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user