Files
server/src/Api/Controllers/MiscController.cs

50 lines
1.5 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Mvc;
using Bit.Core.Models.Api;
2019-02-21 22:43:37 -05:00
using System.Threading.Tasks;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Settings;
2019-08-09 14:06:07 -04:00
using Stripe;
2020-03-07 21:41:53 -05:00
using System.Linq;
using System.Collections.Generic;
namespace Bit.Api.Controllers
{
public class MiscController : Controller
{
2019-02-21 22:43:37 -05:00
private readonly BitPayClient _bitPayClient;
private readonly GlobalSettings _globalSettings;
2019-02-21 22:43:37 -05:00
2019-03-19 23:32:54 -04:00
public MiscController(
BitPayClient bitPayClient,
GlobalSettings globalSettings)
2019-02-21 22:43:37 -05:00
{
_bitPayClient = bitPayClient;
_globalSettings = globalSettings;
2019-02-21 22:43:37 -05:00
}
[Authorize("Application")]
[HttpPost("~/bitpay-invoice")]
[SelfHosted(NotSelfHostedOnly = true)]
public async Task<string> PostBitPayInvoice([FromBody]BitPayInvoiceRequestModel model)
{
var invoice = await _bitPayClient.CreateInvoiceAsync(model.ToBitpayInvoice(_globalSettings));
2019-02-21 22:43:37 -05:00
return invoice.Url;
}
2019-08-09 14:06:07 -04:00
[Authorize("Application")]
[HttpPost("~/setup-payment")]
[SelfHosted(NotSelfHostedOnly = true)]
public async Task<string> PostSetupPayment()
{
var options = new SetupIntentCreateOptions
{
Usage = "off_session"
};
var service = new SetupIntentService();
var setupIntent = await service.CreateAsync(options);
return setupIntent.ClientSecret;
}
}
}