mcire/paytech
Composer 安装命令:
composer require mcire/paytech
包简介
Integration of PayTech payment gateway for Laravel
README 文档
README
This package provides an easy integration of the PayTech payment gateway into your Laravel applications.
Installation
🧿 Prerequisite
You have already created a controller for payments, an associated route and a view containing the product purchase form.
composer require guzzlehttp/guzzle
use App\Http\Controllers\PaymentController; Route::post('/checkout', [PaymentController::class, 'payment'])->name('payment.submit'); Route::get('ipn', [PaymentController::class, 'ipn'])->name('paytech-ipn'); Route::get('payment/success', [PaymentController::class, 'paymentSuccessView'])->name('payment.success.view'); Route::get('payment/cancel', [PaymentController::class, 'cancel'])->name('paytech.cancel');
⬇ Install now
composer require mcire/paytech
The package discovery is enabled by default in Laravel 5.5+. If you're using an earlier version, manually add the service provider and facade in config/app.php:
'providers' => [ // ... Mcire\PayTech\PayTechServiceProvider::class, ], 'aliases' => [ // ... 'PayTech' => Mcire\PayTech\Facades\PayTech::class, ],
Configuration
Publish the configuration file:
php artisan vendor:publish --tag=config
Add the following variables to your .env file:
PAYTECH_API_KEY=your_api_key PAYTECH_API_SECRET=your_api_secret PAYTECH_ENV=test # or 'prod' for production PAYTECH_IPN_URL=https://your-domain.com/ipn PAYTECH_SUCCESS_URL=https://your-domain.com/success PAYTECH_CANCEL_URL=https://your-domain.com/cancel
Tips for configuring PayTech's IPN locally
PayTech requires the callback route (IPN) to be accessible via HTTPS. This can pose a challenge during local development.
If you don't need to handle IPN calls :
simply configure the IPN URL as follows
PAYTECH_IPN_URL=https://127.0.0.1:8000/ipn
If you need to handle IPN calls locally:
Usage
Initiating a Payment (Put it inside your payment controller)
use Mcire\PayTech\Facades\PayTech; try { $response = PayTech::requestPayment([ 'item_name' => 'Product name', 'item_price' => 1000, // Price in cents 'currency' => 'XOF', 'ref_command' => Str::random(12), // Unique reference 'command_name' => 'Order description', ]); // Redirect to PayTech payment page return redirect($response['redirect_url']); } catch (\Exception $e) { // Error handling abort(500, $e->getMessage()); }
php artisan serve
Available Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| item_name | string | Product name | Yes |
| item_price | integer | Price in cents | Yes |
| currency | string | Currency (XOF, EUR, etc.) | Yes |
| ref_command | string | Unique order reference | Yes |
| command_name | string | Order description | Yes |
Handling Returns
The package automatically handles three types of returns:
-
IPN (Instant Payment Notification)
- URL configured in
PAYTECH_IPN_URL - Server-to-server notification from PayTech
- Used to update order status
- URL configured in
-
Success Page
- URL configured in
PAYTECH_SUCCESS_URL - Redirection after successful payment
- URL configured in
-
Cancel Page
- URL configured in
PAYTECH_CANCEL_URL - Redirection after payment cancellation
- URL configured in
Environments
The package supports two environments:
- test: For testing (default)
- prod: For production
Configure the environment via the PAYTECH_ENV variable in your .env file.
Security
- All requests are made over HTTPS
- API keys are securely stored in the
.envfile - Communications are authenticated via API_KEY and API_SECRET headers
Common Error Codes
| Code | Description | Solution |
|---|---|---|
| 400 | Invalid parameters | Check the sent parameters |
| 401 | Authentication failed | Verify your API keys |
| 500 | Server error | Contact PayTech support |
Support
For any questions or issues:
- Open an issue on GitHub
- Contact me at mamadoucirecamara99@gmail.com
License
This package is open-sourced software licensed under the MIT license. See the LICENSE file for more details. This package provides an easy integration of the PayTech payment gateway into your Laravel applications.
mcire/paytech 适用场景与选型建议
mcire/paytech 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mcire/paytech 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mcire/paytech 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-29