承接 souidev/laravel-clictopay 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

souidev/laravel-clictopay

Composer 安装命令:

composer require souidev/laravel-clictopay

包简介

Laravel integration for ClicToPay payment gateway

README 文档

README

This package simplifies the integration of the ClicToPay payment gateway into your Laravel applications.

Installation

  1. Install the package via Composer:

    composer require Souidev/laravel-clictopay

Configuration

  1. Publish the configuration file:

    php artisan vendor:publish --provider="Souidev\ClicToPayLaravel\ClicToPayLaravelServiceProvider" --tag="config"
  2. Configure your ClicToPay credentials:

    • Edit the config/clictopay.php file. It's recommended to use environment variables for sensitive information:

      // config/clictopay.php
      return [
          'username' => env('CLICTOPAY_USERNAME'),
          'password' => env('CLICTOPAY_PASSWORD'),
          'test_mode' => env('CLICTOPAY_TEST_MODE', true),
          'return_url' => env('CLICTOPAY_RETURN_URL'),
          'fail_url' => env('CLICTOPAY_FAIL_URL'),
          'api_base_url' => env('CLICTOPAY_API_BASE_URL', '[https://test.clictopay.com/payment/rest/](https://test.clictopay.com/payment/rest/)'), // Default test URL
      ];
    • Set the corresponding environment variables in your .env file:

      CLICTOPAY_USERNAME=your_username
      CLICTOPAY_PASSWORD=your_password
      CLICTOPAY_TEST_MODE=true  # or false
      CLICTOPAY_RETURN_URL=https://your-site.com/payment/success
      CLICTOPAY_FAIL_URL=https://your-site.com/payment/fail
      

Usage

  1. Use the ClicToPay facade to interact with the ClicToPay API:

    use Souidev\ClicToPayLaravel\Facades\ClicToPay;
    
    try {
        // Register a payment with optional parameters
        $paymentDetails = ClicToPay::registerPayment([
            // Required parameters
            'orderNumber' => 'ORDER-12345',
            'amount' => 10000, // in cents
            'currency' => 788, // Currency code (788 for TND)
            
            // Optional parameters
            'language' => 'fr',           // fr, en, ar
            'pageView' => 'DESKTOP',      // DESKTOP or MOBILE
            'orderDescription' => 'Payment for order #12345',
            'expirationDate' => '2024-12-31T23:59:59', // ISO 8601
            'jsonParams' => json_encode([
                'email' => 'customer@example.com',  // Required if merchant notifications are enabled
                'orderNumber' => '1234567890',      // Your internal order reference
                // Add any additional parameters needed for bank processing
            ])
        ]);
    
        // Redirect user to ClicToPay payment page
        return redirect()->away($paymentDetails['formUrl']);
    
    } catch (\Exception $e) {
        return back()->with('error', $e->getMessage());
    }
  2. Check payment status:

    try {
        $status = ClicToPay::getPaymentStatus([
            'orderId' => 'ORDER-12345',
            'language' => 'fr' // Optional - for localized error messages
        ]);
        
        // Handle the response
        if ($status['ErrorCode'] === '0') { // No system error
            // Process the payment status
            $orderStatus = $status['OrderStatus'];
            // Possible values in $orderStatus:
            // - 0: Order registered but not paid
            // - 1: Order pre-authorized
            // - 2: Order paid
            // - 3: Authorization canceled
            // - 4: Transaction canceled
            // - 5: Authorization on hold
            // - 6: Refund
        }
    } catch (\Exception $e) {
        // Handle error
    }
  3. Get extended order status:

    try {
        $extendedStatus = ClicToPay::getExtendedOrderStatus([
            'orderId' => 'ORDER-12345',
            'language' => 'fr' // Optional - for localized error messages
        ]);
        
        // Handle extended status information
        if ($extendedStatus['ErrorCode'] === '0') {
            // Access additional payment information
            $orderStatus = $extendedStatus['orderStatus'];
            $amount = $extendedStatus['amount'];
            $currency = $extendedStatus['currency'];
            $date = $extendedStatus['date'];
            // ... other available fields
        }
    } catch (\Exception $e) {
        // Handle error
    }

The package automatically handles test/live mode based on your configuration:

  • Test mode: Set CLICTOPAY_TEST_MODE=true in your .env file (uses https://test.clictopay.com/payment/rest/)
  • Production mode: Set CLICTOPAY_TEST_MODE=false (uses https://clictopay.com/payment/rest/ or other provided URL)

Note: When customer notification is enabled for your merchant account, you must include the customer's email address in the jsonParams field as shown in the example above.

Available Methods

Refer to the ClicToPayService class for available methods. Here's a quick overview:

  • registerPayment(array $params): Registers a new payment.
  • registerPreAuth(array $params): Registers a pre-authorization.
  • confirmPayment(array $params): Confirms a pre-authorized payment.
  • cancelPayment(array $params): Cancels a payment.
  • refundPayment(array $params): Refunds a payment.
  • getPaymentStatus(array $params): Retrieves the status of a payment.

Contributing

Please see CONTRIBUTING.md for details.

License

MIT License

souidev/laravel-clictopay 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-22