Skip to content

Commit

Permalink
fix: add logic to handle subscriptions in trial (#4404)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewelwell authored Jul 29, 2024
1 parent 8c86c99 commit c10e012
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/organisations/chargebee/webhook_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def process_subscription(request: Request) -> Response: # noqa: C901
)
return Response(status=status.HTTP_200_OK)

if subscription["status"] != "active":
if subscription["status"] not in ("active", "in_trial"):
# Nothing to do, so return early.
return Response(status=status.HTTP_200_OK)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,14 @@ def test_get_my_permissions_for_admin(
assert response.data["admin"] is True


@pytest.mark.parametrize("subscription_status", ("active", "in_trial"))
@mock.patch("organisations.chargebee.webhook_handlers.extract_subscription_metadata")
def test_chargebee_webhook(
mock_extract_subscription_metadata: MagicMock,
staff_user: FFAdminUser,
staff_client: APIClient,
subscription: Subscription,
subscription_status: str,
) -> None:
# Given
seats = 3
Expand All @@ -580,7 +582,7 @@ def test_chargebee_webhook(
data = {
"content": {
"subscription": {
"status": "active",
"status": subscription_status,
"id": subscription.subscription_id,
"current_term_start": 1699630389,
"current_term_end": 1702222389,
Expand Down

0 comments on commit c10e012

Please sign in to comment.