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

Key error when processing invoice.created webhook #636

Open
hildebert opened this issue Sep 14, 2019 · 0 comments
Open

Key error when processing invoice.created webhook #636

hildebert opened this issue Sep 14, 2019 · 0 comments

Comments

@hildebert
Copy link

Hi! I'm using latest version of pinax-stripe and recently upgraded Stripe id to version 2019-08-14. Now upon receiving invoice.created webhook my app fails with following error:

Traceback (most recent call last):
  File "C:\www\projects\webapp\app\payments\urls.py", line 17, in post
    return super().post(request, args, kwargs)
  File "///views.py", line 210,
 in post
    message=data
  File "C:\Users\gray\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pinax\stripe\actions\events.py",
line 39, in add_event
    webhook.process()
  File "C:\Users\gray\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pinax\stripe\webhooks.py", line 1
37, in process
    raise e
  File "C:\Users\gray\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pinax\stripe\webhooks.py", line 1
28, in process
    self.process_webhook()
  File "C:\Users\gray\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pinax\stripe\webhooks.py", line 4
20, in process_webhook
    send_receipt=settings.PINAX_STRIPE_SEND_EMAIL_RECEIPTS
  File "C:\Users\gray\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pinax\stripe\actions\invoices.py"
, line 99, in sync_invoice_from_stripe_data
    closed=stripe_invoice["closed"],
KeyError: 'closed'

As I can see here: https://github.com/pinax/pinax-stripe/blob/master/pinax/stripe/actions/invoices.py#L99, pinax-stripe expects an invoice to have a field called 'closed'. But this field was removed in newer API version: https://stripe.com/docs/billing/migration/invoice-states

In previous versions of the Stripe API, Invoices did not have statuses. Instead, there was a series of booleans, like closed, paid, and forgiven.

We've introduced statuses on invoices to better correlate Stripe invoices with finance workflows. Now, all Invoice objects have a status property.

Is there a way around this? Or the latest API version pinax-stripe can work with is 2015-10-16?

Thanks.

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

No branches or pull requests

1 participant