mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 14:04:26 +01:00
Test LNUrl Pay payment method information, add doc
This commit is contained in:
@@ -35,7 +35,7 @@ namespace BTCPayServer.Client.Models
|
||||
public string PaymentMethod { get; set; }
|
||||
|
||||
public string CryptoCode { get; set; }
|
||||
public Dictionary<string, JObject> AdditionalData { get; set; }
|
||||
public JObject AdditionalData { get; set; }
|
||||
|
||||
public class Payment
|
||||
{
|
||||
|
||||
@@ -145,8 +145,15 @@ namespace BTCPayServer.Tests
|
||||
Driver.FindElement(By.Id("IsAdmin")).Click();
|
||||
Driver.FindElement(By.Id("RegisterButton")).Click();
|
||||
Driver.AssertNoError();
|
||||
CreatedUser = usr;
|
||||
return usr;
|
||||
}
|
||||
string CreatedUser;
|
||||
|
||||
public TestAccount AsTestAccount()
|
||||
{
|
||||
return new TestAccount(Server) { RegisterDetails = new Models.AccountViewModels.RegisterViewModel() { Password = "123456", Email = CreatedUser } };
|
||||
}
|
||||
|
||||
public (string storeName, string storeId) CreateNewStore(bool keepId = true)
|
||||
{
|
||||
|
||||
@@ -1467,6 +1467,8 @@ namespace BTCPayServer.Tests
|
||||
s.GoToLightningSettings();
|
||||
// LNURL is true by default
|
||||
Assert.True(s.Driver.FindElement(By.Id("LNURLEnabled")).Selected);
|
||||
s.Driver.SetCheckbox(By.Name("LUD12Enabled"), true);
|
||||
s.Driver.FindElement(By.Id("save")).Click();
|
||||
|
||||
// Topup Invoice test
|
||||
var i = s.CreateInvoice(storeId, null, cryptoCode);
|
||||
@@ -1479,13 +1481,13 @@ namespace BTCPayServer.Tests
|
||||
Assert.Equal(1m, fetchedReuqest.MinSendable.ToDecimal(LightMoneyUnit.Satoshi));
|
||||
Assert.NotEqual(1m, fetchedReuqest.MaxSendable.ToDecimal(LightMoneyUnit.Satoshi));
|
||||
var lnurlResponse = await fetchedReuqest.SendRequest(new LightMoney(0.000001m, LightMoneyUnit.BTC),
|
||||
network, new HttpClient());
|
||||
network, new HttpClient(), comment: "lol");
|
||||
|
||||
Assert.Equal(new LightMoney(0.000001m, LightMoneyUnit.BTC),
|
||||
lnurlResponse.GetPaymentRequest(network).MinimumAmount);
|
||||
|
||||
var lnurlResponse2 = await fetchedReuqest.SendRequest(new LightMoney(0.000002m, LightMoneyUnit.BTC),
|
||||
network, new HttpClient());
|
||||
network, new HttpClient(), comment: "lol2");
|
||||
Assert.Equal(new LightMoney(0.000002m, LightMoneyUnit.BTC), lnurlResponse2.GetPaymentRequest(network).MinimumAmount);
|
||||
await Assert.ThrowsAnyAsync<LightningRPCException>(async () =>
|
||||
{
|
||||
@@ -1499,7 +1501,11 @@ namespace BTCPayServer.Tests
|
||||
var inv = await s.Server.PayTester.InvoiceRepository.GetInvoice(i);
|
||||
Assert.Equal(InvoiceStatusLegacy.Complete, inv.Status);
|
||||
});
|
||||
|
||||
var greenfield = await s.AsTestAccount().CreateClient();
|
||||
var paymentMethods = await greenfield.GetInvoicePaymentMethods(s.StoreId, i);
|
||||
Assert.Single(paymentMethods, p => {
|
||||
return p.AdditionalData["providedComment"].Value<string>() == "lol2";
|
||||
});
|
||||
// Standard invoice test
|
||||
s.GoToStore(storeId);
|
||||
s.GoToLightningSettings();
|
||||
@@ -1608,6 +1614,7 @@ namespace BTCPayServer.Tests
|
||||
s.Driver.FindElement(By.Id("Amount")).Clear();
|
||||
s.Driver.FindElement(By.Id("Amount")).SendKeys("0.0000001");
|
||||
s.Driver.FindElement(By.Id("Create")).Click();
|
||||
s.Driver.TakeScreenshot().SaveAsFile(@"C:\Users\NicolasDorier\AppData\Local\Temp\1279276918\wfew.png");
|
||||
s.Driver.FindElement(By.LinkText("View")).Click();
|
||||
s.Driver.FindElement(By.Id("Destination")).SendKeys(lnurl);
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace BTCPayServer
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var lnAddress = username is null ? null : $"{username}@{Request.Host.ToString()}";
|
||||
var lnAddress = username is null ? null : $"{username}@{Request.Host}";
|
||||
List<string[]> lnurlMetadata = new List<string[]>();
|
||||
|
||||
var i = await _invoiceController.CreateInvoiceCoreRaw(
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace BTCPayServer.HostedServices
|
||||
throw new ArgumentException("Amount out of bound", nameof(create));
|
||||
using var ctx = this._dbContextFactory.CreateContext();
|
||||
var o = new Data.PullPaymentData();
|
||||
o.StartDate = create.StartsAt is DateTimeOffset date ? date : DateTimeOffset.UtcNow;
|
||||
o.StartDate = create.StartsAt is DateTimeOffset date ? date : DateTimeOffset.UtcNow - TimeSpan.FromSeconds(1.0);
|
||||
o.EndDate = create.ExpiresAt is DateTimeOffset date2 ? new DateTimeOffset?(date2) : null;
|
||||
o.Period = create.Period is TimeSpan period ? (long?)period.TotalSeconds : null;
|
||||
o.Id = Encoders.Base58.EncodeData(RandomUtils.GetBytes(20));
|
||||
|
||||
@@ -22,6 +22,6 @@ namespace BTCPayServer.Payments
|
||||
|
||||
bool Activated { get; set; }
|
||||
virtual string GetAdditionalDataPartialName() => null;
|
||||
virtual Dictionary<string,JObject> GetAdditionalData() => new();
|
||||
virtual JObject GetAdditionalData() => new();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,19 +35,13 @@ namespace BTCPayServer.Payments
|
||||
return "LNURL/AdditionalPaymentMethodDetails";
|
||||
}
|
||||
|
||||
public override Dictionary<string, JObject> GetAdditionalData()
|
||||
public override JObject GetAdditionalData()
|
||||
{
|
||||
var result = base.GetAdditionalData();
|
||||
if (!string.IsNullOrEmpty(ProvidedComment))
|
||||
{
|
||||
result.TryAdd(nameof(ProvidedComment), new JObject(ProvidedComment));
|
||||
}
|
||||
|
||||
result.Add("providedComment", new JValue(ProvidedComment));
|
||||
if (!string.IsNullOrEmpty(ConsumedLightningAddress))
|
||||
{
|
||||
result.TryAdd(nameof(ConsumedLightningAddress), new JObject(ConsumedLightningAddress));
|
||||
}
|
||||
|
||||
result.Add("consumedLightningAddress", new JValue(ConsumedLightningAddress));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace BTCPayServer.Payments.Lightning
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual Dictionary<string, JObject> GetAdditionalData()
|
||||
public virtual JObject GetAdditionalData()
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
@@ -1142,8 +1142,31 @@
|
||||
"description": "If the payment method is activated (when lazy payments option is enabled"
|
||||
},
|
||||
"additionalData": {
|
||||
"description": "Additional data provided by the payment method.",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"description": "Additional data provided by the payment method."
|
||||
"description": "LNURL Pay information",
|
||||
"properties": {
|
||||
"providedComment": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The provided comment to a LNUrl payment with comments enabled",
|
||||
"example": "Thank you!"
|
||||
},
|
||||
"consumedLightningAddress": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The consumed lightning address of a LN Address payment",
|
||||
"example": "customer@example.com"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"description": "No additional information"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user