Browse documentationOpen

byrcsc/laravel-payrex · 1.x

Installation and setup.

Install Laravel PayRex, publish its configuration, add credentials, and understand every supported environment option.

Laravel PayRex requires PHP 8.3 or 8.4 and Laravel 12 or 13. Install it with Composer:

composer require byrcsc/laravel-payrex

Laravel discovers the package service provider and Payrex facade automatically.

Publishing the configuration

Publish config/payrex.php:

php artisan vendor:publish --tag="payrex-config"

Add your test credentials to .env:

PAYREX_SECRET_KEY=sk_test_...
PAYREX_PUBLIC_KEY=pk_test_...
PAYREX_WEBHOOK_SECRET=whsk_test_...

Use live credentials only in the live environment. Laravel PayRex sends the secret key as the username in HTTP Basic authentication. It must remain on the server. The public key is the only credential intended for PayRex Elements in the browser.

Environment reference

VariableDefaultPurpose
PAYREX_SECRET_KEYnoneAuthenticates server-side API requests
PAYREX_PUBLIC_KEYnoneInitializes PayRex Elements in the browser
PAYREX_WEBHOOK_SECRETnoneVerifies inbound webhook signatures
PAYREX_BASE_URLhttps://api.payrexhq.comPoints the client at PayRex, a proxy, or a local stub
PAYREX_TIMEOUT30Total outbound request timeout in seconds
PAYREX_CONNECT_TIMEOUT10Connection timeout in seconds
PAYREX_RETRY_TIMES1Attempts for retryable GET requests
PAYREX_RETRY_SLEEP200Delay between attempts in milliseconds
PAYREX_WEBHOOKS_ENABLEDtrueRegisters the package webhook route
PAYREX_WEBHOOK_PATHpayrex/webhookURI for inbound deliveries
PAYREX_WEBHOOK_TOLERANCE300Maximum signature age in seconds; 0 disables the age check
PAYREX_WEBHOOK_HEADERPayrex-SignatureHeader containing the signature

Additional webhook middleware and the event-to-class map live directly in config/payrex.php.

Configuration caching

After changing environment values on a deployed application, rebuild Laravel's configuration cache:

php artisan config:cache

If the client reports that no secret key is configured, first confirm the value is present in the deployed environment and then clear stale cached configuration:

php artisan optimize:clear

Optional customer migration

The Eloquent customer concern stores a PayRex customer ID on one of your models. Publish the migration only if you plan to use that concern:

php artisan vendor:publish --tag="payrex-migrations"

The generated migration targets the users table by default. Review and edit the table name or column definition before running it:

php artisan migrate

Verify the installation

Resolve the client and read the configured public key without making a network request:

use ByRcsc\LaravelPayrex\PayrexClient;

$payrex = app(PayrexClient::class);

$payrex->publicKey(); // "pk_test_..."

The facade and the injected client resolve to the same singleton for the current application process.

Laravel PayRex is an unofficial community SDK and is not affiliated with PayRex.

View source