- How do I install unusualify/payable in a Laravel app?
- Install it with Composer by running composer require unusualify/payable. Then add the package trait to the Eloquent models that should act as payers or payees. The package is PSR-4 structured and designed to work alongside your existing Laravel models and migrations.
- Which Laravel versions does unusualify/payable support?
- The provided overview does not list specific Laravel version constraints, so check the package's composer.json require entries before installing. Because it relies on Eloquent traits and polymorphic relationships, it targets modern Laravel releases that support those features. Confirm compatibility in a staging app before upgrading a production project.
- How does the polymorphic payable relationship work?
- The package uses polymorphic relationships so any Eloquent model can be linked to payments as a payer or payee. Instead of tying payments to a single User model, the relationship stores the related model's type and ID. That lets orders, subscriptions, invoices, and users share the same payment logic.
- Can one Eloquent model act as both payer and payee?
- In principle yes, because the package is trait-driven and built on polymorphic relationships. You apply the relevant traits to a model to wire it as a payer, a payee, or both. Check the package source for the exact trait names and relationship methods before relying on this in production.
- Does unusualify/payable support Stripe and other payment gateways?
- The package is designed around pluggable gateways, with Stripe given as an example in the package blurb. Gateway credentials and driver-specific configuration stay in your Laravel application rather than in the polymorphic model layer. Review the package docs for the gateway contract and any supported drivers.
- How do I handle refunds and payment status with unusualify/payable?
- The package includes fluent APIs for tracking transactions, refunds, and payment status. You create a payment through the trait API, then update its status as the gateway confirms or refunds the charge. Keep refunds as explicit state transitions so you retain an auditable record.
- How should I test payment flows without hitting a real gateway?
- Fake the gateway layer in your tests rather than calling Stripe or another provider. Because payments are attached through Eloquent relationships, you can assert database records for transactions, statuses, and refunds. Keeping gateway calls behind an interface makes swapping in a test double straightforward.
- What are the production concerns when using unusualify/payable?
- Wrap payment creation and status updates in database transactions so model records and gateway results stay consistent. Store gateway identifiers and idempotency keys, and process webhooks for asynchronous status changes. Treat refunds and failed payments as state transitions with an audit trail.
- How does unusualify/payable compare to Laravel Cashier?
- Laravel Cashier is the common choice for Stripe subscriptions tied to a billable user model. unusualify/payable differs by making payments polymorphic, so orders, invoices, subscriptions, and other models can act as payers or payees. If you only need Cashier-style user subscriptions, Cashier may be simpler; if you need shared payment logic across models, this package fits better.
- Do I need to change my existing models or migrations to use it?
- You do not need to replace your existing models; you add the package trait to the models that should handle payments. The package works alongside your current migrations, though you should review its payment tables and polymorphic type and ID columns before running them. Adjust table names or key types in staging if they conflict with your schema.