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,26 +1,11 @@
|
||||
module StripeHelper
|
||||
# Check if Stripe is properly configured
|
||||
def stripe_configured?
|
||||
Rails.application.config.stripe[:secret_key].present?
|
||||
end
|
||||
|
||||
# Initialize Stripe with the configured API key
|
||||
def initialize_stripe
|
||||
return false unless stripe_configured?
|
||||
|
||||
Stripe.api_key = Rails.application.config.stripe[:secret_key]
|
||||
true
|
||||
rescue => e
|
||||
Rails.logger.error "Failed to initialize Stripe: #{e.message}"
|
||||
false
|
||||
end
|
||||
|
||||
# Safely call Stripe methods with error handling
|
||||
def safe_stripe_call(&block)
|
||||
return nil unless stripe_configured?
|
||||
# Check if Stripe is properly configured
|
||||
return nil unless Rails.application.config.stripe[:secret_key].present?
|
||||
|
||||
# Initialize Stripe if not already done
|
||||
initialize_stripe unless Stripe.api_key.present?
|
||||
# Stripe is now initialized at application startup
|
||||
Rails.logger.debug "Using globally initialized Stripe"
|
||||
|
||||
begin
|
||||
yield if block_given?
|
||||
|
||||
2
app/helpers/tickets_helper.rb
Normal file
2
app/helpers/tickets_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module TicketsHelper
|
||||
end
|
||||
Reference in New Issue
Block a user