Class: Tang::ChangeSubscription
- Inherits:
-
Object
- Object
- Tang::ChangeSubscription
- Defined in:
- app/services/tang/change_subscription.rb
Class Method Summary collapse
Class Method Details
.call(subscription, plan) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/services/tang/change_subscription.rb', line 3 def self.call(subscription, plan) return subscription if !subscription.valid? begin stripe_sub = Stripe::Subscription.retrieve(subscription.stripe_id) stripe_sub.plan = plan.stripe_id stripe_sub.save subscription.plan = plan subscription.save! rescue Stripe::StripeError => e subscription.errors.add(:base, :invalid, message: e.) end return subscription end |