mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
upd w
This commit is contained in:
@@ -53,6 +53,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.FileSe
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.DynamicReports", "Plugins\BTCPayServer.Plugins.DynamicReports\BTCPayServer.Plugins.DynamicReports.csproj", "{BCB4E68D-089F-481E-A3AE-FC9CED6AA34D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.DynamicReports", "Plugins\BTCPayServer.Plugins.DynamicReports\BTCPayServer.Plugins.DynamicReports.csproj", "{BCB4E68D-089F-481E-A3AE-FC9CED6AA34D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.Bringin", "Plugins\BTCPayServer.Plugins.Bringin\BTCPayServer.Plugins.Bringin.csproj", "{D4AFEC95-64D4-4FC4-9AE4-B82F4C6D6E29}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -253,6 +255,14 @@ Global
|
|||||||
{BCB4E68D-089F-481E-A3AE-FC9CED6AA34D}.Altcoins-Debug|Any CPU.Build.0 = Debug|Any CPU
|
{BCB4E68D-089F-481E-A3AE-FC9CED6AA34D}.Altcoins-Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{BCB4E68D-089F-481E-A3AE-FC9CED6AA34D}.Altcoins-Release|Any CPU.ActiveCfg = Debug|Any CPU
|
{BCB4E68D-089F-481E-A3AE-FC9CED6AA34D}.Altcoins-Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{BCB4E68D-089F-481E-A3AE-FC9CED6AA34D}.Altcoins-Release|Any CPU.Build.0 = Debug|Any CPU
|
{BCB4E68D-089F-481E-A3AE-FC9CED6AA34D}.Altcoins-Release|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D4AFEC95-64D4-4FC4-9AE4-B82F4C6D6E29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D4AFEC95-64D4-4FC4-9AE4-B82F4C6D6E29}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D4AFEC95-64D4-4FC4-9AE4-B82F4C6D6E29}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D4AFEC95-64D4-4FC4-9AE4-B82F4C6D6E29}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D4AFEC95-64D4-4FC4-9AE4-B82F4C6D6E29}.Altcoins-Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D4AFEC95-64D4-4FC4-9AE4-B82F4C6D6E29}.Altcoins-Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D4AFEC95-64D4-4FC4-9AE4-B82F4C6D6E29}.Altcoins-Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D4AFEC95-64D4-4FC4-9AE4-B82F4C6D6E29}.Altcoins-Release|Any CPU.Build.0 = Debug|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{B19C9F52-DC47-466D-8B5C-2D202B7B003F} = {9E04ECE9-E304-4FF2-9CBC-83256E6C6962}
|
{B19C9F52-DC47-466D-8B5C-2D202B7B003F} = {9E04ECE9-E304-4FF2-9CBC-83256E6C6962}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<LangVersion>10</LangVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<!-- -->
|
||||||
|
<!-- Plugin specific properties -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<Product>Dynamic Reports</Product>
|
||||||
|
<Description>Allows you to create custom reports using SQL.</Description>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
</PropertyGroup>
|
||||||
|
<!-- Plugin development properties -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
|
||||||
|
<PreserveCompilationContext>false</PreserveCompilationContext>
|
||||||
|
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- This will make sure that referencing BTCPayServer doesn't put any artifact in the published directory -->
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ProjectReference>
|
||||||
|
<Properties>StaticWebAssetsEnabled=false</Properties>
|
||||||
|
<Private>false</Private>
|
||||||
|
<ExcludeAssets>runtime;native;build;buildTransitive;contentFiles</ExcludeAssets>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Resources\**" />
|
||||||
|
<ProjectReference Include="..\..\submodules\btcpayserver\BTCPayServer\BTCPayServer.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
149
Plugins/BTCPayServer.Plugins.Bringin/Class1.cs
Normal file
149
Plugins/BTCPayServer.Plugins.Bringin/Class1.cs
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using BTCPayServer.JsonConverters;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace BTCPayServer.Plugins.Bringin;
|
||||||
|
|
||||||
|
public class BringinClient
|
||||||
|
{
|
||||||
|
public BringinClient(string apiKey, HttpClient httpClient)
|
||||||
|
{
|
||||||
|
ApiKey = apiKey;
|
||||||
|
HttpClient = httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ApiKey { get; set; }
|
||||||
|
private HttpClient HttpClient { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<string> GetUserId()
|
||||||
|
{
|
||||||
|
var response = await HttpClient.GetAsync($"/api/v0/user/user-id");
|
||||||
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
|
if (response.IsSuccessStatusCode) return JObject.Parse(content)["userId"].ToString();
|
||||||
|
var error = JObject.Parse(content).ToObject<BringinErrorResponse>();
|
||||||
|
throw new BringinException(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RateResponse> GetRate(string ticker = "BTCEUR")
|
||||||
|
{
|
||||||
|
var request = new {ticker};
|
||||||
|
var content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
|
||||||
|
var response = await HttpClient.PostAsync($"/api/v0/offramp/rates", content);
|
||||||
|
var responseContent = await response.Content.ReadAsStringAsync();
|
||||||
|
if (response.IsSuccessStatusCode) return JObject.Parse(responseContent).ToObject<RateResponse>();
|
||||||
|
var error = JObject.Parse(responseContent).ToObject<BringinErrorResponse>();
|
||||||
|
throw new BringinException(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<CreateOrderResponse> PlaceOrder(CreateOrderRequest request)
|
||||||
|
{
|
||||||
|
var content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
|
||||||
|
var response = await HttpClient.PostAsync($"/api/v0/offramp/order/lightning", content);
|
||||||
|
var responseContent = await response.Content.ReadAsStringAsync();
|
||||||
|
if (response.IsSuccessStatusCode) return JObject.Parse(responseContent).ToObject<CreateOrderResponse>();
|
||||||
|
var error = JObject.Parse(responseContent).ToObject<BringinErrorResponse>();
|
||||||
|
throw new BringinException(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RateResponse> GetOrderInfo(GetOrderRequest request)
|
||||||
|
{
|
||||||
|
var content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
|
||||||
|
var response = await HttpClient.PostAsync($"/api/v0/offramp/order/lightning", content);
|
||||||
|
var responseContent = await response.Content.ReadAsStringAsync();
|
||||||
|
if (response.IsSuccessStatusCode) return JObject.Parse(responseContent).ToObject<RateResponse>();
|
||||||
|
var error = JObject.Parse(responseContent).ToObject<BringinErrorResponse>();
|
||||||
|
throw new BringinException(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetOrderResponse
|
||||||
|
{
|
||||||
|
public string OrderId { get; set; }
|
||||||
|
public string Status { get; set; }
|
||||||
|
public string SubType { get; set; }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(NumericStringJsonConverter))]
|
||||||
|
public decimal SourceAmount { get; set; }
|
||||||
|
|
||||||
|
public string SourceCurrency { get; set; }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(NumericStringJsonConverter))]
|
||||||
|
public decimal DestinationAmount { get; set; }
|
||||||
|
|
||||||
|
public string DestinationCurrency { get; set; }
|
||||||
|
public BringinPrice BringinPrice { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BringinPrice
|
||||||
|
{
|
||||||
|
[JsonConverter(typeof(NumericStringJsonConverter))]
|
||||||
|
public decimal Price { get; set; }
|
||||||
|
|
||||||
|
public string Currency { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetOrderRequest
|
||||||
|
{
|
||||||
|
public string UserId { get; set; }
|
||||||
|
public string OrderId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CreateOrderResponse
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(NumericStringJsonConverter))]
|
||||||
|
public decimal Amount { get; set; }
|
||||||
|
|
||||||
|
public string Invoice { get; set; }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(NBitcoin.JsonConverters.DateTimeToUnixTimeConverter))]
|
||||||
|
[JsonProperty("expiresAt")]
|
||||||
|
public string Expiry { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CreateOrderRequest
|
||||||
|
{
|
||||||
|
[JsonConverter(typeof(NumericStringJsonConverter))]
|
||||||
|
public decimal SourceAmount { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("ipAddress")] public string IP { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RateResponse
|
||||||
|
{
|
||||||
|
public string Ticker { get; set; }
|
||||||
|
public string Currency { get; set; }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(NBitcoin.JsonConverters.DateTimeToUnixTimeConverter))]
|
||||||
|
public string Timestamp { get; set; }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(NumericStringJsonConverter))]
|
||||||
|
public decimal Price { get; set; }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(NumericStringJsonConverter))]
|
||||||
|
public decimal BringinPrice { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BringinErrorResponse
|
||||||
|
{
|
||||||
|
public string Message { get; set; }
|
||||||
|
public string StatusCode { get; set; }
|
||||||
|
public string ErrorCode { get; set; }
|
||||||
|
public JObject ErrorDetails { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BringinException : Exception
|
||||||
|
{
|
||||||
|
private readonly BringinClient.BringinErrorResponse _error;
|
||||||
|
|
||||||
|
public BringinException(BringinClient.BringinErrorResponse error)
|
||||||
|
{
|
||||||
|
_error = error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Product>Wabisabi Coinjoin</Product>
|
<Product>Wabisabi Coinjoin</Product>
|
||||||
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
|
<Description>Allows you to integrate your btcpayserver store with coinjoins.</Description>
|
||||||
<Version>1.0.65</Version>
|
<Version>1.0.66</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Plugin development properties -->
|
<!-- Plugin development properties -->
|
||||||
|
|||||||
Reference in New Issue
Block a user