Skip to content

Commit

Permalink
fix charges/invoices listing by using stripe API as suggested in http…
Browse files Browse the repository at this point in the history
  • Loading branch information
ivellios committed Feb 6, 2019
1 parent 0005850 commit c818638
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pinax/stripe/actions/charges.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def sync_charges_for_customer(customer):
Args:
customer: a pinax.stripe.models.Customer object
"""
for charge in customer.stripe_customer.charges().data:
for charge in stripe.Charge.auto_paging_iter(customer=customer.stripe_id):
sync_charge_from_stripe_data(charge)


Expand Down
2 changes: 1 addition & 1 deletion pinax/stripe/actions/invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def sync_invoices_for_customer(customer):
Args:
customer: the customer for whom to synchronize all invoices
"""
for invoice in customer.stripe_customer.invoices().data:
for invoice in stripe.Invoice.auto_paging_iter(customer=customer.stripe_id):
sync_invoice_from_stripe_data(invoice, send_receipt=False)


Expand Down
12 changes: 6 additions & 6 deletions pinax/stripe/tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1666,17 +1666,17 @@ def test_sync_customer_purged_remotely_not_locally(self, RetrieveMock, SyncPayme
self.assertFalse(SyncSubscriptionMock.called)
self.assertTrue(PurgeLocalMock.called)

@patch("pinax.stripe.actions.invoices.sync_invoice_from_stripe_data")
@patch("stripe.Invoice.auto_paging_iter")
@patch("stripe.Customer.retrieve")
def test_sync_invoices_for_customer(self, RetreiveMock, SyncMock):
RetreiveMock().invoices().data = [Mock()]
def test_sync_invoices_for_customer(self, RetrieveMock, SyncMock):
RetrieveMock.return_value = [Mock()]
invoices.sync_invoices_for_customer(self.customer)
self.assertTrue(SyncMock.called)

@patch("pinax.stripe.actions.charges.sync_charge_from_stripe_data")
@patch("stripe.Charge.auto_paging_iter")
@patch("stripe.Customer.retrieve")
def test_sync_charges_for_customer(self, RetreiveMock, SyncMock):
RetreiveMock().charges().data = [Mock()]
def test_sync_charges_for_customer(self, RetrieveMock, SyncMock):
RetrieveMock.return_value = [Mock()]
charges.sync_charges_for_customer(self.customer)
self.assertTrue(SyncMock.called)

Expand Down

0 comments on commit c818638

Please sign in to comment.