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,7 +16,7 @@ default: &default
|
||||
username: <%= ENV.fetch("DB_USERNAME") { "root" } %>
|
||||
password: <%= ENV.fetch("DB_PASSWORD") { "root" } %>
|
||||
host: <%= ENV.fetch("DB_HOST") { "127.0.0.1" } %>
|
||||
port: <%= ENV.fetch("DB_port") { 3306 } %>
|
||||
port: <%= ENV.fetch("DB_PORT") { 3306 } %>
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
Rails.application.configure do
|
||||
# Load environment variables from .env file if dotenv is not available
|
||||
env_file = Rails.root.join('.env')
|
||||
if File.exist?(env_file) && !defined?(Dotenv)
|
||||
File.readlines(env_file).each do |line|
|
||||
next if line.strip.empty? || line.start_with?('#')
|
||||
key, value = line.split('=', 2)
|
||||
ENV[key.strip] = value.strip if key && value
|
||||
end
|
||||
end
|
||||
|
||||
# Try to get Stripe keys from environment variables first, then from credentials
|
||||
stripe_publishable_key = ENV["STRIPE_PUBLISHABLE_KEY"]
|
||||
stripe_secret_key = ENV["STRIPE_SECRET_KEY"]
|
||||
@@ -19,7 +29,12 @@ Rails.application.configure do
|
||||
secret_key: stripe_secret_key,
|
||||
signing_secret: stripe_webhook_secret
|
||||
}
|
||||
end
|
||||
|
||||
# Note: Stripe.api_key is NOT set here - it will be set during checkout process
|
||||
Rails.logger.info "Stripe configuration loaded - will initialize during checkout"
|
||||
# Initialize Stripe API key at application startup if secret key is present
|
||||
if stripe_secret_key.present?
|
||||
Stripe.api_key = stripe_secret_key
|
||||
Rails.logger.info "Stripe initialized at application startup"
|
||||
else
|
||||
Rails.logger.warn "Stripe secret key not found - Stripe will not be initialized"
|
||||
end
|
||||
end
|
||||
@@ -37,15 +37,21 @@ Rails.application.routes.draw do
|
||||
get "dashboard", to: "pages#dashboard", as: "dashboard"
|
||||
|
||||
# === Events ===
|
||||
get "events", to: "events#index", as: "events"
|
||||
# Step 1: Show event
|
||||
get "events/:slug.:id", to: "events#show", as: "event"
|
||||
get "events", to: "events#index", as: "events"
|
||||
get "events/:slug.:id", to: "events#show", as: "event"
|
||||
post "events/:slug.:id/store_cart", to: "events#store_cart", as: "store_cart"
|
||||
|
||||
# === Tickets ===
|
||||
get "events/:slug.:id/tickets/new", to: "tickets#new", as: "ticket_new"
|
||||
post "events/:slug.:id/tickets/create", to: "tickets#create", as: "ticket_create"
|
||||
get "events/:slug.:id/tickets/checkout", to: "tickets#checkout", as: "ticket_checkout"
|
||||
|
||||
# Step 2: Checkout
|
||||
post "events/:slug.:id/checkout", to: "events#checkout", as: "event_checkout"
|
||||
# post "events/:slug.:id/checkout", to: "events#checkout", as: "event_checkout"
|
||||
# Step 3: Collect names
|
||||
get "events/:slug.:id/names", to: "events#collect_names", as: "event_collect_names"
|
||||
# get "events/:slug.:id/names", to: "events#collect_names", as: "event_collect_names"
|
||||
# Step 4: Process names
|
||||
post "events/:slug.:id/names", to: "events#process_names", as: "event_process_names"
|
||||
# post "events/:slug.:id/names", to: "events#process_names", as: "event_process_names"
|
||||
|
||||
# Payment success
|
||||
get "payments/success", to: "events#payment_success", as: "payment_success"
|
||||
|
||||
Reference in New Issue
Block a user