anvarulugov/click-integration-laravel 问题修复 & 功能扩展

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

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

anvarulugov/click-integration-laravel

Composer 安装命令:

composer require anvarulugov/click-integration-laravel

包简介

Laravel package that ports the core Click payment integration logic.

README 文档

README

Latest Version on Packagist Total Downloads

Laravel-oriented port of the official click-integration-php library.
It wraps the Click Shop API and Merchant API flows in familiar Laravel service bindings, configuration and facades, so you can integrate Click in first-party Laravel applications without rewriting the business logic from scratch.

The official Click payment documentation lives at https://docs.click.uz.

Features

  • ✅ Laravel-native bindings & facade for the Click payment client
  • ✅ Multiple configured Click services (per service_id / merchant credentials)
  • ✅ Publishable configuration & migration stub for the payments table
  • ✅ REST helper mirroring the original Application router (/prepare, /complete, /invoice/*, etc.)
  • ✅ Extensible hooks: override any of the Payments lifecycle methods to customise behaviour

Requirements

  • PHP 8.4 or higher
  • Laravel 11 or 12

Installation

composer require anvarulugov/click-integration-laravel

Publish the configuration (and optional migration) to tailor the package to your project:

php artisan vendor:publish --tag="click-integration-config"
php artisan vendor:publish --tag="click-integration-migrations"

Run the migration if you plan to use the bundled payments table schema:

php artisan migrate

Already have your own payments table? Skip the migration publish and adjust the repository as needed.

Configuration

The published config/click-integration.php file mirrors the structure of the base PHP package, with first-class support for multiple services:

return [
    'provider' => [
        'endpoint' => env('CLICK_API_ENDPOINT', 'https://api.click.uz/v2/merchant/'),
        'default_service' => env('CLICK_DEFAULT_SERVICE', 'default'),
        'services' => [
            'default' => [
                'merchant_id' => env('CLICK_MERCHANT_ID'),
                'service_id'  => env('CLICK_SERVICE_ID'),
                'user_id'     => env('CLICK_USER_ID'),
                'secret_key'  => env('CLICK_SECRET_KEY'),
            ],
            // 'secondary' => [
            //     'merchant_id' => env('CLICK_SECONDARY_MERCHANT_ID'),
            //     'service_id'  => env('CLICK_SECONDARY_SERVICE_ID'),
            //     'user_id'     => env('CLICK_SECONDARY_USER_ID'),
            //     'secret_key'  => env('CLICK_SECONDARY_SECRET_KEY'),
            // ],
        ],
    ],
    'database' => [
        'connection' => env('CLICK_DB_CONNECTION'),
        'table'      => env('CLICK_PAYMENTS_TABLE', 'payments'),
    ],
    'session' => [
        'header' => env('CLICK_SESSION_AUTH_HEADER', 'Auth'),
    ],
];

Security tip: keep the credential values in environment variables / secret storage. Only the service keys themselves need to live in version control.

Quick Start

Resolve the payment service

use Click\Integration\Facades\ClickIntegration;

// Uses the default service defined in config
$payments = ClickIntegration::payments();

// Target a specific service/merchant pair
$secondary = ClickIntegration::payments(['service' => 'secondary']);

Shop API methods

// Prepare
$prepareResponse = $payments->prepare($request->all());

// Complete
$completeResponse = $payments->complete($request->all());

Merchant API methods

$payments->create_invoice([
    'token'        => 'uuid-token',
    'phone_number' => '998901234567',
]);

$payments->check_invoice([
    'token'      => 'uuid-token',
    'invoice_id' => 2222,
]);

$payments->create_card_token([
    'token'       => 'uuid-token',
    'card_number' => '4444-4444-4444-4444',
    'expire_date' => '0128',
    'temporary'   => 1,
]);

$payments->verify_card_token([
    'token'    => 'uuid-token',
    'sms_code' => '12345',
]);

$payments->payment_with_card_token([
    'token'      => 'uuid-token',
    'card_token' => 'CARDTOKEN',
]);

$payments->delete_card_token([
    'token'      => 'uuid-token',
    'card_token' => 'CARDTOKEN',
]);

$payments->check_payment([
    'token'      => 'uuid-token',
    'payment_id' => 1111,
]);

$payments->merchant_trans_id([
    'token'             => 'uuid-token',
    'merchant_trans_id' => 7777,
]);

$payments->cancel([
    'token'      => 'uuid-token',
    'payment_id' => 1111,
]);

All methods return associative arrays mirroring Click’s API responses. Exceptions surface as Click\Integration\Exceptions\ClickException using Click’s official error codes.

REST Application Helper

If you expose Click endpoints directly (like the original PHP library), you can use the application runner to dispatch the correct handler based on the request path:

use Click\Integration\Facades\ClickIntegration;
use Illuminate\Support\Facades\Route;

Route::any('/click/{any?}', function () {
    return response()->json(
        ClickIntegration::application()->run()
    );
})->where('any', '.*');

Need to switch to a different service profile?

return response()->json(
    ClickIntegration::application(['service' => 'secondary'])->run()
);

Session helper

Click\Integration\Application\Application::session() mirrors the original library’s token-based guard:

use Click\Integration\Application\Application;
use Click\Integration\Facades\ClickIntegration;

Application::session(env('CLICK_SESSION_TOKEN'), ['/prepare', '/complete'], function () {
    ClickIntegration::application()->run();
});

Requests for endpoints listed in the $access array bypass the session guard. All other routes must provide the header defined by click-integration.session.header (defaults to Auth).

Extending the Payments client

Create your own class extending Click\Integration\Services\Payments to customise any of the lifecycle hooks (they mirror the base PHP package):

use Click\Integration\Services\Payments as BasePayments;
use Psr\Http\Message\ResponseInterface;

class MyPayments extends BasePayments
{
    protected function on_invoice_creating(array $payload): ResponseInterface
    {
        // Inspect or modify payload before forwarding to Click
        return parent::on_invoice_creating($payload);
    }

    protected function on_invoice_created(array $request, ResponseInterface $response, string $token): ?array
    {
        $result = parent::on_invoice_created($request, $response, $token);

        // Add custom bookkeeping here...

        return $result;
    }
}

Bind your custom class in a service provider:

$this->app->bind(\Click\Integration\Services\Payments::class, MyPayments::class);

Testing

composer test

The package ships with Pest & PHPUnit support through Orchestra Testbench.

Roadmap & Ideas

  • Artisan commands to manage Click service credentials
  • Example HTTP controllers for webhook-style integrations
  • Demo application / Postman collection

Contributions and ideas are welcome—open an issue or submit a pull request!

Changelog

Please see CHANGELOG for a full list of updates.

Credits

License

The MIT License (MIT). Please see LICENSE for details.

anvarulugov/click-integration-laravel 适用场景与选型建议

anvarulugov/click-integration-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「payment」 「laravel」 「click」 「shop-api」 「anvarulugov」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 anvarulugov/click-integration-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 anvarulugov/click-integration-laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 anvarulugov/click-integration-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-30