Sha256: a7b61f75d554d48d2fc810521989d413ccd8d5b7ca5457e33784cce2b5c81c5d

Contents?: true

Size: 488 Bytes

Versions: 4

Compression:

Stored size: 488 Bytes

Contents

module Tang
  class ChangeSubscription
    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[:base] << e.message
      end

      return subscription
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tang-0.2.0 app/services/tang/change_subscription.rb
tang-0.1.0 app/services/tang/change_subscription.rb
tang-0.0.9 app/services/tang/change_subscription.rb
tang-0.0.8 app/services/tang/change_subscription.rb