PHPackages                             eboseogbidi/smartpaymentrouter - 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. eboseogbidi/smartpaymentrouter

ActivePackage[Payment Processing](/categories/payments)

eboseogbidi/smartpaymentrouter
==============================

This package can intelligently route payment transactions to the most suitable payment processor based on various factors such as transaction cost, reliability, and currency support.

1.0.1(1y ago)06MITPHP

Since Nov 4Pushed 1y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

SmartPaymentRouter
==================

[](#smartpaymentrouter)

A flexible and intelligent payment routing system that helps you manage multiple payment processors with automatic fallback and smart routing based on cost, reliability, and supported currencies.

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

[](#installation)

You can install the package via composer:

```
composer require eboseogbidi/smartpaymentrouter
```

Migration
---------

[](#migration)

Migrate the schema for the payment transaction log this helps to improve the reliability of the different payment processors:

```
php artisan migrate
```

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

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=smartpaymentrouter-config
```

This will create a `config/smartpaymentrouter.php` file where you can configure your payment processors.

### Basic Configuration Structure

[](#basic-configuration-structure)

```
return [
    'routing_rules' => [
        'transaction_cost' => true,
        'reliability' => true,
        'currency_support' => true,
    ],

    'processors' => [
        'stripe' => [
            'name' => "Stripe",
            'class' => \Eboseogbidi\Smartpaymentrouter\Processors\StripeProcessor::class,
            'transaction_cost' => 1.8,
            'reliability' => 95,
            'currencies' => ['USD', 'GBP'],
        ],
        // Add more processors here
    ],
];
```

Configuration parameters:

- `name`: Display name for the processor
- `class`: The processor class that implements PaymentProcessorInterface
- `transaction_cost`: Processing fee percentage
- `reliability`: Estimated uptime percentage
- `currencies`: Array of supported currencies

Extending PaymentProcessorInterface
-----------------------------------

[](#extending-paymentprocessorinterface)

To create a new payment processor, implement the `PaymentProcessorInterface`:

```
use Eboseogbidi\Smartpaymentrouter\Interfaces\PaymentProcessorInterface;

class StripeProcessor implements PaymentProcessorInterface{

    //If you want to extend the callback functionality
    use DefaultCallbackTrait;

    public function getName():string{
        return 'Stripe';
    }

    public function processPayment(array $paymentData): array{

        //process stripe payment
        return $paymentData;
    }

    public function callback($response){
        return back()->with('success','Works fine');
    }

}
```

Using the Payment Router
------------------------

[](#using-the-payment-router)

Example of how to use the `PaymentRouter` in a Controller :

```
namespace Eboseogbidi\Smartpaymentrouter\Http\Controllers;

use Illuminate\Http\Request;
use Eboseogbidi\Smartpaymentrouter\Services\PaymentRouter;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Log;

class ProcessPaymentController extends BaseController
{

    public function __construct(protected PaymentRouter $paymentRouter){}

    /**
     * Handle the payment transaction.
     *
     * @param Request $request
     * @return mixed
     */
    public function handlePayment(Request $request): mixed
    {

        $request->validate([
            'amount' => 'required|numeric|min:0.01',
            'currency' => 'required|string|max:3',
        ]);

        try {
            $paymentData = $request->all();

            $result = $this->paymentRouter->routeTransaction($paymentData);

           return $result;

        } catch (\Exception $e) {

            Log::error("Payment transaction error: {$e->getMessage()}");

            return back()->with('error','Transaction failed'. $e->getMessage());
        }
    }
}
```

Using the ProcessorManager
--------------------------

[](#using-the-processormanager)

The ProcessorManager provides methods to interact with and modify the payment configuration:

```
use Eboseogbidi\Smartpaymentrouter\Services\ProcessorManager;

class PaymentService
{

    public function __construct(protected ProcessorManager $processorManager){}

    public function updateProcessorConfig()
    {
        // Add new processor
        $this->processorManager->addProcessor('paypal', [
            'name' => 'PayPal',
            'class' => PayPalProcessor::class,
            'transaction_cost' => 2.0,
            'reliability' => 98,
            'currencies' => ['USD', 'EUR'],
        ]);

        // Update existing processor
        $this->processorManager->updateProcessor('stripe', [
            'transaction_cost' => 1.9,
            'reliability' => 97,
        ]);

        // Remove processor
        $this->processorManager->removeProcessor('square');

        //Get Processors
        $this->processorManager->getProcessors();

    }
}
```

Testing
-------

[](#testing)

The package includes a comprehensive test suite. Run the tests with:

```
composer test
```

Error Handling
--------------

[](#error-handling)

The package provides built-in error handling for common scenarios:

```
try {
    $result = $processor->processPayment($paymentData);
} catch (PaymentProcessingException $e) {
    // Handle processor-specific errors
    Log::error('Payment processing failed: ' . $e->getMessage());
} catch (RoutingException $e) {
    // Handle processor-specific errors
    Log::error('Routing error failed: ' . $e->getMessage());
} catch (ValidationException $e) {
    // Handle validation errors
    $errors = $e->getValidationErrors();
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

2

Last Release

551d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/06942f274612907c1c2604b9b7d07d9d2f7744e9a84788975622b96d54b2237d?d=identicon)[EDJ](/maintainers/EDJ)

---

Top Contributors

[![EbosetaleseDunjoyin](https://avatars.githubusercontent.com/u/66825997?v=4)](https://github.com/EbosetaleseDunjoyin "EbosetaleseDunjoyin (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/eboseogbidi-smartpaymentrouter/health.svg)

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

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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