abacatepay/php-sdk
Composer 安装命令:
composer require abacatepay/php-sdk
包简介
A robust PHP SDK for integrating AbacatePay payment solutions into your applications.
README 文档
README
A robust PHP SDK for integrating AbacatePay payment solutions into your applications.
📋 Requirements
- PHP 7.2.5 or higher
- Composer
- Valid AbacatePay account and API credentials
- SSL enabled for production environments
💻 Installation
Install the SDK via Composer:
composer require abacatepay/php-sdk
🔧 Configuration
First, initialize the SDK with your API token:
use AbacatePay\Clients\Client; Client::setToken($_ENV["ABACATEPAY_TOKEN"]);
⚠️ Never commit your API tokens to version control. Use environment variables instead.
🌟 Features
- Simple billing management
- Customer management
- Multiple payment methods support
- Webhook handling
- Secure payment processing
- Error handling and logging
📘 Usage Examples
Billing Management
Initialize the Billing Client
use AbacatePay\Clients\BillingClient; $billingClient = new BillingClient();
List All Billings
$billings = $billingClient->list();
Create a New Billing
use AbacatePay\Resources\Billing; use AbacatePay\Resources\Billing\Product; use AbacatePay\Resources\Billing\Metadata as BillingMetadata; use AbacatePay\Enums\Billing\Methods; use AbacatePay\Enums\Billing\Frequencies; use AbacatePay\Resources\Customer; use AbacatePay\Resources\Customer\Metadata as CustomerMetadata; $billing = $billingClient->create(new Billing([ 'frequency' => Frequencies::ONE_TIME, 'methods' => [Methods::PIX], 'products' => [ new Product([ 'external_id' => 'abc_123', 'name' => 'Product A', 'description' => 'Description of product A', 'quantity' => 1, 'price' => 100 // Price in cents ]) ], 'metadata' => new BillingMetadata([ 'return_url' => 'https://www.abacatepay.com', 'completion_url' => 'https://www.abacatepay.com' ]), 'customer' => new Customer([ 'metadata' => new CustomerMetadata([ 'name' => 'John Doe', 'cellphone' => '01912341234', 'email' => 'john@example.com', 'tax_id' => '13827826837' ]) ]) ]));
It is also possible to use the ID of an existing customer:
// ... 'customer' => new Customer([ 'id' => 'abc_123' ]) // ...
Customer Management
Initialize the Customer Client
use AbacatePay\Clients\CustomerClient; use AbacatePay\Resources\Customer; $customerClient = new CustomerClient();
List All Customers
$customers = $customerClient->list();
Create a New Customer
use AbacatePay\Resources\Customer; use AbacatePay\Resources\Customer\Metadata; $customer = $customerClient->create(new Customer([ 'metadata' => new Metadata([ 'name' => 'John Doe', 'cellphone' => '01912341234', 'email' => 'john@example.com', 'tax_id' => '13827826837' ]) ]));
⚡ Quick Tips
- Use environment variables for API tokens
- Enable error reporting in development
- Always validate customer input
- Handle exceptions appropriately
- Keep the SDK updated
🔍 Error Handling
use AbacatePay\Exceptions\ApiException; try { $billing = $billingClient->create($billingData); } catch (ApiException $e) { // Handle API-specific errors echo $e->getMessage(); } catch (\Exception $e) { // Handle general errors echo $e->getMessage(); }
📚 Documentation
For detailed API documentation and integration guides:
- API Reference
- Integration Guide
- API Status
🛠️ Development
Installing packages
composer install --dev
Running Tests
composer test
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch (git checkout -b feature/amazing-feature)
- Commit your changes (git commit -m 'Add amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a Pull Request
🔒 Security
For security issues, please see our Security Policy.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
💬 Support
- For SDK issues, open an issue
- For API questions, contact ajuda@abacatepay.com
- For urgent issues, contact our support team
Made with ❤️ by AbacatePay Community
abacatepay/php-sdk 适用场景与选型建议
abacatepay/php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.77k 次下载、GitHub Stars 达 23, 最近一次更新时间为 2024 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 abacatepay/php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 abacatepay/php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.77k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-12-07