module ChargebeeRails::Subscription::ClassMethods

Public Instance Methods

estimate(estimation_params) click to toggle source

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

# File lib/chargebee_rails/subscription.rb, line 132
def estimate(estimation_params)
  estimation_params[:trial_end] ||= 0
  ::ChargeBee::Estimate.create_subscription(estimation_params).estimate
end
estimate_changes(estimation_params) click to toggle source

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

# File lib/chargebee_rails/subscription.rb, line 147
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