for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\StripeWebhooks;
use Exception;
use Illuminate\Database\Eloquent\Model;
use Spatie\StripeWebhooks\Exceptions\WebhookFailed;
class StripeWebhookCall extends Model
{
public $guarded = [];
protected $casts = [
'payload' => 'array',
'exception' => 'array',
];
public function process()
$this->clearException();
$jobClass = $this->determineJobClass($this->type);
if ($jobClass === '') {
return;
}
if (! class_exists($jobClass)) {
throw WebhookFailed::jobClassDoesNotExist($this);
jobClassDoesNotExist()
$webhookCall
This check looks for function calls that miss required arguments.
dispatch(new $jobClass($this));
public function saveException(Exception $exception)
$this->exception = [
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
'trace' => $exception->getTraceAsString(),
$this->save();
return $this;
protected function determineJobClass(string $eventType): string
$jobConfigKey = str_replace('.', '_', $eventType);
return config("stripe-webhooks.jobs.{$jobConfigKey}", '');
protected function clearException() {
$this->exception = null;
This check looks for function calls that miss required arguments.