Search by

itmosoft / laravel-refunds

adeelrao007

Payment-provider-agnostic refund records and workflows for Laravel applications.

Package info

github.com/ITMOSOFT/laravel-refunds

pkg:composer/itmosoft/laravel-refunds

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-05 06:28 UTC

This package is auto-updated.

Last update: 2026-11-05 06:29:33 UTC


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 -> approved or rejected
  • approved -> processing or rejected
  • processing -> completed or failed
  • failed -> processing or rejected
  • completed and rejected are 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.