miki-babi / yagoutpay
Laravel package for YagoutPay Payment Gateway
v1.0.1
2025-08-15 01:34 UTC
Requires
- php: >=8.0
This package is not auto-updated.
Last update: 2025-08-16 00:04:27 UTC
README
A comprehensive Laravel package for seamless integration with the YagoutPay Payment Gateway. This package provides a clean, secure, and easy-to-use interface for processing payments through YagoutPay's API.
โจ Features
- ๐ Secure AES-256-CBC Encryption - Built-in encryption for payment data
- ๐ฏ Laravel Integration - Native Laravel service provider and facade
- ๐ก๏ธ Environment-based Configuration - Secure credential management
- ๐ Comprehensive Logging - Built-in logging for debugging and monitoring
- ๐ Callback Handling - Ready-to-use success/failure callback routes
- ๐งช Testing Support - Sandbox environment support
๐ Requirements
- PHP >= 8.0
- Laravel >= 10.0
- OpenSSL extension enabled
๐ฆ Installation
1. Install via Composer
composer require miki-babi/yagoutpay
2. Publish Configuration
php artisan vendor:publish --tag=yagoutpay-config
3. Environment Configuration
Add the following variables to your .env
file:
# YagoutPay Configuration YAGOUT_MERCHANT_ID=your_merchant_id YAGOUT_MERCHANT_KEY=your_merchant_key YAGOUT_PAYMENT_URL=https://sandbox.yagoutpay.com/initiate # Optional: Custom callback URLs YAGOUT_SUCCESS_URL=https://yoursite.com/payment/success YAGOUT_FAILURE_URL=https://yoursite.com/payment/failure
๐ Usage
Basic Payment Initiation
use MikiBabi\YagoutPay\Facades\Yagout; Route::get('/checkout', function () { // Initialize payment $paymentForm = Yagout::initiate( order_no: 'ORDER_' . time(), amount: 150.00, cust_details: [ 'name' => 'John Doe', 'email' => 'john@example.com', 'phone' => '0912345678' ], currency: 'ETB', // Optional, defaults to 'ETB' txn_type: 'SALE', // Optional, defaults to 'SALE' // success_url: route('payment.success'), // Optional // failure_url: route('payment.failure') // Optional ); // The method returns a Blade view that auto-submits to YagoutPay return $paymentForm; });
Controller Example
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use MikiBabi\YagoutPay\Facades\Yagout; class PaymentController extends Controller { public function initiatePayment(Request $request) { $validated = $request->validate([ 'amount' => 'required|numeric|min:1', 'customer_name' => 'required|string|max:255', 'customer_email' => 'required|email', 'customer_phone' => 'required|string|max:20', ]); $order_no = 'ORDER_' . uniqid(); return Yagout::initiate( order_no: $orderId, amount: $validated['amount'], cust_details: [ 'name' => $validated['customer_name'], 'email' => $validated['customer_email'], 'phone' => $validated['customer_phone'] ] ); } public function paymentSuccess(Request $request) { // Handle successful payment $callbackData = $request->all(); // Process your business logic here // e.g., update order status, send confirmation email return view('payment.success', compact('callbackData')); } public function paymentFailure(Request $request) { // Handle failed payment $callbackData = $request->all(); // Process failure logic here // e.g., log error, notify user return view('payment.failure', compact('callbackData')); } }
Route Configuration
// routes/web.php use App\Http\Controllers\PaymentController; Route::post('/payment/initiate', [PaymentController::class, 'initiatePayment']) ->name('payment.initiate'); Route::post('/payment/success', [PaymentController::class, 'paymentSuccess']) ->name('payment.success') ->withoutMiddleware([\App\Http\Middleware\VerifyCsrfToken::class]); Route::post('/payment/failure', [PaymentController::class, 'paymentFailure']) ->name('payment.failure') ->withoutMiddleware([\App\Http\Middleware\VerifyCsrfToken::class]);
โ๏ธ Configuration
The configuration file config/yagoutpay.php
contains the following options:
return [ 'merchant_id' => env('YAGOUT_MERCHANT_ID', ''), 'merchant_key' => env('YAGOUT_MERCHANT_KEY', ''), 'payment_url' => env('YAGOUT_PAYMENT_URL', 'https://sandbox.yagoutpay.com/initiate'), 'success_url' => env('YAGOUT_SUCCESS_URL', url('payment/success')), 'failure_url' => env('YAGOUT_FAILURE_URL', url('payment/failure')) ];
๐งช Testing
Sandbox Environment
For testing, use the sandbox URL:
YAGOUT_PAYMENT_URL=https://sandbox.yagoutpay.com/initiate
Test Credentials
Contact YagoutPay support to obtain sandbox credentials for testing.
๐ Security
- All payment data is encrypted using AES-256-CBC encryption
- Merchant credentials are stored securely in environment variables
- CSRF protection is automatically disabled for callback routes
- All transactions are logged for audit purposes
๐ Troubleshooting
Common Issues
- Encryption Errors: Ensure your
YAGOUT_MERCHANT_KEY
is properly base64 encoded - Callback Issues: Make sure callback URLs are publicly accessible
- Configuration: Verify all environment variables are set correctly
Logging
Check Laravel logs for detailed error information:
tail -f storage/logs/laravel.log
๐ค Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ License
This package is open-sourced software licensed under the MIT license.
๐ Support
- Issues: GitHub Issues
- Email: mikiyasshiferaw99@gmail.com