Here are the contents of the published configuration file, config/r4nkt.php:
return [/* |-------------------------------------------------------------------------- | Base URL |-------------------------------------------------------------------------- | | This determines the base URL for the API that the SDK will use. Generally | speaking, you shouldn't ever need to set or change. | */'base_url'=>env('R4NKT_BASE_URL','https://api.r4nkt.com/v1'),/* |-------------------------------------------------------------------------- | API Token |-------------------------------------------------------------------------- | | R4nkt requires that you use an API token when communicating with its API. | Make one at the r4nkt API settings page: https://r4nkt.com/settings#/api | */'api_token'=>env('R4NKT_API_TOKEN'),/* |-------------------------------------------------------------------------- | Game ID |-------------------------------------------------------------------------- | | R4nkt also requires that you specify the game ID for each API call. Find | this at the game configuration settings: https://r4nkt.com/settings/games | */'game_id'=>env('R4NKT_GAME_ID'),/* |-------------------------------------------------------------------------- | Webhook Signing Secret |-------------------------------------------------------------------------- | | R4nkt will sign webhooks using a secret. You can find the secret used for | individual games at the game configuration settings: | - https://r4nkt.com/settings/games | */'signing_secret'=>env('R4NKT_SIGNING_SECRET'),/* |-------------------------------------------------------------------------- | Custom Player ID Resolver |-------------------------------------------------------------------------- | | This class is responsible for determining the player's custom ID. | | This class should implement | `R4nkt\Laravel\Support\CustomPlayerIdResolver\CustomPlayerIdResolver` | */'custom_player_id_resolver'=>\R4nkt\Laravel\Support\CustomPlayerIdResolver\PrimaryKeyCustomPlayerIdResolver::class,/* |-------------------------------------------------------------------------- | Custom Player ID Decoder |-------------------------------------------------------------------------- | | This class is responsible for decoding the player's custom ID. | | This class should implement | `R4nkt\Laravel\Support\CustomPlayerIdDecoder\CustomPlayerIdDecoder` | */'custom_player_id_decoder'=>\R4nkt\Laravel\Support\CustomPlayerIdDecoder\PrimaryKeyCustomPlayerIdDecoder::class,/* |-------------------------------------------------------------------------- | Date/Time UTC Resolver |-------------------------------------------------------------------------- | | This class is responsible for resolving the date/time UTC value to a | properly formatted string. | | This class should implement | `R4nkt\Laravel\Support\DateTimeUtcResolver\DateTimeUtcResolver` | */'date_time_utc_resolver'=>\R4nkt\Laravel\Support\DateTimeUtcResolver\DefaultDateTimeUtcResolver::class,/* |-------------------------------------------------------------------------- | Webhook Jobs |-------------------------------------------------------------------------- | | Here you can define the job that should be run when a certain webhook | hits your application. | | You can find a list of R4nkt webhook types here: | - https://r4nkt.com/docs/webhooks/events | */'jobs'=> [// 'badge-earned' => \App\Jobs\R4nktWebhooks\HandleBadgeEarned::class,// ... ],];
You should set the signing_secret value for the specific game you are interested in receiving webhooks from.
Finally, you should set up routing. The route that is set up here should match the webhook URL for the specific game you are interested in receiving webhooks from. To do so, you must pass this route using the following command in your app's routes file:
Route::R4nktWebhooks('configured-webhook-route');
This command registers a POST route to a package controller.
Because r4nkt has no way of getting a CSRF token, you must add that route to the $except array of the VerifyCsrfToken middleware like so: