@@ -70,6 +70,7 @@ export default {
70
70
isConfigValid: false ,
71
71
paymentChecker: null ,
72
72
currentView: ' invoice' ,
73
+ allowance: null ,
73
74
paymentStatus: {
74
75
isPayed: false ,
75
76
message: ' ...' ,
@@ -87,6 +88,18 @@ export default {
87
88
this .isConfigValid = await configSvc .isConfigValid ()
88
89
this .activeWallet = await configSvc .getActiveWallet ()
89
90
this .fetchBalance ()
91
+
92
+ try {
93
+ const response = await lnbitsApi (this .serverUrl ).getWithdrawLinks (this .activeWallet )
94
+ const withdrawLinks = response .data || []
95
+ await configSvc .setWithdrawLinks (withdrawLinks)
96
+ this .allowance = withdrawLinks .find ((link ) => link .title === this .requestedBy )
97
+ if (this .allowance ) {
98
+ await this .payInvoice ()
99
+ }
100
+ } catch (err) {
101
+ console .error (err)
102
+ }
90
103
},
91
104
92
105
computed: {
@@ -102,25 +115,31 @@ export default {
102
115
methods: {
103
116
payInvoice : async function () {
104
117
try {
105
- this .showPaymentInProgressCard ()
106
- const response = await lnbitsApi (this .serverUrl ).payInvoice (
107
- this .activeWallet ,
108
- this .paymentRequest
109
- )
118
+
119
+ if (this .allowance ) {
120
+ console .log (' ###################### will try to pay using allowance: ' , this .allowance )
121
+ this .showPaymentInProgressCard (' Using allowance for payment' )
122
+ } else {
123
+ this .showPaymentInProgressCard ()
124
+ await lnbitsApi (this .serverUrl ).payInvoice (this .activeWallet , this .paymentRequest )
125
+ }
126
+
127
+ console .log (' ###################### this.invoice: ' , this .invoice )
110
128
clearInterval (this .paymentChecker )
111
129
setTimeout (() => {
112
130
clearInterval (this .paymentChecker )
113
131
}, 40000 )
114
132
const payResponse = await lnbitsApi (this .serverUrl ).getPayment (
115
133
this .activeWallet ,
116
- response . data . payment_hash
134
+ this . invoice . hash
117
135
)
118
136
119
137
this .paymentChecker = setInterval (() => {
120
138
if (payResponse .data .paid ) {
121
139
clearInterval (this .paymentChecker )
122
140
const preimageHtml = ` <p class="text-wrap"><strong>Preimage: </strong> ${ payResponse .data .preimage } </p>`
123
141
this .showPaymentCompentedCard (preimageHtml)
142
+ // show notif if allowance, close
124
143
}
125
144
}, 1000 )
126
145
} catch (err) {
0 commit comments