›
›
›
  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

Checkout sessions.

Create a PayRex-hosted checkout and confirm payment through a verified webhook.

Checkout sessions provide a PayRex-hosted payment page. They are a good default when you do not need to own the payment form.

Create a session

use ByRcsc\LaravelPayrex\Enums\BillingDetailsCollection;
use ByRcsc\LaravelPayrex\Enums\Currency;
use ByRcsc\LaravelPayrex\Enums\SubmitType;
use ByRcsc\LaravelPayrex\Facades\Payrex;

$session = Payrex::checkoutSessions()->create(
    lineItems: [
        [
            'name' => 'Team plan',
            'amount' => 100_000,
            'quantity' => 5,
        ],
    ],
    successUrl: route('checkout.success'),
    cancelUrl: route('checkout.cancel'),
    paymentMethods: ['card', 'gcash'],
    currency: Currency::PHP,
    description: 'Mar 1, 2026 – Mar 1, 2027',
    customerReferenceId: 'account_1042',
    submitType: SubmitType::Pay,
    billingDetailsCollection: BillingDetailsCollection::Auto,
    metadata: ['account_id' => '1042'],
);

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

Each line item's amount is the per-unit price and quantity is the number of units. In this example the total is five times 100_000.

Complete method signature

create(
    array $lineItems,
    string $successUrl,
    string $cancelUrl,
    array $paymentMethods = [],
    Currency $currency = Currency::PHP,
    ?string $description = null,
    ?string $customerReferenceId = null,
    SubmitType|string|null $submitType = null,
    BillingDetailsCollection|string|null $billingDetailsCollection = null,
    ?int $expiresAt = null,
    ?array $paymentMethodOptions = null,
    ?array $metadata = null,
    array $options = [],
): CheckoutSession

expiresAt is a Unix timestamp. Line-item and checkout limits are validated by PayRex.

Payment method options

Use the same option structure as payment intents:

use ByRcsc\LaravelPayrex\Enums\CaptureType;
use ByRcsc\LaravelPayrex\Enums\InstallmentType;

$session = Payrex::checkoutSessions()->create(
    lineItems: [
        ['name' => 'Reservation', 'amount' => 50_000, 'quantity' => 1],
    ],
    successUrl: route('checkout.success'),
    cancelUrl: route('checkout.cancel'),
    paymentMethods: ['card', 'bdo_installment'],
    paymentMethodOptions: [
        'card' => ['capture_type' => CaptureType::Automatic],
        'bdo_installment' => [
            'installment_types' => [InstallmentType::Zero],
        ],
    ],
);

Retrieve, list, and expire

$session = Payrex::checkoutSessions()->retrieve('cs_...');

$page = Payrex::checkoutSessions()->list(
    limit: 25,
    after: 'cs_...',
);

foreach (Payrex::checkoutSessions()->autoPaging() as $session) {
    // ...
}

$sessions = Payrex::checkoutSessions()->paginate(perPage: 20);

$expired = Payrex::checkoutSessions()->expire('cs_...');

Expiring a session closes it early so it can no longer be paid.

Determine completion

if ($session->isCompleted()) {
    // The session reports completed.
}

Do not use the return to successUrl as the authoritative payment signal. A customer can close the page, replay a URL, or arrive before asynchronous processing completes. Update your application from a verified payment webhook.

Useful response properties include url, status, lineItems, paymentMethods, clientSecret, customerId, customerReferenceId, paymentIntent, expiresAt, metadata, and raw.

What to read next

  • Receiving webhooks to verify the payment result after the customer leaves checkout.
  • Payment intents when your application needs to control the payment form.
  • Testing to fake checkout responses and webhook deliveries.
PreviousPayment intentsNextSetup intents

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

View source

On this page

  1. Create a session
  2. Complete method signature
  3. Payment method options
  4. Retrieve, list, and expire
  5. Determine completion
  6. What to read next