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:
kbe
2025-08-31 10:22:38 +02:00
parent 48c648e2ca
commit 1acc3e09d4
12 changed files with 338 additions and 24 deletions

22
lib/tasks/tickets.rake Normal file
View File

@@ -0,0 +1,22 @@
namespace :tickets do
desc "Clean up expired draft tickets"
task cleanup_expired_drafts: :environment do
puts "Starting cleanup of expired draft tickets..."
CleanupExpiredDraftsJob.perform_now
puts "Cleanup completed."
end
desc "Show stats about draft tickets"
task stats: :environment do
total_drafts = Ticket.draft.count
expired_drafts = Ticket.expired_drafts.count
retryable_drafts = Ticket.can_retry_payment.count
puts "=== Draft Ticket Statistics ==="
puts "Total draft tickets: #{total_drafts}"
puts "Expired draft tickets: #{expired_drafts}"
puts "Retryable draft tickets: #{retryable_drafts}"
puts "Max payment attempts: #{Ticket::MAX_PAYMENT_ATTEMPTS}"
puts "Draft expiry time: #{Ticket::DRAFT_EXPIRY_TIME}"
end
end