hopekelldev / laravel-paystack
Modern Paystack SDK for Laravel 13 and PHP 8.3+.
Requires
- php: ^8.3
- illuminate/http: ^13.0
- illuminate/support: ^13.0
Requires (Dev)
README
๐ Introduction
HopekellDev Laravel Paystack is a modern, lightweight, and fully customizable Paystack SDK built specifically for:
- โก Laravel 13+
- ๐ง PHP 8.3+
- ๐งฉ Clean architecture
- ๐ฅ Static method access
- ๐ก Simple exception handling
- ๐ฆ Easy Laravel installation
Built for developers who want a modern Paystack integration without depending on outdated Laravel Paystack libraries.
โจ Features
- โ Laravel 13 support
- โ PHP 8.3+ support
- โ Static API style
- โ Service-based structure
- โ Centralized HTTP client
- โ Standardized API responses
- โ Built-in exception handling
- โ Laravel package auto-discovery
- โ Easy to extend with more Paystack endpoints
๐ฆ Installation
composer require hopekelldev/laravel-paystack
Publish the config file:
php artisan vendor:publish --tag=paystack-config
โ๏ธ Configuration
Add your Paystack credentials to .env:
PAYSTACK_PUBLIC_KEY=pk_test_xxxxxx PAYSTACK_SECRET_KEY=sk_test_xxxxxx PAYSTACK_BASE_URL=https://api.paystack.co PAYSTACK_TIMEOUT=30
๐งช Quick Usage
use HopekellDev\Paystack\Paystack; $response = Paystack::transactions()->initialize([ 'email' => 'user@email.com', 'amount' => 500000, 'callback_url' => route('payment.callback'), ]); return redirect($response['data']['authorization_url']);
๐ Basic Documentation
Transactions
Initialize Transaction
Paystack::transactions()->initialize([ 'email' => 'user@email.com', 'amount' => 500000, ]);
Verify Transaction
Paystack::transactions()->verify($reference);
List Transactions
Paystack::transactions()->list([ 'perPage' => 50, ]);
Fetch Transaction
Paystack::transactions()->fetch($transactionId);
Plans
Create Plan
Paystack::plans()->create([ 'name' => 'Premium Plan', 'amount' => 100000, 'interval' => 'monthly', ]);
List Plans
Paystack::plans()->list();
Fetch Plan
Paystack::plans()->fetch($planCode);
Update Plan
Paystack::plans()->update($planCode, [ 'name' => 'Updated Premium Plan', ]);
Customers
Create Customer
Paystack::customers()->create([ 'email' => 'user@email.com', 'first_name' => 'John', 'last_name' => 'Doe', ]);
Fetch Customer
Paystack::customers()->fetch($emailOrCustomerCode);
Update Customer
Paystack::customers()->update($customerCode, [ 'first_name' => 'Updated Name', ]);
Dedicated Virtual Accounts
Create Dedicated Virtual Account
Paystack::dedicatedVirtualAccounts()->create([ 'customer' => $customerCode, 'preferred_bank' => 'wema-bank', ]);
Assign Dedicated Virtual Account
Paystack::dedicatedVirtualAccounts()->assign([ 'email' => 'user@email.com', 'first_name' => 'John', 'last_name' => 'Doe', 'phone' => '08000000000', 'preferred_bank' => 'wema-bank', 'country' => 'NG', ]);
List Dedicated Virtual Accounts
Paystack::dedicatedVirtualAccounts()->list();
Fetch Dedicated Virtual Account
Paystack::dedicatedVirtualAccounts()->fetch($dedicatedAccountId);
๐ Covered Endpoints
โ Transactions
- Initialize Transaction
- Verify Transaction
- List Transactions
- Fetch Transaction
- Charge Authorization
- Transaction Totals
- Export Transactions
โ Plans
- Create Plan
- List Plans
- Fetch Plan
- Update Plan
โ Customers
- Create Customer
- List Customers
- Fetch Customer
- Update Customer
- Validate Customer
- Set Risk Action
โ Dedicated Virtual Accounts
- Create Dedicated Account
- Assign Dedicated Account
- List Dedicated Accounts
- Fetch Dedicated Account
- Deactivate Dedicated Account
- Split Dedicated Account
- Remove Split
- List Available Providers
โ ๏ธ Error Handling
All failed Paystack API requests throw:
HopekellDev\Paystack\Exceptions\PaystackException
Example:
use HopekellDev\Paystack\Exceptions\PaystackException; use HopekellDev\Paystack\Paystack; try { $response = Paystack::transactions()->verify($reference); } catch (PaystackException $e) { return $e->getMessage(); }
๐งฑ Package Architecture
Paystack โโโ Services โ โโโ Transactions โ โโโ Plans โ โโโ Customers โ โโโ DedicatedVirtualAccounts โโโ Helpers โ โโโ Http Client โ โโโ Response Formatter โโโ Exceptions
๐ Packaage Folder Structure
src/
โโโ Paystack.php
โโโ PaystackServiceProvider.php
โโโ Exceptions/
โ โโโ PaystackException.php
โโโ Helpers/
โ โโโ ApiResponse.php
โ โโโ HasHttpClient.php
โโโ Services/
โโโ Transactions.php
โโโ Plans.php
โโโ Customers.php
โโโ DedicatedVirtualAccounts.php
๐ค Contributing
Contributions are welcome.
You can help by:
- Adding more Paystack endpoints
- Improving documentation
- Writing tests
- Improving error handling
- Adding Laravel helpers
- Improving developer experience
How to contribute
- Fork the repository
- Create a new branch
- Commit your changes
- Push to your branch
- Open a pull request
๐ฅ Roadmap
- Subscriptions API
- Transfers API
- Transfer Recipients API
- Settlements API
- Refunds API
- Disputes API
- Webhook signature verification
- Laravel webhook controller helper
- Retry logic
- Logging support
- Pest test suite
- GitHub Actions CI
๐ข Call for Collaboration
This library is actively open for collaboration and improvement.
If you are a Laravel developer, fintech builder, open-source contributor, or Paystack user, your support is welcome.
Help make this package better by submitting issues, pull requests, endpoint updates, and documentation improvements.
๐ก License
This package is open-sourced software licensed under the MIT License.
๐จโ๐ป Author
HopekellDev
Building scalable fintech, SaaS, and backend systems.
โญ Support
If this package helps you, please support it by:
- Starring the repository
- Sharing it with Laravel developers
- Reporting bugs
- Suggesting improvements
- Contributing code
๐ฌ Contact
For support, collaboration, or questions:
- GitHub Issues
- Email: support@hopekelltech.com
Built for Laravel developers who need a clean, modern, and extendable Paystack SDK.