1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 01:22:50 -05:00

bitpay invoice api

This commit is contained in:
Kyle Spearrin
2019-02-21 22:43:37 -05:00
parent d514fcdaeb
commit fdaa9504d5
11 changed files with 144 additions and 0 deletions

View File

@ -1,11 +1,21 @@
using System;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Models.Api;
using System.Threading.Tasks;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
namespace Bit.Api.Controllers
{
public class MiscController : Controller
{
private readonly BitPayClient _bitPayClient;
public MiscController(BitPayClient bitPayClient)
{
_bitPayClient = bitPayClient;
}
[HttpGet("~/alive")]
[HttpGet("~/now")]
public DateTime Get()
@ -28,5 +38,14 @@ namespace Bit.Api.Controllers
Headers = HttpContext.Request?.Headers,
});
}
[Authorize("Application")]
[HttpPost("~/bitpay-invoice")]
[SelfHosted(NotSelfHostedOnly = true)]
public async Task<string> PostBitPayInvoice([FromBody]BitPayInvoiceRequestModel model)
{
var invoice = await _bitPayClient.CreateInvoiceAsync(model.ToBitpayClientInvoice());
return invoice.Url;
}
}
}