Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@
### v3.27.0 (2026-07-30)
* * *
### New Resources:
- [`CreditUnit`](https://apidocs.chargebee.com/docs/api/credit_units) has been added.
- [`LedgerEntry`](https://apidocs.chargebee.com/docs/api/ledger_entries) has been added.


### New Actions:
- [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) has been added to [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations).


### New Attributes:
- [`unit_id`](https://apidocs.chargebee.com/docs/api/alerts/alert-object#unit_id) has been added to [`Alert`](https://apidocs.chargebee.com/docs/api/alerts).
- [`subscription_id`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#subscription_id) has been added to [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks).
- [`modified_at`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#modified_at) has been added to [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks).
- [`resource_version`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#resource_version) has been added to [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks).
- [`created_at`](https://apidocs.chargebee.com/docs/api/ledger_account_balances/ledger-account-balance-object#created_at) has been added to [`LedgerAccountBalance`](https://apidocs.chargebee.com/docs/api/ledger_account_balances).
- [`resource_version`](https://apidocs.chargebee.com/docs/api/ledger_account_balances/ledger-account-balance-object#resource_version) has been added to [`LedgerAccountBalance`](https://apidocs.chargebee.com/docs/api/ledger_account_balances).


### New Parameters:
- [`account_type`](https://apidocs.chargebee.com/docs/api/grant_blocks/list-grant-blocks#account_type) has been added as query parameter to [`list_grant_blocks`](https://apidocs.chargebee.com/docs/api/grant_blocks/list-grant-blocks) in [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks).
- [`unit_id`](https://apidocs.chargebee.com/docs/api/alerts/create-an-alert#unit_id) has been added as request body parameter to [`create_an_alert`](https://apidocs.chargebee.com/docs/api/alerts/create-an-alert) in [`Alert`](https://apidocs.chargebee.com/docs/api/alerts).
- [`include_cancellation_day_in_billing`](https://apidocs.chargebee.com/docs/api/estimates/cancel-subscription-for-items-estimate#include_cancellation_day_in_billing) has been added as request body parameter to [`cancel_subscription_for_items_estimate`](https://apidocs.chargebee.com/docs/api/estimates/cancel-subscription-for-items-estimate) in [`Estimate`](https://apidocs.chargebee.com/docs/api/estimates).
- [`subscription_id`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate#subscription_id) has been added as request body parameter to [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations).
- [`unit_id`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate#unit_id) has been added as request body parameter to [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations).
- [`amount`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate#amount) has been added as request body parameter to [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations).
- [`expires_at`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate#expires_at) has been added as request body parameter to [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations).
- [`metadata`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate#metadata) has been added as request body parameter to [`allocate`](https://apidocs.chargebee.com/docs/api/ledger_operations/allocate) in [`LedgerOperation`](https://apidocs.chargebee.com/docs/api/ledger_operations).
- [`include_cancellation_day_in_billing`](https://apidocs.chargebee.com/docs/api/subscriptions/cancel-subscription-for-items#include_cancellation_day_in_billing) has been added as request body parameter to [`cancel_subscription_for_items`](https://apidocs.chargebee.com/docs/api/subscriptions/cancel-subscription-for-items) in [`Subscription`](https://apidocs.chargebee.com/docs/api/subscriptions).


### New Events:
- [`grant_blocks_created`](https://apidocs.chargebee.com/docs/api/events/webhook/grant_blocks_created) has been added.
- [`ledger_updated`](https://apidocs.chargebee.com/docs/api/events/webhook/ledger_updated) has been added.
- [`ledger_account_balance_updated`](https://apidocs.chargebee.com/docs/api/events/webhook/ledger_account_balance_updated) has been added.
- [`grant_blocks_updated`](https://apidocs.chargebee.com/docs/api/events/webhook/grant_blocks_updated) has been added.


### New Enums:
- `ledger_account_balance_updated`, `grant_blocks_created`, `grant_blocks_updated`, and `ledger_updated` have been added as new values enum `EventType`.
- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values enum `PaymentMethod`.
- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values enum `PaymentMethodType`.
- `dana`, `touch_n_go`, `tamara`, `qpay`, `credit_balance_dropped`, `credit`, `debit`, `hold`, and `unhold` have been added as new values enum `Type`.
- `active` and `archived` have been added as new values to enum attribute [`status`](https://apidocs.chargebee.com/docs/api/credit_units/credit-unit-object#status) in [`CreditUnit`](https://apidocs.chargebee.com/docs/api/credit_units).
- `grant_renewal` and `subscription_renewed` have been added as new values to enum attribute [`grant_source`](https://apidocs.chargebee.com/docs/api/grant_blocks/grant-block-object#grant_source) in [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks).
- `provisioned` and `overdraft` have been added as new values to enum attribute [`account_type`](https://apidocs.chargebee.com/docs/api/ledger_entries/ledger-entry-object#account_type) in [`LedgerEntry`](https://apidocs.chargebee.com/docs/api/ledger_entries).
- `credit_unit` has been added as a new value to enum attribute [`unit_type`](https://apidocs.chargebee.com/docs/api/ledger_entries/ledger-entry-object#unit_type) in [`LedgerEntry`](https://apidocs.chargebee.com/docs/api/ledger_entries).
- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values to enum attribute [`payment_method_type`](https://apidocs.chargebee.com/docs/api/payment_intents/payment-intent-object#payment_method_type) in [`PaymentIntent`](https://apidocs.chargebee.com/docs/api/payment_intents).
- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values to enum attribute [`active_payment_attempt.payment_method_type`](https://apidocs.chargebee.com/docs/api/payment_intents/payment-intent-object#active_payment_attempt_payment_method_type) in [`PaymentIntent`](https://apidocs.chargebee.com/docs/api/payment_intents).
- `archived` and `active` have been added as new values to enum query parameter `status.in` in [`list_credit_units`](https://apidocs.chargebee.com/docs/api/credit_units/list-credit-units) of [`CreditUnit`](https://apidocs.chargebee.com/docs/api/credit_units).
- `archived` and `active` have been added as new values to enum query parameter `status.is` in [`list_credit_units`](https://apidocs.chargebee.com/docs/api/credit_units/list-credit-units) of [`CreditUnit`](https://apidocs.chargebee.com/docs/api/credit_units).
- `provisioned` and `overdraft` have been added as new values to enum query parameter `account_type.is` in [`list_grant_blocks`](https://apidocs.chargebee.com/docs/api/grant_blocks/list-grant-blocks) of [`GrantBlock`](https://apidocs.chargebee.com/docs/api/grant_blocks).
- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values to enum request body parameter `payment_method_type` in [`update_a_payment_intent`](https://apidocs.chargebee.com/docs/api/payment_intents/update-a-payment-intent) of [`PaymentIntent`](https://apidocs.chargebee.com/docs/api/payment_intents).
- `dana`, `touch_n_go`, `tamara`, and `qpay` have been added as new values to enum request body parameter `payment_method_type` in [`create_a_payment_intent`](https://apidocs.chargebee.com/docs/api/payment_intents/create-a-payment-intent) of [`PaymentIntent`](https://apidocs.chargebee.com/docs/api/payment_intents).



### v3.26.0 (2026-07-21)
* * *
### New Resources:
Expand Down
43 changes: 18 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ The package needs to be configured with your site's API key, which is available
### Configuring chargebee client
```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="", site="")
```

### Configuring Timeouts

```python
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)
Expand All @@ -55,6 +57,7 @@ cb_client.update_connect_timeout_secs(5000)

```python
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)
Expand Down Expand Up @@ -99,9 +102,7 @@ When configured to use the async client, all model methods return a coroutine, w
```python
async def get_customers():
response = await cb_client.Customer.list(
cb_client.Customer.ListParams(
first_name=Filters.StringFilter(IS="John")
)
cb_client.Customer.ListParams(first_name=Filters.StringFilter(IS="John"))
)
return response
```
Expand All @@ -110,6 +111,7 @@ Note: The async methods will have to be wrapped in an event loop during invocati

```python
import asyncio

response = asyncio.run(get_customers())
```

Expand All @@ -121,9 +123,7 @@ For pagination, `offset` is the parameter that is being used. The value used for
from chargebee import Filters

response = cb_client.Customer.list(
cb_client.Customer.ListParams(
first_name=Filters.StringFilter(IS="John")
)
cb_client.Customer.ListParams(first_name=Filters.StringFilter(IS="John"))
)
offset = response.next_offset
print(offset)
Expand Down Expand Up @@ -193,15 +193,15 @@ response = cb_client.Customer.create(
),
),
None,
{
"chargebee-idempotency-key": "<<UUID>>"
}, # Replace <<UUID>> with a unique string
{"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
idempotencyReplayedValue = (
response.is_idempotency_replayed
) # Retrieves Idempotency replayed header value
print(idempotencyReplayedValue)
```

Expand Down Expand Up @@ -244,17 +244,11 @@ You can enable and configure the retry logic by passing a `retryConfig` object w
from chargebee import Chargebee
from chargebee.retry_config import RetryConfig

retry_config = RetryConfig(
enabled=True,
max_retries=5,
delay_ms=1000,
retry_on=[500]
)
retry_config = RetryConfig(enabled=True, max_retries=5, delay_ms=1000, retry_on=[500])
cb_client = Chargebee(api_key="api_key", site="site")
cb_client.update_retry_config(retry_config)

# ... your Chargebee API operations ...

```

#### Example: Rate Limit retry logic
Expand All @@ -265,17 +259,11 @@ You can enable and configure the retry logic for rate-limit by passing a `retryC
from chargebee import Chargebee
from chargebee.retry_config import RetryConfig

retry_config = RetryConfig(
enabled=True,
max_retries=5,
delay_ms=1000,
retry_on=[429]
)
retry_config = RetryConfig(enabled=True, max_retries=5, delay_ms=1000, retry_on=[429])
cb_client = Chargebee(api_key="api_key", site="site")
cb_client.update_retry_config(retry_config)

# ... your Chargebee API operations ...

```

### Telemetry (OpenTelemetry)
Expand Down Expand Up @@ -314,7 +302,12 @@ trace.set_tracer_provider(provider)
```

```python
from chargebee import Chargebee, RequestTelemetryContext, RequestTelemetryResult, TelemetryAdapter
from chargebee import (
Chargebee,
RequestTelemetryContext,
RequestTelemetryResult,
TelemetryAdapter,
)
from opentelemetry import trace
from opentelemetry.trace import SpanKind, Status, StatusCode

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.26.0
3.27.0
2 changes: 2 additions & 0 deletions chargebee/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def __init__(
self.CpqQuoteSignature = chargebee.CpqQuoteSignature(self.env)
self.CreditNote = chargebee.CreditNote(self.env)
self.CreditNoteEstimate = chargebee.CreditNoteEstimate(self.env)
self.CreditUnit = chargebee.CreditUnit(self.env)
self.Currency = chargebee.Currency(self.env)
self.Customer = chargebee.Customer(self.env)
self.CustomerEntitlement = chargebee.CustomerEntitlement(self.env)
Expand Down Expand Up @@ -95,6 +96,7 @@ def __init__(
self.ItemFamily = chargebee.ItemFamily(self.env)
self.ItemPrice = chargebee.ItemPrice(self.env)
self.LedgerAccountBalance = chargebee.LedgerAccountBalance(self.env)
self.LedgerEntry = chargebee.LedgerEntry(self.env)
self.LedgerOperation = chargebee.LedgerOperation(self.env)
self.Metadata = chargebee.Metadata(self.env)
self.Meter = chargebee.Meter(self.env)
Expand Down
4 changes: 4 additions & 0 deletions chargebee/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@

from chargebee.models.credit_note_estimate.operations import CreditNoteEstimate

from chargebee.models.credit_unit.operations import CreditUnit

from chargebee.models.currency.operations import Currency

from chargebee.models.customer.operations import Customer
Expand Down Expand Up @@ -206,6 +208,8 @@

from chargebee.models.ledger_account_balance.operations import LedgerAccountBalance

from chargebee.models.ledger_entry.operations import LedgerEntry

from chargebee.models.ledger_operation.operations import LedgerOperation

from chargebee.models.metadata.operations import Metadata
Expand Down
1 change: 1 addition & 0 deletions chargebee/models/alert/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class CreateParams(TypedDict):
description: NotRequired[str]
metered_feature_id: NotRequired[str]
currency_code: NotRequired[str]
unit_id: NotRequired[str]
subscription_id: NotRequired[str]
threshold: NotRequired["Alert.CreateThresholdParams"]
meta: NotRequired[str]
Expand Down
3 changes: 2 additions & 1 deletion chargebee/models/alert/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ class AlertResponse(Model):
description: str = None
metered_feature_id: str = None
currency_code: str = None
unit_id: str = None
subscription_id: str = None
status: str = None
meta: str = None
created_at: int = None
updated_at: int = None
threshold: List[ThresholdResponse] = None
threshold: ThresholdResponse = None
filter_conditions: List[FilterConditionResponse] = None


Expand Down
2 changes: 2 additions & 0 deletions chargebee/models/credit_unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .operations import CreditUnit
from .responses import CreditUnitResponse
132 changes: 132 additions & 0 deletions chargebee/models/credit_unit/operations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
from .responses import *
from chargebee import request, environment
from typing import TypedDict, Required, NotRequired, Dict, List, Any, cast
from enum import Enum
from chargebee.filters import Filters


@dataclass
class CreditUnit:
env: environment.Environment

class Status(Enum):
ACTIVE = "active"
ARCHIVED = "archived"

def __str__(self):
return self.value

class ListParams(TypedDict):
limit: NotRequired[int]
offset: NotRequired[str]
status: NotRequired[Filters.EnumFilter]
id: NotRequired[Filters.StringFilter]

class CreateParams(TypedDict):
id: Required[str]
name: Required[str]
is_unlimited: Required[bool]
overdraft_amount: NotRequired[str]
external_name: NotRequired[str]

class UpdateParams(TypedDict):
name: NotRequired[str]
external_name: NotRequired[str]

def list(self, params: ListParams = None, headers=None) -> ListResponse:
jsonKeys = {}
options = {}
return request.send_list_request(
"get",
request.uri_path("credit_units"),
self.env,
cast(Dict[Any, Any], params),
headers,
ListResponse,
None,
False,
jsonKeys,
options,
resource="creditUnit",
operation="list",
)

def create(self, params: CreateParams, headers=None) -> CreateResponse:
jsonKeys = {}
options = {
"isIdempotent": True,
}
return request.send(
"post",
request.uri_path("credit_units"),
self.env,
cast(Dict[Any, Any], params),
headers,
CreateResponse,
None,
False,
jsonKeys,
options,
resource="creditUnit",
operation="create",
)

def update(self, id, params: UpdateParams = None, headers=None) -> UpdateResponse:
jsonKeys = {}
options = {
"isIdempotent": True,
}
return request.send(
"post",
request.uri_path("credit_units", id),
self.env,
cast(Dict[Any, Any], params),
headers,
UpdateResponse,
None,
False,
jsonKeys,
options,
resource="creditUnit",
operation="update",
)

def archive(self, id, headers=None) -> ArchiveResponse:
jsonKeys = {}
options = {
"isIdempotent": True,
}
return request.send(
"post",
request.uri_path("credit_units", id, "archive_command"),
self.env,
None,
headers,
ArchiveResponse,
None,
False,
jsonKeys,
options,
resource="creditUnit",
operation="archive",
)

def reactivate(self, id, headers=None) -> ReactivateResponse:
jsonKeys = {}
options = {
"isIdempotent": True,
}
return request.send(
"post",
request.uri_path("credit_units", id, "reactivate_command"),
self.env,
None,
headers,
ReactivateResponse,
None,
False,
jsonKeys,
options,
resource="creditUnit",
operation="reactivate",
)
Loading
Loading