bog / payment
Laravel package for BOG (Bank of Georgia) payment gateway integration with card management and payment tracking
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/bog/payment
Requires
- php: ^8.0|^8.1|^8.2|^8.3
- illuminate/database: ^12.35
- illuminate/http: ^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- phpunit/phpunit: ^9.0|^10.0
README
A complete Laravel package for integrating Bank of Georgia (BOG) payment gateway into your Laravel application.
๐ Features
- โ Full BOG Payment API integration
- โ OAuth2 authentication
- โ Payment order management
- โ Save cards for future payments
- โ Card management (add, list, delete, set default)
- โ Payment history tracking
- โ Callback handling
- โ Pre-authorization support
- โ Product linking
- โ Complete database migrations
- โ Ready-to-use controllers and routes
๐ Requirements
- PHP >= 8.0
- Laravel >= 9.0, <= 12.0
- BOG Payment API credentials
๐ฆ Installation
Install the package via Composer:
composer require bog/payment
Publish the configuration file:
php artisan vendor:publish --provider="Bog\Payment\BogPaymentServiceProvider" --tag="bog-payment-config"
Run migrations:
php artisan migrate
โ๏ธ Configuration
Add your BOG credentials to the .env file:
BOG_API_BASE_URL=https://api.bog.ge/payments BOG_AUTH_URL=https://api.bog.ge/auth/token BOG_ORDERS_URL=https://api.bog.ge/payments/v1/ecommerce/orders BOG_CLIENT_ID=your_client_id BOG_CLIENT_SECRET=your_client_secret BOG_CALLBACK_URL=https://your-domain.com/bog/callback # Optional - Customize your models BOG_USER_MODEL=App\Models\User BOG_PRODUCT_MODEL=App\Models\Product
๐ Usage
Basic Example
use Bog\Payment\Services\BogAuthService; use Bog\Payment\Services\BogPaymentService; // Get access token $auth = new BogAuthService(); $token = $auth->getAccessToken(); // Create payment order $paymentService = new BogPaymentService(); $orderData = [ 'callback_url' => 'https://your-domain.com/bog/callback', 'purchase_units' => [ 'total_amount' => 100.00, 'currency' => 'GEL', 'basket' => [ [ 'product_id' => '123', 'name' => 'Product Name', 'quantity' => 1, 'unit_price' => 100.00, ] ] ], 'redirect_urls' => [ 'success' => 'https://your-domain.com/success', 'fail' => 'https://your-domain.com/fail', ], ]; $result = $paymentService->createOrder($token['access_token'], $orderData);
Using Models
use Bog\Payment\Models\BogPayment; use Bog\Payment\Models\BogCard; // Get payment by order ID $payment = BogPayment::where('bog_order_id', $orderId)->first(); // Get user's saved cards $cards = BogCard::where('user_id', auth()->id())->get(); // Check payment status if ($payment && $payment->status === 'completed') { // Payment successful }
Using Controllers
The package includes ready-to-use controllers:
use Bog\Payment\Controllers\BogPaymentController; use Bog\Payment\Controllers\BogCardController; // In your routes file Route::post('/bog/orders', [BogPaymentController::class, 'createOrder']); Route::get('/bog/cards', [BogCardController::class, 'listCards']);
๐๏ธ Database
The package automatically creates the following tables:
bog_payments- Payment transactionsbog_cards- Saved payment cardsbog_payment_product- Payment-product relationships
๐ฃ๏ธ Available Routes
Payment Routes
POST /bog/callback - Handle BOG callback
POST /bog/orders - Create payment order
GET /bog/orders/{orderId} - Get order details
POST /bog/orders/{orderId}/save-card - Save card
POST /bog/orders/{parentOrderId}/charge - Charge saved card
Card Management Routes
POST /bog/cards/add - Add new card
GET /bog/cards - List all cards
DELETE /bog/cards/{cardId} - Delete card
POST /bog/cards/{cardId}/set-default - Set default card
To disable these routes, set BOG_ROUTES_ENABLED=false in your .env file.
๐๏ธ Package Structure
src/
โโโ Models/
โ โโโ BogPayment.php # Payment model
โ โโโ BogCard.php # Card model
โโโ Services/
โ โโโ BogAuthService.php # OAuth2 authentication
โ โโโ BogPaymentService.php # Payment operations
โโโ Controllers/
โ โโโ BogPaymentController.php
โ โโโ BogCardController.php
โโโ Exceptions/
โ โโโ BogPaymentException.php
โ โโโ AuthenticationException.php
โ โโโ ...
โโโ Database/Migrations/
โโโ create_bog_payments_table.php
โโโ create_bog_cards_table.php
โโโ ...
๐งช Testing
Test the package installation:
php artisan tinker
use Bog\Payment\Services\BogAuthService; $auth = new BogAuthService(); $token = $auth->getAccessToken(); dd($token);
๐ Troubleshooting
Class not found
composer dump-autoload php artisan config:clear
Config not loading
php artisan vendor:publish --provider="Bog\Payment\BogPaymentServiceProvider" --force
php artisan config:cache
Routes not working
Check that BOG_ROUTES_ENABLED=true in your .env file.
๐ Changelog
Please see CHANGELOG.md for more information on what has changed recently.
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ Security
If you discover any security-related issues, please email the maintainer instead of using the issue tracker.
๐ License
This package is open-sourced software licensed under the MIT license.
๐ Support
For support, email support@example.com or open an issue on GitHub.
๐ Additional Resources
๐ค Author
Your Name
- GitHub: @TatoGi
- Email: tato.laperashvili95@gmail.com
๐ Credits
Special thanks to Bank of Georgia for providing the payment gateway API.
Made with โค๏ธ for the Laravel community