2021-11-15 15:48:31 +01:00
@using BTCPayServer.Services.Apps
2022-07-15 05:38:33 +02:00
@using BTCPayServer.Abstractions.Models
2022-07-18 20:51:53 +02:00
@using BTCPayServer.Views.Apps
@using BTCPayServer.Abstractions.Extensions
2022-11-02 10:21:33 +01:00
@using BTCPayServer.Services.Stores
2022-07-18 20:51:53 +02:00
@model BTCPayServer.Plugins.PointOfSale.Models.UpdatePointOfSaleViewModel
2018-04-03 11:50:41 +09:00
@{
2022-01-24 18:07:52 -08:00
ViewData.SetActivePage(AppsNavPages.Update, "Update Point of Sale", Model.Id);
2022-11-02 10:21:33 +01:00
2022-11-25 02:42:55 +01:00
var checkoutFormOptions = CheckoutFormSelectList.WithSelected(Model.FormId);
2018-04-03 11:50:41 +09:00
}
2021-04-08 15:32:42 +02:00
2022-02-07 10:37:45 +01:00
<form method="post">
<div class="sticky-header-setup"></div>
2022-02-21 03:05:42 +01:00
<div class="sticky-header d-sm-flex align-items-center justify-content-between">
2022-02-07 10:37:45 +01:00
<h2 class="mb-0">@ViewData["Title"]</h2>
<div class="d-flex gap-3 mt-3 mt-sm-0">
<button type="submit" class="btn btn-primary order-sm-1" id="SaveSettings">Save</button>
2022-07-22 15:41:14 +02:00
<a class="btn btn-secondary" asp-action="ViewPointOfSale" asp-route-appId="@Model.Id" id="ViewApp" target="_blank">View</a>
2022-02-07 10:37:45 +01:00
</div>
2022-02-21 03:05:42 +01:00
</div>
2021-04-08 15:32:42 +02:00
2022-02-07 10:37:45 +01:00
<partial name="_StatusMessage" />
2021-07-23 03:57:19 -07:00
2021-12-11 04:32:23 +01:00
<input type="hidden" asp-for="StoreId" />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="row">
2022-01-27 03:56:46 +01:00
<div class="col-xl-8 col-xxl-constrain">
2021-12-11 04:32:23 +01:00
<div class="form-group">
<label asp-for="AppName" class="form-label" data-required></label>
<input asp-for="AppName" class="form-control" required />
<span asp-validation-for="AppName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Title" class="form-label" data-required></label>
<input asp-for="Title" class="form-control" required />
<span asp-validation-for="Title" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Currency" class="form-label"></label>
2022-09-26 03:26:13 +02:00
<input asp-for="Currency" class="form-control w-auto" currency-selection />
2022-06-19 19:55:47 -07:00
<small class="d-inline-block form-text text-muted">Uses the store's default currency (@Model.StoreDefaultCurrency) if empty.</small>
2021-12-11 04:32:23 +01:00
<span asp-validation-for="Currency" class="text-danger"></span>
</div>
</div>
2022-01-28 08:45:56 +01:00
</div>
<div class="row">
2022-01-27 03:56:46 +01:00
<div class="col-xl-10 col-xxl-constrain">
2022-01-28 08:45:56 +01:00
<div class="form-group mb-0">
2021-12-11 04:32:23 +01:00
<label asp-for="Description" class="form-label"></label>
<textarea asp-for="Description" rows="10" cols="40" class="form-control richtext"></textarea>
<span asp-validation-for="Description" class="text-danger"></span>
</div>
</div>
2022-01-28 08:45:56 +01:00
</div>
<div class="row">
2022-01-27 03:56:46 +01:00
<div class="col-xxl-constrain">
2022-06-19 19:55:47 -07:00
<partial name="TemplateEditor" model="@(nameof(Model.Template), "Products", Model.Currency ?? Model.StoreDefaultCurrency)" />
</div>
</div>
<div class="row collapse" id="RawEditor">
<div class="col-xxl-constrain">
<div class="form-group pt-3">
2021-12-11 04:32:23 +01:00
<label asp-for="Template" class="form-label"></label>
2022-06-19 19:55:47 -07:00
<textarea asp-for="Template" rows="10" cols="40" class="form-control"></textarea>
2021-12-11 04:32:23 +01:00
<span asp-validation-for="Template" class="text-danger"></span>
</div>
</div>
2022-01-28 08:45:56 +01:00
</div>
<div class="row">
2022-01-27 03:56:46 +01:00
<div class="col-xl-8 col-xxl-constrain">
2022-01-17 17:19:27 -08:00
<h3 class="mt-5 mb-4">Appearance</h3>
2021-12-11 04:32:23 +01:00
<div class="form-group">
<label asp-for="DefaultView" class="form-label" data-required></label>
<select asp-for="DefaultView" asp-items="@Html.GetEnumSelectList<PosViewType>()" class="form-select" required></select>
<span asp-validation-for="DefaultView" class="text-danger"></span>
2022-11-02 10:21:33 +01:00
<p class="form-text text-muted">Choose the point of sale style for your customers.</p>
2021-12-11 04:32:23 +01:00
</div>
<div class="form-group" id="button-price-text">
<label asp-for="ButtonText" class="form-label" data-required></label>
<input asp-for="ButtonText" class="form-control" required />
<span asp-validation-for="ButtonText" class="text-danger"></span>
</div>
<div class="form-group">
2022-11-25 02:42:55 +01:00
<label asp-for="FormId" class="form-label"></label>
<select asp-for="FormId" class="form-select w-auto" asp-items="@checkoutFormOptions"></select>
<span asp-validation-for="FormId" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="RequiresRefundEmail" class="form-label"></label>
<select asp-for="RequiresRefundEmail" asp-items="@Html.GetEnumSelectList<RequiresRefundEmail>()" class="form-select w-auto"></select>
<span asp-validation-for="RequiresRefundEmail" class="text-danger"></span>
2021-12-11 04:32:23 +01:00
</div>
<section id="discounts" class="p-0">
2022-01-17 17:19:27 -08:00
<h3 class="mt-5 mb-4">Discounts</h3>
2022-07-20 22:29:31 -07:00
<div class="form-group d-flex align-items-center">
<input asp-for="ShowDiscount" type="checkbox" class="btcpay-toggle me-3" />
2022-07-21 13:38:33 +02:00
<div>
<label asp-for="ShowDiscount" class="form-label mb-0"></label>
<div class="text-muted">Not recommended for customer self-checkout.</div>
</div>
2021-12-11 04:32:23 +01:00
<span asp-validation-for="ShowDiscount" class="text-danger"></span>
2022-07-20 22:29:31 -07:00
</div>
2021-12-11 04:32:23 +01:00
</section>
<section id="custom-payments" class="p-0">
2022-01-17 17:19:27 -08:00
<h3 class="mt-5 mb-4">Custom Payments</h3>
2021-12-11 04:32:23 +01:00
<div class="form-group mb-4 d-flex align-items-center">
2022-04-13 21:09:37 -07:00
<input asp-for="ShowCustomAmount" type="checkbox" class="btcpay-toggle me-3" data-bs-toggle="collapse" data-bs-target="#CustomAmountSettings" aria-expanded="@Model.ShowCustomAmount" aria-controls="CustomAmountSettings"/>
2021-12-11 04:32:23 +01:00
<label asp-for="ShowCustomAmount" class="form-label mb-0"></label>
<span asp-validation-for="ShowCustomAmount" class="text-danger"></span>
</div>
<div class="collapse @(Model.ShowCustomAmount ? "show" : "")" id="CustomAmountSettings">
<div class="form-group mb-0 pb-3">
<label asp-for="CustomButtonText" class="form-label" data-required></label>
<input asp-for="CustomButtonText" class="form-control" required />
<span asp-validation-for="CustomButtonText" class="text-danger"></span>
2018-11-17 12:43:11 +09:00
</div>
2021-07-23 03:57:19 -07:00
</div>
2021-12-11 04:32:23 +01:00
</section>
<section id="tips" class="p-0">
2022-01-17 17:19:27 -08:00
<h3 class="mt-5 mb-4">Tips</h3>
2022-04-13 21:09:37 -07:00
<div class="form-group d-flex align-items-center">
<input asp-for="EnableTips" type="checkbox" class="btcpay-toggle me-3" data-bs-toggle="collapse" data-bs-target="#CustomTipsSettings" aria-expanded="@Model.EnableTips" aria-controls="CustomTipsSettings" />
2021-12-11 04:32:23 +01:00
<label asp-for="EnableTips" class="form-label mb-0"></label>
<span asp-validation-for="EnableTips" class="text-danger"></span>
</div>
<div class="collapse @(Model.EnableTips ? "show" : "")" id="CustomTipsSettings">
2022-01-28 08:45:56 +01:00
<div class="form-group pt-3">
2021-12-11 04:32:23 +01:00
<label asp-for="CustomTipText" class="form-label" data-required></label>
<input asp-for="CustomTipText" class="form-control" required />
<span asp-validation-for="CustomTipText" class="text-danger"></span>
2019-03-29 07:51:00 +01:00
</div>
2022-01-28 08:45:56 +01:00
<div class="form-group mb-0">
2021-12-11 04:32:23 +01:00
<label asp-for="CustomTipPercentages" class="form-label"></label>
<input asp-for="CustomTipPercentages" class="form-control" />
<span asp-validation-for="CustomTipPercentages" class="text-danger"></span>
2021-10-27 07:32:56 -07:00
</div>
2021-12-11 04:32:23 +01:00
</div>
</section>
</div>
2022-01-28 08:45:56 +01:00
</div>
<div class="row">
2022-01-27 03:56:46 +01:00
<div class="col-xl-8 col-xxl-constrain">
2022-01-17 17:19:27 -08:00
<h3 class="mt-5 mb-2">Additional Options</h3>
2021-12-11 04:32:23 +01:00
<div class="form-group">
<div class="accordion" id="additional">
<div class="accordion-item">
<h2 class="accordion-header" id="additional-embed-payment-button-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#additional-embed-payment-button" aria-expanded="false" aria-controls="additional-embed-payment-button">
Embed a payment button linking to POS item
<vc:icon symbol="caret-down" />
</button>
</h2>
<div id="additional-embed-payment-button" class="accordion-collapse collapse" aria-labelledby="additional-embed-payment-button-header">
<div class="accordion-body">
<p>You can host point of sale buttons in an external website with the following code.</p>
@if (Model.Example1 != null)
{
<span>For anything with a custom amount</span>
2022-01-27 03:56:46 +01:00
<pre class="p-3">@Model.Example1</pre>
2021-12-11 04:32:23 +01:00
}
@if (Model.Example2 != null)
{
<span>For a specific item of your template</span>
2022-01-27 03:56:46 +01:00
<pre class="p-3">@Model.Example2</pre>
2021-12-11 04:32:23 +01:00
}
2021-10-25 03:06:32 -07:00
</div>
2020-01-23 20:01:49 -06:00
</div>
2021-12-11 04:32:23 +01:00
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="additional-embed-pos-iframe-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#additional-embed-pos-iframe" aria-expanded="false" aria-controls="additional-embed-pos-iframe">
Embed Point of Sale via Iframe
<vc:icon symbol="caret-down" />
</button>
</h2>
<div id="additional-embed-pos-iframe" class="accordion-collapse collapse" aria-labelledby="additional-embed-pos-iframe-header">
<div class="accordion-body">
You can embed this POS via an iframe.
@{
2022-07-22 15:41:14 +02:00
var iframe = $"<iframe src='{Url.Action("ViewPointOfSale", "UIPointOfSale", new { appId = Model.Id }, Context.Request.Scheme)}' style='max-width: 100%; border: 0;'></iframe>";
2021-12-11 04:32:23 +01:00
}
2022-01-27 03:56:46 +01:00
<pre class="p-3">@iframe</pre>
2021-10-25 03:06:32 -07:00
</div>
</div>
2021-12-11 04:32:23 +01:00
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="additional-redirect-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#additional-redirect" aria-expanded="false" aria-controls="additional-redirect">
Redirects
<vc:icon symbol="caret-down" />
</button>
</h2>
<div id="additional-redirect" class="accordion-collapse collapse" aria-labelledby="additional-redirect-header">
<div class="accordion-body">
<div class="form-group">
<label asp-for="RedirectUrl" class="form-label"></label>
<input asp-for="RedirectUrl" class="form-control" />
<span asp-validation-for="RedirectUrl" class="text-danger"></span>
2019-01-31 08:56:21 +01:00
</div>
2021-12-11 04:32:23 +01:00
<div class="form-group">
<label asp-for="RedirectAutomatically" class="form-label"></label>
<select asp-for="RedirectAutomatically" asp-items="Model.RedirectAutomaticallySelectList" class="form-select"></select>
<span asp-validation-for="RedirectAutomatically" class="text-danger"></span>
2019-01-31 08:56:21 +01:00
</div>
</div>
2021-12-11 04:32:23 +01:00
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="additional-notification-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#additional-notification" aria-expanded="false" aria-controls="additional-notification">
Notification URL Callbacks
<vc:icon symbol="caret-down" />
</button>
</h2>
<div id="additional-notification" class="accordion-collapse collapse" aria-labelledby="additional-notification-header">
<div class="accordion-body">
<div class="form-group">
<label asp-for="NotificationUrl" class="form-label"></label>
<input asp-for="NotificationUrl" class="form-control" />
<span asp-validation-for="NotificationUrl" class="text-danger"></span>
2021-07-23 03:57:19 -07:00
</div>
2022-06-06 02:58:32 -07:00
<p>A <code>POST</code> callback will be sent to the specified <code>notificationUrl</code> (for on-chain transactions when there are sufficient confirmations):</p>
2022-01-27 03:56:46 +01:00
<pre class="p-3">@Model.ExampleCallback</pre>
2021-12-11 04:32:23 +01:00
<p><strong>Never</strong> trust anything but <code>id</code>, <strong>ignore</strong> the other fields completely, an attacker can spoof those, they are present only for backward compatibility reason:</p>
2022-02-07 10:37:45 +01:00
<ul>
<li>Send a <code>GET</code> request to <code>https://btcpay.example.com/invoices/{invoiceId}</code> with <code>Content-Type: application/json; Authorization: Basic YourLegacyAPIkey"</code>, Legacy API key can be created with Access Tokens in Store settings</li>
<li>Verify that the <code>orderId</code> is from your backend, that the <code>price</code> is correct and that <code>status</code> is <code>settled</code></li>
<li>You can then ship your order</li>
</ul>
2021-07-23 03:57:19 -07:00
</div>
2021-12-11 04:32:23 +01:00
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="additional-custom-css-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#additional-custom-css" aria-expanded="false" aria-controls="additional-custom-css">
Custom CSS
<vc:icon symbol="caret-down" />
</button>
</h2>
<div id="additional-custom-css" class="accordion-collapse collapse" aria-labelledby="additional-custom-css-header">
<div class="accordion-body">
<div class="form-group">
<label asp-for="CustomCSSLink" class="form-label"></label>
<a href="https://docs.btcpayserver.org/Development/Theme/#2-bootstrap-themes" target="_blank" rel="noreferrer noopener">
<span class="fa fa-question-circle-o text-secondary" title="More information..."></span>
</a>
<input asp-for="CustomCSSLink" class="form-control" />
<span asp-validation-for="CustomCSSLink" class="text-danger"></span>
2019-01-31 08:56:21 +01:00
</div>
2021-12-11 04:32:23 +01:00
<div class="form-group">
<label asp-for="EmbeddedCSS" class="form-label"></label>
<textarea asp-for="EmbeddedCSS" rows="10" cols="40" class="form-control"></textarea>
<span asp-validation-for="EmbeddedCSS" class="text-danger"></span>
2021-07-23 03:57:19 -07:00
</div>
</div>
</div>
</div>
2021-09-24 07:13:38 +02:00
</div>
2021-12-11 04:32:23 +01:00
</div>
</div>
2022-01-28 08:45:56 +01:00
</div>
2021-12-11 04:32:23 +01:00
</form>
2021-05-19 04:39:27 +02:00
2022-02-21 03:05:42 +01:00
<div class="d-flex gap-3 mt-3">
2022-06-28 07:05:02 +02:00
<a class="btn btn-secondary" asp-action="ListInvoices" asp-controller="UIInvoice" asp-route-storeId="@Model.StoreId" asp-route-searchterm="@Model.SearchTerm">Invoices</a>
2022-08-25 22:40:42 -07:00
<a id="DeleteApp" class="btn btn-outline-danger" asp-controller="UIApps" asp-action="DeleteApp" asp-route-appId="@Model.Id" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-description="The app <strong>@Model.AppName</strong> and its settings will be permanently deleted." data-confirm-input="DELETE">Delete this app</a>
2021-12-19 05:05:10 +01:00
</div>
<partial name="_Confirm" model="@(new ConfirmModel("Delete app", "This app will be removed from this store.", "Delete"))" />
2021-05-19 04:39:27 +02:00
@section PageHeadContent {
2022-03-11 08:41:48 +01:00
<link href="~/vendor/highlightjs/default.min.css" rel="stylesheet" asp-append-version="true">
<link href="~/vendor/summernote/summernote-bs5.css" rel="stylesheet" asp-append-version="true" />
<link href="~/main/template-editor.css" rel="stylesheet" asp-append-version="true" />
2021-05-19 04:39:27 +02:00
}
@section PageFootContent {
<partial name="_ValidationScriptsPartial" />
2018-12-14 16:03:02 +08:00
<script id="template-product-item" type="text/template">
2018-12-14 16:16:08 +08:00
<div class="col-sm-4 col-md-3 mb-3">
2018-12-14 16:03:02 +08:00
<div class="card">
{image}
<div class="card-body">
<h6 class="card-title">{title}</h6>
2021-05-19 04:39:27 +02:00
<a href="#" class="js-product-edit btn btn-primary" data-bs-toggle="modal" data-bs-target="#product-modal">Edit</a>
2018-12-14 16:03:02 +08:00
<a href="#" class="js-product-remove btn btn-danger"><i class="fa fa-trash"></i></a>
</div>
</div>
</div>
</script>
<script id="template-product-content" type="text/template">
2019-05-12 02:13:26 -06:00
<div class="mb-3">
<input class="js-product-id" type="hidden" name="id" value="{id}">
<input class="js-product-index" type="hidden" name="index" value="{index}">
2021-06-06 13:44:54 +02:00
<div class="form-group row">
2019-05-12 02:13:26 -06:00
<div class="col-sm-6">
2021-06-06 13:44:54 +02:00
<label class="form-label" data-required>Title</label>
2021-03-29 22:27:42 -07:00
<input type="text" class="js-product-title form-control mb-2" value="{title}" autofocus required />
2019-05-12 02:13:26 -06:00
</div>
<div class="col-sm-3">
2021-06-06 13:44:54 +02:00
<label class="form-label" data-required>Price</label>
2020-01-23 20:19:24 -06:00
<input class="js-product-price form-control mb-2"
2022-03-30 00:58:50 -07:00
inputmode="decimal"
2020-01-23 20:19:24 -06:00
pattern="\d*"
type="number"
2021-03-29 22:27:42 -07:00
value="{price}"
required />
2019-05-12 02:13:26 -06:00
</div>
<div class="col-sm-3">
2021-06-06 13:44:54 +02:00
<label class="form-label">Custom price</label>
2021-05-19 04:39:27 +02:00
<select class="js-product-custom form-select">
2019-05-12 02:13:26 -06:00
{custom}
</select>
</div>
2018-12-14 16:03:02 +08:00
</div>
2021-06-06 13:44:54 +02:00
<div class="form-group">
<label class="form-label">Image</label>
<input type="text" class="js-product-image form-control mb-2" value="{image}" />
2018-12-14 16:03:02 +08:00
</div>
2021-06-06 13:44:54 +02:00
<div class="form-group">
<label class="form-label">Description</label>
<textarea rows="3" cols="40" class="js-product-description form-control mb-2">{description}</textarea>
2018-12-14 16:03:02 +08:00
</div>
2021-06-06 13:44:54 +02:00
<div class="form-group">
<label class="form-label">Inventory (leave blank to not use inventory feature)</label>
2022-03-25 22:09:58 -06:00
<input type="number" inputmode="numeric" step="1" class="js-product-inventory form-control mb-2" value="{inventory}" />
2019-09-02 15:37:52 +02:00
</div>
2021-09-05 15:19:27 -07:00
<div class="form-group d-flex align-items-center">
2021-09-12 21:59:18 -07:00
<input type="checkbox" class="btcpay-toggle me-2" value="{disabled}" />
<label class="form-label mb-0">Disabled</label>
2021-09-05 15:19:27 -07:00
</div>
2018-12-14 16:03:02 +08:00
</div>
</script>
2021-10-25 03:06:32 -07:00
<script>
2022-02-07 10:37:45 +01:00
const posStyleSelector = document.getElementById('DefaultView');
2021-10-25 03:06:32 -07:00
posStyleSelector.addEventListener('change', function(e) {
handleStyleSelected(e.target.value);
});
function handleStyleSelected(style) {
switch (style) {
case '0': // Item list only
2022-07-20 22:29:31 -07:00
case '3': // Print
2021-10-25 03:06:32 -07:00
hideDiscountsSection();
hideButtonPriceTextSection();
showCustomPaymentAmountSection();
hideTipsSection();
break;
case '1': // Item list and cart
showDiscountsSection();
showButtonPriceTextSection();
showCustomPaymentAmountSection();
showTipsSection();
break;
case '2': // Keypad only
2022-07-20 22:29:31 -07:00
showDiscountsSection();
2021-10-25 03:06:32 -07:00
hideButtonPriceTextSection();
hideCustomPaymentAmountSection();
showTipsSection();
break;
}
}
/** Show/hide discounts section */
2022-02-07 10:37:45 +01:00
const discountsSection = document.getElementById('discounts');
2021-10-25 03:06:32 -07:00
function hideDiscountsSection() {
hideElement(discountsSection);
}
function showDiscountsSection() {
showElement(discountsSection);
}
/***************************************/
/** Show/hide button text section */
2022-02-07 10:37:45 +01:00
const buttonPriceTextSection = document.getElementById('button-price-text');
2021-10-25 03:06:32 -07:00
function hideButtonPriceTextSection() {
hideElement(buttonPriceTextSection);
}
function showButtonPriceTextSection() {
showElement(buttonPriceTextSection);
}
/***************************************/
/** Show/hide custom payments amount seciton */
2022-02-07 10:37:45 +01:00
const customPaymentAmountSection = document.getElementById('custom-payments');
2021-10-25 03:06:32 -07:00
function hideCustomPaymentAmountSection() {
hideElement(customPaymentAmountSection);
}
function showCustomPaymentAmountSection() {
showElement(customPaymentAmountSection);
}
/***************************************/
/** Show/hide tips seciton */
2022-02-07 10:37:45 +01:00
const tipsSection = document.getElementById('tips');
2021-10-25 03:06:32 -07:00
function hideTipsSection() {
hideElement(tipsSection);
}
function showTipsSection() {
showElement(tipsSection);
}
/***************************************/
function hideElement(el) {
el.setAttribute('hidden', true);
}
function showElement(el) {
el.removeAttribute('hidden');
}
document.addEventListener("DOMContentLoaded", function() {
handleStyleSelected(posStyleSelector.value);
});
</script>
2019-08-21 17:05:52 +03:00
2022-03-11 08:41:48 +01:00
<script src="~/vendor/vuejs/vue.min.js" asp-append-version="true"></script>
<script src="~/vendor/summernote/summernote-bs5.js" asp-append-version="true"></script>
2018-05-24 23:54:48 +09:00
}