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
-
Install the package via Composer:
composer require Souidev/laravel-clictopay
Configuration
-
Publish the configuration file:
php artisan vendor:publish --provider="Souidev\ClicToPayLaravel\ClicToPayLaravelServiceProvider" --tag="config"
-
Configure your ClicToPay credentials:
-
Edit the
config/clictopay.phpfile. 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
.envfile: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
-
Use the
ClicToPayfacade 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()); }
-
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 }
-
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=truein your.envfile (useshttps://test.clictopay.com/payment/rest/) - Production mode: Set
CLICTOPAY_TEST_MODE=false(useshttps://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
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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 souidev/laravel-clictopay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
Client library to send SMS using Comilio SMS Gateway API (https://www.comilio.it)
Alfabank REST API integration
GovPayNet driver for the Omnipay payment processing library
BlueSnap driver for the Omnipay payment processing library
统计信息
- 总下载量: 35
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-22