tatogi/bog-payment-laravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tatogi/bog-payment-laravel

最新稳定版本:1.0.3

Composer 安装命令:

composer require tatogi/bog-payment-laravel

包简介

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

README 文档

README

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 Latest Version Total Downloads

🚀 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

  • PHP >= 8.1
  • Laravel >= 9.0 (Supports Laravel 10, 11, and 12)
  • BOG Payment API Credentials

📦 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

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

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)

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

Method Endpoint Description
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

  • 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

The package is fully tested with PHPUnit.

vendor/bin/phpunit

👤 Author

Tato

📄 License

This package is open-sourced software licensed under the MIT license.

Made with ❤️ for the Laravel community.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-09