Module: ChargebeeRails::Subscription::ClassMethods

Defined in:
lib/chargebee_rails/subscription.rb

Instance Method Summary collapse

Instance Method Details

#estimate(estimation_params) ⇒ Object

Estimates the cost of subscribing to a new subscription

  • Args :

    • estimation_params -> the estimation options permitted for estimating new subscription in chargebee

  • Returns :

    • the chargebee estimate

For more details on the *estimation params for new subscription estimate*, refer Create subscription estimate



117
118
119
120
# File 'lib/chargebee_rails/subscription.rb', line 117

def estimate(estimation_params)
  estimation_params[:trial_end] ||= 0
  ::ChargeBee::Estimate.create_subscription(estimation_params).estimate
end

#estimate_changes(estimation_params) ⇒ Object

Estimates the cost of changes to an existing subscription estimates the upgrade/downgrade or other changes

  • Args :

    • estimation_params -> the estimation options permitted for estimating subscription update in chargebee

  • Returns :

    • the chargebee estimate

For more details on the *estimation params for subscription update estimate*, refer Update subscription estimate



132
133
134
135
136
# File 'lib/chargebee_rails/subscription.rb', line 132

def estimate_changes(estimation_params)
  estimation_params[:include_delayed_charges] ||= ChargebeeRails.configuration.include_delayed_charges[:changes_estimate]
  estimation_params[:prorate] ||= ChargebeeRails.configuration.proration
  ::ChargeBee::Estimate.update_subscription(estimation_params).estimate
end