byrcsc / laravel-payrex
Unofficial PayRex SDK for Laravel: typed resources, readonly DTOs, and first-class webhook handling.
Fund package maintenance!
Requires
- php: ^8.2
- ext-json: *
- illuminate/console: ^12.0||^13.0
- illuminate/contracts: ^12.0||^13.0
- illuminate/database: ^12.0||^13.0
- illuminate/http: ^12.0||^13.0
- illuminate/support: ^12.0||^13.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.3.1
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0||^11.0
- pestphp/pest: ^3.8.3||^4.0
- pestphp/pest-plugin-arch: ^3.1.1||^4.0
- pestphp/pest-plugin-laravel: ^3.2||^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
An unofficial Laravel SDK for the PayRex payments API: typed resources, readonly DTOs, and webhook handling that feels like the rest of your app.
Built for Laravel projects accepting payments in the Philippines and shared with the community, it brings PayRex's documented API into familiar Laravel conventions.
Read the full documentation for installation, resources, webhooks, pagination, testing, and security guidance.
| Laravel | Supported PHP versions |
|---|---|
| 12.x | 8.2, 8.3, 8.4, 8.5 |
| 13.x | 8.3, 8.4, 8.5 |
Installation
Install the package and publish its configuration:
composer require byrcsc/laravel-payrex
php artisan vendor:publish --tag="payrex-config"
Add your PayRex test credentials:
PAYREX_SECRET_KEY=sk_test_... PAYREX_PUBLIC_KEY=pk_test_... # Only needed for PayRex Elements PAYREX_WEBHOOK_SECRET=whsk_test_... # Only needed for webhooks
See the installation guide for all configuration options and the optional customer migration.
Quick start
Use the facade or inject PayrexClient. Both resolve to the same singleton.
use ByRcsc\LaravelPayrex\Facades\Payrex; $intent = Payrex::paymentIntents()->create( amount: 10_000, paymentMethods: ['card', 'gcash'], description: 'Order #RC-1042', ); $intent->id; $intent->status; $intent->clientSecret;
Amounts are integers in the smallest currency unit: 10_000 is ₱100.00. Never
send a floating-point amount.
What is included
- Typed resources for payments, checkout, customers, refunds, payouts, billing, and webhook endpoints.
- Readonly data objects that retain the untouched API payload on
$raw. - Verified webhooks dispatched as generic and type-specific Laravel events.
- Typed exceptions, response metadata, and conservative retries for
GETrequests. - Automatic cursor iteration and Laravel
CursorPaginatorsupport. - An Eloquent customer concern and Artisan commands for managing webhooks.
Http::fake()support throughout the client.
Important behavior
- Mutating requests are never retried. PayRex documents no idempotency keys, so replaying an ambiguous request could duplicate a payment or refund.
- Queue webhook listeners and deduplicate them using the PayRex event ID. Signature freshness checks do not prevent the same valid event from arriving more than once.
- PayRex does not expose a subscription resource. Recurring billing must be modelled explicitly, such as with a billing statement for each cycle.
- Keep
PAYREX_SECRET_KEYon the server. Only the public key is intended for browser use with PayRex Elements.
Documentation
- Installation and setup
- Quick start
- Client and resources
- Receiving webhooks
- Testing
- Security and operations
Support and contributing
Ask usage questions in GitHub Discussions. For reproducible package bugs, open an issue. See CONTRIBUTING.md before opening a pull request.
Report vulnerabilities privately by following SECURITY.md.
Credits
API behavior is referenced against the official
PayRex documentation and
payrex/payrex-php SDK.
License
MIT. See LICENSE.md. Changelog in CHANGELOG.md.