stripe_billing_version should be integer two

This commit is contained in:
Tanmay Deep Sharma
2025-11-07 02:29:37 +05:30
parent b7035de400
commit 4b8b33c4fd
5 changed files with 7 additions and 5 deletions
@@ -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
@@ -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
@@ -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?
@@ -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
@@ -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