chargebee 3.3.0
pip install chargebee
Released:
Python wrapper for the Chargebee Subscription Billing API
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- Author: Chargebee
- Requires: Python >=3.11
Project description
Chargebee Python Client Library v3
This is the official Python 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.
If you're upgrading from an older version please refer to the Migration Guide
Requirements
- Python 3.11+
Installation
Install the latest version of the library with pip:
pip install chargebee
Install from source with:
python setup.py install
Documentation
See our Python API Reference.
Usage
The package needs to be configured with your site's API key, which is available under Configure Chargebee Section. Refer here for more details.
Configuring chargebee client
from chargebee import Chargebee
cb_client = Chargebee(api_key="", site="")
Configuring Timeouts
from chargebee import Chargebee
cb_client = Chargebee(api_key="api_key", site="site")
cb_client.update_read_timeout_secs(3000)
cb_client.update_connect_timeout_secs(5000)
Configuring Retry Delays
from chargebee import Chargebee
cb_client = Chargebee(api_key="api_key", site="site")
cb_client.update_export_retry_delay_ms(3000)
cb_client.update_time_travel_retry_delay_ms(5000)
Making API Request:
# Create a Customer
response = cb_client.Customer.create(
cb_client.Customer.CreateParams(
first_name="John",
last_name="Doe",
email="john@test.com",
locale="fr-CA",
billing_address=cb_client.Customer.BillingAddress(
first_name="John",
last_name=" Doe",
line1="PO Box 9999",
city="Walnut",
state="California",
zip="91789",
country="US",
),
)
)
customer = response.customer
card = response.card
List API Request With Filter
For pagination, offset
is the parameter that is being used. The value used for this parameter must be the value returned in next_offset
parameter from the previous API call.
from chargebee import Filters
response = cb_client.Customer.list(
cb_client.Customer.ListParams(
first_name=Filters.StringFilter(IS="John")
)
)
offset = response.next_offset
print(offset)
Using enums
There are two variants of enums in chargebee,
- Global enums - These are defined globally and can be accessed across resources.
- Resource specific enums - These are defined within a resource and can be accessed using the resource class name.
# Global Enum
import chargebee
response = cb_client.Customer.create(
cb_client.Customer.CreateParams(
first_name="John",
auto_collection=chargebee.AutoCollection.ON, # global enum
)
)
print(response.customer)
# Resource Specific Enum
response = cb_client.Customer.change_billing_date(
cb_client.Customer.ChangeBillingDateParams(
first_name="John",
billing_day_of_week=cb_client.Customer.BillingDayOfWeek.MONDAY, # resource specific enum
)
)
print(response.customer)
Using custom fields
response = cb_client.Customer.create(
cb_client.Customer.CreateParams(
first_name="John",
cf_host_url="https://john.com", # `cf_host_url` is a custom field in Customer object
)
)
print(response.customer.cf_host_url)
Creating an idempotent request:
Idempotency keys are passed along with request headers to allow a safe retry of POST requests.
response = cb_client.Customer.create(
cb_client.Customer.CreateParams(
first_name="John",
last_name="Doe",
email="john@test.com",
locale="fr-CA",
billing_address=cb_client.Customer.BillingAddress(
first_name="John",
last_name=" Doe",
line1="PO Box 9999",
city="Walnut",
state="California",
zip="91789",
country="US",
),
),
None,
{
"chargebee-idempotency-key": "<<UUID>>"
}, # Replace <<UUID>> with a unique string
)
customer = response.customer
card = response.card
responseHeaders = response.headers # Retrieves response headers
print(responseHeaders)
idempotencyReplayedValue = response.is_idempotency_replayed # Retrieves Idempotency replayed header value
print(idempotencyReplayedValue)
Waiting for Process Completion
The response from the previous API call must be passed as an argument for wait_for_export_completion()
or wait_for_time_travel_completion()
# Wait For Export Completion
from chargebee import Filters
response = cb_client.Export.customers(
cb_client.Export.CustomersParams(
customer=cb_client.Export.CustomersCustomerParams(
first_name=Filters.StringFilter(IS="John")
)
)
)
print(cb_client.Export.wait_for_export_completion(response.export))
Feedback
If you find any bugs or have any feedback, open an issue in this repository or email it to dx@chargebee.com
License
See the LICENSE file.
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- Author: Chargebee
- Requires: Python >=3.11
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file chargebee-3.3.0.tar.gz
.
File metadata
- Download URL: chargebee-3.3.0.tar.gz
- Upload date:
- Size: 239.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61c440a7e63ecdf33c6082deb074fe726fac8c1a49808c32313c427cc9f04e9a |
|
MD5 | 101760b7586a75212452dd3cf44ee8e2 |
|
BLAKE2b-256 | bff8756b613228e04295dc00959d3660cc8b963a4d6fd503c8ade48b68b8703e |
File details
Details for the file chargebee-3.3.0-py3-none-any.whl
.
File metadata
- Download URL: chargebee-3.3.0-py3-none-any.whl
- Upload date:
- Size: 324.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8010eb46ab01277769447f73c9e6c92dbc3adf8bc18f31bd34b9c9c4328f0020 |
|
MD5 | 145ab614115436b05b34f5b17fca31f7 |
|
BLAKE2b-256 | d6d232b32a70b8ddc51fbd81ec6df8c96c0f61124bba35ed0e849e1efc4c29dd |