PHPackages                             donsoft/smartpay - 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. donsoft/smartpay

ActiveLibrary[Payment Processing](/categories/payments)

donsoft/smartpay
================

A Laravel package to intelligently route payment transactions.

v1.0.3(1y ago)05MITPHPPHP ^7.3|^8.0|^8.1|^8.2|^8.3

Since Oct 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/donchi4all/donsoft-smartpay)[ Packagist](https://packagist.org/packages/donsoft/smartpay)[ RSS](/packages/donsoft-smartpay/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

Donsoft SmartPay
================

[](#donsoft-smartpay)

**Donsoft SmartPay** is a Laravel package that intelligently routes payment transactions to the most suitable payment processor based on configurable factors such as transaction cost, reliability, and currency support.

Features
--------

[](#features)

- **Multiple Payment Processor Support**: Supports different payment processors with configurable parameters.
- **Intelligent Routing**: Routes transactions to the best processor based on defined priorities (cost, reliability, currency support).
- **Customizable**: Easily add new processors or modify existing ones.
- **Extensible**: Allows developers to extend processors and define custom behavior.

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

[](#installation)

### 1. Install the package via Composer:

[](#1-install-the-package-via-composer)

```
composer require donsoft/smartpay
```

### 2. Publish the configuration file:

[](#2-publish-the-configuration-file)

```
php artisan vendor:publish --tag=config --provider="Donsoft\\SmartPay\\Providers\\SmartPayServiceProvider"
```

This will create a `config/smartpay.php` file where you can configure your payment processors, priorities, and default settings.

### 3. Add Service Provider (for Laravel versions below 5.5):

[](#3-add-service-provider-for-laravel-versions-below-55)

If you’re using a Laravel version below 5.5, add the following service provider to your `config/app.php`:

```
'providers' => [
    Donsoft\\SmartPay\\Providers\\SmartPayServiceProvider::class,
],
```

Configuration
-------------

[](#configuration)

The configuration file `smartpay.php` allows you to define supported payment processors, the priority of routing factors, and more. Example configuration:

```
return [
    /*
    |--------------------------------------------------------------------------
    | Priority Weights for Payment Processor Selection
    |--------------------------------------------------------------------------
    */
    'priorities' => [
        'currency_support' => 3,  // Most important
        'reliability' => 2,       // Second most important
        'transaction_cost' => 1,  // Least important
    ],

    /*
    |--------------------------------------------------------------------------
    | Supported Payment Processors
    |--------------------------------------------------------------------------
    */
    'processors' => [
        'processorA' => [
            'class' => \\Donsoft\\SmartPay\\Services\\Processors\\ProcessorA::class,
            'cost_per_transaction' => 0.5,
            'supported_currencies' => ['USD', 'EUR'],
            'min_transaction_amount' => 1,
            'reliability' => 0.85,
        ],
        'processorB' => [
            'class' => \\Donsoft\\SmartPay\\Services\\Processors\\ProcessorB::class,
            'cost_per_transaction' => 1.0,
            'supported_currencies' => ['USD'],
            'min_transaction_amount' => 100,
            'reliability' => 0.90,
        ],
    ],

    'default_currency' => 'USD',
];
```

Usage
-----

[](#usage)

This is how to use **Donsoft SmartPay** in your Laravel project:

### 1. Inject the Payment Router into a Controller

[](#1-inject-the-payment-router-into-a-controller)

You can inject the **PaymentRouter** service into your controller and use it to route transactions to the appropriate processor.

```
use Donsoft\\SmartPay\\Services\\Routing\\PaymentRouter;
use Illuminate\\Http\\Request;

class PaymentController extends Controller
{
    protected $paymentRouter;

    public function __construct(PaymentRouter $paymentRouter)
    {
        $this->paymentRouter = $paymentRouter;
    }

    public function processPayment(Request $request)
    {
        $transaction = (object) [
            'amount' => $request->input('amount'),
            'currency' => $request->input('currency', config('smartpay.default_currency')),
        ];

        try {
            $processor = $this->paymentRouter->route($transaction);
            $response = $processor->process($transaction);

            return response()->json($response);
        } catch (\Exception $e) {
            return response()->json(['status' => 'error', 'message' => $e->getMessage()], 400);
        }
    }
}
```

### 2. Example Request to Process Payment:

[](#2-example-request-to-process-payment)

```
POST /api/process-payment
Content-Type: application/json

{
    "amount": 150,
    "currency": "USD"
}
```

This will route the payment to the best processor based on the configuration and transaction details.

Extending the Processor
-----------------------

[](#extending-the-processor)

You can add custom payment processors by extending the base processor class (**`BaseProcessor.php`**) and adding it to the configuration.

### Step 1: Create Your Custom Processor

[](#step-1-create-your-custom-processor)

```
namespace App\\Services\\Processors;

use Donsoft\\SmartPay\\Services\\Processors\\BaseProcessor;

class CustomProcessor extends BaseProcessor
{
    public function __construct()
    {
        parent::__construct(
            'CustomProcessor',
            0.25,  // Cost per transaction
            ['USD', 'GBP'],  // Supported currencies
            0.95,  // Reliability
            10  // Minimum transaction amount
        );
    }

    public function process($transaction)
    {
        // Custom processing logic here
        return $this->successResponse($transaction);
    }
}
```

### Step 2: Add Your Processor to the Configuration

[](#step-2-add-your-processor-to-the-configuration)

```
return [
    'processors' => [
        'customProcessor' => [
            'class' => \\App\\Services\\Processors\\CustomProcessor::class,
            'cost_per_transaction' => 0.25,
            'supported_currencies' => ['USD', 'GBP'],
            'min_transaction_amount' => 10,
            'reliability' => 0.95,
        ],
    ],
];
```

Now, **CustomProcessor** will be included in the intelligent routing when a payment is processed.

Customizing the Configuration
-----------------------------

[](#customizing-the-configuration)

You can adjust the **priorities** and **processors** directly in the `smartpay.php` config file:

- **Priorities**: Adjust the weight of each factor in the routing decision (currency support, reliability, transaction cost).
- **Processors**: Define new or existing payment processors and their configurations (cost per transaction, supported currencies, minimum transaction amounts).

```
'priorities' => [
    'currency_support' => 4,  // Higher priority
    'reliability' => 2,
    'transaction_cost' => 1,
],
```

Running Tests
-------------

[](#running-tests)

The package includes tests to verify its functionality. To run the tests:

```
vendor/bin/phpunit
```

Make sure your test classes are under the **`tests/`** directory.

---

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE).

---

### Conclusion

[](#conclusion)

This **Donsoft SmartPay** package provides a flexible, customizable solution for routing payment transactions in Laravel applications. By allowing easy configuration and extensibility, developers can adapt it to suit their specific business logic and requirements.

If you have any questions or need support, feel free to reach out to the author

```

```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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 ~0 days

Total

4

Last Release

579d ago

PHP version history (2 changes)v1.0.0PHP ^7.3|^8.0

v1.0.2PHP ^7.3|^8.0|^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/ee4c3b8a054ee2ed8a315ad4ed2b293a54264d5d0eb5ee7541a955cf819a8173?d=identicon)[donchi4all](/maintainers/donchi4all)

---

Top Contributors

[![donchi4all](https://avatars.githubusercontent.com/u/33794017?v=4)](https://github.com/donchi4all "donchi4all (3 commits)")

---

Tags

laravellaravel-packagepayment processingpaymentpayment gatewaysmart paytransaction routingmulti-processorcurrency supporttransaction costintelligent routing

### Embed Badge

![Health badge](/badges/donsoft-smartpay/health.svg)

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

###  Alternatives

[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

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