This commit is contained in:
Kukks
2023-10-23 09:51:18 +02:00
parent 2c0bf86fb9
commit 04f78f79f5
4 changed files with 34 additions and 18 deletions

View File

@@ -9,7 +9,7 @@
<PropertyGroup> <PropertyGroup>
<Product>SideShift</Product> <Product>SideShift</Product>
<Description>Allows you to embed a SideShift conversion screen to allow customers to pay with altcoins.</Description> <Description>Allows you to embed a SideShift conversion screen to allow customers to pay with altcoins.</Description>
<Version>1.1.9</Version> <Version>1.1.10</Version>
</PropertyGroup> </PropertyGroup>
<!-- Plugin development properties --> <!-- Plugin development properties -->
<PropertyGroup> <PropertyGroup>

View File

@@ -5,25 +5,22 @@ Vue.component("side-shift", {
if (e && e.preventDefault) { if (e && e.preventDefault) {
e.preventDefault(); e.preventDefault();
} }
const toCurrency = this.toCurrency.toLowerCase();
let settleMethodId = ""; let settleMethodId = "";
let amount = !this.$parent.srvModel.isUnsetTopUp let amount = !this.$parent.srvModel.isUnsetTopUp
? this.toCurrencyDue ? this.toCurrencyDue
: undefined; : undefined;
if (this.toCurrency.toLowerCase() === "lbtc") { if (toCurrency === "lbtc") {
settleMethodId = "liquid"; settleMethodId = "liquid";
} else if (this.toCurrency.toLowerCase() === "usdt") { } else if (toCurrency=== "usdt") {
settleMethodId = "usdtla"; settleMethodId = "usdtla";
} else if ( } else if (
this.toCurrency.endsWith("LightningLike") || toCurrency.endsWith("lightninglike") ||
this.toCurrency.endsWith("LNURLPay") toCurrency.endsWith("lnurlpay")
) { ) {
settleMethodId = "ln"; settleMethodId = "ln";
} else { } else {
settleMethodId = this.toCurrency settleMethodId = toCurrency.replace('_btclike', '').replace('_monerolike', '').replace('_zcashlike', '').toLowerCase();
.replace("_BTCLike", "")
.replace("_MoneroLike", "")
.replace("_ZcashLike", "")
.toLowerCase();
} }
window.__SIDESHIFT__ = { window.__SIDESHIFT__ = {
parentAffiliateId: "qg0OrfHJV", parentAffiliateId: "qg0OrfHJV",

View File

@@ -1,11 +1,21 @@
@using BTCPayServer.Plugins.SideShift @using BTCPayServer.Plugins.SideShift
@using BTCPayServer.Payments
@inject BTCPayServer.Security.ContentSecurityPolicies csp @inject BTCPayServer.Security.ContentSecurityPolicies csp
@inject SideShiftService SideShiftService @inject SideShiftService SideShiftService
@model BTCPayServer.Models.InvoicingModels.PaymentModel @model BTCPayServer.Models.InvoicingModels.PaymentModel
@{ @{
var settings = await SideShiftService.GetSideShiftForInvoice(Model.InvoiceId, Model.StoreId); var settings = await SideShiftService.GetSideShiftForInvoice(Model.InvoiceId, Model.StoreId);
var preferredTargetPaymentMethodId = string.IsNullOrEmpty(settings?.PreferredTargetPaymentMethodId) ? null : Model.AvailableCryptos.Any(crypto => crypto.PaymentMethodId == settings.PreferredTargetPaymentMethodId) ? settings.PreferredTargetPaymentMethodId : null; var preferredTargetPaymentMethodId = "";
if(!PaymentMethodId.TryParse(settings?.PreferredTargetPaymentMethodId, out var preferredPMI))
{
preferredTargetPaymentMethodId = null;
}
else
{
preferredTargetPaymentMethodId = Model.AvailableCryptos.FirstOrDefault(crypto =>
crypto.PaymentMethodId == settings.PreferredTargetPaymentMethodId ||
(crypto.CryptoCode == preferredPMI.CryptoCode && crypto.PaymentMethodId.EndsWith(LNURLPayPaymentType.Instance.GetId()) || crypto.PaymentMethodId.EndsWith(LightningPaymentType.Instance.GetId())))?.PaymentMethodId;
}
} }
@if (settings?.Enabled is true) @if (settings?.Enabled is true)
{ {
@@ -28,7 +38,7 @@
preferredToCurrency: @Json.Serialize(preferredTargetPaymentMethodId), preferredToCurrency: @Json.Serialize(preferredTargetPaymentMethodId),
} }
}, },
created () { async created () {
const self = this; const self = this;
setInterval(function() { setInterval(function() {
if ( self.explicitId === window.ssExplicitId) { if ( self.explicitId === window.ssExplicitId) {
@@ -36,6 +46,12 @@
} }
self.explicitId = window.ssExplicitId; self.explicitId = window.ssExplicitId;
},200) },200)
if(this.preferredToCurrency && this.model.paymentMethodId !== this.preferredToCurrency){
this.$parent.paymentMethodId = this.preferredToCurrency;
await this.$parent.fetchData();
this.$parent.paymentMethodId = "SideShift";
}
}, },
computed: { computed: {
content () { content () {
@@ -45,14 +61,17 @@
return this.model.paymentMethodId; return this.model.paymentMethodId;
}, },
settleMethodId () { settleMethodId () {
if (this.currency.toLowerCase() === "lbtc") {
const toCurrency = this.currency.toLowerCase();
if (toCurrency === "lbtc") {
return 'liquid'; return 'liquid';
} else if (this.currency.toLowerCase() === "usdt") { } else if (toCurrency === "usdt") {
return "usdtla"; return "usdtla";
} else if (this.currency.endsWith('LightningLike') || this.currency.endsWith('LNURLPay')) { } else if (toCurrency.endsWith('lightninglike') || toCurrency.endsWith('lnurlpay')) {
return "ln"; return "ln";
} else { } else {
return this.currency.replace('_BTCLike', '').replace('_MoneroLike', '').replace('_ZcashLike', '').toLowerCase(); return toCurrency.replace('_btclike', '').replace('_monerolike', '').replace('_zcashlike', '').toLowerCase();
} }
}, },
type () { type () {

View File

@@ -7,9 +7,9 @@
if (settings?.Enabled is true) if (settings?.Enabled is true)
{ {
var coins = await SideShiftService.GetDepositOptions();
if (settings.ExplicitMethods?.Any() is true) if (settings.ExplicitMethods?.Any() is true)
{ {
var coins = await SideShiftService.GetDepositOptions();
foreach (var explicitMethod in settings.ExplicitMethods) foreach (var explicitMethod in settings.ExplicitMethods)
{ {
var s = explicitMethod.Split("_"); var s = explicitMethod.Split("_");