transactions_generate creates two records.
Transaction data structure
The fields below are written toorders_transactions in Firestore and the orders_transactions PostgreSQL table.
| Field | Type | Description |
|---|---|---|
amount | number | Amount paid via this payment method in base currency |
amount_currency | string | Currency code of the payment ("USD", "VEF") |
amount_exchange | number | Equivalent amount in local currency (bolivars) |
amount_exchange_rate | number | Exchange rate used for conversion |
client_id | string | ID of the event organizer |
client_name | string | Display name of the event organizer |
date.created | Timestamp | Timestamp set by transactions_generate |
date.updated | Timestamp | Timestamp set by transactions_generate |
event_id | string | Firestore ID of the parent event |
event_name | string | Display name of the event |
office_id | string | ID of the box office |
office_name | string | Display name of the box office |
order_id | string | Firestore document ID of the parent order |
payment_id | string | Identifier for the payment method type |
payment_name | string | Human-readable payment method name |
payment_data | object | Payment-method-specific reference data (see below) |
status | boolean | true when the transaction is active/valid |
custody_account.id | string | ID of the custody account that received the funds |
custody_account.name | string | Display name of the custody account |
custody_account.account_number | string | Account number of the custody account |
point_sale_tmt | boolean | true if the transaction was made through TMT’s own POS |
amount_type | string | Set to "payment" by transactions_generate before writing to the custody account sub-collection |
order_transaction_id | string | The Firestore document ID assigned to this transaction |
payment_data variants
Thepayment_data object shape varies by payment method.
Pago Móvil / Mobile payment:
transactions_generate inspects the payment_data object for the presence of email, account_number, or bank to determine which variant to serialize into PostgreSQL.transactions_generate
Creates oneorders_transactions document per transaction item, copies each transaction to the corresponding custody account’s sub-collection, and marks all purchased tickets as sold in both Firestore and PostgreSQL.
Trigger: POST /transactions_generate (called internally by order_process via Firebase callable)
What it does
- For each transaction in
TransactionData:- Generates a new Firestore document ID for the transaction.
- Sets
date.createdanddate.updatedto the current server timestamp. - Writes the transaction to
orders_transactions/{idtransaction}. - Sets
amount_type = "payment"and writes the transaction tocustody_accounts/{custody_account.id}/transactions/. - Appends a row to the
orders_transactionsPostgreSQL table.
- Queries the
ticketsPostgreSQL table for the currentledgerof each purchased ticket. - Appends a
{ action: "sold" }entry to each ticket’s ledger. - Updates
status = false(sold) on each ticket in Firestore (events/{event_id}/tickets/{id}) and PostgreSQL (tickets). - Looks up the buyer’s
u_usersdocument bycustomer_emailand copies each purchased ticket document intou_users/{uid}/tickets/{ticket_id}.
Request
Array of transaction objects built by
order_process. Each entry must include amount, client_id, client_name, event_id, event_name, office_id, office_name, order_id, payment_data, payment_id, payment_name, status, custody_account, amount_currency, amount_exchange, amount_exchange_rate, and point_sale_tmt.Array of
ticket_id strings (in {event_id}-{doc_id} format) for the tickets being purchased.The event ID — used to locate ticket documents.
The buyer’s email — used to find their
u_users record.Initial UID value. Overwritten at runtime with the actual UID found by email lookup.
Response
true when all transactions and ticket updates completed successfully.transactions_validate
Validates a specific payment reference against an existing order and marks the matching transaction as validated (status: true) in Firestore.
Trigger: POST /transactions_validate
What it does
- Reads the order document from
orders/{idOrder}. - Iterates the order’s
transactionsarray. - For each transaction, if
payment_datamatches the suppliedpayment_datavalue, setsstatus: trueon that transaction entry. - Writes the updated
transactionsarray back to the order document via a batched Firestore update.
Request
The Firestore document ID of the order to validate.
The payment reference string to match against. The transaction whose
payment_data equals this value will have its status set to true.Response
Error response
true when validation succeeded. false when the order document was not found.Where transactions are stored
Aftertransactions_generate runs, each transaction exists in three places:
custody_accounts/{id}/transactions/ fires the custody_process Firestore trigger, which increments balance_available on the custody account document.