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

1.0.3 2025-10-25 08:20 UTC

This package is auto-updated.

Last update: 2025-10-25 14:24:40 UTC


README

A complete Laravel package for integrating Bank of Georgia (BOG) payment gateway into your Laravel application.

License Latest Version Total Downloads

๐Ÿš€ 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 transactions
  • bog_cards - Saved payment cards
  • bog_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

๐Ÿ™ Credits

Special thanks to Bank of Georgia for providing the payment gateway API.

Made with โค๏ธ for the Laravel community