diff --git a/enterprise/app/services/enterprise/billing/topup_checkout_service.rb b/enterprise/app/services/enterprise/billing/topup_checkout_service.rb index e9fd000b8..e896a4d48 100644 --- a/enterprise/app/services/enterprise/billing/topup_checkout_service.rb +++ b/enterprise/app/services/enterprise/billing/topup_checkout_service.rb @@ -5,17 +5,6 @@ class Enterprise::Billing::TopupCheckoutService TOPUP_OPTIONS_CONFIG = 'CHATWOOT_CLOUD_TOPUP_OPTIONS'.freeze - # Used only when CHATWOOT_CLOUD_TOPUP_OPTIONS is not configured, so the - # billing page never breaks during rollout. Real rates live in the config. - FALLBACK_OPTIONS = { - 'usd' => [ - { 'credits' => 1000, 'amount' => 20.0 }, - { 'credits' => 2500, 'amount' => 50.0 }, - { 'credits' => 6000, 'amount' => 100.0 }, - { 'credits' => 12_000, 'amount' => 200.0 } - ] - }.freeze - pattr_initialize [:account!] # Topup packages for the account's billing currency, used by the controller @@ -124,8 +113,6 @@ class Enterprise::Billing::TopupCheckoutService def configured_options config = InstallationConfig.find_by(name: TOPUP_OPTIONS_CONFIG)&.value config = JSON.parse(config) if config.is_a?(String) - config.presence || FALLBACK_OPTIONS - rescue JSON::ParserError - FALLBACK_OPTIONS + config || {} end end diff --git a/spec/enterprise/services/enterprise/billing/topup_checkout_service_spec.rb b/spec/enterprise/services/enterprise/billing/topup_checkout_service_spec.rb index fa4c052a1..2629bdbd9 100644 --- a/spec/enterprise/services/enterprise/billing/topup_checkout_service_spec.rb +++ b/spec/enterprise/services/enterprise/billing/topup_checkout_service_spec.rb @@ -15,6 +15,15 @@ describe Enterprise::Billing::TopupCheckoutService do { 'name' => 'Business', 'product_id' => ['prod_business'], 'price_ids' => ['price_business'] } ]) + create(:installation_config, name: 'CHATWOOT_CLOUD_TOPUP_OPTIONS', value: { + 'usd' => [ + { 'credits' => 1000, 'amount' => 20.0 }, + { 'credits' => 2500, 'amount' => 50.0 }, + { 'credits' => 6000, 'amount' => 100.0 }, + { 'credits' => 12_000, 'amount' => 200.0 } + ] + }) + account.update!( custom_attributes: { plan_name: 'Business', stripe_customer_id: stripe_customer_id }, limits: { 'captain_responses' => 500 }