Codex Guide: Implement DefyTickets Commerce Workflows
Goal
Fully implement these workflows:
order_successcancel_orderrelease_expired_checkout
The workflows must be strongly typed like the existing workflow system, easy to call from checkout, easy to call later from Stripe webhook, and safe for retries.
Do not implement actual email sending today. Add email steps that only log that email would be sent.
Do not implement Stripe webhook endpoint today. Make workflow inputs ready so webhook can call them tomorrow.
Global prerequisites
1. Fix workflow enum support
Add missing workflow types to system enum and database enum/migration.
Required workflow types:
checkoutorder_successcancel_orderrelease_expired_checkout
The app currently discovers order_success, but Postgres rejects it because system.workflows_workflow_type_enum does not contain order_success.
Fix enum in:
types/enums/system.enums.ts- database migration for
system.workflows.workflow_type - any workflow payload maps/registries
Do this before wiring new workflows.
2. Use TypeORM entity creation correctly
For all repository methods that create entities:
Always use:
repository.create(payload)repository.save(entity)
Do not use raw insert(payload) or save(plainObject) for entities extending base classes.
This applies especially to:
- order
- order item
- order coupon
- ticket link
- checkout session
- payment
- payment intent
- coupon redemption
- inventory reservation
- reservation line
Reason: base entity id/audit/version fields must initialize correctly

