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 |account|
begin
zone = ActiveSupport::TimeZone[Saucy::Configuration.merchant_account_time_zone]
account.subscription_status = account.subscription.status
account.next_billing_date = zone.parse(account.subscription.next_billing_date)
account.save!
if account.past_due?
BillingMailer.problem(account).deliver!
else
BillingMailer.receipt(account, account.most_recent_transaction).deliver!
Saucy::Notifications.notify_observers("billed", :account => account)
end
rescue Exception => e
Airbrake.notify(e)
end
end
end
|