›
byrcsc/laravel-payrex · 1.x
Laravel PayRex provides a Laravel client for the PayRex payments API.
Payment code must create PayRex resources, decode responses, handle failures, and verify webhooks. Calling the API through raw HTTP spreads that work across your application.
Laravel PayRex is an unofficial SDK for the documented
PayRex payments API. It provides named resource methods,
typed response objects, Laravel events, and support for Http::fake().
The package is intended for Laravel applications accepting payments in the Philippines. It supports Laravel 12 and 13, tested against every PHP version each release line supports.
| Laravel | Supported PHP versions |
|---|---|
| 12.x | 8.2, 8.3, 8.4, 8.5 |
| 13.x | 8.3, 8.4, 8.5 |
Unofficial SDK. This package is not affiliated with PayRex. It is built and maintained by Ryan Catapang. For PayRex account, settlement, or API policy questions, contact PayRex directly.
The public interface follows PayRex's resource model while handling Laravel integration concerns around it:
Http::fake() support throughout the clientEvery 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.
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.
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'],
paymentMethodOptions: [
'card' => ['capture_type' => 'manual'],
],
options: [
'a_field_payrex_added_after_this_release' => 'value',
],
);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.
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.
For usage questions, start a GitHub discussion. For a reproducible package defect or an API response that is not modeled correctly, open an issue.