Skip to main content

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.
data.amount
number
required
Total order amount in the base (USD) currency.
data.event_id
string
required
Firestore document ID of the event.
data.event_name
string
required
Display name of the event.
data.office_id
string
required
ID of the box office (taquilla) processing the order.
data.office_name
string
required
Display name of the box office.
data.status
boolean
required
Order status flag. Pass true for a completed order.
data.client_id
string
required
ID of the client account that owns this event.
data.client_name
string
required
Display name of the client.
data.exchange_rate
number
required
VEF/USD exchange rate applied at the time of purchase.
data.box_office_name
string
required
Name of the physical box office location.
data.box_office_id
string
required
ID of the physical box office location.
data.tickets
array
required
Array of ticket objects included in the order.
data.transactions
array
required
Array of payment transaction objects covering this order.
data.purchaser_info
object
Optional billing purchaser details (used for invoice generation).
data.recipient_info
object
Optional gift recipient details.
data.is_courtesy
boolean
Marks the order as a courtesy (complimentary) order. Defaults to false.
data.is_corporate
boolean
Marks the order as a corporate order. Defaults to false.
data.is_gift
boolean
Marks the order as a gift order. Defaults to false.

What it does

  1. Normalizes each transaction object, stamping a date.created Firestore Timestamp.
  2. Writes the OrderData document to the orders Firestore collection.
  3. 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.
  4. 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

message
string
"Orden Creada "
status
number
200 on success.
data.valido
boolean
true when the order was created successfully.
data.order
string
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

ConditionBehavior
Missing data.transactionsUnhandled exception; ensure the array is always present.
PostgreSQL insert failureFunction throws; Firestore document may already be written.

Build docs developers (and LLMs) love