Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stripe api version (to fix some issues) #525

Merged
merged 1 commit into from
Nov 26, 2021

Conversation

tasn
Copy link
Contributor

@tasn tasn commented Nov 27, 2017

I'm initiating this api version bump because I'm encountering an issue
where when getting a failed invoice, pinax stripe is trying to get the
subscription, and if the subscription is already cancelled, it wouldn't
show. This has been changed (fixed?) in stripe API 2016-07-06.

I've taken the opportunity to upgrade to a slightly newer api version
since I've reviewed the changes and non of them look like they would
negatively affect pinax.stripe.

Way to reproduce my invoice issue:

Have a cancelled subscription followed by a cancelled invoice (happens
often here). Following that you'd get the following backtrace:

File "pinax/stripe/webhooks.py" in process
118. self.process_webhook()

File "pinax/stripe/webhooks.py" in process_webhook
414. send_receipt=settings.PINAX_STRIPE_SEND_EMAIL_RECEIPTS

File "pinax/stripe/actions/invoices.py" in sync_invoice_from_stripe_data
91. stripe_subscription = subscriptions.retrieve(c, sub_id)

File "pinax/stripe/actions/subscriptions.py" in retrieve
128. subscription = stripe.Subscription.retrieve(sub_id, stripe_account=customer.stripe_account_stripe_id)

File "stripe/api_resources/abstract/api_resource.py" in retrieve
13. instance.refresh()

File "stripe/api_resources/abstract/api_resource.py" in refresh
17. self.refresh_from(self.request('get', self.instance_url()))

File "stripe/stripe_object.py" in request
190. response, api_key = requestor.request(method, url, params, headers)

File "stripe/api_requestor.py" in request
152. resp = self.interpret_response(rbody, rcode, rheaders)

File "stripe/api_requestor.py" in interpret_response
359. self.handle_error_response(rbody, rcode, resp, rheaders)

File "stripe/api_requestor.py" in handle_error_response
177. raise err

Exception Type: InvalidRequestError at /stripe/webhook/
Exception Value: Request req_XXXXXXXX No such subscription:
sub_XXXXXXXXXX

req and sub were redacted by me.

What's this PR do?

Any background context you want to provide?

What ticket or issue # does this fix?

Opened this instead of opening a ticket for the above issue.

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

  • Are all backwards incompatible changes documented in this PR?
    There should be none, as I only upgraded to an API version that didn't change anything that would affect pinax stripe.
  • Have all new dependencies been documented in this PR?
    None.
  • Has the appropriate documentation been updated (if applicable)?
    No relevant ones as I can see.
  • Have you written tests to prove this change works (if applicable)?
    The normal test suite should cover it.

I'm initiating this api version bump because I'm encountering an issue
where when getting a failed invoice, pinax stripe is trying to get the
subscription, and if the subscription is already cancelled, it wouldn't
show. This has been changed (fixed?) in stripe API 2016-07-06.

I've taken the opportunity to upgrade to a slightly newer api version
since I've reviewed the changes and non of them look like they would
negatively affect pinax.stripe.

Way to reproduce my invoice issue:

Have a cancelled subscription followed by a cancelled invoice (happens
often here). Following that you'd get the following backtrace:

File "pinax/stripe/webhooks.py" in process
  118.             self.process_webhook()

File "pinax/stripe/webhooks.py" in process_webhook
  414.             send_receipt=settings.PINAX_STRIPE_SEND_EMAIL_RECEIPTS

File "pinax/stripe/actions/invoices.py" in sync_invoice_from_stripe_data
  91.     stripe_subscription = subscriptions.retrieve(c, sub_id)

File "pinax/stripe/actions/subscriptions.py" in retrieve
  128.     subscription = stripe.Subscription.retrieve(sub_id, stripe_account=customer.stripe_account_stripe_id)

File "stripe/api_resources/abstract/api_resource.py" in retrieve
  13.         instance.refresh()

File "stripe/api_resources/abstract/api_resource.py" in refresh
  17.         self.refresh_from(self.request('get', self.instance_url()))

File "stripe/stripe_object.py" in request
  190.         response, api_key = requestor.request(method, url, params, headers)

File "stripe/api_requestor.py" in request
  152.         resp = self.interpret_response(rbody, rcode, rheaders)

File "stripe/api_requestor.py" in interpret_response
  359.             self.handle_error_response(rbody, rcode, resp, rheaders)

File "stripe/api_requestor.py" in handle_error_response
  177.         raise err

Exception Type: InvalidRequestError at /stripe/webhook/
Exception Value: Request req_XXXXXXXX  No such subscription:
sub_XXXXXXXXXX

req and sub were redacted by me.
@codecov
Copy link

codecov bot commented Nov 27, 2017

Codecov Report

Merging #525 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #525      +/-   ##
==========================================
- Coverage   99.39%   99.38%   -0.02%     
==========================================
  Files          34       34              
  Lines        1829     1793      -36     
  Branches      166      160       -6     
==========================================
- Hits         1818     1782      -36     
  Misses          5        5              
  Partials        6        6
Flag Coverage Δ
#py27dj110 99.05% <ø> (-0.02%) ⬇️
#py27dj111 99.05% <ø> (-0.02%) ⬇️
#py27dj18 99.33% <ø> (-0.02%) ⬇️
#py34dj110 99.05% <ø> (-0.02%) ⬇️
#py34dj111 99.05% <ø> (-0.02%) ⬇️
#py34dj18 99.33% <ø> (-0.02%) ⬇️
#py34dj20 99.05% <ø> (-0.02%) ⬇️
#py35dj110 99.05% <ø> (-0.02%) ⬇️
#py35dj111 99.05% <ø> (-0.02%) ⬇️
#py35dj18 99.33% <ø> (-0.02%) ⬇️
#py35dj20 99.05% <ø> (-0.02%) ⬇️
#py36dj111 99.05% <ø> (-0.02%) ⬇️
#py36dj20 99.05% <ø> (-0.02%) ⬇️
#py36dj20psql 99.05% <ø> (-0.02%) ⬇️
Impacted Files Coverage Δ
pinax/stripe/webhooks.py 99.06% <0%> (-0.02%) ⬇️
pinax/stripe/actions/charges.py 100% <0%> (ø) ⬆️
pinax/stripe/models.py 100% <0%> (ø) ⬆️
pinax/stripe/actions/subscriptions.py 100% <0%> (ø) ⬆️
pinax/stripe/admin.py 100% <0%> (ø) ⬆️

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 112111f...534fc2e. Read the comment docs.

@blueyed
Copy link
Contributor

blueyed commented Nov 27, 2017

@blueyed
Copy link
Contributor

blueyed commented Nov 27, 2017

Can you provide a link to the API doc changes, please?

@tasn
Copy link
Contributor Author

tasn commented Nov 27, 2017

That's a good point.

Link to the changelog: https://stripe.com/docs/upgrades#api-changelog

lermit added a commit to pockost/pinax-stripe that referenced this pull request Apr 3, 2019
@paltman paltman merged commit 78473e1 into pinax:master Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants