This repository was archived by the owner on Jun 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -158,11 +158,13 @@ def cancel_and_refund(
158158 ):
159159 stripe .Subscription .cancel (owner .stripe_subscription_id )
160160
161- start_of_last_period = (
162- current_subscription_datetime - relativedelta (months = 1 )
163- if subscription_plan_interval == "month"
164- else current_subscription_datetime - relativedelta (years = 1 )
165- )
161+ start_of_last_period = current_subscription_datetime - relativedelta (months = 1 )
162+ invoice_grace_period_start = current_subscription_datetime - relativedelta (days = 1 )
163+
164+ if subscription_plan_interval == "year" :
165+ start_of_last_period = current_subscription_datetime - relativedelta (years = 1 )
166+ invoice_grace_period_start = current_subscription_datetime - relativedelta (days = 3 )
167+
166168 invoices_list = stripe .Invoice .list (
167169 subscription = owner .stripe_subscription_id ,
168170 status = "paid" ,
@@ -171,11 +173,7 @@ def cancel_and_refund(
171173 "created.lt" : int (current_subscription_datetime .timestamp ()),
172174 },
173175 )
174- invoice_grace_period_start = (
175- current_subscription_datetime - relativedelta (days = 1 )
176- if subscription_plan_interval == "month"
177- else current_subscription_datetime - relativedelta (days = 3 )
178- )
176+
179177 # we only want to refund the invoices for the latest, current period
180178 recently_paid_invoices_list = [
181179 invoice
You can’t perform that action at this time.
0 commit comments