Merge remote-tracking branch 'source/master'

# Conflicts:
#	BTCPayServer.Tests/UnitTest1.cs
This commit is contained in:
lepipele 2017-10-20 14:04:40 -05:00
commit 505d9904af
12 changed files with 83 additions and 30 deletions

View File

@ -121,3 +121,4 @@ bower_components
output
.vs
**/launchSettings.json

View File

@ -19,6 +19,12 @@ Once you want to stop
docker-compose down
```
If you want to stop, and remove all existing data
```
docker-compose down -v
```
You can run the tests inside a container by running
```

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<Version>1.0.0.15</Version>
<Version>1.0.0.18</Version>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Build\dockerfiles\**" />
@ -22,7 +22,7 @@
<PackageReference Include="Hangfire.PostgreSql" Version="1.4.8.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.2" />
<PackageReference Include="NBitcoin" Version="4.0.0.38" />
<PackageReference Include="NBitpayClient" Version="1.0.0.11" />
<PackageReference Include="NBitpayClient" Version="1.0.0.12" />
<PackageReference Include="DBreeze" Version="1.87.0" />
<PackageReference Include="NBXplorer.Client" Version="1.0.0.17" />
<PackageReference Include="NicolasDorier.CommandLine" Version="1.0.0.1" />

View File

@ -58,6 +58,12 @@ namespace BTCPayServer.Controllers
pairingEntity = await _TokenRepository.GetPairingAsync(request.PairingCode);
pairingEntity.SIN = sin;
if(string.IsNullOrEmpty(pairingEntity.Label) && !string.IsNullOrEmpty(request.Label))
{
pairingEntity.Label = request.Label;
await _TokenRepository.UpdatePairingCode(pairingEntity);
}
var result = await _TokenRepository.PairWithSINAsync(request.PairingCode, sin);
if(result != PairingResult.Complete && result != PairingResult.Partial)
throw new BitpayHttpException(400, $"Error while pairing ({result})");

View File

