PHPackages                             tatogi/bog-payment-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. tatogi/bog-payment-laravel

ActiveLibrary[Payment Processing](/categories/payments)

tatogi/bog-payment-laravel
==========================

Laravel package for BOG (Bank of Georgia) payment gateway integration with card management and payment tracking

1.1.0(4mo ago)04↓92.9%MITPHPPHP ^8.0|^8.1|^8.2|^8.3

Since Jan 9Pushed 4mo agoCompare

[ Source](https://github.com/tatoGi/bog-payment)[ Packagist](https://packagist.org/packages/tatogi/bog-payment-laravel)[ RSS](/packages/tatogi-bog-payment-laravel/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (5)Versions (3)Used By (0)

BOG Payment Laravel Package
===========================

[](#bog-payment-laravel-package)

A robust and clean Laravel package for integrating Bank of Georgia (BOG) payment gateway into your application. Optimized for security, race-condition prevention, and ease of use.

[![License](https://camo.githubusercontent.com/5567b25d7db29527122a30de250e68ec95dda51496f0cf2cbf0a6de7cb0faa90/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7461746f67692f626f672d7061796d656e742d6c61726176656c)](https://packagist.org/packages/tatogi/bog-payment-laravel)[![Latest Version](https://camo.githubusercontent.com/f497e25b13c733a47a4b5cd55883ab46e59141ec24783f47ea6176898be9c5c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7461746f67692f626f672d7061796d656e742d6c61726176656c)](https://packagist.org/packages/tatogi/bog-payment-laravel)[![Total Downloads](https://camo.githubusercontent.com/2815e8840d50062b0c15999a981d404a38ae1dd1ef4926bcabe122db2c8f5244/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7461746f67692f626f672d7061796d656e742d6c61726176656c)](https://packagist.org/packages/tatogi/bog-payment-laravel)

🚀 Key Features
--------------

[](#-key-features)

- ✅ **Race-Condition Prevention**: Atomic locking mechanism for payment callbacks.
- ✅ **Clean Architecture**: Thin controllers with dedicated Form Requests and Service layer logic.
- ✅ **Full BOG API integration**: OAuth2, Order creation, Status tracking.
- ✅ **Card Management**: Securely save cards for 1-click future payments.
- ✅ **Automated Workflows**: Automatic product status updates upon successful payment.
- ✅ **Developer Friendly**: Highly configurable models and comprehensive logging.

📋 Requirements
--------------

[](#-requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 9.0 (Supports Laravel 10, 11, and 12)
- BOG Payment API Credentials

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require tatogi/bog-payment-laravel
```

Publish the configuration and migrations:

```
php artisan vendor:publish --provider="Bog\Payment\BogPaymentServiceProvider"
```

Run the database migrations:

```
php artisan migrate
```

⚙️ Configuration
----------------

[](#️-configuration)

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

```
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
# The package will automatically update these models on successful payments
BOG_USER_MODEL=App\Models\User
BOG_PRODUCT_MODEL=App\Models\Product
```

📖 Usage
-------

[](#-usage)

### Creating a Payment Order

[](#creating-a-payment-order)

The package handles all the heavy lifting, including database records and product linking.

```
use Bog\Payment\Services\BogPaymentService;
use Bog\Payment\Services\BogAuthService;

$auth = app(BogAuthService::class);
$paymentService = app(BogPaymentService::class);

$token = $auth->getAccessToken()['access_token'];

$payload = [
    'callback_url' => 'https://example.com/callback',
    'purchase_units' => [
        'total_amount' => 100.00,
        'currency' => 'GEL',
        'basket' => [
            [
                'product_id' => 'prod-123',
                'name' => 'Premium Item',
                'quantity' => 1,
                'unit_price' => 100.00,
            ]
        ]
    ],
    'redirect_urls' => [
        'success' => 'https://example.com/success',
        'fail' => 'https://example.com/fail',
    ],
    'save_card' => true, // Optional: request card saving
    'user_id' => auth()->id(),
];

$response = $paymentService->createOrder($token, $payload);
return redirect($response['_links']['redirect']['href']);
```

### Callback Handling (Automated)

[](#callback-handling-automated)

The package includes a built-in callback handler that uses **Atomic Locks** to prevent duplicate processing if BOG sends multiple hit requests.

1. Verifies status directly with BOG API (Source of Truth).
2. Updates `bog_payments` table.
3. Saves the card (if requested).
4. Marks products as "ordered" in your database.

🛣️ API Endpoints
----------------

[](#️-api-endpoints)

MethodEndpointDescription**POST**`/bog/callback`BOG Webhook handler**POST**`/bog/orders`Create a new payment order**GET**`/bog/orders/{id}`Get real-time status from BOG**POST**`/bog/cards`List/Add saved cards**DELETE**`/bog/cards/{id}`Remove a saved card🏗️ Architecture
---------------

[](#️-architecture)

- **`BogPaymentService`**: The core logic engine. Handles API communication and DB transactions.
- **`Form Requests`**: Validation is isolated for cleaner controllers.
- **`Atomic Locking`**: Uses Cache-based locks to ensure callbacks are processed exactly once.

🧪 Testing
---------

[](#-testing)

The package is fully tested with PHPUnit.

```
composer test
```

### Test Without BOG Keys (Mock Files)

[](#test-without-bog-keys-mock-files)

If you do not have real BOG credentials yet, you can test the full package flow with local mock files.

1. Create mock JSON files in your Laravel app:

`storage/app/mock-bog/oauth-token.json`

```
{
  "access_token": "mock_access_token",
  "token_type": "Bearer",
  "expires_in": 3600
}
```

`storage/app/mock-bog/order-created.json`

```
{
  "id": "mock_order_123",
  "status": "created",
  "_links": {
    "redirect": {
      "href": "https://example.test/fake-bog-checkout"
    }
  }
}
```

`storage/app/mock-bog/payment-details.json`

```
{
  "id": "mock_order_123",
  "status": "completed",
  "payment_method": "card",
  "amount": 100,
  "currency": "GEL"
}
```

2. Create `routes/mock-bog.php` in your app:

```
