Download the PHP package whilesmart/eloquent-payments without Composer
On this page you can find all versions of the php package whilesmart/eloquent-payments. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download whilesmart/eloquent-payments
More information about whilesmart/eloquent-payments
Files in whilesmart/eloquent-payments
Package eloquent-payments
Short Description Polymorphic payment records for Laravel: gateway-agnostic audit trail attachable to invoices, expenses, subscriptions, or any payable.
License MIT
Informations about the package eloquent-payments
Eloquent Payments
Polymorphic, gateway-agnostic payment records for Laravel. Attaches to invoices, expenses, subscriptions, orders, or any payable model.
Why
whilesmart/eloquent-invoices tracks payment state as scalars on the invoice row (amount_paid_cents, paid_at). That is a good summary view but there is no audit trail: no per-event log, no gateway reference, no multi-installment history, no refund chain, no failed-attempt record.
This package is that audit trail. Invoices, expenses, or anything else payable gets a payments() relationship; each Payment row is a single event.
Install
Attach the HasPayments trait to any payable:
Data model
Every Payment row captures:
payable(morph) -- what's being paid for.owner(nullable morph) -- who initiated / owns the payment, typically the workspace.amount_cents,currency.status--pending | authorized | succeeded | failed | refunded | partially_refunded | cancelled.direction--inbound(collection) /outbound(payout, refund).gateway,gateway_reference-- provider + its ID. Unique pair.method-- free-form string (card,mobile_money,bank_transfer, ...). SeePaymentMethodenum for canonical values.- Audit timestamps --
authorized_at,succeeded_at,failed_at,refunded_at. failure_reason-- text.parent_payment_id-- for refunds, points to the original payment.metadata-- JSON.
Reflecting onto the payable
The HasPayments trait includes recordPayment() which creates a Payment AND, when payments.auto_reflect_on_payable is on (default), syncs the payable's own summary fields:
If the payable has no amount_paid_cents column, reflection is silently skipped -- the package never errors out of ignorance of your schema.
Routes
Registers an apiResource at the configured prefix:
Index filters: payable_type, payable_id, owner_type, owner_id, status, direction, gateway, per_page.
Config
php artisan vendor:publish --tag=payments-config:
Siblings
whilesmart/eloquent-invoices-- invoices (money in). ImplementPayable, attachHasPayments.whilesmart/eloquent-expenses-- expenses (money out). Same pattern; thePaymentdirection flips tooutbound.whilesmart/eloquent-subscriptions(future) -- recurring billing.
All versions of eloquent-payments with dependencies
laravel/framework Version ^11.0|^12.0
whilesmart/eloquent-owner-access Version ^1.0