@ -92,6 +92,27 @@ namespace BTCPayServer.Controllers
return View(model);
}
static Dictionary<string, CultureInfo> _CurrencyProviders = new Dictionary<string, CultureInfo>();
private IFormatProvider GetCurrencyProvider(string currency)
{
lock(_CurrencyProviders)
{
if(_CurrencyProviders.Count == 0)
{
foreach(var culture in CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => !c.IsNeutralCulture))
{
try
{
_CurrencyProviders.TryAdd(new RegionInfo(culture.LCID).ISOCurrencySymbol, culture);
}
catch { }
}
}
return _CurrencyProviders.TryGet(currency);
}
}
[HttpGet]
[Route("i/{invoiceId}")]
[Route("invoice")]
@ -112,6 +133,7 @@ namespace BTCPayServer.Controllers
var model = new PaymentModel()
{
ServerUrl = HttpContext.Request.GetAbsoluteRoot(),
OrderId = invoice.OrderId,
InvoiceId = invoice.Id,
BTCAddress = invoice.DepositAddress.ToString(),
@ -122,7 +144,7 @@ namespace BTCPayServer.Controllers
ExpirationSeconds = Math.Max(0, (int)(invoice.ExpirationTime - DateTimeOffset.UtcNow).TotalSeconds),
MaxTimeSeconds = (int)(invoice.ExpirationTime - invoice.InvoiceTime).TotalSeconds,
ItemDesc = invoice.ProductInformation.ItemDesc,
Rate = invoice.Rate.ToString(),
Rate = invoice.Rate.ToString("C", GetCurrencyProvider(invoice.ProductInformation.Currency)),
RedirectUrl = invoice.RedirectURL,
StoreName = store.StoreName,
TxFees = invoice.TxFee.ToString(),

View File

@ -230,7 +230,7 @@ namespace BTCPayServer.Controllers
{
return View(model);
}
model.Label = model.Label ?? String.Empty;
if(storeId == null) // Permissions are not checked by Policy if the storeId is not passed by url
{
storeId = model.StoreId;

View File

@ -11,7 +11,10 @@ namespace BTCPayServer.Models.InvoicingModels
{
get; set;
}
public string ServerUrl
{
get; set;
}
public string OrderId
{
get; set;

View File

@ -15,7 +15,7 @@ namespace BTCPayServer.Models.StoreViewModels
{
get; set;
}
[Required]
public string Label
{
get; set;

View File

@ -27,6 +27,7 @@
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
<script type="text/javascript">
var serverUrl = "@Model.ServerUrl";
var invoiceId = "@Model.InvoiceId";
var btcAddress = "@Model.BTCAddress";
var btcDue = "@Model.BTCDue"; //must be a string
@ -129,8 +130,6 @@
<div class="single-item-order__right">
<div class="single-item-order__right__btc-price clickable" id="buyerTotalBtcAmount">
<span>@Model.BTCTotalDue</span>
<!---->
<img class="single-item-order__right__btc-price__chevron" src="~/img/chevron.svg">
</div>
<!---->
<div class="single-item-order__right__ex-rate">
@ -180,20 +179,20 @@
<div class="bp-view payment scan" id="scan" style="opacity: 1;">
<div class="payment__scan">
@*<div class="payment__details__instruction__open-wallet hidden-sm-up">
<!---->
<a class="payment__details__instruction__open-wallet__btn action-button action-button--secondary">
<span i18n="">Show QR code</span>
<img class="m-qr-code-icon" src="~/img/qr-code.svg">
</a>
<div class="m-qr-code-container hidden-sm-up hide">
<p class="m-qr-code-header" i18n="">
Hide QR code
<img class="m-qr-code-expand" src="~/img/chevron.svg">
</p>
<!---->
<div class="qr-codes"></div>
</div>
</div>*@
<a class="payment__details__instruction__open-wallet__btn action-button action-button--secondary">
<span i18n="">Show QR code</span>
<img class="m-qr-code-icon" src="~/img/qr-code.svg">
</a>
<div class="m-qr-code-container hidden-sm-up hide">
<p class="m-qr-code-header" i18n="">
Hide QR code
<img class="m-qr-code-expand" src="~/img/chevron.svg">
</p>
<!---->
<div class="qr-codes"></div>
</div>
</div>*@
<!---->
<div class="qr-codes"></div>
</div>
@ -380,7 +379,7 @@
<div class="manual-box__amount__label label" i18n="">Amount</div>
<!---->
<div class="manual-box__amount__value copy-cursor" ngxclipboard="">
<span>@Model.BTCDue BTC</span>
<span>@Model.BTCDue</span> BTC
<div class="copied-label">
<span i18n="">Copied</span>
</div>
@ -427,6 +426,11 @@
<!---->
<div class="success-message" i18n="">This invoice has been paid.</div>
<!---->
<button class="action-button" style="margin-top: 0px;">
<bp-done-text>
<span i18n="" class="i18n-return-to-merchant">Return to @Model.StoreName</span>
</bp-done-text>
</button>
</div>
</div>
<!---->

View File

@ -3,6 +3,8 @@
Layout = "../Shared/_NavLayout.cshtml";
ViewData["Title"] = "Create a new token";
ViewData.AddActivePage(StoreNavPages.Tokens);
ViewBag.HidePublicKey = ViewBag.HidePublicKey ?? false;
ViewBag.ShowStores = ViewBag.ShowStores ?? false;
}
<h4>@ViewData["Title"]</h4>
@ -12,6 +14,10 @@
<form method="post">
<div class="form-group">
<label asp-for="Label"></label>
@if(ViewBag.HidePublicKey)
{
<small class="text-muted">optional</small>
}
<input asp-for="Label" class="form-control" />
<span asp-validation-for="Label" class="text-danger"></span>
</div>

View File

@ -8461,7 +8461,6 @@ strong {
.single-item-order__right__ex-rate {
font-style: italic;
font-size: 11px;
margin-right: 16px;
}
.single-item-order__right__btc-price {

View File

@ -69,7 +69,7 @@ function emailForm() {
// Push the email to a server, once the reception is confirmed move on
customerEmail = emailAddress;
var path = "i/" + invoiceId + "/UpdateCustomer";
var path = serverUrl + "/i/" + invoiceId + "/UpdateCustomer";
$.ajax({
url: path,
@ -171,6 +171,17 @@ function updateState(status) {
if ($(".modal-dialog").hasClass("expired")) {
$(".modal-dialog").removeClass("expired");
}
if (merchantRefLink != "") {
$(".action-button").click(function () {
window.location.href = merchantRefLink;
});
}
else
{
$(".action-button").hide();
}
$(".modal-dialog").addClass("paid");
if ($("#scan").hasClass("active")) {
@ -192,7 +203,7 @@ function updateState(status) {
}
var watcher = setInterval(function () {
var path = "i/" + invoiceId + "/status";
var path = serverUrl + "/i/" + invoiceId + "/status";
$.ajax({
url: path,
type: "GET"
@ -213,11 +224,6 @@ $(".menu__item").click(function () {
// function to load contents in different language should go there
});
// Redirect
$("#expired .action-button").click(function () {
window.location.href = merchantRefLink;
});
// Validate Email address
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;