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

Billing statements.

Create, finalize, send, and reconcile itemized PayRex billing statements.

Billing statements are itemized bills PayRex can send to a customer. They are also the package's natural building block for application-managed recurring billing because PayRex has no subscription resource.

The required lifecycle

A payable statement follows this order:

  1. Create a draft.
  2. Add one or more line items.
  3. Update the draft with dueAt.
  4. Finalize the statement.
  5. Send it to the customer.

PayRex drops due_at during creation but requires it during finalization, so the separate update step is intentional.

Create a draft

use ByRcsc\LaravelPayrex\Enums\BillingDetailsCollection;
use ByRcsc\LaravelPayrex\Enums\Currency;
use ByRcsc\LaravelPayrex\Facades\Payrex;

$statement = Payrex::billingStatements()->create(
    customerId: 'cus_...',
    currency: Currency::PHP,
    description: 'July 2026 plan',
    billingDetailsCollection: BillingDetailsCollection::Auto,
    paymentSettings: [
        'payment_methods' => ['card', 'gcash'],
    ],
    metadata: ['billing_cycle' => '2026-07'],
);

Create accepts customerId, currency, description, billingDetailsCollection, paymentSettings, metadata, and options.

Add and change line items

$lineItem = Payrex::billingStatementLineItems()->create(
    billingStatementId: $statement->id,
    unitPrice: 100_000,
    quantity: 5,
    description: 'Five seats',
);

$lineItem->total(); // 500_000

$lineItem = Payrex::billingStatementLineItems()->update(
    id: $lineItem->id,
    quantity: 6,
);

Payrex::billingStatementLineItems()->delete($lineItem->id);

Line items can only change while the parent statement is a draft. PayRex does not expose a retrieve endpoint for a single line item. Retrieve the parent statement and read its lineItems.

Set the due date and finalize

dueAt is a Unix timestamp:

$statement = Payrex::billingStatements()->update(
    id: $statement->id,
    dueAt: now()->addDays(14)->timestamp,
);

$statement = Payrex::billingStatements()->finalize($statement->id);

Updating a draft also supports customerId, description, billingDetailsCollection, paymentSettings, metadata, and options. Finalization locks the contents and makes the statement payable.

Send the statement

$result = Payrex::billingStatements()->send($statement->id);

PayRex currently answers this operation with HTTP 204 and no body, so the method returns null. Its nullable return type leaves room for PayRex to return the resource later.

Void or mark uncollectible

Void a finalized statement that should not have been issued:

$statement = Payrex::billingStatements()->void($statement->id);

Write off a statement that will not be paid:

$statement = Payrex::billingStatements()->markUncollectible($statement->id);

Deleting is available for statements PayRex allows to be deleted:

$deleted = Payrex::billingStatements()->delete($statement->id);

Retrieve and list

$statement = Payrex::billingStatements()->retrieve('bs_...');

$page = Payrex::billingStatements()->list(limit: 25);

foreach (Payrex::billingStatements()->autoPaging() as $statement) {
    // ...
}

$statements = Payrex::billingStatements()->paginate(perPage: 20);

Response properties

The BillingStatement object includes amount, currency, status, customerId, description, statementDescriptor, billingStatementNumber, billingStatementUrl, billingStatementMerchantName, billingDetailsCollection, setupFutureUsage, lineItems, paymentSettings, paymentIntent, customer, dueAt, finalizedAt, metadata, timestamps, and raw.

React to lifecycle events

Typed events cover creation, update, deletion, finalization, sending, payment, overdue and upcoming-due states, voiding, and marking uncollectible. Use them to reconcile local invoices and schedule follow-up work. Keep listeners queued and idempotent.

What to read next

  • Customers to create the customer named on a statement.
  • Payments and refunds to inspect the payment created from a finalized statement.
  • Events and listeners to reconcile statement updates from verified webhooks.
PreviousEloquent customersNextPayouts

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

View source

On this page

  1. The required lifecycle
  2. Create a draft
  3. Add and change line items
  4. Set the due date and finalize
  5. Send the statement
  6. Void or mark uncollectible
  7. Retrieve and list
  8. Response properties
  9. React to lifecycle events
  10. What to read next