Skip to content

Commit

Permalink
Merge pull request #622 from streeter/fix-sync-invoices
Browse files Browse the repository at this point in the history
Do not call deprecated methods on stripe.Customer
  • Loading branch information
paltman authored Nov 26, 2021
2 parents 915932f + 3ff8bb3 commit 9c22ea3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 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
8 changes: 4 additions & 4 deletions pinax/stripe/tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1667,16 +1667,16 @@ 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.Customer.retrieve")
@patch("stripe.Invoice.auto_paging_iter")
def test_sync_invoices_for_customer(self, RetreiveMock, SyncMock):
RetreiveMock().invoices().data = [Mock()]
RetreiveMock.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.Customer.retrieve")
@patch("stripe.Charge.auto_paging_iter")
def test_sync_charges_for_customer(self, RetreiveMock, SyncMock):
RetreiveMock().charges().data = [Mock()]
RetreiveMock.return_value = [Mock()]
charges.sync_charges_for_customer(self.customer)
self.assertTrue(SyncMock.called)

Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ deps =
flake8 == 3.4.1
flake8-isort == 2.2.2
flake8-quotes == 0.11.0
isort < 4.3.5

[testenv:check_migrated]
setenv =
DJANGO_SETTINGS_MODULE=pinax.stripe.tests.settings
passenv =
commands =
django-admin makemigrations --check -v3 --dry-run --noinput pinax_stripe
deps =
Django < 2.2

0 comments on commit 9c22ea3

Please sign in to comment.