yacoubalhaidari/laravel-clickpay
Composer 安装命令:
composer require yacoubalhaidari/laravel-clickpay
包简介
Laravel package for ClickPay Transaction API
README 文档
README
A simple, all-in-one Laravel package for integrating with the ClickPay Transaction API (hosted, managed, own-form), 3D‑Secure redirect handling, follow‑up transactions (refund/void), transaction & token queries, and PayPage options (framed, hide_shipping).
Table of Contents
Requirements
- PHP 8.0+
- Laravel 8.x or newer
- A ClickPay Profile ID & Server Key
- Guzzle HTTP (automatically installed via Composer)
Installation
-
Require the package via Composer:
composer require yacoubalhaidari/laravel-clickpay
-
Publish the config file:
php artisan vendor:publish --provider="ClickPay\Providers\ClickPayServiceProvider" --tag=config -
(Optional) Add the Facade in
config/app.php:'aliases' => [ // ... 'ClickPay' => ClickPay\Facades\ClickPay::class, ],
Configuration
Edit config/clickpay.php:
return [ 'profile_id' => env('CLICKPAY_PROFILE_ID', 0), 'server_key' => env('CLICKPAY_SERVER_KEY', ''), 'base_url' => env('CLICKPAY_BASE_URL', 'https://secure.clickpay.com.sa'), 'return_url' => env('CLICKPAY_RETURN_URL', null), 'callback_url' => env('CLICKPAY_CALLBACK_URL', null), // المجموعات المسموحة 'classes' => ['ecom','moto','cont'], 'follow_up_types' => ['refund','void'], 'page_options' => ['framed','hide_shipping'], ];
Add to your .env:
CLICKPAY_PROFILE_ID=00000 CLICKPAY_SERVER_KEY=your_server_key_here CLICKPAY_RETURN_URL=https://yourdomain.com/payment/return CLICKPAY_CALLBACK_URL=https://yourdomain.com/payment/callback
Usage
Inject ClickPay\ClickPayService into your controller, or use the ClickPay facade.
Basic Hosted Payment
use ClickPay\Facades\ClickPay; $result = ClickPay::transaction([ 'tran_type' => 'sale', 'tran_class' => 'ecom', 'cart_id' => (string) Str::uuid(), 'cart_description' => 'Order #1234', 'cart_currency' => 'AED', 'cart_amount' => 100.00, ], [ 'framed' => true, 'hide_shipping' => true, ]);
Managed‑Form / Token Payment
$result = ClickPay::transaction([ 'tran_type' => 'sale', 'tran_class' => 'ecom', 'cart_id' => 'ORDER-789', 'cart_description' => 'Monthly Subscription', 'cart_currency' => 'AED', 'cart_amount' => 50.00, 'payment_token' => $jsToken, ]);
Own‑Form / Card‑Details Payment
$result = ClickPay::transaction([ 'tran_type' => 'sale', 'tran_class' => 'ecom', 'cart_id' => 'EVENT-001', 'cart_description' => 'Concert Ticket', 'cart_currency' => 'AED', 'cart_amount' => 75.50, 'card_details' => [ 'pan' => '4111111111111111', 'expiry_month' => 12, 'expiry_year' => 25, 'cvv' => '123', ], ]);
Including Customer Details
You can include customer_details in two ways:
-
Auto‑build defaults by setting:
'include_customer_details' => true, -
Provide specific fields:
'name' => 'John Smith', 'email' => 'jsmith@example.com', 'phone' => '971111111111', 'street1' => '404, 11th St', 'city' => 'Dubai', 'state' => 'DU', 'country' => 'AE', 'zip' => '00000', 'ip' => request()->ip(),
The package will automatically collect these into a customer_details object, filling any missing values with defaults.
3D‑Secure Redirect Handling
public function paymentReturn(Request $req) { try { $data = ClickPay::handleReturn($req->all()); // contains: tranRef, respStatus, respCode, token, customerEmail, etc. } catch (Exception $e) { // handle invalid/missing signature } }
Query Transaction
$status = ClickPay::query($tranRef);
Follow‑Up (Refund / Void)
$refund = ClickPay::followUp('refund', $tranRef, 25.00);
Token Operations
$info = ClickPay::tokenQuery($token); $delete = ClickPay::deleteToken($token);
Error Handling
Throws ClickPay\Exceptions\ClickPayException with Arabic messages:
- الحقل "X" مطلوب
- نوع الصف "X" غير صالح
- خيار الصفحة "X" غير مدعوم
- توقيع إعادة التوجيه غير صالح
PayPage Options
framed→ عرض الصفحة داخل iFramehide_shipping→ إخفاء تفاصيل الشحن من PayPage
Enjoy seamless ClickPay integration in your Laravel app! Feel free to open issues or contribute.
yacoubalhaidari/laravel-clickpay 适用场景与选型建议
yacoubalhaidari/laravel-clickpay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「laravel」 「ClickPay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 yacoubalhaidari/laravel-clickpay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yacoubalhaidari/laravel-clickpay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 yacoubalhaidari/laravel-clickpay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Official laravel package to implement ClickPay integration with laravel apps
Alfabank REST API integration
Laravel package for Accurate Online API integration.
TrinkPOS Sanal POS (Virtual POS) API client for PHP
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-01