PHPackages                             err0r/laratransaction - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. err0r/laratransaction

ActiveLibrary[Payment Processing](/categories/payments)

err0r/laratransaction
=====================

Laravel Payment Transactions Helper

v1.1.2(1y ago)0128MITPHPPHP ^8.2CI passing

Since Nov 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/200-0K/laratransaction)[ Packagist](https://packagist.org/packages/err0r/laratransaction)[ Docs](https://github.com/err0r/laratransaction)[ GitHub Sponsors](https://github.com/err0r)[ RSS](/packages/err0r-laratransaction/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (14)Versions (8)Used By (0)

Laravel Payment Transactions Package
====================================

[](#laravel-payment-transactions-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2e4b19f11a6afc1558a07f9d675679998a7c5e5720c07a7a8450c99dbd9acd1a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f65727230722f6c6172617472616e73616374696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/err0r/laratransaction)[![Total Downloads](https://camo.githubusercontent.com/c336a05a711298375bc938414d608fb958b54a9d11c0a1d5d8914084e2298b27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f65727230722f6c6172617472616e73616374696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/err0r/laratransaction)

Important

This package is currently under development and is **not yet ready for production use**.
Click the **Watch** button to stay updated and be notified when the package is ready for deployment!

This package provides a complete transaction management system for Laravel applications, offering powerful features:

💳 **Payment Processing**

- Track payment transactions with multiple statuses (pending, completed, failed, cancelled)
- Support various transaction types (payment, refund)
- Handle diverse payment methods (credit card, bank transfer, cash, etc.)

🔗 **Flexible Integration**

- Associate transactions with any model using polymorphic relationships
- Store rich transaction metadata
- Track payment gateway information and IDs

🌍 **Internationalization**

- Fully localized and translatable
- JSON-based translations

🛠️ **Developer Friendly**

- Fluent builder pattern for creating transactions
- Eloquent relationships and scopes
- API Resources for JSON responses
- Extensive configuration options

🔒 **Reliable &amp; Secure**

- UUID support for better security
- Soft deletes for data integrity
- Comprehensive audit trail
- Transaction history tracking

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require err0r/laratransaction
```

Publish the config file with:

```
php artisan vendor:publish --tag="laratransaction-config"
```

Publish and run the migrations with:

```
php artisan vendor:publish --tag="laratransaction-migrations"
php artisan migrate
```

Optionally, you can publish the translations using:

```
php artisan vendor:publish --tag="laratransaction-translations"
```

After that, you need to seed the transaction statuses, types, and payment methods:

```
php artisan laratransaction:seed
```

Usage
-----

[](#usage)

### Adding Transactions to Your Models

[](#adding-transactions-to-your-models)

Add the `HasTransaction` trait to any model that needs transaction support:

```
use Err0r\Laratransaction\Traits\HasTransaction;

class Order extends Model
{
    use HasTransaction;
}
```

### Creating Transactions

[](#creating-transactions)

Use the fluent helper method to create transactions:

```
use Err0r\Laratransaction\Builders\TransactionBuilder;
use Err0r\Laratransaction\Enums\TransactionStatus;
use Err0r\Laratransaction\Enums\TransactionType;
use Err0r\Laratransaction\Enums\PaymentMethod;

// Create a transaction for an order
$order = Order::find(1);

$order->transactionBuilder()
    ->status(TransactionStatus::PENDING)
    ->type(TransactionType::PAYMENT)
    ->paymentMethod(PaymentMethod::CREDIT_CARD)
    ->amount(100.00, 'USD')
    ->gateway('stripe')
    ->gatewayTransactionId('ch_123456')
    ->metadata(['order_id' => 12345])
    ->save();

// Or use the static method
$transaction = TransactionBuilder::create()
    ->transactionable($order)
    ->status(TransactionStatus::PENDING)
    ->type(TransactionType::PAYMENT)
    ->paymentMethod(PaymentMethod::CREDIT_CARD)
    ->amount(100.00, 'USD')
    ->gateway('stripe')
    ->gatewayTransactionId('ch_123456')
    ->metadata(['order_id' => 12345])
    ->save();
```

### Querying Transactions

[](#querying-transactions)

The package provides convenient scopes for filtering transactions:

```
// Get all pending transactions
Transaction::pending()->get();

// Get completed transactions
Transaction::completed()->get();

// Get failed transactions
Transaction::failed()->get();

// Get cancelled transactions
Transaction::cancelled()->get();
```

### Checking Transaction Status

[](#checking-transaction-status)

```
$transaction->isPending();
$transaction->isCompleted();
$transaction->isFailed();
$transaction->isCancelled();
```

### Updating Transaction Status

[](#updating-transaction-status)

```
use Err0r\Laratransaction\Enums\TransactionStatus;

$transaction->markAsCompleted();
$transaction->markAsFailed();
$transaction->markAsCancelled();
```

Or set the status directly:

```
$transaction->setStatus(TransactionStatus::COMPLETED);
$transaction->save();
```

### Updating Transaction Types

[](#updating-transaction-types)

```
use Err0r\Laratransaction\Enums\TransactionType;

$transaction->setType(TransactionType::REFUND);
$transaction->save();
```

### Updating Payment Methods

[](#updating-payment-methods)

```
use Err0r\Laratransaction\Enums\PaymentMethod;

$transaction->setPaymentMethod(PaymentMethod::BANK_TRANSFER);
$transaction->save();
```

### Accessing Related Models

[](#accessing-related-models)

```
// Get all transactions for a model
$order->transactions;

// Access transaction details
$transaction->status;     // TransactionStatus model
$transaction->type;       // TransactionType model
$transaction->paymentMethod;  // PaymentMethod model
```

Resource Classes
----------------

[](#resource-classes)

The package provides several resource classes to transform your models into JSON representations:

- [`TransactionResource`](src/Resources/TransactionResource.php): Transforms a transaction model.
- [`TransactionStatusResource`](src/Resources/TransactionStatusResource.php): Transforms a transaction status model.
- [`TransactionTypeResource`](src/Resources/TransactionTypeResource.php): Transforms a transaction type model.
- [`PaymentMethodResource`](src/Resources/PaymentMethodResource.php): Transforms a payment

Testing
-------

[](#testing)

> TODO

```
composer test
```

Changelog
---------

[](#changelog)

> TODO

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

> TODO

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

> TODO

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Faisal](https://github.com/err0r)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance47

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Recently: every ~48 days

Total

7

Last Release

397d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3762076?v=4)[Ross Ho'okano](/maintainers/Err0r)[@err0r](https://github.com/err0r)

---

Top Contributors

[![200-0K](https://avatars.githubusercontent.com/u/38166228?v=4)](https://github.com/200-0K "200-0K (27 commits)")

---

Tags

laravelerr0rlaratransaction

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/err0r-laratransaction/health.svg)

```
[![Health](https://phpackages.com/badges/err0r-laratransaction/health.svg)](https://phpackages.com/packages/err0r-laratransaction)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[finity-labs/fin-mail

A powerful email template manager and composer for Filament with dynamic token replacement, template versioning, and inline email sending.

284.4k1](/packages/finity-labs-fin-mail)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
