1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 00: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;
}
}
}

View File

@ -63,6 +63,8 @@ namespace Bit.Api
// Rate limiting
services.AddSingleton<IIpPolicyStore, MemoryCacheIpPolicyStore>();
services.AddSingleton<IRateLimitCounterStore, MemoryCacheRateLimitCounterStore>();
// BitPay
services.AddSingleton<BitPayClient>();
}
// Identity

View File

@ -14,6 +14,9 @@
},
"braintree": {
"production": true
},
"bitPay": {
"production": true
}
}
}

View File

@ -62,6 +62,10 @@
"merchantId": "SECRET",
"publicKey": "SECRET",
"privateKey": "SECRET"
},
"bitPay": {
"production": false,
"base58Secret": "SECRET"
}
},
"IpRateLimitOptions": {