feat: Implement complete ticket purchasing flow with new TicketsController
- Create new TicketsController with actions for name collection, creation, and checkout - Add dedicated ticket views (new.html.erb, checkout.html.erb, show.html.erb) - Update ticket_selection_controller.js to handle form submission via AJAX - Add store_cart endpoint in EventsController for session-based cart management - Update routes to support new ticket flow: /tickets/new, /create, /checkout - Fix attribute name consistency across views (title→name, starts_at→start_time) - Add Stripe checkout integration with proper error handling - Remove deprecated collect_names flow in favor of streamlined approach The flow is now: Event selection → AJAX cart storage → Name collection → Checkout → Payment
This commit is contained in:
16
bin/debug_env_vars.rb
Executable file
16
bin/debug_env_vars.rb
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env ruby
|
||||
# Debug script to check environment variables and Rails config
|
||||
|
||||
puts "=== Environment Variables ==="
|
||||
puts "STRIPE_PUBLISHABLE_KEY: #{ENV['STRIPE_PUBLISHABLE_KEY'] ? 'SET' : 'NOT SET'}"
|
||||
puts "STRIPE_SECRET_KEY: #{ENV['STRIPE_SECRET_KEY'] ? 'SET' : 'NOT SET'}"
|
||||
puts "STRIPE_WEBHOOK_SECRET: #{ENV['STRIPE_WEBHOOK_SECRET'] ? 'SET' : 'NOT SET'}"
|
||||
puts
|
||||
|
||||
# Load Rails environment
|
||||
require_relative '../config/environment'
|
||||
|
||||
puts "=== Rails Configuration ==="
|
||||
puts "Rails.application.config.stripe: #{Rails.application.config.stripe.inspect}"
|
||||
puts "Secret key present: #{Rails.application.config.stripe[:secret_key].present?}"
|
||||
puts "Publishable key present: #{Rails.application.config.stripe[:publishable_key].present?}"
|
||||
19
bin/debug_stripe_config.rb
Normal file
19
bin/debug_stripe_config.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Test script to verify Stripe configuration in controller context
|
||||
puts "Testing Stripe configuration..."
|
||||
puts "Rails.application.config.stripe:"
|
||||
puts Rails.application.config.stripe.inspect
|
||||
|
||||
puts "\nChecking secret_key:"
|
||||
secret_key = Rails.application.config.stripe[:secret_key]
|
||||
puts "Secret key present: #{secret_key.present?}"
|
||||
puts "Secret key length: #{secret_key.length if secret_key.present?}"
|
||||
|
||||
puts "\nChecking publishable_key:"
|
||||
publishable_key = Rails.application.config.stripe[:publishable_key]
|
||||
puts "Publishable key present: #{publishable_key.present?}"
|
||||
|
||||
puts "\nChecking signing_secret:"
|
||||
signing_secret = Rails.application.config.stripe[:signing_secret]
|
||||
puts "Signing secret present: #{signing_secret.present?}"
|
||||
25
bin/test_controller_stripe.rb
Normal file
25
bin/test_controller_stripe.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Test script to verify Stripe concern methods in actual controller context
|
||||
puts "Testing Stripe concern methods in controller context..."
|
||||
|
||||
# Create a mock request and response
|
||||
request = ActionDispatch::TestRequest.create
|
||||
response = ActionDispatch::TestResponse.create
|
||||
|
||||
# Create an instance of EventsController
|
||||
controller = EventsController.new
|
||||
controller.request = request
|
||||
controller.response = response
|
||||
|
||||
puts "Controller instance created successfully"
|
||||
puts "stripe_configured? method available: #{controller.respond_to?(:stripe_configured?)}"
|
||||
puts "initialize_stripe method available: #{controller.respond_to?(:initialize_stripe)}"
|
||||
|
||||
if controller.respond_to?(:stripe_configured?)
|
||||
puts "stripe_configured? result: #{controller.stripe_configured?}"
|
||||
end
|
||||
|
||||
if controller.respond_to?(:initialize_stripe?)
|
||||
puts "initialize_stripe result: #{controller.initialize_stripe}"
|
||||
end
|
||||
18
bin/test_stripe_check.rb
Executable file
18
bin/test_stripe_check.rb
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Test to simulate the exact check that's happening in the EventsController
|
||||
puts "Testing the exact Stripe configuration check from EventsController..."
|
||||
|
||||
# Simulate the exact check
|
||||
stripe_configured = Rails.application.config.stripe[:secret_key].present?
|
||||
puts "Direct check result: #{stripe_configured}"
|
||||
|
||||
# Check the actual value
|
||||
puts "Secret key value: #{Rails.application.config.stripe[:secret_key]}"
|
||||
|
||||
# Check if it's nil or empty
|
||||
puts "Secret key is nil?: #{Rails.application.config.stripe[:secret_key].nil?}"
|
||||
puts "Secret key is empty?: #{Rails.application.config.stripe[:secret_key].empty?}"
|
||||
|
||||
# Check the type
|
||||
puts "Secret key class: #{Rails.application.config.stripe[:secret_key].class}"
|
||||
21
bin/test_stripe_concern.rb
Executable file
21
bin/test_stripe_concern.rb
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Create a mock controller to test the StripeConcern
|
||||
class TestController
|
||||
include StripeConcern
|
||||
|
||||
def self.name
|
||||
"TestController"
|
||||
end
|
||||
end
|
||||
|
||||
# Test the StripeConcern methods
|
||||
controller = TestController.new
|
||||
|
||||
puts "Testing StripeConcern..."
|
||||
puts "stripe_configured? method exists: #{controller.respond_to?(:stripe_configured?)}"
|
||||
puts "stripe_configured? result: #{controller.stripe_configured?}"
|
||||
|
||||
# Check the Rails configuration directly
|
||||
puts "Rails.application.config.stripe: #{Rails.application.config.stripe}"
|
||||
puts "Secret key present?: #{Rails.application.config.stripe[:secret_key].present?}"
|
||||
@@ -1,42 +1,15 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Test script to verify Stripe configuration and initialization
|
||||
require 'stripe'
|
||||
# Test Stripe configuration
|
||||
puts "Testing Stripe configuration..."
|
||||
puts "STRIPE_PUBLISHABLE_KEY: #{ENV['STRIPE_PUBLISHABLE_KEY']}"
|
||||
puts "STRIPE_SECRET_KEY: #{ENV['STRIPE_SECRET_KEY']}"
|
||||
puts "STRIPE_WEBHOOK_SECRET: #{ENV['STRIPE_WEBHOOK_SECRET']}"
|
||||
|
||||
# Get Stripe keys from environment variables
|
||||
stripe_secret_key = ENV["STRIPE_SECRET_KEY"]
|
||||
# Check if Rails application can access the config
|
||||
puts "\nRails config check:"
|
||||
puts "Rails.application.config.stripe[:publishable_key]: #{Rails.application.config.stripe[:publishable_key]}"
|
||||
puts "Rails.application.config.stripe[:secret_key]: #{Rails.application.config.stripe[:secret_key]}"
|
||||
puts "Rails.application.config.stripe[:signing_secret]: #{Rails.application.config.stripe[:signing_secret]}"
|
||||
|
||||
if stripe_secret_key.nil? || stripe_secret_key.empty?
|
||||
puts "❌ Stripe secret key is not set in environment variables"
|
||||
exit 1
|
||||
end
|
||||
|
||||
puts "✅ Stripe secret key is set"
|
||||
puts "✅ Length of secret key: #{stripe_secret_key.length} characters"
|
||||
|
||||
# Test that Stripe is NOT initialized at this point
|
||||
if Stripe.api_key.nil? || Stripe.api_key.empty?
|
||||
puts "✅ Stripe is not yet initialized (as expected for lazy initialization)"
|
||||
else
|
||||
puts "⚠️ Stripe appears to be pre-initialized (not expected for lazy initialization)"
|
||||
end
|
||||
|
||||
# Now test initializing Stripe during "checkout"
|
||||
puts "🔄 Initializing Stripe during checkout process..."
|
||||
Stripe.api_key = stripe_secret_key
|
||||
|
||||
# Test the API key by retrieving the account information
|
||||
begin
|
||||
account = Stripe::Account.retrieve("self")
|
||||
puts "✅ Stripe API key is properly configured and authenticated"
|
||||
puts "✅ Account ID: #{account.id}"
|
||||
rescue Stripe::AuthenticationError => e
|
||||
puts "❌ Stripe API key authentication failed: #{e.message}"
|
||||
exit 1
|
||||
rescue Stripe::PermissionError => e
|
||||
# This means the key is valid but doesn't have permission to retrieve account
|
||||
puts "✅ Stripe API key is properly configured (limited permissions)"
|
||||
rescue => e
|
||||
puts "❌ Error testing Stripe API key: #{e.message}"
|
||||
exit 1
|
||||
end
|
||||
puts "\nStripe configured?: #{Rails.application.config.stripe[:secret_key].present?}"
|
||||
25
bin/test_stripe_initialization.rb
Executable file
25
bin/test_stripe_initialization.rb
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Test Stripe initialization
|
||||
puts "Testing Stripe initialization..."
|
||||
puts "Rails.application.config.stripe: #{Rails.application.config.stripe}"
|
||||
puts "Secret key present?: #{Rails.application.config.stripe[:secret_key].present?}"
|
||||
|
||||
# Try to initialize Stripe directly
|
||||
begin
|
||||
Stripe.api_key = Rails.application.config.stripe[:secret_key]
|
||||
puts "Stripe successfully initialized with API key"
|
||||
rescue => e
|
||||
puts "Error initializing Stripe: #{e.message}"
|
||||
end
|
||||
|
||||
# Test creating a simple Stripe object
|
||||
begin
|
||||
# This won't actually create a customer, just test if the API key works
|
||||
Stripe::Customer.list(limit: 1)
|
||||
puts "Stripe API connection successful"
|
||||
rescue Stripe::AuthenticationError => e
|
||||
puts "Stripe Authentication Error: #{e.message}"
|
||||
rescue => e
|
||||
puts "Other Stripe Error: #{e.message}"
|
||||
end
|
||||
Reference in New Issue
Block a user