Skip to content

Commit c818638

Browse files
committed
fix charges/invoices listing by using stripe API as suggested in https://github.com/pinax/pinax-stripe/issues/623\#issuecomment-455814540
1 parent 0005850 commit c818638

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pinax/stripe/actions/charges.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def sync_charges_for_customer(customer):
160160
Args:
161161
customer: a pinax.stripe.models.Customer object
162162
"""
163-
for charge in customer.stripe_customer.charges().data:
163+
for charge in stripe.Charge.auto_paging_iter(customer=customer.stripe_id):
164164
sync_charge_from_stripe_data(charge)
165165

166166

pinax/stripe/actions/invoices.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def sync_invoices_for_customer(customer):
131131
Args:
132132
customer: the customer for whom to synchronize all invoices
133133
"""
134-
for invoice in customer.stripe_customer.invoices().data:
134+
for invoice in stripe.Invoice.auto_paging_iter(customer=customer.stripe_id):
135135
sync_invoice_from_stripe_data(invoice, send_receipt=False)
136136

137137

pinax/stripe/tests/test_actions.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1666,17 +1666,17 @@ def test_sync_customer_purged_remotely_not_locally(self, RetrieveMock, SyncPayme
16661666
self.assertFalse(SyncSubscriptionMock.called)
16671667
self.assertTrue(PurgeLocalMock.called)
16681668

1669-
@patch("pinax.stripe.actions.invoices.sync_invoice_from_stripe_data")
1669+
@patch("stripe.Invoice.auto_paging_iter")
16701670
@patch("stripe.Customer.retrieve")
1671-
def test_sync_invoices_for_customer(self, RetreiveMock, SyncMock):
1672-
RetreiveMock().invoices().data = [Mock()]
1671+
def test_sync_invoices_for_customer(self, RetrieveMock, SyncMock):
1672+
RetrieveMock.return_value = [Mock()]
16731673
invoices.sync_invoices_for_customer(self.customer)
16741674
self.assertTrue(SyncMock.called)
16751675

1676-
@patch("pinax.stripe.actions.charges.sync_charge_from_stripe_data")
1676+
@patch("stripe.Charge.auto_paging_iter")
16771677
@patch("stripe.Customer.retrieve")
1678-
def test_sync_charges_for_customer(self, RetreiveMock, SyncMock):
1679-
RetreiveMock().charges().data = [Mock()]
1678+
def test_sync_charges_for_customer(self, RetrieveMock, SyncMock):
1679+
RetrieveMock.return_value = [Mock()]
16801680
charges.sync_charges_for_customer(self.customer)
16811681
self.assertTrue(SyncMock.called)
16821682

0 commit comments

Comments
 (0)