SDKs overview
Chargebee offers a suite of Software Development Kits (SDKs) designed to facilitate integration with its subscription management and recurring billing platform. These SDKs wrap the underlying Chargebee RESTful API, providing language-specific interfaces and helper functions to simplify common tasks such as creating and managing customers, subscriptions, invoices, and payments. By abstracting the complexities of direct HTTP requests, authentication, and response parsing, Chargebee SDKs aim to reduce development time and effort.
The SDKs are maintained by Chargebee and are available for several popular programming languages. They generally follow idiomatic patterns for each language, enabling developers to integrate Chargebee functionalities using familiar syntax and structures. This approach allows developers to focus on their application's business logic rather than the intricacies of API communication. Additionally, the SDKs often include features like request validation, error handling, and object serialization/deserialization, further enhancing the developer experience.
Official SDKs by language
Chargebee provides official SDKs for a range of programming languages, ensuring broad compatibility for different development environments. Each SDK is designed to offer a consistent way to interact with the Chargebee API, adhering to the best practices of its respective language ecosystem. Detailed documentation and usage examples for each SDK are available on the Chargebee documentation portal.
| Language | Package/Module | Installation Command | Maturity/Status |
|---|---|---|---|
| Java | com.chargebee:chargebee-java |
Maven: <dependency><groupId>com.chargebee</groupId><artifactId>chargebee-java</artifactId><version>[latest_version]</version></dependency>Gradle: implementation 'com.chargebee:chargebee-java:[latest_version]' |
Actively Maintained |
| Python | chargebee |
pip install chargebee |
Actively Maintained |
| Ruby | chargebee |
gem install chargebee |
Actively Maintained |
| PHP | chargebee/chargebee |
composer require chargebee/chargebee |
Actively Maintained |
| Node.js | chargebee |
npm install chargebee |
Actively Maintained |
| .NET | ChargeBee.Api |
dotnet add package ChargeBee.Api |
Actively Maintained |
Installation
Installing Chargebee SDKs typically involves using the standard package manager for the respective programming language. Each SDK is distributed through its ecosystem's primary repository, ensuring ease of access and version management. Before installation, developers should ensure they have the correct runtime environment and package manager configured. For specific version requirements and detailed setup instructions, refer to the official Chargebee SDK documentation.
Java
For Java projects, the Chargebee SDK is available via Maven Central and can be included in your project's pom.xml (for Maven) or build.gradle (for Gradle).
<!-- Maven -->
<dependency>
<groupId>com.chargebee</groupId>
<artifactId>chargebee-java</artifactId>
<version>[latest_version]</version>
</dependency>
// Gradle
implementation 'com.chargebee:chargebee-java:[latest_version]'
Python
The Python SDK is distributed via PyPI and can be installed using pip:
pip install chargebee
Ruby
The Ruby SDK is available as a gem and can be installed using gem install or by adding it to your Gemfile:
gem install chargebee
# Gemfile
gem 'chargebee'
PHP
The PHP SDK is managed with Composer:
composer require chargebee/chargebee
Node.js
The Node.js SDK is available on npm:
npm install chargebee
.NET
The .NET SDK is distributed as a NuGet package:
dotnet add package ChargeBee.Api
Quickstart example
This quickstart example demonstrates how to configure the Chargebee Python SDK and retrieve a list of customers. The principles of initialization and making API calls are similar across other SDKs, though the syntax will vary according to the language.
First, ensure you have your Chargebee site name and API key. These credentials are required to authenticate your requests. You can find these in your Chargebee dashboard under Settings > Configure Chargebee > API Keys. For security, it is recommended to manage API keys securely, such as through environment variables, rather than hardcoding them directly into your application.
import chargebee
# Configure Chargebee with your site name and API key
chargebee.configure(
site='your_chargebee_site_name',
api_key='your_chargebee_api_key'
)
try:
# Retrieve a list of customers
# The list method returns a 'ListResult' object
result = chargebee.Customer.list({
'limit': 5 # Optional: retrieve up to 5 customers
})
print("Successfully retrieved customers:")
for customer_entry in result:
customer = customer_entry.customer
print(f" Customer ID: {customer.id}, Email: {customer.email}")
except chargebee.APIError as e:
print(f"Chargebee API Error: {e.message}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
This example initializes the Chargebee client with credentials and then calls the Customer.list() method to fetch customer records. The result is an iterable object, allowing you to access individual customer objects and their properties. Error handling is included to catch potential issues during API communication, such as network problems or authentication failures, consistent with Chargebee's API error handling documentation.
Community libraries
While Chargebee maintains official SDKs for core languages, the open-source community may also develop and maintain additional libraries or integrations. These community-driven projects can offer specialized functionalities, integrations with specific frameworks, or support for languages not officially covered by Chargebee. Developers contributing to or using community libraries should be aware that these projects may have varying levels of support, documentation, and maintenance compared to official SDKs.
Before adopting a community library, it is advisable to evaluate its active maintenance, community engagement, and compatibility with the latest Chargebee API versions. Resources like GitHub and relevant developer forums are good places to discover and assess such contributions. For example, developers leveraging a RESTful API often consult Mozilla's Web Docs on REST to ensure community libraries adhere to standard architectural principles.
Currently, the primary and recommended method for integrating with Chargebee involves using the officially provided SDKs due to their direct support and alignment with the platform's development roadmap. Any community contributions would typically be found in public repositories or developer communities rather than through a centralized Chargebee-maintained list.