A robust PHP SDK for integrating AbacatePay payment solutions into your applications.
- PHP 7.2.5 or higher
- Composer
- Valid AbacatePay account and API credentials
- SSL enabled for production environments
Install the SDK via Composer:
composer require abacatepay/php-sdkFirst, 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.
- Simple billing management
- Customer management
- Multiple payment methods support
- Webhook handling
- Secure payment processing
- Error handling and logging
Initialize the Billing Client
use AbacatePay\Clients\BillingClient;
$billingClient = new BillingClient();$billings = $billingClient->list();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'
])
// ...Initialize the Customer Client
use AbacatePay\Clients\CustomerClient;
use AbacatePay\Resources\Customer;
$customerClient = new CustomerClient();$customers = $customerClient->list();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'
])
]));- Use environment variables for API tokens
- Enable error reporting in development
- Always validate customer input
- Handle exceptions appropriately
- Keep the SDK updated
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();
}For detailed API documentation and integration guides:
- API Reference
- Integration Guide
- API Status
composer install --dev
composer testWe 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
For security issues, please see our Security Policy.
This project is licensed under the MIT License - see the LICENSE file for details.
- 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