granada-pride/paytabs
Composer 安装命令:
composer require granada-pride/paytabs
包简介
This provide integration with the PayTabs payment gateway
README 文档
README
PayTabs Payment Gateway Integration for Laravel
Table of Contents
Description
PayTabs Payment Gateway Integration with Laravel Framework
Installation
You can install the package via composer:
composer require granada-pride/paytabs
Note: This package is compatible with Laravel 9 and higher. Ensure your application meets this requirement before installing.
Configuration
After installation, publish the configuration file using the following command:
php artisan vendor:publish --provider="GranadaPride\Paytabs\PaytabsServiceProvider"
The configuration file paytabs.php will be added to your config directory. Here is a sample configuration:
return [ 'profile_id' => env('PAYTABS_PROFILE_ID'), 'server_key' => env('PAYTABS_SERVER_KEY'), 'currency' => env('PAYTABS_CURRENCY'), 'region' => env('PAYTABS_REGION'), 'iframe_message_target' => env('PAYTABS_IFRAME_MESSAGE_TARGET'), ];
Configuration Options
- profile_id: Your PayTabs profile ID, required for API requests.
- server_key: Your PayTabs server key, used for authentication.
- currency: The currency code in which payments will be processed (e.g., USD).
- region: The region for your PayTabs account (e.g., ARE, SAU).
Usage
Create PayPage
Here’s how to create a payment page using this package:
use GranadaPride\Paytabs\Paytabs; use GranadaPride\Paytabs\DTO\CustomerDetails; $paytabs = Paytabs::make(); // Set Cart Information $paytabs->setCart('CART123', 150.00, 'Sample Cart Description'); // Set Customer Information using the CustomerDetails DTO $customerDetails = new CustomerDetails( name: 'John Doe', phone: '+123456789', email: 'johndoe@example.com', street: '123 Main St', city: 'Cityville', state: 'Stateland', country: 'US', zipCode: '12345' ); $paytabs->setCustomer($customerDetails); // Option 1: Use Customer Information for Shipping if it's the same $paytabs->useCustomerForShipping(); // Option 2: Set Shipping Information separately if it's different $shippingDetails = new CustomerDetails( name: 'Jane Doe', phone: '+987654321', email: 'janedoe@example.com', street: '456 Market St', city: 'Townsville', state: 'Regionland', country: 'US', zipCode: '54321' ); $paytabs->setShipping($shippingDetails); // Set URLs and Language $paytabs->setCallbackUrl('https://yourdomain.com/callback') ->setReturnUrl('https://yourdomain.com/return') ->setPaypageLang('en'); // To display IFrame $paytabs->displayIFrame(); // and you sholud update your .env with PAYTABS_IFRAME_MESSAGE_TARGET this A valid HTTPS website URL of your domain (the recipient) that will receive the event. In order for the event to be dispatched, this domain must match exactly (including scheme, hostname, and port). // Generate Payment Page $response = $paytabs->paypage(); // Handle the response dd($response);
Query Transaction
You can also query a transaction using its reference:
use GranadaPride\Paytabs\Paytabs; $response = Paytabs::make() ->queryTransaction('TST2422201903602'); dd($response);
Troubleshooting
Common Issues
- Invalid Credentials: Ensure that your profile_id and server_key in the configuration file are correct.
- Unsupported Region: Double-check that the region in your configuration file is valid and supported by PayTabs.
- Transaction Failure: Verify the transaction data (e.g., cart amount, customer details) to ensure it meets PayTabs' requirements.
If you encounter other issues, refer to the PayTabs API Documentation for more details.
Testing
Soon...
Contribution
Contributions are welcome! If you’d like to contribute to this package, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Write your code and ensure it is well-documented.
- Submit a pull request with a clear description of your changes.
License
This package is open-sourced software licensed under the MIT license.
granada-pride/paytabs 适用场景与选型建议
granada-pride/paytabs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.26k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 08 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 granada-pride/paytabs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 granada-pride/paytabs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-10