Skip to content

Commit

Permalink
feat: allow custom memo on invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
talvasconcelos committed Aug 5, 2024
1 parent ae4a8f9 commit 1a3bf13
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
37 changes: 28 additions & 9 deletions static/js/tpos.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ const tposJS = async () => {
searchTerm: '',
categoryFilter: '',
cart: new Map(),
denomIsSats: tpos.currency == 'sats'
denomIsSats: tpos.currency == 'sats',
customMemo: ''
}
},
computed: {
Expand Down Expand Up @@ -391,14 +392,28 @@ const tposJS = async () => {
})
return
}

if (this.tip_options && this.tip_options.length) {
this.rounding = false
this.tipRounding = null
this.showTipModal()
} else {
this.showInvoice()
}
this.$q
.dialog({
title: 'Prompt',
message: 'Add a memo to the invoice?',
prompt: {
model: '',
isValid: val => val.length > 2,
type: 'text'
},
cancel: true,
persistent: false
})
.onDismiss(data => {
this.customMemo = data.trim()
if (this.tip_options && this.tip_options.length) {
this.rounding = false
this.tipRounding = null
this.showTipModal()
} else {
this.showInvoice()
}
})
},
showTipModal: function () {
if (!this.atmMode) {
Expand All @@ -419,6 +434,10 @@ const tposJS = async () => {
memo: this.amountFormatted,
tipAmount: this.tipAmountSat
}

if (this.customMemo && this.customMemo.length > 2) {
params.memo = this.customMemo
}
if (this.cart.size) {
let details = [...this.cart.values()].map(item => {
return {
Expand Down
2 changes: 1 addition & 1 deletion views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def api_tpos_create_invoice(
payment_hash, payment_request = await create_invoice(
wallet_id=tpos.wallet,
amount=amount,
memo=f"{memo} to {tpos.name}" if memo else f"{tpos.name}",
memo=f"{memo} - ({tpos.name})" if memo else f"{tpos.name}",
extra={
"tag": "tpos",
"tipAmount": tip_amount,
Expand Down

0 comments on commit 1a3bf13

Please sign in to comment.