question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Error parsing reponse when using NFC Plugin

See original GitHub issue

What is your BTCPay version?

v1.6.10.0 + LNURL NFC Support v1.0.4.0

How did you deploy BTCPay Server?

Lunanode automatic deployment

What happened?

If I pay with LNURLw NFC or LNURLw, the BTCPayServer send error code 500 even when the payment is successful and the NFC plugin struggles with parsing the response and the alert at the end is triggered in the try/catch at the bottom of lnurlwnfc.js. The payment is successful but it is annoying to close the javascript alert every time.

I hardly found the source code there https://github.com/Kukks/btcpayserver/tree/plugins/collection/Plugins/BTCPayServer.Plugins.NFC

`sendData: function (lnurl) {

        this.submitting = true;
        //Post LNURLW data to server
        var xhr = new XMLHttpRequest()
        xhr.open('POST', window.lnurlWithdrawSubmitUrl, true)
        xhr.setRequestHeader('Content-Type', 'application/json')
        xhr.send(JSON.stringify({lnurl, destination: this.$parent.srvModel.btcAddress}))
        const self = this;
        //User feedback, reset on failure
        xhr.onload = function () {
            if (xhr.readyState === xhr.DONE) {
                console.log(xhr.response);
                console.log(xhr.responseText);
                self.scanning = false;
                self.submitting = false;

                if(self.readerAbortController) {
                    self.readerAbortController.abort()
                }

                try {
                    var data = JSON.parse(xhr.response)

                    if(data && data.status == "ERROR") {
                        alert(data.reason)
                    }
                } catch (err) {
                    alert("Error parsing response.")
                }
            }
        }
    }`

How did you encounter this bug?

  1. Created a btcpayserver invoce via Keypad only app
  2. Tried to pay via (NFC) LNURLw tag
  3. Payment is successful but the alert appeared

Relevant log output

No response

What browser do you use?

Safari 16.0

Additional information

Snímek obrazovky 2022-09-22 v 10 06 46 Snímek obrazovky 2022-09-22 v 10 06 57 Snímek obrazovky 2022-09-22 v 10 07 06

Are you sure this is a bug report?

  • I confirm this is a bug report

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gorrdycommented, Sep 28, 2022

Update the plugin, in 1.0.4.0 there is the bug we discussed earier.

1reaction
Kukkscommented, Sep 27, 2022

That can’t be as it runs the same code 😅 Must be some caching issue on the device…

Read more comments on GitHub >

github_iconTop Results From Across the Web

phonegap's nfc plugin object is throwing exception in one ...
2 Answers. If you're using Cordova, and installed the plugin with cordova plugin add phonegap-nfc , Cordova will create a global variable nfc...
Read more >
Core NFC | Apple Developer Forums
I am able to use NFCTagReaderSession polling for .iso15693 which correctly detects the tags and then have had to roll my own NDEF...
Read more >
NFC basics
This document describes the basic NFC tasks you perform in Android. It explains how to send and receive NFC data in the form...
Read more >
brew update/brew upgrade failing with Error: Not a ...
On some scheduled jobs on macOS, since few days the brew update and brew upgrade are failing. Area for Triage: Question, Bug, or...
Read more >
pokusew/nfc-pcsc: Easy reading and writing ...
Easy reading and writing NFC tags and cards in Node.js - GitHub ... TypeError: NFC is not a constructor; Transaction failed error when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found