PHPackages                             chargebee/chargebee-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. chargebee/chargebee-php

ActiveLibrary[Payment Processing](/categories/payments)

chargebee/chargebee-php
=======================

ChargeBee API client implementation for PHP

v4.19.0(1mo ago)768.0M—5%67[9 issues](https://github.com/chargebee/chargebee-php/issues)[1 PRs](https://github.com/chargebee/chargebee-php/pulls)9MITPHPPHP &gt;=8.1.0CI passing

Since Jul 10Pushed 1mo ago37 watchersCompare

[ Source](https://github.com/chargebee/chargebee-php)[ Packagist](https://packagist.org/packages/chargebee/chargebee-php)[ Docs](https://github.com/chargebee/chargebee-php)[ RSS](/packages/chargebee-chargebee-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (237)Used By (9)

Chargebee PHP Client Library - API V2
=====================================

[](#chargebee-php-client-library---api-v2)

[![Packagist](https://camo.githubusercontent.com/f77f15584c4a0b4ad0f649d6777e5b582b5fa08cd16a94461e5bd793d5fd34c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368617267656265652f6368617267656265652d7068702e7376673f6d61784167653d33)](https://packagist.org/packages/chargebee/chargebee-php)[![Packagist](https://camo.githubusercontent.com/bcbd8e7fb7d917eb69a14947693843a96c5b73564d6af628d794219d97f65f6a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368617267656265652f6368617267656265652d7068702e7376673f6d61784167653d33)](https://packagist.org/packages/chargebee/chargebee-php/stats)[![Packagist](https://camo.githubusercontent.com/cebdd156ba11589a3db792aad01ecba421fc91d76cc9a4fec552ef8b91e44f39/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6368617267656265652f6368617267656265652d7068702e7376673f6d61784167653d33)](https://packagist.org/packages/chargebee/chargebee-php/stats)[![Packagist](https://camo.githubusercontent.com/d0b7c18fbab2c4334cf090e176e31ab5f8b18ace0d05d4f4c18379a5371c052f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6368617267656265652f6368617267656265652d7068702e7376673f6d61784167653d33)](https://packagist.org/packages/chargebee/chargebee-php)

Note

[![Join Discord](https://camo.githubusercontent.com/ed15441a7673cc5a79d517647e7f3250b96c0f1ca6abf2763742436c134169da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f72642d4561726c792532304163636573732d626c75653f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465)](https://discord.gg/S3SXDzXHAg)

We are trialing a Discord server for developers building with Chargebee. Limited spots are open on a first-come basis. Join [here](https://discord.gg/gpsNqnhDm2) if interested.

This is the official PHP library for integrating with Chargebee.

- 📘 For a complete reference of available APIs, check out our [API Documentation](https://apidocs.chargebee.com/docs/api/?lang=php).
- 🧪 To explore and test API capabilities interactively, head over to our [API Explorer](https://api-explorer.chargebee.com).

> Note: Chargebee now supports two API versions - [V1](https://apidocs.chargebee.com/docs/api/v1) and [V2](https://apidocs.chargebee.com/docs/api), 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](https://github.com/chargebee/chargebee-php/tree/chargebee-v1).

Requirements
------------

[](#requirements)

PHP 8.1 or later

Installation
------------

[](#installation)

### Composer

[](#composer)

`Chargebee` is available on [Packagist](https://packagist.org/packages/chargebee/chargebee-php) and can be installed using [Composer](https://getcomposer.org/)

```
composer require chargebee/chargebee-php
```

To use the bindings,

```
require_once('vendor/autoload.php');
```

Usage
-----

[](#usage)

### To create a new subscription:

[](#to-create-a-new-subscription)

```
use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{your_site}",
    "apiKey" => "{your_apiKey}",
]);

$result = $chargebee->subscription()->createWithItems("customer_id", [
    "subscription_items" => [
        [
            "item_price_id" => "Montly-Item",
            "quantity" => "3",
        ]
    ]
]);
$subscription = $result->subscription;
$customer = $result->customer;
```

### Create an idempotent request

[](#create-an-idempotent-request)

[Idempotency keys](https://apidocs.chargebee.com/docs/api/idempotency?prod_cat_ver=2) are passed along with request headers to allow a safe retry of POST requests.

```
use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{your_site}",
    "apiKey" => "{your_apiKey}",
]);
$responseCustomer = $chargebee->customer()->create([
    "first_name" => "John",
    "last_name" => "Doe",
    "email" => "john@test.com",
    "card" => [
        "first_name" => "Joe",
        "last_name" => "Doe",
        "number" => "4012888888881881",
        "expiry_month" => "10",
        "expiry_year" => "29",
        "cvv" => "231"
        ]
    ],
    [
        "chargebee-idempotency-key" => "" // Replace  with a unique string
    ]
);
$responseHeaders = $responseCustomer->getResponseHeaders(); // Retrieves response headers
print_r($responseHeaders);
$idempotencyReplayedValue = $responseCustomer->isIdempotencyReplayed(); // Retrieves Idempotency replayed header value
print_r($idempotencyReplayedValue);
```

`isIdempotencyReplayed()` method can be accessed to differentiate between original and replayed requests.

### Retry Handling

[](#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:

[](#key-features-include)

- **Automatic retries for specific HTTP status codes**: Retries are automatically triggered for status codes `500`, `502`, `503`, and `504`.
- **Exponential backoff**: Retry delays increase exponentially to prevent overwhelming the server.
- **Rate limit management**: If a `429 Too Many Requests` response is received with a `Retry-After` header, 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 `retryConfig` parameter in the environment configuration.

#### Example: Customizing Retry Logic

[](#example-customizing-retry-logic)

You can enable and configure the retry logic by passing a `retryConfig` object when initializing the Chargebee environment:

```
use Chargebee\ChargebeeClient;

// Retry Configurations
$retryConfig = new RetryConfig();
$retryConfig->setEnabled(true); // Enable retry mechanism
$retryConfig->setMaxRetries(5); // Maximum number of retries
$retryConfig->setDelayMs(1000); // Delay in milliseconds before retrying
$retryConfig->setRetryOn([500, 502, 503, 504]); // Retry on these HTTP status codes

$chargebee = new ChargebeeClient(options: [
    "site" => "{your_site}",
    "apiKey" => "{your_apiKey}",
    "retryConfig" => $retryConfig,
]);

// ... your Chargebee API operations below ...
```

#### Example: Rate Limit retry logic

[](#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:

```
use Chargebee\ChargebeeClient;

// Retry Configurations
$retryConfig = new RetryConfig();
$retryConfig->setEnabled(true); // Enable retry mechanism
$retryConfig->setMaxRetries(5); // Maximum number of retries
$retryConfig->setDelayMs(1000); // Delay in milliseconds before retrying
$retryConfig->setRetryOn([429]); // Retry on 429 HTTP status codes

$chargebee = new ChargebeeClient(options: [
    "site" => "{your_site}",
    "apiKey" => "{your_apiKey}",
    "retryConfig" => $retryConfig,
]);

// ... your Chargebee API operations below ...
```

License
-------

[](#license)

See the LICENSE file.

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance87

Actively maintained with recent releases

Popularity61

Solid adoption and visibility

Community39

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Total

229

Last Release

53d ago

Major Versions

v3.47.0 → v4.9.02025-09-03

v3.48.0 → 4.10.02025-09-23

v3.49.0 → v4.11.02025-10-28

v3.50.0 → v4.12.02025-11-26

v3.51.0 → v4.14.02026-01-12

PHP version history (2 changes)v3.0.0PHP &gt;=5.6.0

v4.0.0-beta.1PHP &gt;=8.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1d3bf9c89377cf8045bf8bebed3245072851037f809301361fe2c7d83c0af32?d=identicon)[chargebee](/maintainers/chargebee)

---

Top Contributors

[![rraman](https://avatars.githubusercontent.com/u/535773?v=4)](https://github.com/rraman "rraman (92 commits)")[![SangeethaBaskaran](https://avatars.githubusercontent.com/u/10059229?v=4)](https://github.com/SangeethaBaskaran "SangeethaBaskaran (87 commits)")[![cb-alish](https://avatars.githubusercontent.com/u/162097444?v=4)](https://github.com/cb-alish "cb-alish (45 commits)")[![cb-vaibhav](https://avatars.githubusercontent.com/u/1768604?v=4)](https://github.com/cb-vaibhav "cb-vaibhav (26 commits)")[![cb-thiyagu](https://avatars.githubusercontent.com/u/539363?v=4)](https://github.com/cb-thiyagu "cb-thiyagu (22 commits)")[![cb-khushbubibay](https://avatars.githubusercontent.com/u/90763103?v=4)](https://github.com/cb-khushbubibay "cb-khushbubibay (14 commits)")[![cb-goutham](https://avatars.githubusercontent.com/u/35914593?v=4)](https://github.com/cb-goutham "cb-goutham (12 commits)")[![cb-yateshmathuria](https://avatars.githubusercontent.com/u/85875129?v=4)](https://github.com/cb-yateshmathuria "cb-yateshmathuria (11 commits)")[![hellokps](https://avatars.githubusercontent.com/u/872557?v=4)](https://github.com/hellokps "hellokps (10 commits)")[![saravana-cb](https://avatars.githubusercontent.com/u/3005472?v=4)](https://github.com/saravana-cb "saravana-cb (9 commits)")[![cb-navaneedhan](https://avatars.githubusercontent.com/u/64066477?v=4)](https://github.com/cb-navaneedhan "cb-navaneedhan (7 commits)")[![cb-thushitamariaselvan](https://avatars.githubusercontent.com/u/126495463?v=4)](https://github.com/cb-thushitamariaselvan "cb-thushitamariaselvan (6 commits)")[![cb-nithins](https://avatars.githubusercontent.com/u/126080858?v=4)](https://github.com/cb-nithins "cb-nithins (5 commits)")[![cb-gaurav](https://avatars.githubusercontent.com/u/55385089?v=4)](https://github.com/cb-gaurav "cb-gaurav (4 commits)")[![cb-sriramthiagarajan](https://avatars.githubusercontent.com/u/78782731?v=4)](https://github.com/cb-sriramthiagarajan "cb-sriramthiagarajan (3 commits)")[![geoffreytran](https://avatars.githubusercontent.com/u/544500?v=4)](https://github.com/geoffreytran "geoffreytran (3 commits)")[![cb-bharathvaj](https://avatars.githubusercontent.com/u/44696641?v=4)](https://github.com/cb-bharathvaj "cb-bharathvaj (2 commits)")[![cb-karthikp](https://avatars.githubusercontent.com/u/78947874?v=4)](https://github.com/cb-karthikp "cb-karthikp (2 commits)")[![bjdelange](https://avatars.githubusercontent.com/u/2757512?v=4)](https://github.com/bjdelange "bjdelange (2 commits)")[![Wojciechem](https://avatars.githubusercontent.com/u/4303141?v=4)](https://github.com/Wojciechem "Wojciechem (1 commits)")

---

Tags

chargebeephppaymentschargebeesubscription billingrecurring billing

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/chargebee-chargebee-php/health.svg)

```
[![Health](https://phpackages.com/badges/chargebee-chargebee-php/health.svg)](https://phpackages.com/packages/chargebee-chargebee-php)
```

###  Alternatives

[unicodeveloper/laravel-paystack

A Laravel Package for Paystack

650975.6k11](/packages/unicodeveloper-laravel-paystack)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[mnastalski/przelewy24-php

Przelewy24 PHP library

52101.2k2](/packages/mnastalski-przelewy24-php)[invoiced/invoiced

Invoiced PHP Library

14117.1k](/packages/invoiced-invoiced)[prevailexcel/laravel-nowpayments

A Laravel Package for NOWPayments

1414.2k](/packages/prevailexcel-laravel-nowpayments)[itsmurumba/laravel-mpesa

Laravel Package for Mpesa Daraja API

191.6k](/packages/itsmurumba-laravel-mpesa)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
