From c8af0e8644a489fabe4e5194f5505f209cffa347 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 12 Aug 2017 23:06:29 -0400 Subject: [PATCH] billings jobs setup --- src/Billing/BillingSettings.cs | 1 + src/Billing/Controllers/JobsController.cs | 38 +++++++++++++++++++++++ src/Billing/settings.json | 3 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/Billing/Controllers/JobsController.cs diff --git a/src/Billing/BillingSettings.cs b/src/Billing/BillingSettings.cs index c04bc95aa..8bfe15d01 100644 --- a/src/Billing/BillingSettings.cs +++ b/src/Billing/BillingSettings.cs @@ -5,5 +5,6 @@ public virtual string StripeWebhookKey { get; set; } public virtual string StripeWebhookSecret { get; set; } public virtual string BraintreeWebhookKey { get; set; } + public virtual string JobsKey { get; set; } } } diff --git a/src/Billing/Controllers/JobsController.cs b/src/Billing/Controllers/JobsController.cs new file mode 100644 index 000000000..100dfbf3f --- /dev/null +++ b/src/Billing/Controllers/JobsController.cs @@ -0,0 +1,38 @@ +using Bit.Core.Services; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Options; +using System.Threading.Tasks; + +namespace Bit.Billing.Controllers +{ + [Route("jobs")] + public class JobsController : Controller + { + private readonly BillingSettings _billingSettings; + private readonly IOrganizationService _organizationService; + private readonly IUserService _userService; + + public JobsController( + IOptions billingSettings, + IOrganizationService organizationService, + IUserService userService) + { + _billingSettings = billingSettings?.Value; + _organizationService = organizationService; + _userService = userService; + } + + [HttpPost("expirations")] + public async Task PostExpirations([FromQuery] string key) + { + if(key != _billingSettings.JobsKey) + { + return new BadRequestResult(); + } + + // TODO check for all users/orgs that are expired and disable them + + return new OkResult(); + } + } +} diff --git a/src/Billing/settings.json b/src/Billing/settings.json index f4cf9fb95..eaf671b8c 100644 --- a/src/Billing/settings.json +++ b/src/Billing/settings.json @@ -38,7 +38,8 @@ "billingSettings": { "stripeWebhookKey": "SECRET", "stripeWebhookSecret": "SECRET", - "braintreeWebhookKey": "SECRET" + "braintreeWebhookKey": "SECRET", + "jobsKey": "SECRET" }, "braintree": { "production": false,