Retrieve a ticket PDF file that was generated after successful payment processing. This endpoint returns the actual PDF file that can be displayed, downloaded, or sent to customers.
Tickets are automatically generated when the fulfillment service receives a payment-succeeded event from Kafka. This endpoint allows you to retrieve the generated PDF after it has been created.
The ticket generation process is fully event-driven and asynchronous:
Payment succeeds - The payment service publishes a payment-succeeded event to Kafka
Event consumed - The fulfillment service listens on the payment-succeeded topic
Order enrichment - The service fetches additional order details from the ordering service
Ticket creation - A ticket record is created with status pending
PDF generation - A PDF is generated with event details, seat info, and QR code
Storage - The PDF is saved to the local filesystem (/app/data/tickets/{ticketId}.pdf)
Database update - The ticket record is updated with status generated and the PDF path
Event publishing - A ticket-issued event is published to notify other services
Ticket generation is idempotent. If the fulfillment service receives multiple payment-succeeded events for the same order (e.g., due to event replay), it will only generate one ticket.
QR code data string in the format {orderId}:{seatNumber}:{eventId}. This QR code is embedded in the PDF and can be scanned at the venue for validation.
Tickets are stored on the local filesystem with a Docker volume mount for persistence.
In production, you should replace the local filesystem storage with a cloud storage solution like AWS S3, Azure Blob Storage, or Google Cloud Storage for better scalability and availability.
The fulfillment service subscribes to the payment-succeeded topic and processes events automatically.Source code reference: services/fulfillment/src/Infrastructure/Events/PaymentSucceededEventConsumer.cs:1-171Consumer configuration:
Topic: payment-succeeded
Consumer Group: Defined in Kafka__ConsumerGroupId environment variable
Auto Offset Reset: Earliest (processes all messages from the beginning)
After successful ticket generation, the service publishes a ticket-issued event that can be consumed by notification services to email tickets to customers.
Wait for ticket generation - After receiving payment confirmation, wait a few seconds before attempting to retrieve the ticket PDF. The ticket generation is asynchronous and may take 1-3 seconds to complete.
Implement polling or webhooks - For better UX, either:
Poll the endpoint every 1-2 seconds until the ticket is available
Subscribe to the ticket-issued Kafka topic to get notified when generation completes
Use WebSockets for real-time ticket availability notifications
Cache tickets appropriately - Once retrieved, cache ticket PDFs on the client side or in a CDN. Don’t repeatedly download the same ticket as it creates unnecessary load on the storage system.