feat: Refactor cart storage to use API architecture
Move store_cart functionality from main EventsController to API namespace: - Add store_cart method to Api::V1::EventsController with API key bypass - Remove store_cart from main EventsController - Update routes to use RESTful API endpoint structure - Maintain session-based cart storage for frontend compatibility
This commit is contained in:
@@ -6,7 +6,7 @@ class EventsController < ApplicationController
|
||||
include StripeConcern
|
||||
|
||||
before_action :authenticate_user!, only: [ :checkout, :process_names, :payment_success, :download_ticket ]
|
||||
before_action :set_event, only: [ :show, :checkout, :process_names, :store_cart ]
|
||||
before_action :set_event, only: [ :show, :checkout, :process_names ]
|
||||
|
||||
# Display all events
|
||||
def index
|
||||
@@ -91,16 +91,6 @@ class EventsController < ApplicationController
|
||||
process_payment(cart_data)
|
||||
end
|
||||
|
||||
# Store cart data in session (AJAX endpoint)
|
||||
def store_cart
|
||||
cart_data = params[:cart] || {}
|
||||
session[:pending_cart] = cart_data
|
||||
|
||||
render json: { status: "success", message: "Cart stored successfully" }
|
||||
rescue => e
|
||||
Rails.logger.error "Error storing cart: #{e.message}"
|
||||
render json: { status: "error", message: "Failed to store cart" }, status: 500
|
||||
end
|
||||
|
||||
# Handle successful payment
|
||||
def payment_success
|
||||
|
||||
Reference in New Issue
Block a user