byrcsc/laravel-payrex · 1.x
Checkout sessions.
Create and manage PayRex-hosted checkout pages, line items, payment methods, expiry, and cursor pagination.
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 = [],
): CheckoutSessionexpiresAt 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.