feat: Implement payment retry system and draft ticket expiry management
- Add 30-minute expiry window for draft tickets with automatic cleanup - Implement 3-attempt payment retry mechanism with tracking - Create background job for cleaning expired draft tickets every 10 minutes - Add comprehensive UI warnings for expiring tickets and retry attempts - Enhance dashboard to display pending draft tickets with retry options - Add payment cancellation handling with smart retry redirections - Include rake tasks for manual cleanup and statistics - Add database fields: expires_at, payment_attempts, last_payment_attempt_at, stripe_session_id - Fix payment attempt counter display to show correct attempt number (1/3, 2/3, 3/3)
This commit is contained in:
23
config/initializers/ticket_cleanup_scheduler.rb
Normal file
23
config/initializers/ticket_cleanup_scheduler.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# Schedule regular cleanup of expired draft tickets
|
||||
#
|
||||
# This will run every 10 minutes to clean up expired draft tickets
|
||||
# If you're using a more sophisticated scheduler like sidekiq or whenever,
|
||||
# you can move this logic there.
|
||||
|
||||
Rails.application.config.after_initialize do
|
||||
# Only run in production and development, not in test
|
||||
unless Rails.env.test?
|
||||
# Schedule the cleanup job to run every 10 minutes
|
||||
Thread.new do
|
||||
loop do
|
||||
begin
|
||||
CleanupExpiredDraftsJob.perform_later
|
||||
rescue => e
|
||||
Rails.logger.error "Failed to schedule expired drafts cleanup: #{e.message}"
|
||||
end
|
||||
|
||||
sleep 10.minutes
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -42,6 +42,7 @@ Rails.application.routes.draw do
|
||||
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"
|
||||
post "events/:slug.:id/tickets/retry", to: "tickets#retry_payment", as: "ticket_retry_payment"
|
||||
|
||||
# Payment routes
|
||||
get "payments/success", to: "tickets#payment_success", as: "payment_success"
|
||||
|
||||
Reference in New Issue
Block a user