abacatepay/php-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 abacatepay/php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.77k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 23
  • Watchers: 4
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-12-07