use stripe subscription status

pull/6819/head
Thibault Duplessis 2020-06-15 10:49:06 -06:00
parent 2f186c3317
commit ab9615f907
2 changed files with 5 additions and 4 deletions

View File

@ -224,7 +224,7 @@ final class PlanApi(
case None =>
logger.warn(s"${user.username} sync: unset DB patron that's not in stripe")
patronColl.update.one($id(patron.id), patron.removeStripe) >> sync(user)
case Some(customer) if customer.firstSubscription.isDefined && !user.plan.active =>
case Some(customer) if customer.firstSubscription.exists(_.isActive) && !user.plan.active =>
logger.warn(s"${user.username} sync: enable plan of customer with a subscription")
setDbUserPlan(user, user.plan.enable) inject ReloadUser
case customer => fuccess(Synced(patron.some, customer))

View File

@ -72,10 +72,11 @@ case class StripeSubscription(
id: String,
plan: StripePlan,
customer: CustomerId,
cancel_at_period_end: Boolean
cancel_at_period_end: Boolean,
status: String
) {
def renew = !cancel_at_period_end
def renew = !cancel_at_period_end
def isActive = status == "active"
}
case class StripeCustomer(