BUG - Cannot sync plans: KeyError: 'name'
nortigo opened this issue · 2 comments
nortigo commented
Issue Summary
I created a plan and when I try to run the sync_plans() command, it gives me a KeyError exception.
PINAX_STRIPE_API_VERSION = '2018-05-21'
Steps to Reproduce
- Create a plan directly into Stripe
- Run sync_plans() command
What were you expecting to happen?
All plans are synced
What actually happened?
An error occured:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/frujo/projects/venvs/potweedquebec/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/home/frujo/projects/venvs/potweedquebec/lib/python3.5/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/frujo/projects/venvs/potweedquebec/lib/python3.5/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/frujo/projects/venvs/potweedquebec/lib/python3.5/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/home/frujo/projects/venvs/potweedquebec/lib/python3.5/site-packages/pinax/stripe/management/commands/sync_plans.py", line 11, in handle
plans.sync_plans()
File "/home/frujo/projects/venvs/potweedquebec/lib/python3.5/site-packages/pinax/stripe/actions/plans.py", line 18, in sync_plans
sync_plan(plan)
File "/home/frujo/projects/venvs/potweedquebec/lib/python3.5/site-packages/pinax/stripe/actions/plans.py", line 35, in sync_plan
"name": plan["name"],
File "/home/frujo/projects/venvs/potweedquebec/lib/python3.5/site-packages/stripe/stripe_object.py", line 122, in __getitem__
raise err
File "/home/frujo/projects/venvs/potweedquebec/lib/python3.5/site-packages/stripe/stripe_object.py", line 111, in __getitem__
return super(StripeObject, self).__getitem__(k)
KeyError: 'name'
Here is the content of plan object:
{
"active": true,
"aggregate_usage": null,
"amount": 9900,
"billing_scheme": "per_unit",
"created": 1529548131,
"currency": "cad",
"id": "plan_D5TUZ94qhUdjwb",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"nickname": "monthly",
"object": "plan",
"product": "prod_D5TTbUCPvM9h5U",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
}
jibusayone commented
The weird thing is that running sync_plans
command for the second time, successfully does the sync for me.
razvanbalosin commented
@jibusayone In Stripe version 2018-05-21
the field name
has been renamed to nickname
on the plan object. You will have to update actions/plans.py (sync_plans) and models/Plan (name)