Module: Saucy::Subscription::ClassMethods

Defined in:
lib/saucy/subscription.rb

Instance Method Summary collapse

Instance Method Details

#update_subscriptions!Object



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/saucy/subscription.rb', line 282

def update_subscriptions!
  recently_billed = where("next_billing_date <= ?", Time.now)
  recently_billed.each do ||
    begin
      zone = ActiveSupport::TimeZone[Saucy::Configuration.]
      .subscription_status = .subscription.status
      .next_billing_date = zone.parse(.subscription.next_billing_date)
      .save!
      if .past_due?
        BillingMailer.problem().deliver!
      else
        BillingMailer.receipt(, .most_recent_transaction).deliver!
        Saucy::Notifications.notify_observers("billed", :account => )
      end
    rescue Exception => e
      Airbrake.notify(e)
    end
  end
end