order_created
POST https://{region}-{project}.cloudfunctions.net/order_created
Creates a new order document in the orders Firestore collection and inserts a corresponding row into the PostgreSQL orders table. All transactions and ticket metadata are normalized and stored.
Request body
All fields are nested under a top-level data key.
Total order amount in the base (USD) currency.
Firestore document ID of the event.
Display name of the event.
ID of the box office (taquilla) processing the order.
Display name of the box office.
Order status flag. Pass true for a completed order.
ID of the client account that owns this event.
Display name of the client.
VEF/USD exchange rate applied at the time of purchase.
Name of the physical box office location.
ID of the physical box office location.
Array of ticket objects included in the order. Composite ticket identifier in the format {event_id}-{ticket_doc_id}.
Face value of this ticket.
Internal ticket type / zone ID.
Attendee details written back to the ticket document. data.tickets[].metadata.customer_email
Attendee email address.
data.tickets[].metadata.customer_id
Attendee national ID (cédula).
data.tickets[].metadata.customer_name
Attendee full name.
data.tickets[].metadata.customer_phone
Attendee phone number.
data.tickets[].metadata.customer_address
Attendee address. Defaults to empty string.
data.tickets[].metadata.customer_country
Attendee country object { code, name, key }. Defaults to { code: "ve", name: "Venezuela", key: 0 }.
data.tickets[].metadata.customer_id_type
ID document type prefix (e.g. "V", "E"). Defaults to "V".
false for unsold/pending tickets that need attendee data written.
Array of payment transaction objects covering this order. data.transactions[].amount
Amount charged in the base currency for this transaction leg.
data.transactions[].amount_currency
Currency code of the original charge, e.g. "USD" or "VEF".
data.transactions[].amount_exchange
Amount in the local (VEF) equivalent.
data.transactions[].amount_exchange_rate
Exchange rate used for amount_exchange.
data.transactions[].payment_id
Payment method identifier (e.g. Stripe PaymentIntent ID, Mercantil reference).
data.transactions[].payment_name
Human-readable payment method name (e.g. "Stripe", "Mercantil TDD").
data.transactions[].payment_data
Raw payment gateway response data stored for reference.
data.transactions[].status
true if this transaction leg succeeded.
data.transactions[].custody_account
Bank account where funds are held. Show custody_account fields
data.transactions[].custody_account.id
Custody account document ID.
data.transactions[].custody_account.name
Display name of the custody account.
data.transactions[].custody_account.account_number
Bank account number.
data.transactions[].point_sale_tmt
true when the sale originates from a TMT-owned point of sale (triggers conciliation flow instead of direct payout split).
Optional billing purchaser details (used for invoice generation).
Optional gift recipient details.
Marks the order as a courtesy (complimentary) order. Defaults to false.
Marks the order as a corporate order. Defaults to false.
Marks the order as a gift order. Defaults to false.
What it does
Normalizes each transaction object, stamping a date.created Firestore Timestamp.
Writes the OrderData document to the orders Firestore collection.
Inserts a row into the PostgreSQL orders table with fields: id, amount, client_id, client_name, date_created, event_id, event_name, office_id, office_name, status, status_type_id, status_type_name, tickets, transactions, exchange_rate, box_office_name, box_office_id.
status_type is always set to { id: "completed", name: "Completada" } at creation.
The Firestore onDocumentCreated trigger order_process fires automatically after this call completes.
Response
true when the order was created successfully.
The Firestore document ID of the newly created order.
Example
curl -X POST \
https://{region}-{project}.cloudfunctions.net/order_created \
-H 'Content-Type: application/json' \
-d '{
"data": {
"amount": 50.00,
"event_id": "evt_abc123",
"event_name": "Gran Concierto 2026",
"office_id": "off_xyz",
"office_name": "Taquilla Central",
"status": true,
"client_id": "client_001",
"client_name": "Promotora XYZ",
"exchange_rate": 36.50,
"box_office_name": "Taquilla A",
"box_office_id": "boff_001",
"is_courtesy": false,
"is_corporate": false,
"is_gift": false,
"tickets": [
{
"ticket_id": "evt_abc123-tkt_001",
"amount": 50.00,
"id": "zone_general",
"status": false,
"metadata": {
"customer_email": "[email protected] ",
"customer_id": "12345678",
"customer_name": "Juan Pérez",
"customer_phone": "04141234567",
"customer_id_type": "V"
}
}
],
"transactions": [
{
"amount": 50.00,
"amount_currency": "USD",
"amount_exchange": 1825.00,
"amount_exchange_rate": 36.50,
"payment_id": "pi_3ABC",
"payment_name": "Stripe",
"payment_data": {},
"status": true,
"point_sale_tmt": false,
"custody_account": {
"id": "acct_stripe_usd",
"name": "Cuenta USD Stripe",
"account_number": "000123"
}
}
]
}
}'
Errors
Condition Behavior Missing data.transactions Unhandled exception; ensure the array is always present. PostgreSQL insert failure Function throws; Firestore document may already be written.