PHPackages                             tarzann419/autopay-laravel - 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. tarzann419/autopay-laravel

ActiveLibrary[Payment Processing](/categories/payments)

tarzann419/autopay-laravel
==========================

Laravel package for Interswitch AutoPay XML bulk payment processing

v1.0.0(6mo ago)30MITPHPPHP ^8.0|^8.1|^8.2

Since Nov 6Pushed 6mo agoCompare

[ Source](https://github.com/tarzann419/autopay-laravel)[ Packagist](https://packagist.org/packages/tarzann419/autopay-laravel)[ Docs](https://github.com/tarzann419/autopay-laravel)[ RSS](/packages/tarzann419-autopay-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

AutoPay Laravel Package
=======================

[](#autopay-laravel-package)

A Laravel package for processing bulk payments through Interswitch AutoPay XML API.

Features
--------

[](#features)

- ✅ Simple, fluent API for bulk payment processing
- ✅ Automatic Interswitch authentication
- ✅ XML payload generation and parsing
- ✅ Transaction logging to database
- ✅ Configurable switching charges
- ✅ Comprehensive error handling
- ✅ PSR-4 compliant

Requirements
------------

[](#requirements)

- PHP ^8.0
- Laravel ^9.0|^10.0|^11.0
- ext-curl
- ext-xml

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

[](#installation)

Install the package via Composer:

```
composer require tarzann419/autopay-laravel
```

Publish the configuration file:

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

Publish and run the migrations:

```
php artisan vendor:publish --tag=autopay-migrations
php artisan migrate
```

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

[](#configuration)

Add your Interswitch credentials to your `.env` file:

```
# Interswitch AutoPay credentials — get these from your AutoPay dashboard or by contacting AutoPay customer support
# Switching charge: per-transaction processing fee (in Naira) charged by the payment switch/bank. Set this to the value agreed with Interswitch or your bank; the package will use it when calculating total charges.
AUTOPAY_CLIENT_ID=your_client_id
AUTOPAY_CLIENT_SECRET=your_client_secret
AUTOPAY_TERMINAL_ID=XXXXXXXX
AUTOPAY_SWITCHING_CHARGE=0
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
use DanOgbo\AutoPay\Facades\AutoPay;

$batchData = [
    'batch_no' => 'BATCH001',
    'batch_name' => 'January 2025 Salary',
    'month' => 'January',
    'year' => '2025',
];

$payments = [
    [
        'beneficiary_id' => 'BEN001',
        'beneficiary_name' => 'John Doe',
        'account_number' => '0123456789',
        'bank_code' => '058',
        'account_type' => 'SAVINGS',
        'amount' => 150000.00,
    ],
    [
        'beneficiary_id' => 'BEN002',
        'beneficiary_name' => 'Jane Smith',
        'account_number' => '0987654321',
        'bank_code' => '011',
        'account_type' => 'CURRENT',
        'amount' => 200000.00,
    ],
    // ... more payments
];

$sourceAccount = '1234567890';
$narration = 'January 2025 Salary Payment';

$result = AutoPay::processBulkPayment(
    $batchData,
    $payments,
    $sourceAccount,
    $narration
);

if ($result->isSuccessful()) {
    echo "Payment processed successfully!";
    echo "Batch Name: " . $result->getBatchName();
    echo "Transaction ID: " . $result->getTransactionId();
} else {
    echo "Payment failed: " . $result->getError();
}
```

### Using in a Controller

[](#using-in-a-controller)

```
namespace App\Http\Controllers;

use DanOgbo\AutoPay\Facades\AutoPay;
use DanOgbo\AutoPay\Exceptions\AutoPayException;
use Illuminate\Http\Request;

class SalaryController extends Controller
{
    public function processSalary(Request $request)
    {
        $validated = $request->validate([
            'batch_no' => 'required|string',
            'batch_name' => 'required|string',
            'month' => 'required|string',
            'year' => 'required|string',
            'source_account' => 'required|string',
            'narration' => 'required|string',
        ]);

        // Get employees from your database
        $employees = $this->getEmployeesForPayment($validated['batch_no']);

        // Transform to payment format
        $payments = $employees->map(function ($employee) {
            return [
                'beneficiary_id' => $employee->employee_no,
                'beneficiary_name' => $employee->full_name,
                'account_number' => $employee->account_number,
                'bank_code' => $employee->bank_code,
                'account_type' => $employee->account_type,
                'amount' => $employee->monthly_pay,
            ];
        })->toArray();

        try {
            $result = AutoPay::processBulkPayment(
                [
                    'batch_no' => $validated['batch_no'],
                    'batch_name' => $validated['batch_name'],
                    'month' => $validated['month'],
                    'year' => $validated['year'],
                ],
                $payments,
                $validated['source_account'],
                $validated['narration']
            );

            if ($result->isSuccessful()) {
                return redirect()->back()->with('success', 'Payment processed successfully');
            } else {
                return redirect()->back()->with('error', $result->getError());
            }

        } catch (AutoPayException $e) {
            return redirect()->back()->with('error', 'Payment failed: ' . $e->getMessage());
        }
    }
}
```

### Using the Processor Directly

[](#using-the-processor-directly)

```
use DanOgbo\AutoPay\Services\AutoPayXmlProcessor;

$processor = new AutoPayXmlProcessor();

$result = $processor->process(
    $batchData,
    $payments,
    $sourceAccount,
    $narration
);
```

### Query Transactions

[](#query-transactions)

```
use DanOgbo\AutoPay\Models\AutoPayTransaction;

// Get all transactions
$transactions = AutoPayTransaction::latest()->get();

// Get successful transactions
$successful = AutoPayTransaction::successful()->get();

// Get failed transactions
$failed = AutoPayTransaction::failed()->get();

// Get by batch number
$batch = AutoPayTransaction::byBatchNo('BATCH001')->first();

// Check status
if ($batch->isSuccessful()) {
    echo "Payment was successful";
}
```

Payment Data Structure
----------------------

[](#payment-data-structure)

Each payment in the `$payments` array should have:

FieldTypeRequiredDescription`beneficiary_id`stringYesUnique beneficiary reference/ID`beneficiary_name`stringYesName of the beneficiary`account_number`stringYesBank account number`bank_code`stringYesBank CBN code (e.g., '058' for GTBank)`account_type`stringYes'SAVINGS' or 'CURRENT'`amount`floatYesPayment amount in NairaResponse Object
---------------

[](#response-object)

The `PaymentResult` object provides:

```
$result->isSuccessful()      // bool: Check if payment succeeded
$result->isFailed()          // bool: Check if payment failed
$result->getResponseCode()   // string: Interswitch response code
$result->getError()          // string: Error message if failed
$result->getBatchName()      // string: Generated batch name
$result->getTransactionId()  // string: Transaction ID
$result->getMetadata()       // array: Payment metadata
$result->toArray()           // array: Convert to array
```

Configuration Options
---------------------

[](#configuration-options)

The `config/autopay.php` file allows you to customize:

```
return [
    // Interswitch credentials
    'client_id' => env('AUTOPAY_CLIENT_ID'),
    'client_secret' => env('AUTOPAY_CLIENT_SECRET'),
    'terminal_id' => env('AUTOPAY_TERMINAL_ID', '3PSA0001'),

    // API endpoints
    'auth_url' => env('AUTOPAY_AUTH_URL', 'https://saturn.interswitchng.com/v2/authenticate?wsdl'),
    'request_url' => env('AUTOPAY_REQUEST_URL', 'https://saturn.interswitchng.com/v3/autopayservice?wsdl'),

    // Processing charge per transaction (in Naira)
    'switching_charge' => env('AUTOPAY_SWITCHING_CHARGE', 0),

    // Table names
    'tables' => [
        'transactions' => 'autopay_transactions',
    ],

    // Logging
    'logging' => [
        'enabled' => env('AUTOPAY_LOGGING', true),
        'channel' => env('AUTOPAY_LOG_CHANNEL', 'stack'),
    ],
];
```

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

[](#error-handling)

The package throws `AutoPayException` for errors:

```
use DanOgbo\AutoPay\Exceptions\AutoPayException;

try {
    $result = AutoPay::processBulkPayment(...);
} catch (AutoPayException $e) {
    Log::error('AutoPay Error: ' . $e->getMessage());
    // Handle the error
}
```

Logging
-------

[](#logging)

All API requests and responses are logged when logging is enabled:

```
AUTOPAY_LOGGING=true
AUTOPAY_LOG_CHANNEL=stack
```

Check your logs at `storage/logs/laravel.log`

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

- Never commit your `.env` file
- Keep your Interswitch credentials secure
- Use environment variables for sensitive data
- Enable logging only in development/staging

Support
-------

[](#support)

For issues or questions, please open an issue on GitHub.

License
-------

[](#license)

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

Credits
-------

[](#credits)

- [Nanichang Katzing](https://github.com/nanichang)
- [Daniel Ogbo](https://github.com/tarzann419)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for recent changes.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance68

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

188d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23899ed434e3cd60d0efbeabac6f645566ea0fd0923693c44d00063fe0648d42?d=identicon)[tarzann419](/maintainers/tarzann419)

---

Top Contributors

[![tarzann419](https://avatars.githubusercontent.com/u/108550261?v=4)](https://github.com/tarzann419 "tarzann419 (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tarzann419-autopay-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/tarzann419-autopay-laravel/health.svg)](https://phpackages.com/packages/tarzann419-autopay-laravel)
```

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[asciisd/knet

Knet package is provides an expressive, fluent interface to KNet's payment services.

141.1k](/packages/asciisd-knet)[dena-a/iran-payment

a Laravel package to handle Internet Payment Gateways for Iran Banking System

312.4k1](/packages/dena-a-iran-payment)

PHPackages © 2026

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