diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index fd634b3dd..ff26bedce 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -119,6 +119,9 @@ $(IncludeRazorContentInPack) + + $(IncludeRazorContentInPack) + $(IncludeRazorContentInPack) diff --git a/BTCPayServer/Controllers/AppsController.PointOfSale.cs b/BTCPayServer/Controllers/AppsController.PointOfSale.cs index ab0c133c8..0145e79b1 100644 --- a/BTCPayServer/Controllers/AppsController.PointOfSale.cs +++ b/BTCPayServer/Controllers/AppsController.PointOfSale.cs @@ -308,5 +308,37 @@ namespace BTCPayServer.Controllers }; return View(model); } + + + [HttpPost] + [Route("{appId}/pay")] + [IgnoreAntiforgeryToken] + [EnableCors(CorsPolicies.All)] + public async Task PayButtonHandle(string appId, [FromForm]PayButtonViewModel model) + { + var app = await GetApp(appId, AppType.PointOfSale); + var settings = app.GetSettings(); + + var store = await GetStore(app); + var invoice = await _InvoiceController.CreateInvoiceCore(new NBitpayClient.Invoice() + { + Price = model.Price, + Currency = model.Currency, + ItemDesc = model.CheckoutDesc, + OrderId = model.OrderId, + BuyerEmail = model.NotifyEmail, + NotificationURL = model.ServerIpn, + RedirectURL = model.BrowserRedirect, + FullNotifications = true + }, store, HttpContext.Request.GetAbsoluteRoot()); + return Redirect(invoice.Data.Url); + } + + [HttpGet] + [Route("{appId}/paybuttontest")] + public async Task PayButtonTest(string appId) + { + return View(); + } } } diff --git a/BTCPayServer/Models/AppViewModels/PayButtonViewModel.cs b/BTCPayServer/Models/AppViewModels/PayButtonViewModel.cs index 8d8dfe807..58dcf4672 100644 --- a/BTCPayServer/Models/AppViewModels/PayButtonViewModel.cs +++ b/BTCPayServer/Models/AppViewModels/PayButtonViewModel.cs @@ -14,7 +14,7 @@ namespace BTCPayServer.Models.AppViewModels public int ButtonSize { get; set; } public string ServerIpn { get; set; } public string BrowserRedirect { get; set; } - public string EmailToNotify { get; set; } + public string NotifyEmail { get; set; } // public string UrlRoot { get; set; } diff --git a/BTCPayServer/Views/Apps/PayButton.cshtml b/BTCPayServer/Views/Apps/PayButton.cshtml index 1942053f0..110a72594 100644 --- a/BTCPayServer/Views/Apps/PayButton.cshtml +++ b/BTCPayServer/Views/Apps/PayButton.cshtml @@ -82,10 +82,10 @@
- - {{ errors.first('emailToNotify') }} + + {{ errors.first('notifyEmail') }}
@@ -145,7 +145,7 @@ en: { attributes: { price: 'Price', checkoutDesc: 'Checkout Description', orderId: 'Order Id', - serverIpn: 'Server IPN', emailToNotify: 'Send Email Notifications', browserRedirect: 'Browser Redirect' + serverIpn: 'Server IPN', notifyEmail: 'Send Email Notifications', browserRedirect: 'Browser Redirect' } } }; @@ -167,8 +167,8 @@ srvModel.buttonSize = buttonSize; } - var html = '<form method="POST" action="' + srvModel.urlRoot + '/apps/3jVExUHqRkGi4eaJEFCTxw5zjk14VAFzoVZXZJ3fbwED/pos">'; - html += addinput("amount", srvModel.price); + var html = '<form method="POST" action="' + srvModel.urlRoot + '/apps/3jVExUHqRkGi4eaJEFCTxw5zjk14VAFzoVZXZJ3fbwED/pay">'; + html += addinput("price", srvModel.price); if (srvModel.currency) { html += addinput("currency", srvModel.currency); } @@ -185,8 +185,8 @@ if (srvModel.browserRedirect) { html += addinput("browserRedirect", srvModel.browserRedirect); } - if (srvModel.emailToNotify) { - html += addinput("emailToNotify", srvModel.emailToNotify); + if (srvModel.notifyEmail) { + html += addinput("notifyEmail", srvModel.notifyEmail); } var width = "209px"; diff --git a/BTCPayServer/Views/Apps/PayButtonTest.cshtml b/BTCPayServer/Views/Apps/PayButtonTest.cshtml new file mode 100644 index 000000000..3e46f6f15 --- /dev/null +++ b/BTCPayServer/Views/Apps/PayButtonTest.cshtml @@ -0,0 +1,14 @@ + +
+
+
+ +
+ + + +
+ +
+
+