feat: add successful payment response handling

This commit is contained in:
fsociety
2024-09-10 22:20:56 +02:00
parent f584c07912
commit 6075060b56
2 changed files with 10 additions and 8 deletions

View File

@@ -10,7 +10,7 @@ export default (livewireComponent) => ({
.then(response => { .then(response => {
console.log('Payment response:', response); console.log('Payment response:', response);
this.$wire.call('logThis', 'Payment response: ' + JSON.stringify(response)); this.$wire.call('logThis', 'Payment response: ' + JSON.stringify(response));
this.$wire.call('success', response.preimage); this.$wire.call('success');
}) })
.catch(error => { .catch(error => {
console.error('Payment failed:', error); console.error('Payment failed:', error);

View File

@@ -1,12 +1,14 @@
<div x-data="webln(@this)" class="p-2 sm:p-4" wire:ignore> <div x-data="webln(@this)" class="p-2 sm:p-4">
<div class="font-mono space-y-1 p-2 sm:p-4 text-white break-words"> <div class="font-mono space-y-1 p-2 sm:p-4 text-white break-words">
<div wire:ignore>
<div class="text-xs sm:text-base break-words">Test Payment from WebLN to "The Ben"</div> <div class="text-xs sm:text-base break-words">Test Payment from WebLN to "The Ben"</div>
<div class="text-xs sm:text-base break-words">1 sat</div> <div class="text-xs sm:text-base break-words">1 sat</div>
<div class="text-xs sm:text-base break-words">hash: {{ $invoice['payment_hash'] }}</div> <div class="text-xs sm:text-base break-words">hash: {{ $invoice['payment_hash'] }}</div>
<div class="text-xs sm:text-base break-words">payment_request: {{ $invoice['payment_request'] }}</div> <div class="text-xs sm:text-base break-words">payment_request: {{ $invoice['payment_request'] }}</div>
</div>
<div class="mt-6"> <div class="mt-6">
@if(!$paymentDone) @if(!$paymentDone)
<div class="flex justify-center"> <div class="flex justify-center" wire:loading.attr="disabled">
<button x-on:click="pay" <button x-on:click="pay"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"> class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Pay Invoice Pay Invoice
@@ -17,7 +19,7 @@
<div class="text-green-500"> <div class="text-green-500">
Success! Payment done. Success! Payment done.
</div> </div>
<button wire:click="reloadMe" <button wire:click="reloadMe" wire:loading.attr="disabled"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"> class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Reload Reload
</button> </button>