byrcsc/laravel-payrex · 1.x
Managing endpoints.
Register, inspect, update, enable, disable, test, and delete PayRex webhook endpoints through resources and Artisan commands.
The webhook resource manages the remote endpoints to which PayRex delivers events. Receiving deliveries is a separate concern covered in receiving webhooks.
Create an endpoint
use ByRcsc\LaravelPayrex\Facades\Payrex;
$endpoint = Payrex::webhooks()->create(
url: route('payrex.webhook'),
events: [
'payment_intent.succeeded',
'refund.updated',
],
description: 'Production Laravel application',
);
$endpoint->secretKey;Copy the returned signing secret to PAYREX_WEBHOOK_SECRET immediately.
PayRex will not show it in full again.
Retrieve, list, and paginate
$endpoint = Payrex::webhooks()->retrieve('wh_...');
$page = Payrex::webhooks()->list(limit: 25);
foreach (Payrex::webhooks()->autoPaging() as $endpoint) {
// ...
}
$endpoints = Payrex::webhooks()->paginate(perPage: 20);The WebhookEndpoint object includes id, url, status, description,
secretKey, events, livemode, timestamps, and raw. Use isEnabled() for
a status check.
Update an endpoint
$endpoint = Payrex::webhooks()->update(
id: 'wh_...',
url: 'https://example.com/payrex/webhook',
events: [
'payment_intent.succeeded',
'refund.created',
'refund.updated',
],
description: 'Primary endpoint',
);Only non-null values are sent.
Enable, disable, or delete
$endpoint = Payrex::webhooks()->disable('wh_...');
$endpoint = Payrex::webhooks()->enable('wh_...');
$deleted = Payrex::webhooks()->delete('wh_...');Disable an endpoint to pause deliveries without removing its configuration. Delete it when PayRex should stop delivering permanently.
Artisan commands
Register an endpoint. Omit --event to subscribe to every type mapped in
config/payrex.php:
php artisan payrex:webhook-create "https://example.com/payrex/webhook"Repeat --event to choose types:
php artisan payrex:webhook-create "https://example.com/payrex/webhook" \
--event="payment_intent.succeeded" \
--event="refund.updated" \
--description="Production"List the first page or every page:
php artisan payrex:webhook-list --limit=25
php artisan payrex:webhook-list --allUpdate an endpoint:
php artisan payrex:webhook-update wh_... \
--url="https://example.com/payrex/webhook" \
--event="payment_intent.succeeded" \
--description="Primary endpoint"Enable or disable:
php artisan payrex:webhook-toggle wh_... --enable
php artisan payrex:webhook-toggle wh_... --disableDelete with an interactive confirmation or skip it explicitly:
php artisan payrex:webhook-delete wh_...
php artisan payrex:webhook-delete wh_... --forceTest listener wiring
Dispatch a synthetic event without contacting PayRex:
php artisan payrex:webhook-test
php artisan payrex:webhook-test "payment_intent.succeeded"The command dispatches PayrexWebhookReceived and the configured typed event.
Its payload is deliberately minimal and unsigned. It proves that Laravel
listener wiring works; it does not prove signature verification or
compatibility with every real PayRex field.