feat: Add APIs for limit check in accounts (#7242)

This commit is contained in:
Shivam Mishra
2023-06-16 08:41:40 +05:30
committed by GitHub
parent 0d465362ac
commit e8a27bea4b
9 changed files with 223 additions and 5 deletions

View File

@@ -18,16 +18,25 @@ class Enterprise::Billing::HandleStripeEventService
# skipping self hosted plan events
return if plan.blank? || account.blank?
update_account_attributes(subscription, plan)
change_plan_features
end
def update_account_attributes(subscription, plan)
# https://stripe.com/docs/api/subscriptions/object
account.update(
custom_attributes: {
stripe_customer_id: subscription.customer,
stripe_price_id: subscription['plan']['id'],
stripe_product_id: subscription['plan']['product'],
plan_name: plan['name'],
subscribed_quantity: subscription['quantity']
subscribed_quantity: subscription['quantity'],
subscription_status: subscription['status'],
subscription_ends_on: Time.zone.at(subscription['current_period_end'])
}
)
change_plan_features
end
def process_subscription_deleted