Chargebee provides an HTTP-based API that follows the principles of REST. The HTTP rules followed allow simple HTTP clients like cURL to be used as well. The URLs are resource-oriented, the request format is form-encoded, and the responses are in JSON.
Depending on the type of operation, the endpoints use one of two HTTP methods:
GET
: Used for all read-only operations such as retrieving a resource or listing a group of resources.POST
: Used for all write operations. Such operations modify the state of a resource.A history of changes to the API is provided in the API Changelog.
Note
Sometimes, while working with Chargebee APIs, you may see undocumented attributes returned in the response. Such attributes should be ignored.
Some features in the API are part of the Early Access Program and are labeled "EAP," "Beta," or "Early Access." Please review the terms and conditions that apply to these features before using them.
Chargebee follows the REST model of exposing resources as urls. For example, subscriptions are exposed as
The PHP client library provide a corresponding class representation of the resource. For example, subscriptions are represented by
Subscription
All operations specific to that resource are exposed as class methods in the corresponding resource class. The methods accepts the input params as hash. You could also pass the environment configuration specific to that request as an additional parameter.
The response is in JSON format. Currently Chargebee does not support any other response format. The Result class wraps the response sent by the server. It has methods that allow you to fetch the specific resource from the result. The ListResult class is used to wrap list responses.
Note: Sometimes, while working with Chargebee APIs, you may see undocumented attributes returned in the response. Such attributes should be ignored.
require_once('vendor/autoload.php'); use ChargeBee\ChargeBee\Environment; use ChargeBee\ChargeBee\Models\Subscription; Environment::configure("{site}","{site_api_key}"); $result = Subscription::createWithItems("__test__8asz8Ru9WhHOJO",array( "subscriptionItems" => array(array( "itemPriceId" => "day-pass-USD", "unitPrice" => 100), array( "itemPriceId" => "basic-USD", "billingCycles" => 2, "quantity" => 1)) )); $subscription = $result->subscription(); $customer = $result->customer(); $card = $result->card(); $invoice = $result->invoice(); $unbilledCharges = $result->unbilledCharges();
require_once('vendor/autoload.php'); use ChargeBee\ChargeBee\Environment; use ChargeBee\ChargeBee\Models\Subscription; Environment::configure("{site}","{site_api_key}"); $result = Subscription::createWithItems("__test__8asz8Ru9WhHOJO",array( "subscriptionItems" => array(array( "itemPriceId" => "day-pass-USD", "unitPrice" => 100), array( "itemPriceId" => "basic-USD", "billingCycles" => 2, "quantity" => 1)) )); $subscription = $result->subscription(); $customer = $result->customer(); $card = $result->card(); $invoice = $result->invoice(); $unbilledCharges = $result->unbilledCharges();
Chargebee provides the following open-source client libraries as a wrapper around the HTTP API:
To view this API reference tailored to the programming language of your choice, select the language in the “Library” dropdown above. Reach out to us at Chargebee Support if you’d like to request any other language bindings.Note
Select the programming language of your choice from the “Library” dropdown at the top of the page.
composer require chargebee/chargebee-php
The source code for the client library is available as a public repository at github. The code is provided with MIT license. So in case you need any modifications please feel free to do so. If you think it would be useful for other users please do let us know.
Newer versions of client library are released whenever there are new additions to the API. The version
numbering format is major-version.minor-version(s). All
minor releases are backward compatible. Please check the
change notes
for more details.
The latest version details for API V2 are:
Version: 3.17.0
Released On: 2023-05-16