-
-
Notifications
You must be signed in to change notification settings - Fork 78
Subscriptions refactor #222
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
Conversation
| @@ -0,0 +1,145 @@ | |||
| class SubscriptionService < Service | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Controllers to Services! Love it!
|
|
||
| def self.transition_plan user:, old_plan:, new_plan:, stripe_object: nil | ||
| # Fetch the user's current Stripe information | ||
| stripe_object ||= SubscriptionService.stripe_customer_object_for(current_user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance this could still return nil?
| ) | ||
|
|
||
| report_subscription_change_to_slack current_user, old_billing_plan, new_billing_plan | ||
| SubscriptionService.report_subscription_change_to_slack current_user, old_billing_plan, new_billing_plan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooo didn't realize this was a thing!
| add_referral_benefits_to( | ||
| referree: user | ||
| referrer: user.referrer || user # if a user wasn't referred by anyone, we treat them as referring themselves <3 | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected token tRPAREN
| add_first_time_premium_benefits_to(user) | ||
| add_referral_benefits_to( | ||
| referree: user | ||
| referrer: user.referrer || user # if a user wasn't referred by anyone, we treat them as referring themselves <3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected token tIDENTIFIER
| SubscriptionService.add_referral_benefits_to( | ||
| referree: current_user | ||
| referrer: current_user.referrer || current_user | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected token tRPAREN
| SubscriptionService.add_first_time_premium_benefits_to(current_user) | ||
| SubscriptionService.add_referral_benefits_to( | ||
| referree: current_user | ||
| referrer: current_user.referrer || current_user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected token tIDENTIFIER
| success = SubscriptionService.transition_plan( | ||
| user: current_user, | ||
| old_plan: BillingPlan.find(current_user.selected_billing_plan_id) | ||
| new_plan: BillingPlan.find(new_plan_id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected token tIDENTIFIER
unexpected token tCOMMA
|
Replaced by #263 |
Work in progress, not ready to merge and needs tested