Skip to content

PayRex for LaravelAccept Payments in the Philippines

Cards, GCash, Maya, BillEase, QR Ph, BDO Installment - integrated into your Laravel app in minutes.

PayRex for Laravel

Quick Look ​

See how simple it is to accept payments with PayRex for Laravel.

There are two main ways to accept payments: Checkout Sessions for a hosted payment page, or Payment Intents with PayRex Elements for a custom payment UI.

Hosted Checkout ​

php
use LegionHQ\LaravelPayrex\Facades\Payrex;

$session = Payrex::checkoutSessions()->create([
    'line_items' => [
        ['name' => 'Pro Plan', 'amount' => 99900, 'quantity' => 1],
    ],
    'payment_methods' => ['card', 'gcash', 'maya'],
    'success_url' => route('checkout.success'),
    'cancel_url' => route('checkout.cancel'),
]);

return redirect()->away($session->url);

Payment Intent (Custom UI) ​

php
use LegionHQ\LaravelPayrex\Facades\Payrex;

// Create a Payment Intent on the backend
$paymentIntent = Payrex::paymentIntents()->create([
    'amount' => 10000, // ₱100.00 in cents
    'payment_methods' => ['card', 'gcash', 'maya'],
]);

// Pass the client secret to your frontend for PayRex Elements
return response()->json([
    'client_secret' => $paymentIntent->clientSecret,
]);

Handle Webhooks ​

php
use Illuminate\Support\Facades\Event;
use LegionHQ\LaravelPayrex\Events\PaymentIntentSucceeded;

Event::listen(PaymentIntentSucceeded::class, function (PaymentIntentSucceeded $event) {
    /** @var PaymentIntent $paymentIntent */
    $paymentIntent = $event->data();

    Order::query()
        ->where('payment_intent_id', $paymentIntent->id)
        ->update(['status' => 'paid']);
});
php
use LegionHQ\LaravelPayrex\Facades\Payrex;

$event = Payrex::constructEvent(
    $request->getContent(),
    $request->header('Payrex-Signature'),
);

$type = $event->eventType();    // WebhookEventType::PaymentIntentSucceeded

/** @var PaymentIntent $paymentIntent */
$paymentIntent = $event->data();

Released under the MIT License.