Skip to content

Commit e758a4a

Browse files
authored
feat(subscription): Allow to skip invoice on subscription termination (#327)
This is related to getlago/lago-api@78cbba4.
1 parent 405d25c commit e758a4a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

lago_python_client/models/subscription.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class SubscriptionResponse(BaseResponseModel):
4545
current_billing_period_started_at: Optional[str]
4646
current_billing_period_ending_at: Optional[str]
4747
on_termination_credit_note: Optional[str]
48+
on_termination_invoice: Optional[str]
4849

4950

5051
class SubscriptionsResponse(BaseResponseModel):

tests/fixtures/subscription.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"billing_time": "anniversary",
1313
"terminated_at": null,
1414
"on_termination_credit_note": "skip",
15+
"on_termination_invoice": "skip",
1516
"subscription_at": "2022-04-29T08:59:51Z",
1617
"previous_plan_code": null,
1718
"next_plan_code": null,

tests/test_subscription_client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,26 @@ def test_valid_destroy_subscription_request(httpx_mock: HTTPXMock):
140140
assert response.plan_code == "eartha lynch"
141141

142142

143-
def test_valid_destroy_subscription_with_on_termination_credit_note_request(httpx_mock: HTTPXMock):
143+
def test_valid_destroy_subscription_with_on_termination_actions_request(httpx_mock: HTTPXMock):
144144
client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
145145
identifier = "sub_id"
146146

147147
httpx_mock.add_response(
148148
method="DELETE",
149-
url="https://api.getlago.com/api/v1/subscriptions/" + identifier + "?on_termination_credit_note=skip",
149+
url="https://api.getlago.com/api/v1/subscriptions/"
150+
+ identifier
151+
+ "?on_termination_credit_note=skip&on_termination_invoice=skip",
150152
content=mock_response(),
151153
)
152-
response = client.subscriptions.destroy(identifier, {"on_termination_credit_note": "skip"})
154+
response = client.subscriptions.destroy(
155+
identifier, {"on_termination_credit_note": "skip", "on_termination_invoice": "skip"}
156+
)
153157

154158
assert response.external_customer_id == "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
155159
assert response.status == "active"
156160
assert response.plan_code == "eartha lynch"
157161
assert response.on_termination_credit_note == "skip"
162+
assert response.on_termination_invoice == "skip"
158163

159164

160165
def test_valid_destroy_pending_subscription_request(httpx_mock: HTTPXMock):

0 commit comments

Comments
 (0)