This is the source code for the .NET client library for Chargebee APIs. The latest version (v3) of the library supports the following:
- .NET Standard 1.2+
- .NET Core 1.0+
- .NET Framework 4.5+
The versioning scheme of this library is inspired by SemVer and the format is v{MAJOR}.{MINOR}.{PATCH}
. For example, v3.0.0
and v2.5.1
are valid library versions.
The following table provides some details for each major version:
Library major version | Status | Compatible API versions | Branch |
---|---|---|---|
v3 | Active | v2 and v1 | master |
v2 | Inactive | v2 and v1 | chargebee-v2 |
v1 | Inactive | v1 | chargebee-v1 |
A couple of terms used in the above table are explained below:
- Status: The current development status for the library version. An Active major version is currently being maintained and continues to get backward-compatible changes. Inactive versions no longer receive any updates.
- Branch: The branch in this repository containing the source code for the latest release of the library version. Every version of the library has been tagged. You can check out the source code for any version using its tag.
🔴 Attention: The support for v2 will eventually be discontinued on December 31st 2023 and will no longer receive any further updates. We strongly recommend upgrading to v3 as soon as possible. Note: See the changelog for a history of changes.
You can install any release of an active library version using NuGet—a package manager for Visual Studio—by running the following command in the NuGet Package Manager Console:
$ Install-Package ChargeBee -Version {MAJOR}.{MINOR}.{PATCH}
For example, the following commands are valid:
- Install the latest version:
$ Install-Package ChargeBee -Version 3.0.0
- Install an earlier version, say v2.5.1:
$ Install-Package ChargeBee -Version 2.5.1
Some examples for using the library are listed below.
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("site","api_key");
EntityResult result = Subscription.Create()
.PlanId("basic")
.Request();
Subscription subscription = result.Subscription;
Customer customer = result.Customer;
Idempotency keys are passed along with request headers to allow a safe retry of POST requests.
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("site","api_key");
EntityResult result = Customer.Create()
.FirstName("John")
.LastName("Doe")
.Email("[email protected]")
.SetIdempotencyKey("<<UUID>>") // Replace <<UUID>> with a unique string
.Request();
Customer customer = result.Customer;
Console.WriteLine(ApiConfig.SerializeObject(customer));
HttpResponseHeaders httpResponseHeaders = result.ResponseHeaders; // Retrieves response headers
Console.WriteLine(httpResponseHeaders);
string idempotencyReplayedValue = result.IsIdempotencyReplayed(); // Retrieves idempotency replayed header value
Console.WriteLine(idempotencyReplayedValue);
isIdempotencyReplayed()
method can be accessed to differentiate between original and replayed requests.
ApiConfig.SerializeObject(obj);
ApiConfig.DeserializeObject<T>(jsonString);
You may contribute patches to any of the Active versions of this library. To do so, raise a PR against the respective branch.
If you find something amiss, you are welcome to create an issue.
The API documentation for the .NET library can be found in our API reference.
See the LICENSE.