fix: Resolve QR code generation errors in checkout email notifications
This fixes the 'data must be a String, QRSegment, or an Array' error that was preventing checkout completion. Changes: - Move email sending outside payment transaction to avoid rollback on email failure - Add error handling around PDF generation in mailers - Improve QR code data building with multiple fallback strategies - Use direct foreign key access instead of through associations for reliability - Add comprehensive logging for debugging QR code issues - Ensure checkout succeeds even if email/PDF generation fails The payment process will now complete successfully regardless of email issues, while still attempting to send confirmation emails with PDF attachments.
This commit is contained in:
@@ -75,9 +75,16 @@ class Order < ApplicationRecord
|
||||
transaction do
|
||||
update!(status: "paid")
|
||||
tickets.update_all(status: "active")
|
||||
|
||||
# Send purchase confirmation email
|
||||
end
|
||||
|
||||
# Send purchase confirmation email outside the transaction
|
||||
# so that payment completion isn't affected by email failures
|
||||
begin
|
||||
TicketMailer.purchase_confirmation_order(self).deliver_now
|
||||
rescue StandardError => e
|
||||
Rails.logger.error "Failed to send purchase confirmation email for order #{id}: #{e.message}"
|
||||
Rails.logger.error e.backtrace.join("\n")
|
||||
# Don't re-raise the error - payment should still succeed
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user