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:
@@ -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?}"
|
||||
Reference in New Issue
Block a user