paytabs/php-sdk
Composer 安装命令:
composer require paytabs/php-sdk
包简介
Official PayTabs PHP SDK for Payment Gateway integrations
README 文档
README
Official PHP SDK for integrating with PayTabs Payment Gateway.
Requirements
- PHP
^8.4 - cURL extension enabled
Install
composer require paytabs/php-sdk:^3.0
Quick Start
<?php use Paytabs\Sdk\Http\Http; use Paytabs\Sdk\Paytabs; use Paytabs\Sdk\Profile\ProfilesFactory; use Paytabs\Sdk\Request\Payload\PayloadsFactory; use Paytabs\Sdk\Request\RequestsFactory; use Paytabs\Sdk\Enums\TranClass; use Paytabs\Sdk\Enums\TranType; $profile = ProfilesFactory::createUaeProfile( (int) getenv('PAYTABS_PROFILE_ID'), (string) getenv('PAYTABS_SERVER_KEY') ); $payload = PayloadsFactory::hostedPage(); $payload ->buildTransaction(TranType::Sale, TranClass::Ecom) ->buildCart('order-1001', 'AED', 100.00, 'Order 1001') ->buildHideShipping(true); $request = RequestsFactory::paymentRequest($profile, $payload); $http = (new Http()) ->setLogger(Paytabs::getLogger()) ->setRequest($request); try { $response = $http->submit(); } catch (\Paytabs\Sdk\Exceptions\HttpRequestException $e) { // Transport failure or non-2xx response. throw $e; } if ($response->isFailure()) { $failure = $response->getFailure(); echo $failure->code.' - '.$failure->message; exit; } if ($response->isRedirect()) { $redirect = $response->getRedirect(); header('Location: '.$redirect->redirect_url); exit; }
Security Notes
- Do not log card data, CVV, full tokens, or full webhook signatures.
- Store credentials in environment variables, not in repository files.
- Always verify webhook signatures and reject invalid requests.
See webhook verification guide: docs/usage/Webhooks.md
Logging Configuration
The SDK logger can be configured with environment variables:
PAYTABS_LOG_PATH: Directory where SDK log files are stored.- Default:
/var/log/paytabs-sdk/ - Fallback: system temporary directory when the configured/default path is empty.
- Default:
PAYTABS_LOG_BROWSER: Enables browser logger mode when set totrue.- Default behavior uses file logger mode.
Example:
export PAYTABS_LOG_PATH="/var/log/paytabs-sdk" export PAYTABS_LOG_BROWSER="false"
Documentation
- Architecture: ARCHITECTURE.md
- Diagrams: docs/diagrams
- Payment Request guide: docs/usage/PaymentRequest.md
- Invoices guide: docs/usage/Invoices.md
- Webhooks guide: docs/usage/Webhooks.md
- Samples: Samples
Project Governance
- License: LICENSE
- Security policy: SECURITY.md
- Contribution guide: CONTRIBUTING.md
- Changelog: CHANGELOG.md
- Release checklist: docs/release-checklist.md
- Support policy: SUPPORT.md
Samples Setup
- Copy
Samples/.env.sampletoSamples/.env. - Replace placeholder values with sandbox credentials.
- Run samples locally and expose callback URL when needed.
Development Commands
composer lint
composer test
Live gateway tests are opt-in only:
PAYTABS_RUN_LIVE_TESTS=1 composer test
Versioning
This SDK follows semantic versioning. Breaking changes are introduced only in major versions.
Support
For integration support, use PayTabs official support channels. For security vulnerabilities, report via the PayTabs Bug Bounty Program and follow SECURITY.md. Public issues are intended for reproducible SDK bugs and enhancement requests.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2026-06-24