module StripeHelper # Safely call Stripe methods with error handling def safe_stripe_call(&block) # Check if Stripe is properly configured return nil unless Rails.application.config.stripe[:secret_key].present? # Stripe is now initialized at application startup Rails.logger.debug "Using globally initialized Stripe" begin yield if block_given? rescue Stripe::StripeError => e Rails.logger.error "Stripe Error: #{e.message}" nil end end end