Class: Susply::ChangeSubscription

Inherits:
Object
  • Object
show all
Defined in:
app/services/susply/change_subscription.rb

Class Method Summary collapse

Class Method Details

.call(owner, new_plan) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/services/susply/change_subscription.rb', line 3

def self.call(owner, new_plan)
  if owner.has_active_subscription?
    Susply::CreatePayment.call(owner.active_subscription, "plan_change")
    Susply::CancelSubscription.call(owner.active_subscription)
  end

  new_subscription = Susply::CreateSubscription.call(owner, new_plan)

  new_subscription
end