mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Improve checkout page
This commit is contained in:
@@ -48,7 +48,8 @@ namespace BTCPayServer.Controllers
|
|||||||
StoreName = store.StoreName,
|
StoreName = store.StoreName,
|
||||||
TxFees = invoice.TxFee.ToString(),
|
TxFees = invoice.TxFee.ToString(),
|
||||||
InvoiceBitcoinUrl = dto.PaymentUrls.BIP72,
|
InvoiceBitcoinUrl = dto.PaymentUrls.BIP72,
|
||||||
TxCount = invoice.Payments.Count + 1,
|
TxCount = invoice.GetTxCount(),
|
||||||
|
BTCPaid = invoice.GetTotalPaid().ToString(),
|
||||||
Status = invoice.Status
|
Status = invoice.Status
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,12 @@ namespace BTCPayServer.Invoicing
|
|||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetTxCount()
|
||||||
|
{
|
||||||
|
return Calculate().TxCount;
|
||||||
|
}
|
||||||
|
|
||||||
public string OrderId
|
public string OrderId
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
@@ -114,10 +120,11 @@ namespace BTCPayServer.Invoicing
|
|||||||
return Calculate().TotalDue;
|
return Calculate().TotalDue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private (Money TotalDue, Money Paid) Calculate()
|
private (Money TotalDue, Money Paid, int TxCount) Calculate()
|
||||||
{
|
{
|
||||||
var totalDue = Money.Coins((decimal)(ProductInformation.Price / Rate)) + TxFee;
|
var totalDue = Money.Coins((decimal)(ProductInformation.Price / Rate)) + TxFee;
|
||||||
var paid = Money.Zero;
|
var paid = Money.Zero;
|
||||||
|
int txCount = 1;
|
||||||
var payments =
|
var payments =
|
||||||
Payments
|
Payments
|
||||||
.OrderByDescending(p => p.ReceivedTime)
|
.OrderByDescending(p => p.ReceivedTime)
|
||||||
@@ -130,11 +137,14 @@ namespace BTCPayServer.Invoicing
|
|||||||
{
|
{
|
||||||
var paidEnough = totalDue <= paid;
|
var paidEnough = totalDue <= paid;
|
||||||
if(!paidEnough)
|
if(!paidEnough)
|
||||||
|
{
|
||||||
|
txCount++;
|
||||||
totalDue += TxFee;
|
totalDue += TxFee;
|
||||||
|
}
|
||||||
return !paidEnough;
|
return !paidEnough;
|
||||||
})
|
})
|
||||||
.ToArray();
|
.ToArray();
|
||||||
return (totalDue, paid);
|
return (totalDue, paid, txCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Money GetTotalPaid()
|
public Money GetTotalPaid()
|
||||||
|
|||||||
@@ -71,14 +71,14 @@ namespace BTCPayServer.Invoicing
|
|||||||
|
|
||||||
private async Task<(bool NeedSave, UTXOChanges Changes)> UpdateInvoice(UTXOChanges changes, InvoiceEntity invoice)
|
private async Task<(bool NeedSave, UTXOChanges Changes)> UpdateInvoice(UTXOChanges changes, InvoiceEntity invoice)
|
||||||
{
|
{
|
||||||
if(invoice.Status == "invalid" && (invoice.Status == "new" || invoice.Status == "paidPartial"))
|
if(invoice.Status == "invalid")
|
||||||
{
|
{
|
||||||
return (false, changes);
|
return (false, changes);
|
||||||
}
|
}
|
||||||
bool needSave = false;
|
bool needSave = false;
|
||||||
bool shouldWait = true;
|
bool shouldWait = true;
|
||||||
|
|
||||||
if(invoice.ExpirationTime < DateTimeOffset.UtcNow)
|
if(invoice.ExpirationTime < DateTimeOffset.UtcNow && (invoice.Status == "new" || invoice.Status == "paidPartial"))
|
||||||
{
|
{
|
||||||
needSave = true;
|
needSave = true;
|
||||||
invoice.Status = "invalid";
|
invoice.Status = "invalid";
|
||||||
|
|||||||
@@ -90,6 +90,10 @@ namespace BTCPayServer.Models.InvoicingModels
|
|||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
public string BTCPaid
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
public string StoreEmail
|
public string StoreEmail
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
|
|||||||
@@ -127,7 +127,7 @@
|
|||||||
<!---->
|
<!---->
|
||||||
<div class="single-item-order__right">
|
<div class="single-item-order__right">
|
||||||
<div class="single-item-order__right__btc-price clickable" id="buyerTotalBtcAmount">
|
<div class="single-item-order__right__btc-price clickable" id="buyerTotalBtcAmount">
|
||||||
<span>@Model.BTCDue</span>
|
<span>@Model.BTCTotalDue</span>
|
||||||
<!---->
|
<!---->
|
||||||
<img class="single-item-order__right__btc-price__chevron" src="~/img/chevron.svg">
|
<img class="single-item-order__right__btc-price__chevron" src="~/img/chevron.svg">
|
||||||
</div>
|
</div>
|
||||||
@@ -152,9 +152,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="line-items__item__value" i18n="">@Model.TxCount transaction x @Model.TxFees BTC</div>
|
<div class="line-items__item__value" i18n="">@Model.TxCount transaction x @Model.TxFees BTC</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="line-items__item">
|
||||||
|
<div class="line-items__item__label">
|
||||||
|
<span i18n="">Already Paid</span>
|
||||||
|
</div>
|
||||||
|
<div class="line-items__item__value" i18n="">-@Model.BTCPaid BTC</div>
|
||||||
|
</div>
|
||||||
<div class="line-items__item line-items__item--total">
|
<div class="line-items__item line-items__item--total">
|
||||||
<div class="line-items__item__label" i18n="">Total</div>
|
<div class="line-items__item__label" i18n="">Due </div>
|
||||||
<div class="line-items__item__value">@Model.BTCTotalDue BTC</div>
|
<div class="line-items__item__value">@Model.BTCDue BTC</div>
|
||||||
</div>
|
</div>
|
||||||
<!---->
|
<!---->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
<ul class="nav nav-pills nav-stacked">
|
<ul class="nav nav-pills nav-stacked">
|
||||||
<li class="@ManageNavPages.IndexNavClass(ViewContext)"><a asp-action="Index">Profile</a></li>
|
<li class="@ManageNavPages.IndexNavClass(ViewContext)"><a asp-action="Index">Profile</a></li>
|
||||||
<li class="@ManageNavPages.ChangePasswordNavClass(ViewContext)"><a asp-action="ChangePassword">Password</a></li>
|
<li class="@ManageNavPages.ChangePasswordNavClass(ViewContext)"><a asp-action="ChangePassword">Password</a></li>
|
||||||
<li class="@ManageNavPages.TokensNavClass(ViewContext)"><a asp-action="ListTokens">Access Tokens</a></li>
|
|
||||||
@if (hasExternalLogins)
|
@if (hasExternalLogins)
|
||||||
{
|
{
|
||||||
<li class="@ManageNavPages.ExternalLoginsNavClass(ViewContext)"><a asp-action="ExternalLogins">External logins</a></li>
|
<li class="@ManageNavPages.ExternalLoginsNavClass(ViewContext)"><a asp-action="ExternalLogins">External logins</a></li>
|
||||||
|
|||||||
@@ -10121,7 +10121,7 @@ All mobile class names should be prefixed by m- */
|
|||||||
.paid-partial .top-header,
|
.paid-partial .top-header,
|
||||||
.refund-complete .top-header,
|
.refund-complete .top-header,
|
||||||
.archived .top-header {
|
.archived .top-header {
|
||||||
max-height: 49px;
|
max-height: 59px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.paid .timer-row,
|
.paid .timer-row,
|
||||||
@@ -11068,7 +11068,7 @@ line-items {
|
|||||||
}
|
}
|
||||||
|
|
||||||
line-items.expanded {
|
line-items.expanded {
|
||||||
height: 110px;
|
height: 120px;
|
||||||
border-top: 1px solid rgba(238, 238, 238, 0.5);
|
border-top: 1px solid rgba(238, 238, 238, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user