›
›
›
  1. docs
  2. ›
  3. byrcsc/laravel-payrex
1.x
Browse documentationOpenClose

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Client and resources
  • Data objects and enums
  • Errors and retries
  • Pagination

Accepting payments

  • Payment intents
  • Checkout sessions
  • Setup intents
  • Payments and refunds

Customers and billing

  • Customers
  • Eloquent customers
  • Billing statements
  • Payouts

Webhooks

  • Receiving webhooks
  • Events and listeners
  • Managing endpoints

Advanced usage

  • Testing
  • Security and operations
  • Troubleshooting

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Client and resources
  • Data objects and enums
  • Errors and retries
  • Pagination

Accepting payments

  • Payment intents
  • Checkout sessions
  • Setup intents
  • Payments and refunds

Customers and billing

  • Customers
  • Eloquent customers
  • Billing statements
  • Payouts

Webhooks

  • Receiving webhooks
  • Events and listeners
  • Managing endpoints

Advanced usage

  • Testing
  • Security and operations
  • Troubleshooting

byrcsc/laravel-payrex · 1.x

Introduction.

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.

LaravelSupported PHP versions
12.x8.2, 8.3, 8.4, 8.5
13.x8.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.

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'],
    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.

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.

What to read next

  • Installation and setup to add test credentials and verify the configured client.
  • Quick start to accept a payment through hosted checkout or a payment intent.
  • Receiving webhooks to verify the event that confirms the payment result.

For usage questions, start a GitHub discussion. For a reproducible package defect or an API response that is not modeled correctly, open an issue.

NextInstallation and setup

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

View source

On this page

  1. What the package provides
  2. A first payment intent
  3. Resource-oriented by design
  4. Operational expectations
  5. What to read next