Module: Saucy::Subscription::ClassMethods

Defined in:
lib/saucy/subscription.rb

Instance Method Summary collapse

Instance Method Details

#update_subscriptions!Object



222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/saucy/subscription.rb', line 222

def update_subscriptions!
  recently_billed = where("next_billing_date <= ?", Time.now)
  recently_billed.each do ||
    .subscription_status = .subscription.status
    .next_billing_date = .subscription.next_billing_date
    .save!
    if .past_due?
      BillingMailer.problem(, .subscription.transactions.last).deliver!
    else
      BillingMailer.receipt(, .subscription.transactions.last).deliver!
    end
  end
end