byrcsc/laravel-payrex · 1.x
Introduction.
An unofficial Laravel SDK for the PayRex payments API, covering payments, customers, billing statements, and webhooks.
Laravel PayRex is an unofficial SDK that brings the documented PayRex payments API into familiar Laravel conventions. It provides named, typed resource methods, readonly data objects, Laravel events, and framework-native testing support without hiding the underlying PayRex concepts.
The package is intended for Laravel applications accepting payments in the Philippines. It currently supports PHP 8.3 and 8.4, and Laravel 12 and 13.
| Requirement | Supported versions |
|---|---|
| PHP | 8.3, 8.4 |
| Laravel | 12.x, 13.x |
Note: This SDK is unofficial and not affiliated with PayRex. It is built and maintained by Ryan Catapang. For PayRex account, settlement, or API policy questions, contact PayRex directly.
What the package provides
The public interface follows PayRex's resource model while handling Laravel integration concerns around it:
- Payment intents, setup intents, hosted checkout, customers, and payments
- Refunds, payouts, billing statements, and billing statement line items
- Verified webhooks dispatched as Laravel events
- Typed exceptions for non-successful API responses
- Cursor pagination that works with Laravel's paginator conventions
- An Eloquent concern for associating a model with a PayRex customer
- Artisan commands for inspecting and managing webhook endpoints
Http::fake()support throughout the client
Every data object also retains its untouched API payload on $raw. If PayRex
adds a field before the package models it, the response remains available to
your application.
A first payment intent
Install the package with Composer and publish its configuration:
composer require byrcsc/laravel-payrex
php artisan vendor:publish --tag="payrex-config"Add your test credentials to the application's environment:
PAYREX_SECRET_KEY=sk_test_...
PAYREX_PUBLIC_KEY=pk_test_...
PAYREX_WEBHOOK_SECRET=whsk_test_...You can then 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 always integers in the smallest currency unit. 10_000 represents
₱100.00; never send a floating-point amount. PayRex currently supports only
Philippine pesos.
Resource-oriented by design
Methods accept PayRex's documented parameters as named, typed arguments. An
optional trailing $options array lets you use a newly introduced API field
without waiting for a package release:
Payrex::paymentIntents()->create(
amount: 10_000,
paymentMethods: ['card'],
options: [
'payment_method_options' => [
'card' => ['capture_type' => 'manual'],
],
],
);Null arguments are omitted rather than sent as empty values. Unknown enum
values decode to null instead of causing hydration to fail, making the SDK
tolerant of additive changes from PayRex.
Operational expectations
Payments need careful failure handling. The package retries safe GET requests after connection failures, rate limits, or server errors when retries are enabled. Mutating requests are never retried automatically because PayRex does not document idempotency keys.
Webhook deliveries may arrive more than once. Queue webhook listeners and deduplicate work using the PayRex event ID before changing application state.
The package never exposes the secret key through its public interface. Only the public key intended for PayRex Elements can be retrieved for browser use.
Where to go next
Continue with installation and setup, then follow the quick start to choose between a payment intent and PayRex hosted checkout. The remaining sections document every resource, webhook event, Artisan command, data-object convention, and operational boundary shipped in version 1.x.
For usage questions, start a GitHub discussion. For a reproducible package defect or an API response that is not modelled correctly, open an issue.