slack-strava
slack-strava copied to clipboard
Warn that a subscription expires within two weeks and offer to renew
If you cancel a subscription at period end, but keep using the bot, it won't warn you that the subscription is going to expire. It will then cancel and it's not obvious that a user needs to subscribe again.
- Warn that the subscription is going to expire.
- Change the expired text to say to use
subscribeto create a new subscription.
For starters, do #163
Something like
logger.info "Checking Stripe subscriptions for #{Team.striped.count} team(s)."
Team.active.striped.each do |team|
customer = Stripe::Customer.retrieve(team.stripe_customer_id)
if customer.subscriptions.none? && team.subscribed?
logger.info "No active subscriptions for #{team} (#{team.stripe_customer_id}), downgrading."
else
customer.subscriptions.each do |subscription|
subscription_name = "#{subscription.plan.name} (#{ActiveSupport::NumberHelper.number_to_currency(subscription.plan.amount.to_f / 100)})"
logger.info "Checking #{team} subscription to #{subscription_name}, #{subscription.status}."
case subscription.status
when 'active'
if subscription.cancel_at_period_end && (Time.now + 2.weeks > subscription.current_period_end)
logger.warn "Subscription for #{team} is active, but expires in under two weeks on #{subscription.current_period_end}."
end
end
end
end
end
Likely not worth it, out of hundreds of subscriptions not one active is not set to auto-renew.