From ec4c346e0a619daa7269d5af27e02c0d2fdbbaa0 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Sun, 31 May 2020 11:42:49 +0900 Subject: [PATCH] [Greenfield] Document store API --- BTCPayServer.Client/Models/StoreBaseData.cs | 15 ++--- BTCPayServer/BTCPayServer.csproj | 2 +- .../GreenField/StoresController.cs | 4 +- .../swagger/v1/swagger.template.stores.json | 63 ++++++++++++------- 4 files changed, 52 insertions(+), 32 deletions(-) diff --git a/BTCPayServer.Client/Models/StoreBaseData.cs b/BTCPayServer.Client/Models/StoreBaseData.cs index 517c7232b..07e211727 100644 --- a/BTCPayServer.Client/Models/StoreBaseData.cs +++ b/BTCPayServer.Client/Models/StoreBaseData.cs @@ -29,11 +29,13 @@ namespace BTCPayServer.Client.Models public double PaymentTolerance { get; set; } = 0; public bool AnyoneCanCreateInvoice { get; set; } - public bool ShowRecommendedFee { get; set; } + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool ShowRecommendedFee { get; set; } = true; + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int RecommendedFeeBlockTarget { get; set; } = 1; - public int RecommendedFeeBlockTarget { get; set; } - - public string DefaultLang { get; set; } + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string DefaultLang { get; set; } = "en"; public bool LightningAmountInSatoshi { get; set; } public string CustomLogo { get; set; } @@ -42,14 +44,13 @@ namespace BTCPayServer.Client.Models public string HtmlTitle { get; set; } - public bool AnyoneCanInvoice { get; set; } - public bool RedirectAutomatically { get; set; } public bool RequiresRefundEmail { get; set; } [JsonConverter(typeof(StringEnumConverter))] - public NetworkFeeMode NetworkFeeMode { get; set; } + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public NetworkFeeMode NetworkFeeMode { get; set; } = NetworkFeeMode.Never; public bool PayJoinEnabled { get; set; } public bool LightningPrivateRouteHints { get; set; } diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 7c492a029..2580501bd 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -219,5 +219,5 @@ <_ContentIncludedByDefault Remove="Views\Authorization\Authorize.cshtml" /> - + diff --git a/BTCPayServer/Controllers/GreenField/StoresController.cs b/BTCPayServer/Controllers/GreenField/StoresController.cs index a6c1636e4..fe10705d1 100644 --- a/BTCPayServer/Controllers/GreenField/StoresController.cs +++ b/BTCPayServer/Controllers/GreenField/StoresController.cs @@ -128,7 +128,7 @@ namespace BTCPayServer.Controllers.GreenField CustomLogo = storeBlob.CustomLogo, CustomCSS = storeBlob.CustomCSS, HtmlTitle = storeBlob.HtmlTitle, - AnyoneCanInvoice = storeBlob.AnyoneCanInvoice, + AnyoneCanCreateInvoice = storeBlob.AnyoneCanInvoice, LightningDescriptionTemplate = storeBlob.LightningDescriptionTemplate, PaymentTolerance = storeBlob.PaymentTolerance, RedirectAutomatically = storeBlob.RedirectAutomatically, @@ -164,7 +164,7 @@ namespace BTCPayServer.Controllers.GreenField blob.CustomLogo = restModel.CustomLogo; blob.CustomCSS = restModel.CustomCSS; blob.HtmlTitle = restModel.HtmlTitle; - blob.AnyoneCanInvoice = restModel.AnyoneCanInvoice; + blob.AnyoneCanInvoice = restModel.AnyoneCanCreateInvoice; blob.LightningDescriptionTemplate = restModel.LightningDescriptionTemplate; blob.PaymentTolerance = restModel.PaymentTolerance; blob.RedirectAutomatically = restModel.RedirectAutomatically; diff --git a/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores.json b/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores.json index fa6e483b6..54e8dffe2 100644 --- a/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores.json +++ b/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores.json @@ -276,14 +276,12 @@ "properties": { "name": { "type": "string", - "description": "The name of the store", - "nullable": true + "description": "The name of the store" }, "website": { "type": "string", "description": "The absolute url of the store", - "format": "url", - "nullable": true + "format": "url" }, "invoiceExpiration": { "type": "integer", @@ -306,58 +304,79 @@ }, "lightningDescriptionTemplate": { "type": "string", - "nullable": true + "nullable": true, + "description": "The BOLT11 description of the lightning invoice in the checkout. You can use placeholders '{StoreName}', '{ItemDescription}' and '{OrderId}'." }, "paymentTolerance": { "type": "number", - "format": "double" + "format": "double", + "minimum": 0.0, + "maximum": 100.0, + "default": 0.0, + "description": "Consider an invoice fully paid, even if the payment is missing 'x' % of the full amount." }, "anyoneCanCreateInvoice": { - "type": "boolean" + "type": "boolean", + "default": false, + "description": "If true, then no authentication is needed to create invoices on this store." }, "showRecommendedFee": { - "type": "boolean" + "type": "boolean", + "default": true }, "recommendedFeeBlockTarget": { "type": "integer", - "format": "int32" + "format": "int32", + "default": 1, + "description": "The fee rate recommendation in the checkout page for the on-chain payment to be confirmed after 'x' blocks." }, "defaultLang": { "type": "string", - "nullable": true + "default": "en", + "description": "The default language to use in the checkout page. (The different translations available are listed [here](https://github.com/btcpayserver/btcpayserver/tree/master/BTCPayServer/wwwroot/locales)" }, "lightningAmountInSatoshi": { - "type": "boolean" + "type": "boolean", + "default": false, + "description": "If true, lightning payment methods show amount in satoshi in the checkout page." }, "customLogo": { "type": "string", - "nullable": true + "nullable": true, + "description": "URL to a logo to include in the checkout page." }, "customCSS": { "type": "string", - "nullable": true + "nullable": true, + "description": "URL to a CSS stylesheet to include in the checkout page" }, "htmlTitle": { "type": "string", - "nullable": true - }, - "anyoneCanInvoice": { - "type": "boolean" + "nullable": true, + "description": "The HTML title of the checkout page (when you over the tab in your browser)" }, "redirectAutomatically": { - "type": "boolean" + "type": "boolean", + "default": false, + "description": "After successfull payment, should the checkout page redirect the user automatically to the redirect URL of the invoice?" }, "requiresRefundEmail": { - "type": "boolean" + "type": "boolean", + "default": false, + "description": "If true, the checkout page will ask to enter an email address before accessing payment information." }, "networkFeeMode": { "$ref": "#/components/schemas/NetworkFeeMode" }, "payJoinEnabled": { - "type": "boolean" + "type": "boolean", + "default": false, + "description": "If true, payjoin will be proposed in the checkout page if possible. ([More information](https://docs.btcpayserver.org/Payjoin/#btcpay-server-payjoin-guide))" }, "lightningPrivateRouteHints": { - "type": "boolean" + "type": "boolean", + "default": false, + "description": "Should private route hints be included in the lightning payment of the checkout page." } } }, @@ -379,7 +398,7 @@ }, "NetworkFeeMode": { "type": "string", - "description": "", + "description": "Check whether network fee should be added to the invoice if on-chain payment is used. ([More information](https://docs.btcpayserver.org/FAQ/FAQ-Stores/#add-network-fee-to-invoice-vary-with-mining-fees))", "x-enumNames": [ "MultiplePaymentsOnly", "Always",