Skip to content

fix charges/invoices listing by using stripe API#630

Open
ivellios wants to merge 1 commit into
pinax:originalfrom
deployed:fix_pulling_charges/invoices_from_stripe
Open

fix charges/invoices listing by using stripe API#630
ivellios wants to merge 1 commit into
pinax:originalfrom
deployed:fix_pulling_charges/invoices_from_stripe

Conversation

@ivellios
Copy link
Copy Markdown

@ivellios ivellios commented Feb 6, 2019

What's this PR do?

As described in #623 invoices is no longer available in the pulled stripe customer data, thus pulling invoices list from the stripe API separately with customer id. Suggested by @polski-g in his comment: https://github.com/pinax/pinax-stripe/issues/623\#issuecomment-455814540

Same goes for charges as noted by the user in the comment.

Any background context you want to provide?

What ticket or issue # does this fix?

Closes #623

Definition of Done (check if considered and/or addressed):

  • Are all backwards incompatible changes documented in this PR?
  • Have all new dependencies been documented in this PR?
  • Has the appropriate documentation been updated (if applicable)?
  • Have you written tests to prove this change works (if applicable)?

@ivellios
Copy link
Copy Markdown
Author

ivellios commented Feb 6, 2019

I see no backwards incompatible changes that should be documented in this PR.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 6, 2019

Codecov Report

Merging #630 into master will decrease coverage by 0.2%.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #630      +/-   ##
========================================
- Coverage   99.21%    99%   -0.21%     
========================================
  Files          33     33              
  Lines        1911   1911              
  Branches      175    175              
========================================
- Hits         1896   1892       -4     
- Misses          7      9       +2     
- Partials        8     10       +2
Flag Coverage Δ
#py27dj110 98.69% <0%> (-0.21%) ⬇️
#py27dj111 98.69% <0%> (-0.21%) ⬇️
#py27dj18 98.95% <0%> (-0.21%) ⬇️
#py34dj110 98.69% <0%> (-0.21%) ⬇️
#py34dj111 98.69% <0%> (-0.21%) ⬇️
#py34dj18 98.95% <0%> (-0.21%) ⬇️
#py34dj20 98.69% <0%> (-0.21%) ⬇️
#py35dj110 98.69% <0%> (-0.21%) ⬇️
#py35dj111 98.69% <0%> (-0.21%) ⬇️
#py35dj18 98.95% <0%> (-0.21%) ⬇️
#py35dj20 98.69% <0%> (-0.21%) ⬇️
#py36dj111 98.69% <0%> (-0.21%) ⬇️
#py36dj20 98.69% <0%> (-0.21%) ⬇️
#py36dj20psql 98.69% <0%> (-0.21%) ⬇️
Impacted Files Coverage Δ
pinax/stripe/actions/invoices.py 96.87% <0%> (-3.13%) ⬇️
pinax/stripe/actions/charges.py 93.33% <0%> (-2.23%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0005850...c818638. Read the comment docs.

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()]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is correct. I believe that stripe.Customer.retrieve isn't actually called anymore. You would need to keep the @patch("pinax.stripe.actions.invoices.sync_invoice_from_stripe_data") and remove the @patch("stripe.Customer.retrieve") patch, which would mean that stripe.Invoice.auto_paging_iter is set to the RetrieveMock and pinax.stripe.actions.invoices.sync_invoice_from_stripe_data is set to the SyncMock.

@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):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above should also apply here.

@streeter
Copy link
Copy Markdown
Contributor

I had attempted to fix the invoices method removal (in #622), but didn't know about the auto_paging_iter method. I updated my PR to use that, but keep the code coverage the same.

@paltman paltman changed the base branch from master to 4.x November 26, 2021 15:54
@paltman paltman added the Original The original full pinax-stripe version with cached models and actions service layer label Nov 26, 2021
@paltman paltman changed the base branch from 4.x to original November 26, 2021 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Original The original full pinax-stripe version with cached models and actions service layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot sync customers - KeyError Invoices

4 participants