From af37e24b173c264320da88d520b9a46d80efb58e Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Fri, 5 Dec 2025 18:38:08 +0530 Subject: [PATCH] add transaction block on subscribe credits and reset response --- .../enterprise/billing/handle_stripe_event_service.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/enterprise/app/services/enterprise/billing/handle_stripe_event_service.rb b/enterprise/app/services/enterprise/billing/handle_stripe_event_service.rb index 57d6ad330..50afe5b41 100644 --- a/enterprise/app/services/enterprise/billing/handle_stripe_event_service.rb +++ b/enterprise/app/services/enterprise/billing/handle_stripe_event_service.rb @@ -54,18 +54,17 @@ class Enterprise::Billing::HandleStripeEventService update_plan_features if billing_period_renewed? - handle_subscription_credits(plan, previous_usage) - account.reset_response_usage + ActiveRecord::Base.transaction do + handle_subscription_credits(plan, previous_usage) + account.reset_response_usage + end elsif plan_changed? handle_plan_change_credits(plan, previous_usage) end end def capture_previous_usage - { - responses: account.custom_attributes['captain_responses_usage'].to_i, - monthly: current_plan_credits[:responses] - } + { responses: account.custom_attributes['captain_responses_usage'].to_i, monthly: current_plan_credits[:responses] } end def current_plan_credits