From 4b8b33c4fd31ee2738d1716ff90199032d71f0f7 Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Fri, 7 Nov 2025 02:23:58 +0530 Subject: [PATCH] stripe_billing_version should be integer two --- app/views/api/v1/models/_account.json.jbuilder | 2 ++ enterprise/app/jobs/enterprise/billing/credit_sync_job.rb | 2 +- .../enterprise/billing/create_stripe_customer_service.rb | 2 +- .../enterprise/billing/create_stripe_customer_service_spec.rb | 4 ++-- .../enterprise/billing/v2/usage_reporter_service_spec.rb | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/api/v1/models/_account.json.jbuilder b/app/views/api/v1/models/_account.json.jbuilder index 886777017..463db1cd3 100644 --- a/app/views/api/v1/models/_account.json.jbuilder +++ b/app/views/api/v1/models/_account.json.jbuilder @@ -7,6 +7,8 @@ if resource.custom_attributes.present? json.subscription_status resource.custom_attributes['subscription_status'] json.subscription_ends_on resource.custom_attributes['subscription_ends_on'] json.stripe_subscription_id resource.custom_attributes['stripe_subscription_id'] if resource.custom_attributes['stripe_subscription_id'].present? + json.stripe_billing_version resource.custom_attributes['stripe_billing_version'] if resource.custom_attributes['stripe_billing_version'].present? + json.stripe_customer_id resource.custom_attributes['stripe_customer_id'] if resource.custom_attributes['stripe_customer_id'].present? if resource.custom_attributes['pending_stripe_pricing_plan_id'].present? json.pending_stripe_pricing_plan_id resource.custom_attributes['pending_stripe_pricing_plan_id'] end diff --git a/enterprise/app/jobs/enterprise/billing/credit_sync_job.rb b/enterprise/app/jobs/enterprise/billing/credit_sync_job.rb index bfcb7d4a5..6856f5523 100644 --- a/enterprise/app/jobs/enterprise/billing/credit_sync_job.rb +++ b/enterprise/app/jobs/enterprise/billing/credit_sync_job.rb @@ -15,7 +15,7 @@ class Enterprise::Billing::CreditSyncJob < ApplicationJob Rails.logger.info '[CreditSyncJob] Starting credit sync for all accounts' accounts_with_stripe = Account.where( - "custom_attributes->>'stripe_customer_id' IS NOT NULL AND custom_attributes->>'stripe_billing_version' = '2'" + "custom_attributes->>'stripe_customer_id' IS NOT NULL AND custom_attributes->>'stripe_billing_version' = 2" ) synced_count = 0 failed_count = 0 diff --git a/enterprise/app/services/enterprise/billing/create_stripe_customer_service.rb b/enterprise/app/services/enterprise/billing/create_stripe_customer_service.rb index 5fc6bc082..05f8048cf 100644 --- a/enterprise/app/services/enterprise/billing/create_stripe_customer_service.rb +++ b/enterprise/app/services/enterprise/billing/create_stripe_customer_service.rb @@ -57,7 +57,7 @@ class Enterprise::Billing::CreateStripeCustomerService attributes = { stripe_customer_id: customer_id, - stripe_billing_version: '2' + stripe_billing_version: 2 } if hacker_plan_config&.value.present? diff --git a/spec/enterprise/services/enterprise/billing/create_stripe_customer_service_spec.rb b/spec/enterprise/services/enterprise/billing/create_stripe_customer_service_spec.rb index 731a77762..802d56392 100644 --- a/spec/enterprise/services/enterprise/billing/create_stripe_customer_service_spec.rb +++ b/spec/enterprise/services/enterprise/billing/create_stripe_customer_service_spec.rb @@ -54,7 +54,7 @@ describe Enterprise::Billing::CreateStripeCustomerService do expect(Stripe::Customer).to have_received(:create).with({ name: account.name, email: admin1.email }) expect(account.reload.custom_attributes).to include( 'stripe_customer_id' => 'cus_random_number', - 'stripe_billing_version' => '2', + 'stripe_billing_version' => 2, 'stripe_pricing_plan_id' => 'bpp_hacker_123', 'plan_name' => 'Hacker', 'subscribed_quantity' => 2 @@ -79,7 +79,7 @@ describe Enterprise::Billing::CreateStripeCustomerService do expect(Stripe::Customer).not_to have_received(:create) expect(account.reload.custom_attributes).to include( 'stripe_customer_id' => 'cus_existing_v2', - 'stripe_billing_version' => '2', + 'stripe_billing_version' => 2, 'stripe_pricing_plan_id' => 'bpp_hacker_123', 'plan_name' => 'Hacker', 'subscribed_quantity' => 2 diff --git a/spec/enterprise/services/enterprise/billing/v2/usage_reporter_service_spec.rb b/spec/enterprise/services/enterprise/billing/v2/usage_reporter_service_spec.rb index 7bd2ce6e6..354463bb7 100644 --- a/spec/enterprise/services/enterprise/billing/v2/usage_reporter_service_spec.rb +++ b/spec/enterprise/services/enterprise/billing/v2/usage_reporter_service_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe Enterprise::Billing::V2::UsageReporterService do - let(:account) { create(:account, custom_attributes: { 'stripe_billing_version' => '2', 'stripe_customer_id' => 'cus_123' }) } + let(:account) { create(:account, custom_attributes: { 'stripe_billing_version' => 2, 'stripe_customer_id' => 'cus_123' }) } let(:service) { described_class.new(account: account) } describe '#report' do