mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
Unify checkout v1 behaviour with v2
This commit is contained in:
parent
03b793d7e2
commit
8de55cef31
@ -164,7 +164,7 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
var invoiceId = s.CreateInvoice(defaultPaymentMethod: "BTC_LightningLike");
|
var invoiceId = s.CreateInvoice(defaultPaymentMethod: "BTC_LightningLike");
|
||||||
s.GoToInvoiceCheckout(invoiceId);
|
s.GoToInvoiceCheckout(invoiceId);
|
||||||
Assert.Equal("Bitcoin (Lightning) (BTC)", s.Driver.FindElement(By.ClassName("payment__currencies")).Text);
|
Assert.Equal("Bitcoin (Lightning)", s.Driver.FindElement(By.ClassName("payment__currencies")).Text);
|
||||||
s.Driver.Quit();
|
s.Driver.Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
var invoiceId = s.CreateInvoice(10, "USD", "a@g.com");
|
var invoiceId = s.CreateInvoice(10, "USD", "a@g.com");
|
||||||
s.GoToInvoiceCheckout(invoiceId);
|
s.GoToInvoiceCheckout(invoiceId);
|
||||||
Assert.Contains("sats", s.Driver.FindElement(By.ClassName("payment__currencies_noborder")).Text);
|
Assert.Contains("sats", s.Driver.FindElement(By.ClassName("buyerTotalLine")).Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Timeout = TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
|
@ -671,7 +671,7 @@ namespace BTCPayServer.Controllers
|
|||||||
var displayedPaymentMethods = invoice.GetPaymentMethods().Select(p => p.GetId()).ToList();
|
var displayedPaymentMethods = invoice.GetPaymentMethods().Select(p => p.GetId()).ToList();
|
||||||
|
|
||||||
// Exclude Lightning if OnChainWithLnInvoiceFallback is active and we have both payment methods
|
// Exclude Lightning if OnChainWithLnInvoiceFallback is active and we have both payment methods
|
||||||
if (storeBlob is { CheckoutType: CheckoutType.V2, OnChainWithLnInvoiceFallback: true } &&
|
if (storeBlob is { OnChainWithLnInvoiceFallback: true } &&
|
||||||
displayedPaymentMethods.Contains(btcId))
|
displayedPaymentMethods.Contains(btcId))
|
||||||
{
|
{
|
||||||
displayedPaymentMethods.Remove(lnId);
|
displayedPaymentMethods.Remove(lnId);
|
||||||
@ -787,11 +787,13 @@ namespace BTCPayServer.Controllers
|
|||||||
Request.Host,
|
Request.Host,
|
||||||
Request.PathBase) : null;
|
Request.PathBase) : null;
|
||||||
|
|
||||||
|
var isAltcoinsBuild = false;
|
||||||
|
#if ALTCOINS
|
||||||
|
isAltcoinsBuild = true,
|
||||||
|
#endif
|
||||||
|
|
||||||
var model = new PaymentModel
|
var model = new PaymentModel
|
||||||
{
|
{
|
||||||
#if ALTCOINS
|
|
||||||
AltcoinsBuild = true,
|
|
||||||
#endif
|
|
||||||
Activated = paymentMethodDetails.Activated,
|
Activated = paymentMethodDetails.Activated,
|
||||||
CryptoCode = network.CryptoCode,
|
CryptoCode = network.CryptoCode,
|
||||||
RootPath = Request.PathBase.Value.WithTrailingSlash(),
|
RootPath = Request.PathBase.Value.WithTrailingSlash(),
|
||||||
@ -856,12 +858,15 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
var availableCryptoPaymentMethodId = kv.GetId();
|
var availableCryptoPaymentMethodId = kv.GetId();
|
||||||
var availableCryptoHandler = _paymentMethodHandlerDictionary[availableCryptoPaymentMethodId];
|
var availableCryptoHandler = _paymentMethodHandlerDictionary[availableCryptoPaymentMethodId];
|
||||||
|
var pmName = availableCryptoHandler.GetPaymentMethodName(availableCryptoPaymentMethodId);
|
||||||
return new PaymentModel.AvailableCrypto
|
return new PaymentModel.AvailableCrypto
|
||||||
{
|
{
|
||||||
Displayed = displayedPaymentMethods.Contains(kv.GetId()),
|
Displayed = displayedPaymentMethods.Contains(kv.GetId()),
|
||||||
PaymentMethodId = kv.GetId().ToString(),
|
PaymentMethodId = kv.GetId().ToString(),
|
||||||
CryptoCode = kv.Network?.CryptoCode ?? kv.GetId().CryptoCode,
|
CryptoCode = kv.Network?.CryptoCode ?? kv.GetId().CryptoCode,
|
||||||
PaymentMethodName = availableCryptoHandler.GetPaymentMethodName(availableCryptoPaymentMethodId),
|
PaymentMethodName = isAltcoinsBuild
|
||||||
|
? pmName
|
||||||
|
: pmName.Replace("Bitcoin (", "").Replace(")", "").Replace("Lightning ", ""),
|
||||||
IsLightning =
|
IsLightning =
|
||||||
kv.GetId().PaymentType == PaymentTypes.LightningLike,
|
kv.GetId().PaymentType == PaymentTypes.LightningLike,
|
||||||
CryptoImage = Request.GetRelativePathOrAbsolute(availableCryptoHandler.GetCryptoImage(availableCryptoPaymentMethodId)),
|
CryptoImage = Request.GetRelativePathOrAbsolute(availableCryptoHandler.GetCryptoImage(availableCryptoPaymentMethodId)),
|
||||||
|
@ -78,7 +78,6 @@ namespace BTCPayServer.Models.InvoicingModels
|
|||||||
public bool Activated { get; set; }
|
public bool Activated { get; set; }
|
||||||
public string InvoiceCurrency { get; set; }
|
public string InvoiceCurrency { get; set; }
|
||||||
public string ReceiptLink { get; set; }
|
public string ReceiptLink { get; set; }
|
||||||
public bool AltcoinsBuild { get; set; }
|
|
||||||
public CheckoutType CheckoutType { get; set; }
|
public CheckoutType CheckoutType { get; set; }
|
||||||
public int? RequiredConfirmations { get; set; }
|
public int? RequiredConfirmations { get; set; }
|
||||||
public long? ReceivedConfirmations { get; set; }
|
public long? ReceivedConfirmations { get; set; }
|
||||||
|
@ -52,8 +52,7 @@
|
|||||||
<div class="paywithRowRight cursorPointer" v-on:click="openPaymentMethodDialog">
|
<div class="paywithRowRight cursorPointer" v-on:click="openPaymentMethodDialog">
|
||||||
<span class="payment__currencies " v-show="!changingCurrencies">
|
<span class="payment__currencies " v-show="!changingCurrencies">
|
||||||
<img v-bind:src="srvModel.cryptoImage" />
|
<img v-bind:src="srvModel.cryptoImage" />
|
||||||
<span>{{srvModel.paymentMethodName}} ({{srvModel.cryptoCode}})</span>
|
<span>{{srvModel.paymentMethodName}}</span>
|
||||||
<span v-show="srvModel.isLightning">⚡</span>
|
|
||||||
<span class="clickable_indicator fa fa-angle-right"></span>
|
<span class="clickable_indicator fa fa-angle-right"></span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -65,8 +64,6 @@
|
|||||||
<a href="@crypto.Link" class="payment-method" data-payment-method="@crypto.PaymentMethodId" rel="noreferrer noopener">
|
<a href="@crypto.Link" class="payment-method" data-payment-method="@crypto.PaymentMethodId" rel="noreferrer noopener">
|
||||||
<img alt="@crypto.PaymentMethodName" src="@crypto.CryptoImage" asp-append-version="true" />
|
<img alt="@crypto.PaymentMethodName" src="@crypto.CryptoImage" asp-append-version="true" />
|
||||||
@crypto.PaymentMethodName
|
@crypto.PaymentMethodName
|
||||||
@(crypto.IsLightning ? Html.Raw("⚡") : null)
|
|
||||||
<span>@crypto.CryptoCode</span>
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
@ -77,7 +74,7 @@
|
|||||||
{
|
{
|
||||||
<div class="payment__currencies_noborder">
|
<div class="payment__currencies_noborder">
|
||||||
<img v-bind:src="srvModel.cryptoImage" />
|
<img v-bind:src="srvModel.cryptoImage" />
|
||||||
<span>{{srvModel.paymentMethodName}} ({{srvModel.cryptoCode}})</span>
|
<span>{{srvModel.paymentMethodName}}</span>
|
||||||
<span v-show="srvModel.isLightning">⚡</span>
|
<span v-show="srvModel.isLightning">⚡</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,6 @@
|
|||||||
var displayedPaymentMethods = Model.AvailableCryptos.Where(c => c.Displayed).ToList();
|
var displayedPaymentMethods = Model.AvailableCryptos.Where(c => c.Displayed).ToList();
|
||||||
}
|
}
|
||||||
@functions {
|
@functions {
|
||||||
private string PaymentMethodName(PaymentModel.AvailableCrypto pm)
|
|
||||||
{
|
|
||||||
return Model.AltcoinsBuild
|
|
||||||
? pm.PaymentMethodName
|
|
||||||
: pm.PaymentMethodName.Replace("Bitcoin (", "").Replace(")", "").Replace("Lightning ", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
private string ToJsValue(object value)
|
private string ToJsValue(object value)
|
||||||
{
|
{
|
||||||
return Safe.Json(value).ToString()?.Replace("\"", "'");
|
return Safe.Json(value).ToString()?.Replace("\"", "'");
|
||||||
@ -96,7 +89,7 @@
|
|||||||
class="btcpay-pill m-0 payment-method"
|
class="btcpay-pill m-0 payment-method"
|
||||||
:class="{ active: pmId === @ToJsValue(crypto.PaymentMethodId) }"
|
:class="{ active: pmId === @ToJsValue(crypto.PaymentMethodId) }"
|
||||||
v-on:click.prevent="changePaymentMethod(@ToJsValue(crypto.PaymentMethodId))">
|
v-on:click.prevent="changePaymentMethod(@ToJsValue(crypto.PaymentMethodId))">
|
||||||
@PaymentMethodName(crypto)
|
@crypto.PaymentMethodName
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
@await Component.InvokeAsync("UiExtensionPoint", new { location = "checkout-payment-method", model = Model })
|
@await Component.InvokeAsync("UiExtensionPoint", new { location = "checkout-payment-method", model = Model })
|
||||||
|
Loading…
Reference in New Issue
Block a user