From 385cd038b0687d4cab7a2bcdfa6845ab16109aff Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 30 Apr 2024 10:21:01 -0700 Subject: [PATCH] stripe: Pass ids, not objects, to pagination API. Signed-off-by: Anders Kaseorg --- corporate/lib/stripe.py | 3 ++- corporate/tests/test_stripe.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py index 2671854e70..d883f491e2 100644 --- a/corporate/lib/stripe.py +++ b/corporate/lib/stripe.py @@ -5264,8 +5264,9 @@ def get_all_invoices_for_customer(customer: Customer) -> Generator[stripe.Invoic for invoice in invoices: yield invoice last_invoice = invoice + assert last_invoice.id is not None invoices = stripe.Invoice.list( - customer=customer.stripe_customer_id, starting_after=last_invoice, limit=100 + customer=customer.stripe_customer_id, starting_after=last_invoice.id, limit=100 ) diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index d37d0d4759..2472ef7b2c 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -557,7 +557,9 @@ class StripeTestCase(ZulipTestCase): def send_stripe_webhook_events(self, most_recent_event: stripe.Event) -> None: while True: - events_old_to_new = list(reversed(stripe.Event.list(ending_before=most_recent_event))) + events_old_to_new = list( + reversed(stripe.Event.list(ending_before=most_recent_event.id)) + ) if len(events_old_to_new) == 0: break for event in events_old_to_new: