diff --git a/BTCPayServer/Controllers/PublicController.cs b/BTCPayServer/Controllers/PublicController.cs index 5c0dea090..c30259ccb 100644 --- a/BTCPayServer/Controllers/PublicController.cs +++ b/BTCPayServer/Controllers/PublicController.cs @@ -37,7 +37,6 @@ namespace BTCPayServer.Controllers [HttpPost] [Route("api/v1/invoices")] - [MediaTypeAcceptConstraintAttribute("text/html")] [IgnoreAntiforgeryToken] [EnableCors(CorsPolicies.All)] public async Task PayButtonHandle([FromForm]PayButtonViewModel model, CancellationToken cancellationToken) @@ -78,6 +77,15 @@ namespace BTCPayServer.Controllers ModelState.AddModelError("Store", e.Message); return View(); } + + if (model.JsonResponse) + { + return Json(new + { + InvoiceId = invoice.Data.Id, + InvoiceUrl = invoice.Data.Url + }); + } if (string.IsNullOrEmpty(model.CheckoutQueryString)) { diff --git a/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs b/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs index 6c688a26b..76fa3530b 100644 --- a/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs @@ -41,5 +41,7 @@ namespace BTCPayServer.Models.StoreViewModels public List CurrencyDropdown { get; set; } public string PayButtonImageUrl { get; set; } public string PayButtonText { get; set; } + public bool UseModal { get; set; } + public bool JsonResponse { get; set; } } } diff --git a/BTCPayServer/Views/Stores/PayButton.cshtml b/BTCPayServer/Views/Stores/PayButton.cshtml index 787dfac77..5ea5da217 100644 --- a/BTCPayServer/Views/Stores/PayButton.cshtml +++ b/BTCPayServer/Views/Stores/PayButton.cshtml @@ -47,6 +47,11 @@
+
+ +