mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Try / catch for webhooks
This commit is contained in:
parent
c4bfb33dbf
commit
ebd9a2c328
@ -108,15 +108,27 @@ class WebhookHandler implements ShouldQueue
|
||||
|
||||
$client = new Client(['headers' => array_merge($base_headers, $headers)]);
|
||||
|
||||
try {
|
||||
|
||||
$response = $client->post($subscription->target_url, [
|
||||
RequestOptions::JSON => $data, // or 'json' => [...]
|
||||
]);
|
||||
|
||||
nlog($response);
|
||||
|
||||
if ($response->getStatusCode() == 410 || $response->getStatusCode() == 200) {
|
||||
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(),
|
||||
);
|
||||
|
||||
}
|
||||
catch(\Exception $e){
|
||||
|
||||
// nlog($e->getMessage());
|
||||
|
||||
SystemLogger::dispatch(
|
||||
$e->getMessage(),
|
||||
@ -128,6 +140,10 @@ class WebhookHandler implements ShouldQueue
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function failed($exception)
|
||||
{
|
||||
nlog(print_r($exception->getMessage(), 1));
|
||||
|
Loading…
Reference in New Issue
Block a user