Error handling in livewire

This commit is contained in:
David Bomba 2024-09-05 15:06:21 +10:00
parent 076f168707
commit 63f3115a02
8 changed files with 76 additions and 47 deletions

View File

@ -196,6 +196,7 @@ class InvoicePay extends Component
#[Computed()]
public function component(): string
{
if (!$this->terms_accepted) {
return Terms::class;
}
@ -217,6 +218,7 @@ class InvoicePay extends Component
}
return ProcessPayment::class;
}
#[Computed()]
@ -239,8 +241,6 @@ class InvoicePay extends Component
$this->setContext('settings', $settings); // $this->context['settings'] = $settings;
$this->setContext('db', $this->db); // $this->context['db'] = $this->db;
nlog($this->invoices);
if(is_array($this->invoices))
$this->invoices = Invoice::find($this->transformKeys($this->invoices));
@ -284,4 +284,13 @@ class InvoicePay extends Component
{
return render('flow2.invoice-pay');
}
public function exception($e, $stopPropagation)
{
nlog($e->getMessage());
$stopPropagation();
}
}

View File

@ -75,4 +75,13 @@ class PaymentMethod extends Component
{
return render('flow2.payment-method', ['methods' => $this->methods]);
}
public function exception($e, $stopPropagation)
{
nlog($e->getMessage());
$stopPropagation();
}
}

View File

@ -29,7 +29,7 @@ class ProcessPayment extends Component
private array $payment_data_payload = [];
public $isLoading = true;
public function mount()
{
@ -55,6 +55,7 @@ class ProcessPayment extends Component
$company_gateway = CompanyGateway::find($this->getContext()['company_gateway_id']);
if (!$responder_data['success']) {
nlog("ouchiees");
throw new PaymentFailed($responder_data['error'], 400);
}
@ -83,4 +84,14 @@ class ProcessPayment extends Component
return render($this->payment_view, $this->payment_data_payload);
}
public function exception($e, $stopPropagation)
{
nlog($e->getMessage());
$stopPropagation();
}
}

View File

@ -135,4 +135,5 @@ class RequiredFields extends Component
'contact' => $this->getContext()['contact'],
]);
}
}

View File

