byrcsc/laravel-payrex · 1.x
Data objects and enums.
Work with Laravel PayRex readonly response objects, nested resources, raw payloads, dates, helper methods, and backed enums.
Every modeled PayRex response is hydrated into a readonly data object under
ByRcsc\LaravelPayrex\Data. These objects provide typed, camel-cased
properties without discarding the original API payload.
$intent = Payrex::paymentIntents()->retrieve('pi_...');
$intent->id; // string
$intent->amount; // ?int
$intent->status; // ?PaymentIntentStatus
$intent->latestPayment; // ?Payment
$intent->createdAt; // ?CarbonImmutable
$intent->raw; // untouched response arrayMain response types
| Data object | Notable properties |
|---|---|
PaymentIntent | amount, amountReceived, amountCapturable, status, clientSecret, nextAction, latestPayment, customer |
CheckoutSession | url, status, lineItems, clientSecret, customerId, paymentIntent, expiresAt |
SetupIntent | status, clientSecret, nextAction, paymentMethodId, customer |
Payment | amount, amountRefunded, fee, netAmount, status, paymentIntentId, paymentMethod, customer |
Refund | amount, status, reason, paymentId, remarks |
Customer | name, email, currency, billing, deleted, metadata |
CustomerSession | clientSecret, customerId, customer, components, expiredAt |
PaymentMethod | type, details, billingDetails, allowRedisplay |
BillingStatement | amount, status, customerId, lineItems, paymentIntent, dueAt, billingStatementUrl |
BillingStatementLineItem | unitPrice, quantity, description, billingStatementId |
Payout | amount, netAmount, status, destination |
PayoutTransaction | amount, netAmount, transactionType, transactionId |
WebhookEndpoint | url, status, secretKey, events |
Deleted | id, deleted |
All applicable objects also expose livemode, metadata, createdAt,
updatedAt, and raw.
Nested objects and dates
Nested PayRex objects are hydrated recursively. For example,
$intent->latestPayment is a Payment, and a payment's
$payment->billing is a Billing object.
Unix timestamps decode to CarbonImmutable. Missing or malformed optional
values become null rather than producing guessed defaults.
Raw payloads
Every data object retains the untouched API object on $raw:
$networkReference = $payment->raw['network_reference'] ?? null;This preserves access to a new PayRex field before the package adds a typed property. It is also useful when diagnosing a sanitized response. Prefer typed properties for established fields and keep raw access localized.
Unknown enum values
Response enums are decoded with tryFrom(). If PayRex introduces a new value,
the typed property becomes null instead of throwing:
$intent->status; // null for an unknown future status
$intent->raw['status']; // the exact value PayRex returnedThis makes additive API changes non-fatal while keeping the unknown value observable.
Enum catalog
| Enum | Values |
|---|---|
Currency | PHP |
PaymentMethodType | card, gcash, maya, qrph, bdo_installment |
PaymentIntentStatus | awaiting_payment_method, awaiting_next_action, awaiting_capture, processing, succeeded, canceled |
CheckoutSessionStatus | active, completed, expired |
SetupIntentStatus | awaiting_payment_method, awaiting_next_action, processing, succeeded, canceled |
PaymentStatus | paid, failed |
RefundStatus | pending, succeeded, failed |
RefundReason | fraudulent, requested_by_customer, product_out_of_stock, service_not_provided, product_was_damaged, service_misaligned, wrong_product_received, others |
BillingStatementStatus | draft, open, paid, void, uncollectible |
PayoutStatus | pending, in_transit, successful, failed |
PayoutTransactionType | payment, refund, adjustment |
CaptureType | automatic, manual |
InstallmentType | regular, zero, regular_holiday, zero_holiday |
SubmitType | pay, book, donate, send |
BillingDetailsCollection | auto, always |
WebhookStatus | enabled, disabled |
Backed enums may be passed directly to supported resource methods:
use ByRcsc\LaravelPayrex\Enums\PaymentMethodType;
$intent = Payrex::paymentIntents()->create(
amount: 10_000,
paymentMethods: [
PaymentMethodType::Card,
PaymentMethodType::Gcash,
],
);Convenience methods
Several objects answer common state questions:
$intent->hasSucceeded();
$intent->requiresAction();
$intent->redirectUrl();
$session->isCompleted();
$customer->isDeleted();
$endpoint->isEnabled();
$lineItem->total();Listing implements Countable and IteratorAggregate, and provides
first(), collect(), and isEmpty().