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

Data objects and enums.

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

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
PaymentMethodSummarytype, details, the trimmed payment method embedded in a Payment
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; 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.

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();
$statement->isDraft();
$endpoint->isEnabled();
$lineItem->total();

Listing implements Countable and IteratorAggregate, and provides first(), collect(), and isEmpty().

What to read next

  • Client and resources to see which methods return each data object.
  • Pagination to work with Listing responses.
  • Errors and retries to inspect typed API failures.
PreviousClient and resourcesNextErrors and retries

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

View source

On this page

  1. Main response types
  2. Nested objects and dates
  3. Raw payloads
  4. Unknown enum values
  5. Enum catalog
  6. Convenience methods
  7. What to read next