@ -87,7 +87,6 @@ class LivewireInstantPayment
public function run()
{
nlog($this->data);
$company_gateway = CompanyGateway::query()->find($this->data['company_gateway_id']);

82
composer.lock generated
View File

@ -535,16 +535,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.321.3",
"version": "3.321.4",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "92e5d5fbfd3b29522b763d49d8f2fdf32e58fc1e"
"reference": "986326efde1d0598ec9fc1b185716550be8ef522"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/92e5d5fbfd3b29522b763d49d8f2fdf32e58fc1e",
"reference": "92e5d5fbfd3b29522b763d49d8f2fdf32e58fc1e",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/986326efde1d0598ec9fc1b185716550be8ef522",
"reference": "986326efde1d0598ec9fc1b185716550be8ef522",
"shasum": ""
},
"require": {
@ -627,9 +627,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.321.3"
"source": "https://github.com/aws/aws-sdk-php/tree/3.321.4"
},
"time": "2024-09-03T18:04:21+00:00"
"time": "2024-09-04T18:09:31+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -3489,16 +3489,16 @@
},
{
"name": "horstoeko/zugferd",
"version": "v1.0.58",
"version": "v1.0.59",
"source": {
"type": "git",
"url": "https://github.com/horstoeko/zugferd.git",
"reference": "e5ebbecd786bd901a6c9f9873e608631b18f9b9e"
"reference": "d967bfeb886d3f51a82f78b447637d82a36a71cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/horstoeko/zugferd/zipball/e5ebbecd786bd901a6c9f9873e608631b18f9b9e",
"reference": "e5ebbecd786bd901a6c9f9873e608631b18f9b9e",
"url": "https://api.github.com/repos/horstoeko/zugferd/zipball/d967bfeb886d3f51a82f78b447637d82a36a71cb",
"reference": "d967bfeb886d3f51a82f78b447637d82a36a71cb",
"shasum": ""
},
"require": {
@ -3558,9 +3558,9 @@
],
"support": {
"issues": "https://github.com/horstoeko/zugferd/issues",
"source": "https://github.com/horstoeko/zugferd/tree/v1.0.58"
"source": "https://github.com/horstoeko/zugferd/tree/v1.0.59"
},
"time": "2024-09-02T15:21:11+00:00"
"time": "2024-09-04T03:04:52+00:00"
},
{
"name": "horstoeko/zugferdvisualizer",
@ -4881,16 +4881,16 @@
},
{
"name": "laravel/slack-notification-channel",
"version": "v3.3.1",
"version": "v3.3.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/slack-notification-channel.git",
"reference": "fc8f931b9ae868945cf0c39aeda71f1cbe180484"
"reference": "5e04e4a0834b84650a207a76b7a67de8156d0b04"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/slack-notification-channel/zipball/fc8f931b9ae868945cf0c39aeda71f1cbe180484",
"reference": "fc8f931b9ae868945cf0c39aeda71f1cbe180484",
"url": "https://api.github.com/repos/laravel/slack-notification-channel/zipball/5e04e4a0834b84650a207a76b7a67de8156d0b04",
"reference": "5e04e4a0834b84650a207a76b7a67de8156d0b04",
"shasum": ""
},
"require": {
@ -4940,9 +4940,9 @@
],
"support": {
"issues": "https://github.com/laravel/slack-notification-channel/issues",
"source": "https://github.com/laravel/slack-notification-channel/tree/v3.3.1"
"source": "https://github.com/laravel/slack-notification-channel/tree/v3.3.2"
},
"time": "2024-08-17T20:57:03+00:00"
"time": "2024-09-04T06:56:09+00:00"
},
{
"name": "laravel/socialite",
@ -6698,16 +6698,16 @@
},
{
"name": "mtdowling/jmespath.php",
"version": "2.7.0",
"version": "2.8.0",
"source": {
"type": "git",
"url": "https://github.com/jmespath/jmespath.php.git",
"reference": "bbb69a935c2cbb0c03d7f481a238027430f6440b"
"reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/bbb69a935c2cbb0c03d7f481a238027430f6440b",
"reference": "bbb69a935c2cbb0c03d7f481a238027430f6440b",
"url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/a2a865e05d5f420b50cc2f85bb78d565db12a6bc",
"reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc",
"shasum": ""
},
"require": {
@ -6724,7 +6724,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
"dev-master": "2.8-dev"
}
},
"autoload": {
@ -6758,9 +6758,9 @@
],
"support": {
"issues": "https://github.com/jmespath/jmespath.php/issues",
"source": "https://github.com/jmespath/jmespath.php/tree/2.7.0"
"source": "https://github.com/jmespath/jmespath.php/tree/2.8.0"
},
"time": "2023-08-25T10:54:48+00:00"
"time": "2024-09-04T18:46:31+00:00"
},
{
"name": "myclabs/deep-copy",
@ -9599,27 +9599,27 @@
},
{
"name": "sabre/uri",
"version": "3.0.1",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/sabre-io/uri.git",
"reference": "1774043c843f1db7654ecc93368a98be29b07544"
"reference": "38eeab6ed9eec435a2188db489d4649c56272c51"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sabre-io/uri/zipball/1774043c843f1db7654ecc93368a98be29b07544",
"reference": "1774043c843f1db7654ecc93368a98be29b07544",
"url": "https://api.github.com/repos/sabre-io/uri/zipball/38eeab6ed9eec435a2188db489d4649c56272c51",
"reference": "38eeab6ed9eec435a2188db489d4649c56272c51",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.17",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"friendsofphp/php-cs-fixer": "^3.64",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "^9.6"
},
"type": "library",
@ -9655,7 +9655,7 @@
"issues": "https://github.com/sabre-io/uri/issues",
"source": "https://github.com/fruux/sabre-uri"
},
"time": "2023-06-09T07:04:02+00:00"
"time": "2024-09-04T15:30:08+00:00"
},
{
"name": "sabre/xml",
@ -16743,16 +16743,16 @@
},
{
"name": "phpunit/phpunit",
"version": "10.5.31",
"version": "10.5.32",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "43e7c3e6a484e538453f89dfa6a6f308c32792da"
"reference": "f069f46840445d37a4e6f0de8c5879598f9c4327"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/43e7c3e6a484e538453f89dfa6a6f308c32792da",
"reference": "43e7c3e6a484e538453f89dfa6a6f308c32792da",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f069f46840445d37a4e6f0de8c5879598f9c4327",
"reference": "f069f46840445d37a4e6f0de8c5879598f9c4327",
"shasum": ""
},
"require": {
@ -16824,7 +16824,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.31"
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.32"
},
"funding": [
{
@ -16840,7 +16840,7 @@
"type": "tidelift"
}
],
"time": "2024-09-03T11:57:55+00:00"
"time": "2024-09-04T13:33:39+00:00"
},
{
"name": "react/cache",

View File

@ -17,7 +17,7 @@
@foreach($methods as $index => $method)
<button wire:loading.remove
class="flex px-4 py-3 border rounded-lg lg:-mb-1 hover:shadow-sm transition duration-300"
wire:click="handleSelect('{{ $method['company_gateway_id'] }}', '{{ $method['gateway_type_id'] }}', '{{ $amount }}')"
wire:click="handleSelect('{{ $method['company_gateway_id'] }}', '{{ $method['gateway_type_id'] }}', '{{ $amount }}')">
<span>{{ $method['label'] }}</span>
</button>
@endforeach

View File

@ -4,7 +4,7 @@
<p class="font-semibold tracking-tight group flex items-center gap-2 text-lg mb-3">
{{ ctrans('texts.required_fields') }}
</p>
@if($is_loading)
<svg class="animate-spin h-5 w-5 text-primary" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>