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

Error when applying complimentary plan to member #11765

Closed
kevinansfield opened this issue Apr 22, 2020 · 10 comments
Closed

Error when applying complimentary plan to member #11765

kevinansfield opened this issue Apr 22, 2020 · 10 comments
Assignees
Labels
bug [triage] something behaving unexpectedly

Comments

@kevinansfield
Copy link
Contributor

kevinansfield commented Apr 22, 2020

Originally reported at https://forum.ghost.org/t/complimentary-premium-plan-return-an-error/13738/1

The only problem I have at the moment is in the complimentary Premium Plan. When I select a member, change the toggle and hit save it return this.

Internal server error, cannot edit a member. Cannot read property ‘id’ of undefined
But I’m able to add notes change the name and save just not a complimentary option.

TypeError: Cannot read property 'id' of undefined
        at StripePaymentProcessor.setComplimentarySubscription (/home/ghost/node_modules/@tryghost/members-api/lib/stripe/index.js:252:45)

(Internal discussion for future reference https://ghost.slack.com/archives/C02G9E68C/p1587559818050500)

@kevinansfield kevinansfield added the bug [triage] something behaving unexpectedly label Apr 22, 2020
@kevinansfield kevinansfield self-assigned this Apr 22, 2020
@kevinansfield
Copy link
Contributor Author

There appear to be two causes for this so far:

  1. If the monthly/yearly price is set to 0 we have a hash collision with plan identifiers that results in the complimentary plan not being created
  2. Something within the upgrade process resulting in the complimentary plan not being created

@allouis
Copy link
Contributor

allouis commented Jun 12, 2020

This is in progress in this WIP PR: https://github.com/TryGhost/Members/pull/167/files

Was a little slower than I'd have liked due to looking at the new "Prices" from Stripe and trying to use that, I think it's worth it though as this cleans up a lot of things!

@allouis
Copy link
Contributor

allouis commented Jun 16, 2020

Closing in favour of https://github.com/TryGhost/Members/issues/168

@allouis allouis closed this as completed Jun 16, 2020
@matthanley
Copy link
Contributor

Repro case from @kevinansfield:

My repro steps:

  1. change yearly pricing to 0 + save
  2. change currency to one not used before + save
  3. create a new member
  4. try to apply complimentary plan

Monthly/yearly plans set to zero-value isn't a valid use-case with the current plan implementation, so this can be fixed with additional validation on plan prices.

@matthanley matthanley reopened this Jun 25, 2020
@allouis
Copy link
Contributor

allouis commented Jun 25, 2020

https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts <-- resource for when we do validation

@ErisDS
Copy link
Member

ErisDS commented Jun 25, 2020

The solution to this should be validating that the values are not < 1. This works for all currencies we support. There will be a larger refactor of currency support soon.

allouis added a commit to allouis/Ghost-Admin that referenced this issue Jun 30, 2020
allouis added a commit to allouis/Ghost-Admin that referenced this issue Jul 1, 2020
allouis added a commit to allouis/Ghost-Admin that referenced this issue Jul 2, 2020
allouis added a commit to allouis/Ghost-Admin that referenced this issue Jul 2, 2020
allouis added a commit to allouis/Ghost-Admin that referenced this issue Jul 2, 2020
allouis added a commit to allouis/Ghost that referenced this issue Jul 2, 2020
refs TryGhost#11765

This ensures that plans will always be set to 1 of the currency
allouis added a commit to TryGhost/Admin that referenced this issue Jul 3, 2020
refs TryGhost/Ghost#11765

Adds handling to disallow plans of less than 1

Co-authored-by: Matt Hanley <3798302+matthanley@users.noreply.github.com>
allouis added a commit that referenced this issue Jul 3, 2020
refs #11765

This ensures that plans will always be set to 1 of the currency
@allouis
Copy link
Contributor

allouis commented Jul 3, 2020

The Ghost API & Admin no longer allow creating plans with an amount of 0. So future installs/setups should not run into this problems.

We have not removed existing 0 amount plans, but they may still cause issues with Complimentary plans, the fix would be to update your plans to have an amount of 1 or more ☺️

@sbounmy
Copy link

sbounmy commented Aug 4, 2020

This is still occuring for me on 3.27.0. Any idea ?
Plan is on 5e / month
Image of screensot

@sbounmy
Copy link

sbounmy commented Aug 18, 2020

@allouis bump ! still occuring with 3.29.1

I made sure my plan's price is > 0
Screenshot 2020-08-18 at 10 45 46

@allouis
Copy link
Contributor

allouis commented Aug 19, 2020

@sbounmy If you think this is still a bug on the latest version, would you be able to open an issue with reproducible steps and stack traces from the errors and any other useful info? Thanks ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [triage] something behaving unexpectedly
Projects
None yet
Development

No branches or pull requests

5 participants