Key error when processing `invoice.created` webhook
hildebert opened this issue · 0 comments
hildebert commented
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.