harbdhulquadri/smart-routing
Composer 安装命令:
composer require harbdhulquadri/smart-routing
包简介
A smart payment routing system for Laravel applications
README 文档
README
Smart Payment Router is a Laravel package that provides intelligent payment routing capabilities for your application. It dynamically selects the best payment processor for each transaction based on factors such as transaction cost, reliability, and currency support.
Features
- Dynamic routing logic to select the best payment processor for each transaction
- Configurable routing rules
- Easy management of payment processors (add, update, remove)
- Adapter pattern for easy integration of new payment processors
- Logging and monitoring mechanisms
- Robust error handling
- Secure handling of sensitive payment information
- Compatible with Laravel 10.x
- Comprehensive test suite
Installation
You can install the package via composer:
composer require harbdhulquadri/smart-routing:dev-master
Configuration
After installation, publish the configuration file:
php artisan vendor:publish --provider="Codehunter\SmartPaymentRouter\SmartPaymentRouterServiceProvider" --tag="config"
This will create a config/smart_payment_router.php file. You can modify this file to add or configure payment processors.
Usage
To use the Smart Payment Router in your application:
use Codehunter\SmartPaymentRouter\PaymentRouter; class PaymentController extends Controller { protected $paymentRouter; public function __construct(PaymentRouter $paymentRouter) { $this->paymentRouter = $paymentRouter; } public function processPayment(Request $request) { $transaction = [ 'amount' => $request->input('amount'), 'currency' => $request->input('currency'), ]; try { $processor = $this->paymentRouter->route($transaction); $result = $processor->process($transaction); if ($result) { return response()->json(['message' => 'Payment processed successfully']); } else { return response()->json(['error' => 'Payment processing failed'], 400); } } catch (PaymentProcessorNotFoundException $e) { return response()->json(['error' => $e->getMessage()], 400); } } }
Adding a New Payment Processor
To add a new payment processor:
- Create a new adapter class that extends
PaymentProcessorAdapter. - Implement the required methods in your adapter class.
- Add the new processor to your configuration file.
Example of adding a new processor in the configuration:
'new_processor' => [ 'name' => 'New Processor', 'adapter' => \App\PaymentProcessors\NewProcessorAdapter::class, 'supported_currencies' => ['USD', 'EUR'], 'min_amount' => 1, 'max_amount' => 10000, 'base_fee' => 0.30, 'percentage_fee' => 0.025, 'reliability_score' => 0.97, ],
Security
The Smart Payment Router package follows security best practices for handling sensitive payment information. However, it's crucial to ensure that your entire application adheres to PCI DSS standards when dealing with payment data.
Testing
To run the package tests:
vendor/bin/phpunit
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
The Smart Payment Router package is open-sourced software licensed under the MIT license.
harbdhulquadri/smart-routing 适用场景与选型建议
harbdhulquadri/smart-routing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 10 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 harbdhulquadri/smart-routing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 harbdhulquadri/smart-routing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-21