8000 [Fix] Fix issues by talvasconcelos · Pull Request #127 · lnbits/tpos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Fix] Fix issues #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class CreateTposData(BaseModel):
lnaddress: bool = Field(False)
lnaddress_cut: Optional[int] = Field(0)

@validator("withdraw_pin", pre=True)
def empty_string_to_none(cls, v):
if v == "" or v is None:
return None
return v


class TposClean(BaseModel):
id: str
Expand Down
32 changes: 21 additions & 11 deletions static/js/tpos.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,9 @@ window.app = Vue.createApp({
this.atmGetWithdraw()
} else {
const dialog = this.invoiceDialog

let params = {
amount: this.sat,
memo: this.amountFormatted
memo: this.total > 0 ? this.totalFormatted : this.amountFormatted
}
if (this.tipAmountSat > 0) {
params.tip_amount = this.tipAmountSat
Expand Down Expand Up @@ -572,6 +571,11 @@ window.app = Vue.createApp({
}

ndef. => {
// Abort scan immediately to prevent duplicate reads
readerAbortController.abort()

this.nfcTagReading = false

//Decode NDEF data from tag
const textDecoder = new TextDecoder('utf-8')

Expand All @@ -580,19 +584,26 @@ window.app = Vue.createApp({
return payload.toUpperCase().indexOf('LNURL') !== -1
})

if (!record) {
Quasar.Notify.create({
type: 'negative',
message: 'No valid LNURL found on this NFC tag.'
})
return
}

const lnurl = textDecoder.decode(record.data)

//User feedback, show loader icon
this.nfcTagReading = false
if (this.atmMode) {
const URL = lnurl.replace('lnurlp://', 'https://')
LNbits.api
.request('GET', `${lnurl.replace('lnurlw://', 'https://')}`)
.then(res => {
this.makeWithdraw(res.data.payLink, readerAbortController)
this.makeWithdraw(res.data.payLink)
})
} else {
this.payInvoice(lnurl, readerAbortController)
this.payInvoice(lnurl)
}

Quasar.Notify.create({
Expand All @@ -611,7 +622,7 @@ window.app = Vue.createApp({
})
}
},
makeWithdraw(payLink, readerAbortController) {
makeWithdraw(payLink) {
if (!payLink) {
Quasar.Notify.create({
type: 'negative',
Expand Down Expand Up @@ -642,14 +653,12 @@ window.app = Vue.createApp({
message: 'Topup successful!'
})
}
readerAbortController.abort()
})
.catch(e => {
console.error(e)
readerAbortController.abort()
})
},
payInvoice(lnurl, readerAbortController) {
payInvoice(lnurl) {
return axios
.post(
'/tpos/api/v1/tposs/' +
Expand All @@ -668,8 +677,9 @@ window.app = Vue.createApp({
message: response.data.detail
})
}

readerAbortController.abort()
})
.catch(error => {
console.error(error)
})
},
async getRates() {
Expand Down
1 change: 1 addition & 0 deletions templates/tpos/dialogs.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
rel="noopener noreferrer"
>
<lnbits-qrcode
:options="{margin: 4}"
:value="'lightning:' + invoiceDialog.data.payment_request.toUpperCase()"
class="rounded-borders"
></lnbits-qrcode>
Expand Down
0