›
byrcsc/laravel-payrex · 1.x
Read PayRex responses through typed data objects, enums, and raw payloads.
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 array| 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 |
PaymentMethodSummary | type, details, the trimmed payment method embedded in a Payment |
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 PayRex objects are hydrated recursively. For example,
$intent->latestPayment is a Payment; that payment's $payment->billing is
a Billing object, whose $billing->address is a BillingAddress.
Two payment-method shapes exist because PayRex embeds a shorter one. The
PaymentMethod returned by customers()->listPaymentMethods() carries an
id, billingDetails, and allowRedisplay. The $payment->paymentMethod
embedded in a payment is a PaymentMethodSummary: type, details, and
raw only. Read the identifier from $intent->paymentMethodId rather than
from the summary.
Unix timestamps decode to CarbonImmutable. Missing or malformed optional
values become null rather than producing guessed defaults.
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.
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 | 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,
],
);Several objects answer common state questions:
$intent->hasSucceeded();
$intent->requiresAction();
$intent->redirectUrl();
$session->isCompleted();
$customer->isDeleted();
$statement->isDraft();
$endpoint->isEnabled();
$lineItem->total();Listing implements Countable and IteratorAggregate, and provides
first(), collect(), and isEmpty().
Listing responses.