From 1055e61bb4d8008f042f5236a4520db8c1c32d72 Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Mon, 27 Mar 2023 18:28:53 +0200 Subject: [PATCH] NFC improvements Two changes which fix #4807: - Once permissions are granted we start scanning immediately, no need to ask for permissions or have the user click the button again - We don't abort the scan, which gets rid of the cases in which the OS took over after the scan, because the user left the card on the device Also adds feedback for the NFC states scanning and submitting. --- BTCPayServer/Plugins/NFC/NFCController.cs | 6 +- .../Views/Shared/NFC/CheckoutEnd.cshtml | 140 +++++++++++------- BTCPayServer/wwwroot/locales/checkout/en.json | 2 + 3 files changed, 89 insertions(+), 59 deletions(-) diff --git a/BTCPayServer/Plugins/NFC/NFCController.cs b/BTCPayServer/Plugins/NFC/NFCController.cs index db43ac429..a09749770 100644 --- a/BTCPayServer/Plugins/NFC/NFCController.cs +++ b/BTCPayServer/Plugins/NFC/NFCController.cs @@ -175,18 +175,18 @@ namespace BTCPayServer.Plugins.NFC } } - if (bolt11 is null) + if (string.IsNullOrEmpty(bolt11)) { return BadRequest("Could not fetch BOLT11 invoice to pay to."); } var result = await info.SendRequest(bolt11, httpClient); - if (result.Status.Equals("ok", StringComparison.InvariantCultureIgnoreCase)) + if (!string.IsNullOrEmpty(result.Status) && result.Status.Equals("ok", StringComparison.InvariantCultureIgnoreCase)) { return Ok(result.Reason); } - return BadRequest(result.Reason); + return BadRequest(result.Reason ?? "Unknown error"); } } } diff --git a/BTCPayServer/Views/Shared/NFC/CheckoutEnd.cshtml b/BTCPayServer/Views/Shared/NFC/CheckoutEnd.cshtml index b0a2b4f61..e30ea250a 100644 --- a/BTCPayServer/Views/Shared/NFC/CheckoutEnd.cshtml +++ b/BTCPayServer/Views/Shared/NFC/CheckoutEnd.cshtml @@ -5,9 +5,11 @@

- +