Browse documentationOpen

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 array

Main response types

Data objectNotable properties
PaymentIntentamount, amountReceived, amountCapturable, status, clientSecret, nextAction, latestPayment, customer
CheckoutSessionurl, status, lineItems, clientSecret, customerId, paymentIntent, expiresAt
SetupIntentstatus, clientSecret, nextAction, paymentMethodId, customer
Paymentamount, amountRefunded, fee, netAmount, status, paymentIntentId, paymentMethod, customer
Refundamount, status, reason, paymentId, remarks
Customername, email, currency, billing, deleted, metadata
CustomerSessionclientSecret, customerId, customer, components, expiredAt
PaymentMethodtype, details, billingDetails, allowRedisplay
BillingStatementamount, status, customerId, lineItems, paymentIntent, dueAt, billingStatementUrl
BillingStatementLineItemunitPrice, quantity, description, billingStatementId
Payoutamount, netAmount, status, destination
PayoutTransactionamount, netAmount, transactionType, transactionId
WebhookEndpointurl, status, secretKey, events
Deletedid, 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 returned

This makes additive API changes non-fatal while keeping the unknown value observable.

Enum catalog

EnumValues
CurrencyPHP
PaymentMethodTypecard, gcash, maya, qrph, bdo_installment
PaymentIntentStatusawaiting_payment_method, awaiting_next_action, awaiting_capture, processing, succeeded, canceled
CheckoutSessionStatusactive, completed, expired
SetupIntentStatusawaiting_payment_method, awaiting_next_action, processing, succeeded, canceled
PaymentStatuspaid, failed
RefundStatuspending, succeeded, failed
RefundReasonfraudulent, requested_by_customer, product_out_of_stock, service_not_provided, product_was_damaged, service_misaligned, wrong_product_received, others
BillingStatementStatusdraft, open, paid, void, uncollectible
PayoutStatuspending, in_transit, successful, failed
PayoutTransactionTypepayment, refund, adjustment
CaptureTypeautomatic, manual
InstallmentTyperegular, zero, regular_holiday, zero_holiday
SubmitTypepay, book, donate, send
BillingDetailsCollectionauto, always
WebhookStatusenabled, 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().

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

View source