diff --git a/BTCPayServer.Plugins.Branta/Data/Domain/InvoiceData.cs b/BTCPayServer.Plugins.Branta/Data/Domain/InvoiceData.cs index ecebf56..62943c5 100644 --- a/BTCPayServer.Plugins.Branta/Data/Domain/InvoiceData.cs +++ b/BTCPayServer.Plugins.Branta/Data/Domain/InvoiceData.cs @@ -31,6 +31,8 @@ public class InvoiceData public string ZeroKnowledgeSecret { get; set; } + public string PluginVersion { get; set; } + public string GetVerifyLink() { if (ExpirationDate <= DateTime.UtcNow || Status != InvoiceDataStatus.Success) diff --git a/BTCPayServer.Plugins.Branta/Migrations/20251214192229_Add-PluginVersion-To-InvoiceData.Designer.cs b/BTCPayServer.Plugins.Branta/Migrations/20251214192229_Add-PluginVersion-To-InvoiceData.Designer.cs new file mode 100644 index 0000000..516d724 --- /dev/null +++ b/BTCPayServer.Plugins.Branta/Migrations/20251214192229_Add-PluginVersion-To-InvoiceData.Designer.cs @@ -0,0 +1,75 @@ +// +using System; +using BTCPayServer.Plugins.Branta; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace BTCPayServer.Plugins.Branta.Migrations +{ + [DbContext(typeof(BrantaDbContext))] + [Migration("20251214192229_Add-PluginVersion-To-InvoiceData")] + partial class AddPluginVersionToInvoiceData + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("BTCPayServer.Plugins.Branta") + .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("BTCPayServer.Plugins.Branta.Data.Domain.InvoiceData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("Environment") + .HasColumnType("integer"); + + b.Property("ExpirationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("FailureReason") + .HasColumnType("text"); + + b.Property("InvoiceId") + .HasColumnType("text"); + + b.Property("PaymentId") + .HasColumnType("text"); + + b.Property("PluginVersion") + .HasColumnType("text"); + + b.Property("ProcessingTime") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreId") + .HasColumnType("text"); + + b.Property("ZeroKnowledgeSecret") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Invoice", "BTCPayServer.Plugins.Branta"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BTCPayServer.Plugins.Branta/Migrations/20251214192229_Add-PluginVersion-To-InvoiceData.cs b/BTCPayServer.Plugins.Branta/Migrations/20251214192229_Add-PluginVersion-To-InvoiceData.cs new file mode 100644 index 0000000..9f781a9 --- /dev/null +++ b/BTCPayServer.Plugins.Branta/Migrations/20251214192229_Add-PluginVersion-To-InvoiceData.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BTCPayServer.Plugins.Branta.Migrations +{ + /// + public partial class AddPluginVersionToInvoiceData : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "PluginVersion", + schema: "BTCPayServer.Plugins.Branta", + table: "Invoice", + type: "text", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "PluginVersion", + schema: "BTCPayServer.Plugins.Branta", + table: "Invoice"); + } + } +} diff --git a/BTCPayServer.Plugins.Branta/Migrations/MyPluginDbContextModelSnapshot.cs b/BTCPayServer.Plugins.Branta/Migrations/MyPluginDbContextModelSnapshot.cs index 128ffb2..e01f782 100644 --- a/BTCPayServer.Plugins.Branta/Migrations/MyPluginDbContextModelSnapshot.cs +++ b/BTCPayServer.Plugins.Branta/Migrations/MyPluginDbContextModelSnapshot.cs @@ -47,6 +47,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("PaymentId") .HasColumnType("text"); + b.Property("PluginVersion") + .HasColumnType("text"); + b.Property("ProcessingTime") .HasColumnType("integer"); diff --git a/BTCPayServer.Plugins.Branta/Models/InvoiceDataViewModel.cs b/BTCPayServer.Plugins.Branta/Models/InvoiceDataViewModel.cs index 2638321..1ba9eb7 100644 --- a/BTCPayServer.Plugins.Branta/Models/InvoiceDataViewModel.cs +++ b/BTCPayServer.Plugins.Branta/Models/InvoiceDataViewModel.cs @@ -19,6 +19,7 @@ public InvoiceDto(InvoiceData invoice) Status = invoice.Status; FailureReason = invoice.FailureReason; ExpirationDate = invoice.ExpirationDate; + PluginVersion = invoice.PluginVersion; VerifyLink = invoice.GetVerifyLink(); } } diff --git a/BTCPayServer.Plugins.Branta/Services/BrantaService.cs b/BTCPayServer.Plugins.Branta/Services/BrantaService.cs index 7e082f1..64a8fee 100644 --- a/BTCPayServer.Plugins.Branta/Services/BrantaService.cs +++ b/BTCPayServer.Plugins.Branta/Services/BrantaService.cs @@ -137,7 +137,8 @@ private async Task CreateInvoiceAsync(InvoiceEntity btcPayInvoice, .Value, Environment = brantaSettings.StagingEnabled ? Enums.ServerEnvironment.Staging : Enums.ServerEnvironment.Production, StoreId = btcPayInvoice.StoreId, - ZeroKnowledgeSecret = secret + ZeroKnowledgeSecret = secret, + PluginVersion = Helper.GetVersion() }; if (!brantaSettings.BrantaEnabled) diff --git a/BTCPayServer.Plugins.Branta/Views/UIBranta/ViewLogs.cshtml b/BTCPayServer.Plugins.Branta/Views/UIBranta/ViewLogs.cshtml index 3ab9ff2..01043db 100644 --- a/BTCPayServer.Plugins.Branta/Views/UIBranta/ViewLogs.cshtml +++ b/BTCPayServer.Plugins.Branta/Views/UIBranta/ViewLogs.cshtml @@ -30,6 +30,7 @@ Status Failure Reason Verify Link + Plugin Version Processing Time (ms) @@ -58,6 +59,7 @@ Expired } + @invoice.PluginVersion @(invoice.ProcessingTime > 0 ? invoice.ProcessingTime : "") }