Download the PHP package chargebee/chargebee-php without Composer
On this page you can find all versions of the php package chargebee/chargebee-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chargebee/chargebee-php
More information about chargebee/chargebee-php
Files in chargebee/chargebee-php
Package chargebee-php
Short Description ChargeBee API client implementation for PHP
License MIT
Homepage https://github.com/chargebee/chargebee-php
Informations about the package chargebee-php
Chargebee PHP Client Library - API V2
We are trialing a Discord server for developers building with Chargebee. Limited spots are open on a first-come basis. Join here if interested.
This is the official PHP library for integrating with Chargebee.
- π For a complete reference of available APIs, check out our API Documentation.
- π§ͺ To explore and test API capabilities interactively, head over to our API Explorer.
Note: Chargebee now supports two API versions - V1 and V2, of which V2 is the latest release and all future developments will happen in V2. This library is for API version V2. If youβre looking for V1, head to chargebee-v1 branch.
Requirements
PHP 8.1 or later
Installation
Composer
is available on Packagist and can be installed using Composer
composer require chargebee/chargebee-php
To use the bindings,
require_once('vendor/autoload.php');
Usage
To create a new subscription:
Create an idempotent request
Idempotency keys are passed along with request headers to allow a safe retry of POST requests.
isIdempotencyReplayed() method can be accessed to differentiate between original and replayed requests.
Retry Handling
Chargebee's SDK includes built-in retry logic to handle temporary network issues and server-side errors. This feature is disabled by default but can be enabled when needed.
Key features include:
- Automatic retries for specific HTTP status codes: Retries are automatically triggered for status codes
500,502,503, and504. - Exponential backoff: Retry delays increase exponentially to prevent overwhelming the server.
- Rate limit management: If a
429 Too Many Requestsresponse is received with aRetry-Afterheader, the SDK waits for the specified duration before retrying.Note: Exponential backoff and max retries do not apply in this case.
- Customizable retry behavior: Retry logic can be configured using the
retryConfigparameter in the environment configuration.
Example: Customizing Retry Logic
You can enable and configure the retry logic by passing a retryConfig object when initializing the Chargebee environment:
Example: Rate Limit retry logic
You can enable and configure the retry logic for rate-limit by passing a retryConfig object when initializing the Chargebee environment:
Telemetry (OpenTelemetry)
Optional. Pass a telemetryAdapter when you want Chargebee API calls traced in your observability stack (Datadog, Splunk, Honeycomb, Jaeger, etc.). OpenTelemetry is not bundled with chargebee/chargebee-php β install and configure it in your app, implement TelemetryAdapter, and wire it on the client.
The SDK builds standardized span attributes (startAttributes, endAttributes) following the stable OpenTelemetry HTTP semantic conventions (url.full, http.request.method, http.response.status_code, server.address, error.type) plus Chargebee-specific chargebee.* attributes β use them as-is so spans render correctly in your APM and stay consistent across SDKs.
Note:
url.fullintentionally omits the query string (it carries only scheme, host, and path) to avoid leaking potentially sensitive query parameters into traces. This is a deliberate, cross-SDK PII-safety choice.
Spans are named chargebee.{resource}.{operation} (e.g. chargebee.subscription.create).
When no adapter is configured, the SDK skips all telemetry work β zero overhead for existing integrations.
Trace shape
The SDK emits one CLIENT span per API call, covering the full lifecycle. Retries reuse the same span β onRequestStart runs once before the retry loop and onRequestEnd runs once after the final outcome.
If you separately enable HTTP auto-instrumentation (e.g. an OpenTelemetry PHP agent on Guzzle), it will create an additional transport-level HTTP span as a sibling of the Chargebee span. For the cleanest trace where
chargebee.{resource}.{operation}is the single propagating span, leave HTTP auto-instrumentation off for Chargebee calls.
OpenTelemetry setup
OpenTelemetry is not bundled β install it in your app:
Configure OpenTelemetry at app startup (tracer provider, exporter, propagator), then pass your adapter:
RequestTelemetryResult also exposes durationMs if you want to record request duration on the span (e.g. $span->setAttribute('chargebee.request.duration_ms', $result->durationMs)).
To add custom span attributes (tenant ID, correlation ID, etc.), set them in your adapter's onRequestStart / onRequestEnd β use your own namespace (e.g. app.tenant_id), not chargebee.*.
Spans are exported by your own OpenTelemetry setup, so they flow to whatever backend you've configured. The Chargebee config above stays the same regardless of backend.
License
See the LICENSE file.
All versions of chargebee-php with dependencies
guzzlehttp/guzzle Version >=7
php-http/discovery Version ^1.0
psr/http-client Version ^1.0
psr/http-factory Version ^1.0