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

BUG - Cannot sync plans: KeyError: 'name' #572

Open
nortigo opened this issue Jun 25, 2018 · 2 comments
Open

BUG - Cannot sync plans: KeyError: 'name' #572

nortigo opened this issue Jun 25, 2018 · 2 comments

Comments

@nortigo
Copy link

nortigo commented Jun 25, 2018

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

  1. Create a plan directly into Stripe
  2. 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
Copy link

jibusayone commented Mar 17, 2019

The weird thing is that running sync_plans command for the second time, successfully does the sync for me.

@razvanbalosin
Copy link

@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)

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

3 participants