Enables balance payments via invoice
Adds functionality for users to pay their Castle balance by generating and paying a Lightning invoice. This includes: - Adding API endpoints for invoice generation and payment recording. - Updating the frontend to allow users to initiate the invoice payment process. - Passing the wallet's `inkey` to the frontend for payment status checks.
This commit is contained in:
parent
ef3e2d9e0d
commit
854164614f
3 changed files with 35 additions and 9 deletions
|
|
@ -34,6 +34,7 @@ window.app = Vue.createApp({
|
|||
amount: null,
|
||||
paymentRequest: null,
|
||||
paymentHash: null,
|
||||
checkWalletKey: null,
|
||||
loading: false
|
||||
},
|
||||
settingsDialog: {
|
||||
|
|
@ -326,6 +327,7 @@ window.app = Vue.createApp({
|
|||
// Show the payment request in the dialog
|
||||
this.payDialog.paymentRequest = response.data.payment_request
|
||||
this.payDialog.paymentHash = response.data.payment_hash
|
||||
this.payDialog.checkWalletKey = response.data.check_wallet_key
|
||||
|
||||
this.$q.notify({
|
||||
type: 'positive',
|
||||
|
|
@ -334,21 +336,21 @@ window.app = Vue.createApp({
|
|||
})
|
||||
|
||||
// Poll for payment completion
|
||||
this.pollForPayment(response.data.payment_hash)
|
||||
this.pollForPayment(response.data.payment_hash, response.data.check_wallet_key)
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
} finally {
|
||||
this.payDialog.loading = false
|
||||
}
|
||||
},
|
||||
async pollForPayment(paymentHash) {
|
||||
async pollForPayment(paymentHash, checkWalletKey) {
|
||||
// Poll every 2 seconds for payment status
|
||||
const checkPayment = async () => {
|
||||
try {
|
||||
const response = await LNbits.api.request(
|
||||
'GET',
|
||||
`/api/v1/payments/${paymentHash}`,
|
||||
this.g.user.wallets[0].inkey
|
||||
checkWalletKey
|
||||
)
|
||||
|
||||
if (response.data && response.data.paid) {
|
||||
|
|
@ -415,6 +417,7 @@ window.app = Vue.createApp({
|
|||
this.payDialog.amount = Math.abs(this.balance.balance)
|
||||
this.payDialog.paymentRequest = null
|
||||
this.payDialog.paymentHash = null
|
||||
this.payDialog.checkWalletKey = null
|
||||
this.payDialog.show = true
|
||||
},
|
||||
async showReceivableDialog() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue