Skip to content

Commit

Permalink
Do not call deprecated method on stripe.Customer
Browse files Browse the repository at this point in the history
The invoices method was removed on the stripe.Customer object in stripe/stripe-python@d416e9e

This replaces that same logic to fetch the invoices and sync them and
does it within the method itself. This should be backwards compatible
with stripe-python < 2.0 as well as the 2.0 and up release.

Fixes pinax#582
  • Loading branch information
streeter committed Dec 5, 2018
1 parent 0005850 commit f9e88b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pinax/stripe/actions/invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def sync_invoices_for_customer(customer):
Args:
customer: the customer for whom to synchronize all invoices
"""
for invoice in customer.stripe_customer.invoices().data:
stripe_customer = customer.stripe_customer
stripe_invoices = stripe.Invoice.list(customer=stripe_customer.id)
for invoice in stripe_invoices.data:
sync_invoice_from_stripe_data(invoice, send_receipt=False)


Expand Down
4 changes: 3 additions & 1 deletion pinax/stripe/tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1667,9 +1667,11 @@ def test_sync_customer_purged_remotely_not_locally(self, RetrieveMock, SyncPayme
self.assertTrue(PurgeLocalMock.called)

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

Expand Down

0 comments on commit f9e88b2

Please sign in to comment.