{"id":50749271,"url":"https://github.com/whilesmartphp/eloquent-payments","last_synced_at":"2026-06-11T00:01:26.247Z","repository":{"id":353780893,"uuid":"1219363474","full_name":"whilesmartphp/eloquent-payments","owner":"whilesmartphp","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-10T18:20:18.000Z","size":61,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2026-06-10T20:11:48.961Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whilesmartphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-23T19:56:31.000Z","updated_at":"2026-04-25T13:17:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/whilesmartphp/eloquent-payments","commit_stats":null,"previous_names":["whilesmartphp/eloquent-payments"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/whilesmartphp/eloquent-payments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-payments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-payments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-payments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-payments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whilesmartphp","download_url":"https://codeload.github.com/whilesmartphp/eloquent-payments/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-payments/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34175887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-11T00:01:02.466Z","updated_at":"2026-06-11T00:01:26.232Z","avatar_url":"https://github.com/whilesmartphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eloquent Payments\n\nPolymorphic, gateway-agnostic payment records for Laravel. Attaches to invoices, expenses, subscriptions, orders, or any payable model.\n\n## Why\n\n`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.\n\nThis package is that audit trail. Invoices, expenses, or anything else payable gets a `payments()` relationship; each `Payment` row is a single event.\n\n## Install\n\n```\ncomposer require whilesmart/eloquent-payments\nphp artisan migrate\n```\n\nAttach the `HasPayments` trait to any payable:\n\n```php\nuse Whilesmart\\Payments\\Contracts\\Payable;\nuse Whilesmart\\Payments\\Traits\\HasPayments;\n\nclass Invoice extends Model implements Payable\n{\n    use HasPayments;\n}\n```\n\n## Data model\n\nEvery `Payment` row captures:\n\n- **`payable`** (morph) -- what's being paid for.\n- **`owner`** (nullable morph) -- who initiated / owns the payment, typically the workspace.\n- **`amount_cents`**, **`currency`**.\n- **`status`** -- `pending | authorized | succeeded | failed | refunded | partially_refunded | cancelled`.\n- **`direction`** -- `inbound` (collection) / `outbound` (payout, refund).\n- **`gateway`**, **`gateway_reference`** -- provider + its ID. Unique pair.\n- **`method`** -- free-form string (`card`, `mobile_money`, `bank_transfer`, ...). See `PaymentMethod` enum for canonical values.\n- **Audit timestamps** -- `authorized_at`, `succeeded_at`, `failed_at`, `refunded_at`.\n- **`failure_reason`** -- text.\n- **`parent_payment_id`** -- for refunds, points to the original payment.\n- **`metadata`** -- JSON.\n\n## Reflecting onto the payable\n\nThe `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:\n\n```php\n$invoice-\u003erecordPayment([\n    'amount_cents'      =\u003e 50000,\n    'currency'          =\u003e 'USD',\n    'status'            =\u003e 'succeeded',\n    'method'            =\u003e 'card',\n    'gateway'           =\u003e 'stripe',\n    'gateway_reference' =\u003e 'ch_123...',\n    'succeeded_at'      =\u003e now(),\n]);\n\n// Effect:\n//   invoice.amount_paid_cents  += 50000 (or rather, set to sum of succeeded payments)\n//   invoice.paid_at             = now() if cumulative \u003e= total_cents\n```\n\nIf the payable has no `amount_paid_cents` column, reflection is silently skipped -- the package never errors out of ignorance of your schema.\n\n## Routes\n\nRegisters an `apiResource` at the configured prefix:\n\n```\nGET    /api/payments\nPOST   /api/payments\nGET    /api/payments/{payment}\nPUT    /api/payments/{payment}\nDELETE /api/payments/{payment}\n```\n\nIndex filters: `payable_type`, `payable_id`, `owner_type`, `owner_id`, `status`, `direction`, `gateway`, `per_page`.\n\n## Config\n\n`php artisan vendor:publish --tag=payments-config`:\n\n```php\nreturn [\n    'register_routes' =\u003e env('PAYMENTS_REGISTER_ROUTES', true),\n    'route_prefix' =\u003e env('PAYMENTS_ROUTE_PREFIX', 'api'),\n    'route_middleware' =\u003e ['api', 'auth:sanctum'],\n    'table' =\u003e env('PAYMENTS_TABLE', 'payments'),\n    'auto_reflect_on_payable' =\u003e env('PAYMENTS_AUTO_REFLECT', true),\n];\n```\n\n## Siblings\n\n- `whilesmart/eloquent-invoices` -- invoices (money in). Implement `Payable`, attach `HasPayments`.\n- `whilesmart/eloquent-expenses` -- expenses (money out). Same pattern; the `Payment` direction flips to `outbound`.\n- `whilesmart/eloquent-subscriptions` (future) -- recurring billing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-payments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhilesmartphp%2Feloquent-payments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-payments/lists"}