mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Try / catch for webhooks
This commit is contained in:
parent
c4bfb33dbf
commit
ebd9a2c328
@ -108,17 +108,29 @@ class WebhookHandler implements ShouldQueue
|
|||||||
|
|
||||||
$client = new Client(['headers' => array_merge($base_headers, $headers)]);
|
$client = new Client(['headers' => array_merge($base_headers, $headers)]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
$response = $client->post($subscription->target_url, [
|
$response = $client->post($subscription->target_url, [
|
||||||
RequestOptions::JSON => $data, // or 'json' => [...]
|
RequestOptions::JSON => $data, // or 'json' => [...]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
nlog($response);
|
if ($response->getStatusCode() == 410 || $response->getStatusCode() == 200)
|
||||||
|
$subscription->delete();
|
||||||
|
|
||||||
|
SystemLogger::dispatch(
|
||||||
|
$response,
|
||||||
|
SystemLog::CATEGORY_WEBHOOK,
|
||||||
|
SystemLog::EVENT_WEBHOOK_RESPONSE,
|
||||||
|
SystemLog::TYPE_WEBHOOK_RESPONSE,
|
||||||
|
$this->company->clients->first(),
|
||||||
|
);
|
||||||
|
|
||||||
if ($response->getStatusCode() == 410 || $response->getStatusCode() == 200) {
|
|
||||||
$subscription->delete();
|
|
||||||
}
|
}
|
||||||
|
catch(\Exception $e){
|
||||||
|
|
||||||
SystemLogger::dispatch(
|
// nlog($e->getMessage());
|
||||||
|
|
||||||
|
SystemLogger::dispatch(
|
||||||
$e->getMessage(),
|
$e->getMessage(),
|
||||||
SystemLog::CATEGORY_WEBHOOK,
|
SystemLog::CATEGORY_WEBHOOK,
|
||||||
SystemLog::EVENT_WEBHOOK_RESPONSE,
|
SystemLog::EVENT_WEBHOOK_RESPONSE,
|
||||||
@ -126,6 +138,10 @@ class WebhookHandler implements ShouldQueue
|
|||||||
$this->company->clients->first(),
|
$this->company->clients->first(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function failed($exception)
|
public function failed($exception)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user