R4nkt signs all requests that hit your game's specified webhook url. This package will automatically verify each webhook request's signature. If any signature is not valid, the request was likely not sent by r4nkt and will be rejected and a
R4nkt\R4nktWebhooks\WebhookFailedexception will be thrown.
Unless something is wrong, this package will respond with a status code of
200to all webhook requests. This will prevent r4nkt from resending the same event.
When using this package, you have two ways to handle incoming webhook requests:
If you want to do something when a specific event type comes in you can define a job that does the work. Here's an example of such a job:
class HandleBadgeEarnedCheck implements ShouldQueue
use InteractsWithQueue, Queueable, SerializesModels;
/** @var \R4nkt\LaravelWebhooks\R4nktWebhookCall */
public function __construct(R4nktWebhookCall $webhookCall)
$this->webhookCall = $webhookCall;
public function handle()
// do your work here
// you can access the payload of the webhook call with $this->webhookCall->payload
Once your job is created, it must be registered in the jobs array in the
r4nkt.phpconfig file. The key should be the name of the r4nkt event type and the value should be the job's fully qualified class name.
'jobs' => [
'badgeEarned' => \App\Jobs\R4nktWebhooks\HandleBadgeEarnedCheck::class,
Upon receiving a valid webhook request, this package will fire a
r4nkt-webhooks::*event. So, you can define event listeners to listen for any events this package might fire.
The event payload will be the instance of
R4nktWebhookCallthat was created for the incoming request.
Here is an example of how you can listen for an event by registering a listener in the
* The event listener mappings for the application.
* @var array
protected $listen = [
'r4nkt-webhooks::badgeEarned' => [
Here's an example of such a listener:
class BadgeEarned implements ShouldQueue
public function handle(R4nktWebhookCall $webhookCall)
// do your work here
// you can access the payload of the webhook call with `$webhookCall->payload`
As already noted, your events or jobs will receive an instance of
You can access the raw payload by calling:
$r4nktWebhookCall->payload; // returns an array
Or you can opt to get more specific information:
$r4nktWebhookCall->type(); // returns the webhook type, e.g. `badgeEarned`
$r4nktWebhookCall->dateTime(); // returns the date/time (string, Ymdhis) when r4nkt generated this webhook call