Greenfield: Invoices Payment Methods: Additional Data

closes #3154
This commit is contained in:
Kukks
2022-02-07 09:39:48 +01:00
committed by Andrew Camilleri
parent 631ddc0af2
commit 1c5cf29540
10 changed files with 36 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ namespace BTCPayServer.Client.Models
public string PaymentMethod { get; set; }
public string CryptoCode { get; set; }
public Dictionary<string, object> AdditionalData { get; set; }
public class Payment
{

View File

@@ -365,7 +365,8 @@ namespace BTCPayServer.Controllers.Greenfield
PaymentLink =
method.GetId().PaymentType.GetPaymentLink(method.Network, details, accounting.Due,
Request.GetAbsoluteRoot()),
Payments = payments.Select(paymentEntity => ToPaymentModel(entity, paymentEntity)).ToList()
Payments = payments.Select(paymentEntity => ToPaymentModel(entity, paymentEntity)).ToList(),
AdditionalData = details.GetAdditionalData()
};
}).ToArray();
}

View File

@@ -1,3 +1,5 @@
using System.Collections.Generic;
namespace BTCPayServer.Payments
{
/// <summary>
@@ -19,5 +21,6 @@ namespace BTCPayServer.Payments
bool Activated { get; set; }
virtual string GetAdditionalDataPartialName() => null;
virtual Dictionary<string,object> GetAdditionalData() => new();
}
}

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using BTCPayServer.Client.JsonConverters;
using BTCPayServer.Lightning;
using BTCPayServer.Payments.Lightning;
@@ -11,6 +12,7 @@ namespace BTCPayServer.Payments
[JsonConverter(typeof(LightMoneyJsonConverter))]
public LightMoney GeneratedBoltAmount { get; set; }
public string BTCPayInvoiceId { get; set; }
public bool Bech32Mode { get; set; }
@@ -31,5 +33,21 @@ namespace BTCPayServer.Payments
return "LNURL/AdditionalPaymentMethodDetails";
}
public override Dictionary<string, object> GetAdditionalData()
{
var result = base.GetAdditionalData();
if (!string.IsNullOrEmpty(ProvidedComment))
{
result.TryAdd(nameof(ProvidedComment), ProvidedComment);
}
if (!string.IsNullOrEmpty(ConsumedLightningAddress))
{
result.TryAdd(nameof(ConsumedLightningAddress), ConsumedLightningAddress);
}
return result;
}
}
}

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using BTCPayServer.Lightning;
using NBitcoin;
@@ -40,5 +41,10 @@ namespace BTCPayServer.Payments.Lightning
{
return null;
}
public virtual Dictionary<string, object> GetAdditionalData()
{
return new();
}
}
}

View File

@@ -1140,6 +1140,10 @@
"activated": {
"type": "boolean",
"description": "If the payment method is activated (when lazy payments option is enabled"
},
"additionalData": {
"type": "object",
"description": "Additional data provided by the payment method."
}
}
},

Binary file not shown.

View File

@@ -0,0 +1 @@
{"Identifier":"BTCPayServer.Plugins.FixedFloat","Name":"FixedFloat","Version":"1.0.1.0","Description":"Allows you to embed a FixedFloat conversion screen to allow customers to pay with altcoins.","SystemPlugin":false,"Dependencies":[{"Identifier":"BTCPayServer","Condition":"\u003E=1.4.0.0"}]}

Binary file not shown.

View File

@@ -0,0 +1 @@
{"Identifier":"BTCPayServer.Plugins.SideShift","Name":"SideShift","Version":"1.0.3.0","Description":"Allows you to embed a SideShift conversion screen to allow customers to pay with altcoins.","SystemPlugin":false,"Dependencies":[{"Identifier":"BTCPayServer","Condition":"\u003E=1.4.0.0"}]}