feat: Checkout worflow using Stripe working.
This commit is contained in:
@@ -65,7 +65,8 @@ module Api
|
|||||||
|
|
||||||
render json: { status: "success", message: "Cart stored successfully" }
|
render json: { status: "success", message: "Cart stored successfully" }
|
||||||
rescue => e
|
rescue => e
|
||||||
Rails.logger.error "Error storing cart: #{e.message}"
|
error_message = e.message.present? ? e.message : "Erreur inconnue"
|
||||||
|
Rails.logger.error "Error storing cart: #{error_message}"
|
||||||
render json: { status: "error", message: "Failed to store cart" }, status: 500
|
render json: { status: "error", message: "Failed to store cart" }, status: 500
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
class EventsController < ApplicationController
|
class EventsController < ApplicationController
|
||||||
include StripeConcern
|
include StripeConcern
|
||||||
|
|
||||||
before_action :authenticate_user!, only: [ :checkout, :process_names, :payment_success, :download_ticket ]
|
before_action :authenticate_user!, only: [ :checkout, :process_names, :download_ticket ]
|
||||||
before_action :set_event, only: [ :show, :checkout, :process_names ]
|
before_action :set_event, only: [ :show, :checkout, :process_names ]
|
||||||
|
|
||||||
# Display all events
|
# Display all events
|
||||||
@@ -92,77 +92,6 @@ class EventsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# Handle successful payment
|
|
||||||
def payment_success
|
|
||||||
session_id = params[:session_id]
|
|
||||||
event_id = params[:event_id]
|
|
||||||
|
|
||||||
# Check if Stripe is properly configured
|
|
||||||
stripe_configured = Rails.application.config.stripe[:secret_key].present?
|
|
||||||
Rails.logger.debug "Payment success - Stripe configured: #{stripe_configured}"
|
|
||||||
|
|
||||||
unless stripe_configured
|
|
||||||
redirect_to dashboard_path, alert: "Le système de paiement n'est pas correctement configuré. Veuillez contacter l'administrateur."
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
# Stripe is now initialized at application startup, no need to initialize here
|
|
||||||
Rails.logger.debug "Payment success - Using globally initialized Stripe"
|
|
||||||
|
|
||||||
begin
|
|
||||||
session = Stripe::Checkout::Session.retrieve(session_id)
|
|
||||||
|
|
||||||
if session.payment_status == "paid"
|
|
||||||
# Create tickets
|
|
||||||
@event = Event.find(event_id)
|
|
||||||
order_items = JSON.parse(session.metadata["order_items"])
|
|
||||||
@tickets = []
|
|
||||||
|
|
||||||
# Get names from session if they exist
|
|
||||||
ticket_names = session.metadata["ticket_names"] ? JSON.parse(session.metadata["ticket_names"]) : {}
|
|
||||||
|
|
||||||
order_items.each do |item|
|
|
||||||
ticket_type = TicketType.find(item["ticket_type_id"])
|
|
||||||
item["quantity"].times do |i|
|
|
||||||
# Get names if this ticket type requires them
|
|
||||||
first_name = nil
|
|
||||||
last_name = nil
|
|
||||||
|
|
||||||
if ticket_type.requires_id
|
|
||||||
name_key = "#{ticket_type.id}_#{i}"
|
|
||||||
names = ticket_names[name_key] || {}
|
|
||||||
first_name = names["first_name"]
|
|
||||||
last_name = names["last_name"]
|
|
||||||
end
|
|
||||||
|
|
||||||
ticket = Ticket.create!(
|
|
||||||
user: current_user,
|
|
||||||
ticket_type: ticket_type,
|
|
||||||
status: "active",
|
|
||||||
first_name: first_name,
|
|
||||||
last_name: last_name
|
|
||||||
)
|
|
||||||
@tickets << ticket
|
|
||||||
|
|
||||||
# Send confirmation email for each ticket
|
|
||||||
TicketMailer.purchase_confirmation(ticket).deliver_now
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Clear session data
|
|
||||||
session.delete(:pending_cart)
|
|
||||||
session.delete(:ticket_names)
|
|
||||||
|
|
||||||
render "payment_success"
|
|
||||||
else
|
|
||||||
redirect_to event_path(@event.slug, @event), alert: "Le paiement n'a pas été complété avec succès"
|
|
||||||
end
|
|
||||||
rescue Stripe::StripeError => e
|
|
||||||
redirect_to dashboard_path, alert: "Erreur lors du traitement de votre confirmation de paiement : #{e.message}"
|
|
||||||
rescue => e
|
|
||||||
redirect_to dashboard_path, alert: "Une erreur inattendue s'est produite : #{e.message}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Download ticket PDF
|
# Download ticket PDF
|
||||||
def download_ticket
|
def download_ticket
|
||||||
@@ -267,7 +196,7 @@ class EventsController < ApplicationController
|
|||||||
payment_method_types: [ "card" ],
|
payment_method_types: [ "card" ],
|
||||||
line_items: line_items,
|
line_items: line_items,
|
||||||
mode: "payment",
|
mode: "payment",
|
||||||
success_url: payment_success_url(event_id: @event.id, session_id: "{CHECKOUT_SESSION_ID}"),
|
success_url: payment_success_url(session_id: "{CHECKOUT_SESSION_ID}"),
|
||||||
cancel_url: event_url(@event.slug, @event),
|
cancel_url: event_url(@event.slug, @event),
|
||||||
customer_email: current_user.email,
|
customer_email: current_user.email,
|
||||||
metadata: {
|
metadata: {
|
||||||
@@ -281,8 +210,9 @@ class EventsController < ApplicationController
|
|||||||
Rails.logger.debug "Redirecting to Stripe session URL: #{session.url}"
|
Rails.logger.debug "Redirecting to Stripe session URL: #{session.url}"
|
||||||
redirect_to session.url, allow_other_host: true
|
redirect_to session.url, allow_other_host: true
|
||||||
rescue Stripe::StripeError => e
|
rescue Stripe::StripeError => e
|
||||||
Rails.logger.error "Stripe error: #{e.message}"
|
error_message = e.message.present? ? e.message : "Erreur Stripe inconnue"
|
||||||
redirect_to event_path(@event.slug, @event), alert: "Erreur de traitement du paiement : #{e.message}"
|
Rails.logger.error "Stripe error: #{error_message}"
|
||||||
|
redirect_to event_path(@event.slug, @event), alert: "Erreur de traitement du paiement : #{error_message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# This controller permit users to create a new ticket for an event,
|
# This controller permit users to create a new ticket for an event,
|
||||||
# complete their details and proceed to payment
|
# complete their details and proceed to payment
|
||||||
class TicketsController < ApplicationController
|
class TicketsController < ApplicationController
|
||||||
before_action :authenticate_user!, only: [ :new ]
|
before_action :authenticate_user!, only: [ :new, :payment_success, :payment_cancel ]
|
||||||
before_action :set_event, only: [ :new ]
|
before_action :set_event, only: [ :new ]
|
||||||
|
|
||||||
# Handle new ticket creation
|
# Handle new ticket creation
|
||||||
@@ -84,7 +84,8 @@ class TicketsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
flash[:alert] = "Une erreur est survenue: #{e.message}"
|
error_message = e.message.present? ? e.message : "Erreur inconnue"
|
||||||
|
flash[:alert] = "Une erreur est survenue: #{error_message}"
|
||||||
redirect_to ticket_new_path(params[:slug], params[:id])
|
redirect_to ticket_new_path(params[:slug], params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -117,12 +118,83 @@ class TicketsController < ApplicationController
|
|||||||
begin
|
begin
|
||||||
@checkout_session = create_stripe_session
|
@checkout_session = create_stripe_session
|
||||||
rescue => e
|
rescue => e
|
||||||
Rails.logger.error "Stripe checkout session creation failed: #{e.message}"
|
error_message = e.message.present? ? e.message : "Erreur Stripe inconnue"
|
||||||
|
Rails.logger.error "Stripe checkout session creation failed: #{error_message}"
|
||||||
flash[:alert] = "Erreur lors de la création de la session de paiement"
|
flash[:alert] = "Erreur lors de la création de la session de paiement"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Handle successful payment
|
||||||
|
def payment_success
|
||||||
|
session_id = params[:session_id]
|
||||||
|
|
||||||
|
# Check if Stripe is properly configured
|
||||||
|
stripe_configured = Rails.application.config.stripe[:secret_key].present?
|
||||||
|
Rails.logger.debug "Payment success - Stripe configured: #{stripe_configured}"
|
||||||
|
|
||||||
|
unless stripe_configured
|
||||||
|
redirect_to dashboard_path, alert: "Le système de paiement n'est pas correctement configuré. Veuillez contacter l'administrateur."
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# Stripe is now initialized at application startup, no need to initialize here
|
||||||
|
Rails.logger.debug "Payment success - Using globally initialized Stripe"
|
||||||
|
|
||||||
|
begin
|
||||||
|
stripe_session = Stripe::Checkout::Session.retrieve(session_id)
|
||||||
|
|
||||||
|
if stripe_session.payment_status == "paid"
|
||||||
|
# Get event_id and ticket_ids from session metadata
|
||||||
|
event_id = stripe_session.metadata["event_id"]
|
||||||
|
ticket_ids_data = stripe_session.metadata["ticket_ids"]
|
||||||
|
|
||||||
|
unless event_id.present? && ticket_ids_data.present?
|
||||||
|
redirect_to dashboard_path, alert: "Informations de commande manquantes"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# Update existing draft tickets to active
|
||||||
|
@event = Event.find(event_id)
|
||||||
|
ticket_ids = ticket_ids_data.split(",")
|
||||||
|
@tickets = current_user.tickets.where(id: ticket_ids, status: "draft")
|
||||||
|
|
||||||
|
if @tickets.empty?
|
||||||
|
redirect_to dashboard_path, alert: "Billets non trouvés"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@tickets.update_all(status: "active")
|
||||||
|
|
||||||
|
# Send confirmation emails
|
||||||
|
@tickets.each do |ticket|
|
||||||
|
TicketMailer.purchase_confirmation(ticket).deliver_now
|
||||||
|
end
|
||||||
|
|
||||||
|
# Clear session data
|
||||||
|
session.delete(:pending_cart)
|
||||||
|
session.delete(:ticket_names)
|
||||||
|
session.delete(:draft_ticket_ids)
|
||||||
|
|
||||||
|
render "payment_success"
|
||||||
|
else
|
||||||
|
redirect_to dashboard_path, alert: "Le paiement n'a pas été complété avec succès"
|
||||||
|
end
|
||||||
|
rescue Stripe::StripeError => e
|
||||||
|
error_message = e.message.present? ? e.message : "Erreur Stripe inconnue"
|
||||||
|
redirect_to dashboard_path, alert: "Erreur lors du traitement de votre confirmation de paiement : #{error_message}"
|
||||||
|
rescue => e
|
||||||
|
error_message = e.message.present? ? e.message : "Erreur inconnue"
|
||||||
|
Rails.logger.error "Payment success error: #{e.class} - #{error_message}"
|
||||||
|
redirect_to dashboard_path, alert: "Une erreur inattendue s'est produite : #{error_message}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Handle payment failure/cancellation
|
||||||
|
def payment_cancel
|
||||||
|
redirect_to dashboard_path, alert: "Le paiement a été annulé"
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@ticket = current_user.tickets.includes(:ticket_type, :event).find(params[:ticket_id])
|
@ticket = current_user.tickets.includes(:ticket_type, :event).find(params[:ticket_id])
|
||||||
@event = @ticket.event
|
@event = @ticket.event
|
||||||
@@ -160,7 +232,7 @@ class TicketsController < ApplicationController
|
|||||||
line_items: line_items,
|
line_items: line_items,
|
||||||
mode: "payment",
|
mode: "payment",
|
||||||
success_url: payment_success_url + "?session_id={CHECKOUT_SESSION_ID}",
|
success_url: payment_success_url + "?session_id={CHECKOUT_SESSION_ID}",
|
||||||
cancel_url: ticket_checkout_url(@event.slug, @event.id),
|
cancel_url: payment_cancel_url,
|
||||||
metadata: {
|
metadata: {
|
||||||
event_id: @event.id,
|
event_id: @event.id,
|
||||||
user_id: current_user.id,
|
user_id: current_user.id,
|
||||||
|
|||||||
@@ -1,41 +1,46 @@
|
|||||||
import { Controller } from "@hotwired/stimulus"
|
import { Controller } from "@hotwired/stimulus";
|
||||||
|
|
||||||
// Controller for handling flash messages
|
// Controller for handling flash messages
|
||||||
// Automatically dismisses messages after a timeout and handles manual closing
|
// Automatically dismisses messages after a timeout and handles manual closing
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
// Define targets for the controller
|
// Define targets for the controller
|
||||||
static targets = ["message"]
|
static targets = ["message"];
|
||||||
|
|
||||||
// Initialize the controller when it connects to the DOM
|
// Initialize the controller when it connects to the DOM
|
||||||
connect() {
|
connect() {
|
||||||
console.log("FlashMessageController mounted", this.element);
|
// console.log("FlashMessageController mounted", this.element);
|
||||||
|
console.log("FlashMessageController mounted");
|
||||||
|
|
||||||
// Initialize Lucide icons for this element if available
|
// Initialize Lucide icons for this element if available
|
||||||
if (typeof lucide !== 'undefined') {
|
if (typeof lucide !== "undefined") {
|
||||||
lucide.createIcons({ within: this.element });
|
lucide.createIcons({ within: this.element });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-dismiss after 2 seconds
|
// Auto-dismiss after 2 seconds
|
||||||
this.timeout = setTimeout(() => {
|
this.timeout = setTimeout(() => {
|
||||||
this.close()
|
this.close();
|
||||||
}, 5000)
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up the timeout when the controller disconnects
|
// Clean up the timeout when the controller disconnects
|
||||||
disconnect() {
|
disconnect() {
|
||||||
if (this.timeout) {
|
if (this.timeout) {
|
||||||
clearTimeout(this.timeout)
|
clearTimeout(this.timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the flash message with a fade-out animation
|
// Close the flash message with a fade-out animation
|
||||||
close() {
|
close() {
|
||||||
// Add opacity transition classes
|
// Add opacity transition classes
|
||||||
this.element.classList.add('opacity-0', 'transition-opacity', 'duration-300')
|
this.element.classList.add(
|
||||||
|
"opacity-0",
|
||||||
|
"transition-opacity",
|
||||||
|
"duration-300",
|
||||||
|
);
|
||||||
|
|
||||||
// Remove element after transition completes
|
// Remove element after transition completes
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.element.remove()
|
this.element.remove();
|
||||||
}, 300)
|
}, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,20 +110,63 @@
|
|||||||
|
|
||||||
<script src="https://js.stripe.com/v3/"></script>
|
<script src="https://js.stripe.com/v3/"></script>
|
||||||
<script>
|
<script>
|
||||||
const stripe = Stripe('<%= Rails.application.config.stripe[:publishable_key] %>');
|
let stripeInstance = null;
|
||||||
|
|
||||||
function redirectToCheckout() {
|
// Initialize Stripe when the script is loaded
|
||||||
stripe.redirectToCheckout({
|
function initializeStripe() {
|
||||||
|
if (typeof Stripe !== 'undefined' && !stripeInstance) {
|
||||||
|
stripeInstance = Stripe('<%= Rails.application.config.stripe[:publishable_key] %>');
|
||||||
|
console.log('Stripe initialized successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to redirect to checkout
|
||||||
|
function redirectToCheckout(buttonElement) {
|
||||||
|
// Ensure Stripe is initialized
|
||||||
|
if (!stripeInstance) {
|
||||||
|
initializeStripe();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stripeInstance) {
|
||||||
|
alert('Erreur: Le système de paiement n\'est pas disponible. Veuillez rafraîchir la page.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show loading state
|
||||||
|
const originalText = buttonElement.innerHTML;
|
||||||
|
buttonElement.disabled = true;
|
||||||
|
buttonElement.innerHTML = '<span class="flex items-center justify-center"><svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>Redirection...</span>';
|
||||||
|
|
||||||
|
stripeInstance.redirectToCheckout({
|
||||||
sessionId: '<%= @checkout_session.id %>'
|
sessionId: '<%= @checkout_session.id %>'
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
alert(result.error.message);
|
alert('Erreur de paiement: ' + result.error.message);
|
||||||
|
// Restore button state
|
||||||
|
buttonElement.disabled = false;
|
||||||
|
buttonElement.innerHTML = originalText;
|
||||||
}
|
}
|
||||||
|
}).catch(function(error) {
|
||||||
|
console.error('Stripe error:', error);
|
||||||
|
alert('Une erreur est survenue. Veuillez réessayer.');
|
||||||
|
// Restore button state
|
||||||
|
buttonElement.disabled = false;
|
||||||
|
buttonElement.innerHTML = originalText;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize Stripe when the page is loaded
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
initializeStripe();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fallback: Try to initialize after a short delay
|
||||||
|
setTimeout(function() {
|
||||||
|
initializeStripe();
|
||||||
|
}, 500);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button onclick="redirectToCheckout()"
|
<button onclick="redirectToCheckout(this)"
|
||||||
class="w-full bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white font-medium py-4 px-6 rounded-xl shadow-sm transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-offset-2 transform hover:-translate-y-0.5">
|
class="w-full bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white font-medium py-4 px-6 rounded-xl shadow-sm transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-offset-2 transform hover:-translate-y-0.5">
|
||||||
<span class="flex items-center justify-center">
|
<span class="flex items-center justify-center">
|
||||||
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
|||||||
150
app/views/tickets/payment_success.html.erb
Executable file
150
app/views/tickets/payment_success.html.erb
Executable file
@@ -0,0 +1,150 @@
|
|||||||
|
<div class="min-h-screen bg-gradient-to-br from-purple-50 to-indigo-50 py-12 px-4 sm:px-6">
|
||||||
|
<div class="max-w-3xl mx-auto">
|
||||||
|
<div class="bg-white rounded-2xl shadow-xl overflow-hidden">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="bg-gradient-to-r from-purple-600 to-indigo-700 px-6 py-8 text-center">
|
||||||
|
<div class="flex justify-center mb-4">
|
||||||
|
<div class="w-16 h-16 rounded-full bg-white/20 flex items-center justify-center">
|
||||||
|
<svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h1 class="text-3xl font-bold text-white mb-2">Paiement réussi !</h1>
|
||||||
|
<p class="text-purple-100">Félicitations pour votre achat</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
<div class="p-6 sm:p-8">
|
||||||
|
<div class="text-center mb-8">
|
||||||
|
<p class="text-xl text-gray-700">
|
||||||
|
Vos billets pour <span class="font-bold text-purple-700"><%= @event.name %></span> ont été achetés avec succès.
|
||||||
|
</p>
|
||||||
|
<p class="text-gray-500 mt-2">
|
||||||
|
Un email de confirmation avec vos billets a été envoyé à <span class="font-medium"><%= current_user.email %></span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Event Details -->
|
||||||
|
<div class="bg-gray-50 rounded-xl p-6 mb-8">
|
||||||
|
<h2 class="text-xl font-bold text-gray-900 mb-4 flex items-center">
|
||||||
|
<svg class="w-5 h-5 mr-2 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
|
||||||
|
</svg>
|
||||||
|
Détails de l'événement
|
||||||
|
</h2>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
<div class="flex items-center p-3 bg-white rounded-lg">
|
||||||
|
<svg class="w-5 h-5 text-purple-500 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path>
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path>
|
||||||
|
</svg>
|
||||||
|
<div>
|
||||||
|
<p class="text-xs text-gray-500">Lieu</p>
|
||||||
|
<p class="font-medium"><%= @event.venue_name %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center p-3 bg-white rounded-lg">
|
||||||
|
<svg class="w-5 h-5 text-purple-500 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||||
|
</svg>
|
||||||
|
<div>
|
||||||
|
<p class="text-xs text-gray-500">Date & Heure</p>
|
||||||
|
<p class="font-medium"><%= @event.start_time.strftime("%d %B %Y à %H:%M") %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tickets -->
|
||||||
|
<div class="mb-8">
|
||||||
|
<h2 class="text-xl font-bold text-gray-900 mb-4 flex items-center">
|
||||||
|
<svg class="w-5 h-5 mr-2 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"></path>
|
||||||
|
</svg>
|
||||||
|
Vos billets
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div class="space-y-4">
|
||||||
|
<% @tickets.each do |ticket| %>
|
||||||
|
<div class="bg-gradient-to-r from-purple-50 to-indigo-50 rounded-xl border border-purple-100 p-5">
|
||||||
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
||||||
|
<div class="flex-1">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div class="w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center mr-4">
|
||||||
|
<svg class="w-5 h-5 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"></path>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="font-bold text-gray-900"><%= ticket.ticket_type.name %></h3>
|
||||||
|
<p class="text-sm text-gray-600">Prix: <span class="font-medium"><%= number_to_currency(ticket.price_cents / 100.0, unit: "€") %></span></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<%= link_to download_ticket_path(ticket, format: :pdf),
|
||||||
|
class: "inline-flex items-center px-4 py-2 bg-gradient-to-r from-purple-600 to-indigo-600 text-white rounded-lg hover:from-purple-700 hover:to-indigo-700 transition-all duration-200 text-sm font-medium shadow-sm" do %>
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
|
||||||
|
</svg>
|
||||||
|
Télécharger PDF
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4 pt-4 border-t border-purple-100 flex items-center justify-between">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<svg class="w-4 h-4 text-gray-500 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"></path>
|
||||||
|
</svg>
|
||||||
|
<span class="text-xs text-gray-500">Code QR: <%= ticket.qr_code[0..7] %></span>
|
||||||
|
</div>
|
||||||
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
|
||||||
|
Actif
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Important Notice -->
|
||||||
|
<div class="bg-blue-50 border border-blue-100 rounded-xl p-5 mb-8">
|
||||||
|
<div class="flex">
|
||||||
|
<svg class="w-5 h-5 text-blue-500 mr-3 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||||
|
</svg>
|
||||||
|
<div>
|
||||||
|
<h3 class="font-bold text-blue-800 mb-1">Important</h3>
|
||||||
|
<p class="text-sm text-blue-700">
|
||||||
|
Veuillez télécharger et sauvegarder vos billets. Présentez-les à l'entrée du lieu pour accéder à l'événement.
|
||||||
|
Un email de confirmation avec vos billets a été envoyé à votre adresse email.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Action Buttons -->
|
||||||
|
<div class="flex flex-col sm:flex-row gap-4 justify-center">
|
||||||
|
<%= link_to dashboard_path,
|
||||||
|
class: "inline-flex items-center justify-center px-6 py-3 bg-gradient-to-r from-purple-600 to-indigo-600 text-white rounded-xl hover:from-purple-700 hover:to-indigo-700 transition-all duration-200 font-medium shadow-sm" do %>
|
||||||
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path>
|
||||||
|
</svg>
|
||||||
|
Tableau de bord
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= link_to events_path,
|
||||||
|
class: "inline-flex items-center justify-center px-6 py-3 bg-white text-gray-700 rounded-xl border border-gray-300 hover:bg-gray-50 transition-all duration-200 font-medium shadow-sm" do %>
|
||||||
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
|
||||||
|
</svg>
|
||||||
|
Voir plus d'événements
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -12,9 +12,7 @@ Rails.application.routes.draw do
|
|||||||
# Defines the root path route ("/")
|
# Defines the root path route ("/")
|
||||||
root "pages#home"
|
root "pages#home"
|
||||||
|
|
||||||
|
|
||||||
# === Devise ===
|
# === Devise ===
|
||||||
|
|
||||||
# Routes for devise authentication Gem
|
# Routes for devise authentication Gem
|
||||||
# Bind devise to user
|
# Bind devise to user
|
||||||
devise_for :users, path: "auth", path_names: {
|
devise_for :users, path: "auth", path_names: {
|
||||||
@@ -45,20 +43,13 @@ Rails.application.routes.draw do
|
|||||||
post "events/:slug.:id/tickets/create", to: "tickets#create", as: "ticket_create"
|
post "events/:slug.:id/tickets/create", to: "tickets#create", as: "ticket_create"
|
||||||
get "events/:slug.:id/tickets/checkout", to: "tickets#checkout", as: "ticket_checkout"
|
get "events/:slug.:id/tickets/checkout", to: "tickets#checkout", as: "ticket_checkout"
|
||||||
|
|
||||||
# Step 2: Checkout
|
# Payment routes
|
||||||
# post "events/:slug.:id/checkout", to: "events#checkout", as: "event_checkout"
|
get "payments/success", to: "tickets#payment_success", as: "payment_success"
|
||||||
# Step 3: Collect names
|
get "payments/cancel", to: "tickets#payment_cancel", as: "payment_cancel"
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Payment success
|
|
||||||
get "payments/success", to: "events#payment_success", as: "payment_success"
|
|
||||||
|
|
||||||
# === Tickets ===
|
# === Tickets ===
|
||||||
get "tickets/:ticket_id/download", to: "events#download_ticket", as: "download_ticket"
|
get "tickets/:ticket_id/download", to: "events#download_ticket", as: "download_ticket"
|
||||||
|
|
||||||
|
|
||||||
# API routes versioning
|
# API routes versioning
|
||||||
namespace :api do
|
namespace :api do
|
||||||
namespace :v1 do
|
namespace :v1 do
|
||||||
@@ -68,11 +59,7 @@ Rails.application.routes.draw do
|
|||||||
post :store_cart
|
post :store_cart
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# resources :bundles, only: [ :index, :show, :create, :update, :destroy ]
|
# resources :ticket_types, only: [ :index, :show, :create, :update, :destroy ]
|
||||||
|
|
||||||
|
|
||||||
# Additional API endpoints can be added here as needed
|
|
||||||
# Example: search, filtering, user-specific endpoints
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user