mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
feat(payment): add WebLN payment functionality
Implemented functionality to create an invoice and make payment using WebLN. Also added error handling and logging for payment process. Updated UI to display payment information and a button to initiate payment.
This commit is contained in:
@@ -2,11 +2,30 @@ import {requestProvider} from "webln";
|
||||
|
||||
export default (livewireComponent) => ({
|
||||
|
||||
invoice: livewireComponent.entangle('invoice'),
|
||||
|
||||
async pay() {
|
||||
console.log('payment_request: ' + this.invoice.payment_request);
|
||||
await webln.sendPayment(this.invoice.payment_request)
|
||||
.then(response => {
|
||||
console.log('Payment response:', response);
|
||||
this.$wire.call('logThis', 'Payment response: ' + JSON.stringify(response));
|
||||
this.$wire.call('reloadMe');
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Payment failed:', error);
|
||||
this.$wire.call('logThis', 'Payment failed: ' + error);
|
||||
this.$wire.call('reloadMe');
|
||||
});
|
||||
},
|
||||
|
||||
async init() {
|
||||
console.log('WebLN initialized');
|
||||
|
||||
let webln;
|
||||
try {
|
||||
console.log(this.invoice);
|
||||
|
||||
webln = await requestProvider();
|
||||
console.log('WebLN provider acquired');
|
||||
this.$wire.call('logThis', 'WebLN provider acquired');
|
||||
|
||||
Reference in New Issue
Block a user