itmosoft / laravel-refunds
Payment-provider-agnostic refund records and workflows for Laravel applications.
Requires
- php: ^8.3
- illuminate/contracts: ^12.0 || ^13.0
- illuminate/database: ^12.0 || ^13.0
- illuminate/support: ^12.0 || ^13.0
Requires (Dev)
- orchestra/testbench: ^10.0 || ^11.0
- phpunit/phpunit: ^11.0 || ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Payment-provider-agnostic refund records and workflows for Laravel 12 and 13.
Features
- Full and partial refund records.
- Optional refund line items and snapshots.
- Optional link to an RMA/return request.
- Provider and provider-reference storage (no gateway calls).
- Refund status lifecycle and status history.
- Events:
RefundCreated,RefundStatusChanged. - Configurable table prefix.
- Laravel facade and service container binding.
Requirements
- PHP 8.3+
- Laravel 12 or 13
illuminate/database,illuminate/support
Installation
composer require itmosoft/laravel-refunds php artisan vendor:publish --tag=itmosoft-refunds-config php artisan migrate
Usage
use ItmoSoft\Refunds\Facades\Refunds; $refund = Refunds::create([ 'order_id' => 123, 'amount' => 49.99, 'currency' => 'USD', 'reason' => 'returned_item', ], [ [ 'order_item_id' => 456, 'description' => 'Product name', 'quantity' => 1, 'amount' => 49.99, 'snapshot' => ['sku' => 'SKU-001'], ], ]); $refund = Refunds::changeStatus($refund, 'approved', 'Approved by support'); $refund = Refunds::changeStatus($refund, 'processing'); $refund = Refunds::changeStatus($refund, 'completed');
Alternatively resolve ItmoSoft\Refunds\Services\RefundManager from the container.
Status transitions
pending->approvedorrejectedapproved->processingorrejectedprocessing->completedorfailedfailed->processingorrejectedcompletedandrejectedare terminal
The configured statuses list controls supported status names; transition rules are enforced by the manager.
Configuration
Publish itmosoft-refunds.php. Set table_prefix, default currency, and optional model class names. The package stores order_id and return_request_id as scalar references to avoid imposing foreign-key assumptions on host applications.
Tests
composer install
composer test
Boundaries
This package records and manages refund workflows. It does not call payment gateways, move money, modify inventory, calculate tax, or decide legal refund eligibility. Integrate a payment adapter to execute an approved refund externally, then persist the provider reference and resulting status.
License
MIT.