mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 21:32:27 +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");
|
||||
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();
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ namespace BTCPayServer.Tests
|
||||
|
||||
var invoiceId = s.CreateInvoice(10, "USD", "a@g.com");
|
||||
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)]
|
||||
|
@ -671,7 +671,7 @@ namespace BTCPayServer.Controllers
|
||||
var displayedPaymentMethods = invoice.GetPaymentMethods().Select(p => p.GetId()).ToList();
|
||||
|
||||
// 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.Remove(lnId);
|
||||
@ -787,11 +787,13 @@ namespace BTCPayServer.Controllers
|
||||
Request.Host,
|
||||
Request.PathBase) : null;
|
||||
|
||||
var isAltcoinsBuild = false;
|
||||
#if ALTCOINS
|
||||
isAltcoinsBuild = true,
|
||||
#endif
|
||||
|
||||
var model = new PaymentModel
|
||||
{
|
||||
#if ALTCOINS
|
||||
AltcoinsBuild = true,
|
||||
#endif
|
||||
Activated = paymentMethodDetails.Activated,
|
||||
CryptoCode = network.CryptoCode,
|
||||
RootPath = Request.PathBase.Value.WithTrailingSlash(),
|
||||
@ -856,12 +858,15 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
var availableCryptoPaymentMethodId = kv.GetId();
|
||||
var availableCryptoHandler = _paymentMethodHandlerDictionary[availableCryptoPaymentMethodId];
|
||||
var pmName = availableCryptoHandler.GetPaymentMethodName(availableCryptoPaymentMethodId);
|
||||
return new PaymentModel.AvailableCrypto
|
||||
{
|
||||
Displayed = displayedPaymentMethods.Contains(kv.GetId()),
|
||||
PaymentMethodId = kv.GetId().ToString(),
|
||||
CryptoCode = kv.Network?.CryptoCode ?? kv.GetId().CryptoCode,
|
||||
PaymentMethodName = availableCryptoHandler.GetPaymentMethodName(availableCryptoPaymentMethodId),
|
||||
PaymentMethodName = isAltcoinsBuild
|
||||
? pmName
|
||||
: pmName.Replace("Bitcoin (", "").Replace(")", "").Replace("Lightning ", ""),
|
||||
IsLightning =
|
||||
kv.GetId().PaymentType == PaymentTypes.LightningLike,
|
||||
CryptoImage = Request.GetRelativePathOrAbsolute(availableCryptoHandler.GetCryptoImage(availableCryptoPaymentMethodId)),
|
||||
|
@ -78,7 +78,6 @@ namespace BTCPayServer.Models.InvoicingModels
|
||||
public bool Activated { get; set; }
|
||||
public string InvoiceCurrency { get; set; }
|
||||
public string ReceiptLink { get; set; }
|
||||
public bool AltcoinsBuild { get; set; }
|
||||
public CheckoutType CheckoutType { get; set; }
|
||||
public int? RequiredConfirmations { get; set; }
|
||||
public long? ReceivedConfirmations { get; set; }
|
||||
|
@ -52,8 +52,7 @@
|
||||
<div class="paywithRowRight cursorPointer" v-on:click="openPaymentMethodDialog">
|
||||
<span class="payment__currencies " v-show="!changingCurrencies">
|
||||
<img v-bind:src="srvModel.cryptoImage" />
|
||||
<span>{{srvModel.paymentMethodName}} ({{srvModel.cryptoCode}})</span>
|
||||
<span v-show="srvModel.isLightning">⚡</span>
|
||||
<span>{{srvModel.paymentMethodName}}</span>
|
||||
<span class="clickable_indicator fa fa-angle-right"></span>
|
||||
</span>
|
||||
</div>
|
||||
@ -65,8 +64,6 @@
|
||||
<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" />
|
||||
@crypto.PaymentMethodName
|
||||
@(crypto.IsLightning ? Html.Raw("⚡") : null)
|
||||
<span>@crypto.CryptoCode</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
@ -77,7 +74,7 @@
|
||||
{
|
||||
<div class="payment__currencies_noborder">
|
||||
<img v-bind:src="srvModel.cryptoImage" />
|
||||
<span>{{srvModel.paymentMethodName}} ({{srvModel.cryptoCode}})</span>
|
||||
<span>{{srvModel.paymentMethodName}}</span>
|
||||
<span v-show="srvModel.isLightning">⚡</span>
|
||||
</div>
|
||||
}
|
||||
|
@ -15,13 +15,6 @@
|
||||
var displayedPaymentMethods = Model.AvailableCryptos.Where(c => c.Displayed).ToList();
|
||||
}
|
||||
@functions {
|
||||
private string PaymentMethodName(PaymentModel.AvailableCrypto pm)
|
||||
{
|
||||
return Model.AltcoinsBuild
|
||||
? pm.PaymentMethodName
|
||||
: pm.PaymentMethodName.Replace("Bitcoin (", "").Replace(")", "").Replace("Lightning ", "");
|
||||
}
|
||||
|
||||
private string ToJsValue(object value)
|
||||
{
|
||||
return Safe.Json(value).ToString()?.Replace("\"", "'");
|
||||
@ -96,7 +89,7 @@
|
||||
class="btcpay-pill m-0 payment-method"
|
||||
:class="{ active: pmId === @ToJsValue(crypto.PaymentMethodId) }"
|
||||
v-on:click.prevent="changePaymentMethod(@ToJsValue(crypto.PaymentMethodId))">
|
||||
@PaymentMethodName(crypto)
|
||||
@crypto.PaymentMethodName
|
||||
</a>
|
||||
}
|
||||
@await Component.InvokeAsync("UiExtensionPoint", new { location = "checkout-payment-method", model = Model })
|
||||
|
Loading…
Reference in New Issue
Block a user