Transactions
Financial transaction records in Siren — data model, three-layer PHP structure, status lifecycle, REST API, and PHP data access.
Last updated: October 28, 2026
A transaction in Siren represents a commerce event — typically an order, payment, or other monetary exchange coming from an integrated platform such as WooCommerce, EDD, NorthCommerce, or LifterLMS. Transactions sit upstream of conversions in the attribution pipeline: when a transaction is attributed to a collaborator, it produces an engagement and conversion, which in turn triggers an obligation recording what is owed.
Transactions are created automatically by platform integrations when orders come in, or manually through the API. Each transaction carries one or more detail line items that describe the individual products, credits, or debits that make up the total.
In PHP, transactions are organized into three layers. The transaction itself is the header record, linked to a conversion. Transaction details are the line items within that header — individual products, shipping charges, tax amounts, discounts, and fees. Transaction detail attributes are key-value metadata attached to individual line items, such as the product’s category list, SKU, or the collaborators who “own” that product.
The transaction object
| Field | REST name | PHP getter | Type | Description |
|---|---|---|---|---|
| ID | id | getId() | integer | Unique identifier |
| Status | status | getStatus() | string | Current status: complete, cancelled, or refunded |
| Created | dateCreated | getCreatedDate() | datetime | When the record was created |
Transactions are created with a status of complete by default. The status field exists to support transitions like refunds and cancellations.
The TransactionDetail object (line items)
Each transaction contains one or more detail line items describing the individual components of the commerce event.
| Field | REST name | PHP getter | Type | Description |
|---|---|---|---|---|
| ID | id | getId() | integer | Unique identifier |
| Transaction | transactionId | getTransactionId() | integer | The parent transaction this detail belongs to |
| Name | name | getName() | string | Display name (e.g., a product name) |
| Description | description | getDescription() | string | Longer description of the line item |
| Type | type | getType() | string | Type identifier (see detail types below) |
| Value | value | getValue() | integer (REST) / Amount (PHP) | Per-unit value at the currency’s stored scale (hundredths for money, so $19.99 is 1999) |
| Quantity | quantity | getQuantity() | integer | Number of units |
| Units | units | getUnits() | string | Currency code (e.g., USD) |
In PHP, the value field is an Amount object that pairs the integer value with its currency. Call $detail->getValue()->getValue() to get the raw integer (in cents), and $detail->getValue()->getCurrency() to get the Currency model. See The Amount & Currency System for details on working with monetary values.
The value represents the per-unit price, not the line total. Siren calculates line totals internally by multiplying value * quantity.
Detail types
| Type | Description |
|---|---|
product | A product line item (the main purchasable goods) |
subscription | A subscription product line item |
shipping | Shipping charges |
tax | Tax amounts |
discount | Discount amounts (stored as negative values) |
fee | Additional fees (payment processing, handling, etc.) |
refund | Money a refund gave back for one of the sale’s lines (stored as negative values). See Refund lines |
These types correspond directly to the built-in transaction compilers that control which detail types are included in commission calculations. A program configured with the includeLineItems compiler will include product and subscription types; the includeTaxes compiler includes tax types, and so on. See Line Item Filters for a user-level overview of how these filters are configured through the admin UI.
Refund lines
Siren writes a refund on the sale’s own transaction as refund details. Each one gives back part of one sale detail, with a negative value and a quantity of 1, so the transaction’s details add up to what the customer kept. Each carries these attributes:
| Key | Description |
|---|---|
refundOf | The id of the sale detail it gives back |
refundId | The platform’s id for the refund, such as a Shopify or WooCommerce refund id. A refund that came with no id gets one that starts with siren-refund- |
refundedQuantity | How many units of the sale detail the refund returned. Absent when it returned money but no units |
refundedAt | When the refund was recorded, as an ISO 8601 date |
When the platform names the refunded lines, each one gives back its units at the line’s unit price, and money beyond them comes off the shipping, fee, and tax details first. When it sends only an amount, the amount comes off every detail in proportion to what’s left of it. A whole refund gives back whatever each detail has left. A refund with an id is recorded once, and nothing is given back beyond what a detail has left.
A refund of part of an order then works the sale’s unpaid rewards out again from the details as they stand. A refund that leaves the transaction worth nothing reverses the whole sale. See How Refunds Work.
The TransactionDetailAttribute object (line item metadata)
Transaction detail attributes are key-value pairs attached to individual line items. They store metadata that the core transaction detail model doesn’t capture.
| Field | PHP getter | Type | Description |
|---|---|---|---|
| Transaction Detail ID | getTransactionDetailId() | integer | The transaction detail this attribute belongs to |
| Key | getKey() | string | The attribute key (e.g., sku, categories, collaborators) |
| Value | getValue() | mixed | The attribute value (stored as a string; arrays and objects are JSON-encoded) |
Attributes use a compound primary key of transactionDetailId + key, so each line item can have at most one value per key. The identity is accessible through getIdentity() which returns ['transactionDetailId' => ..., 'key' => ...].
Common attribute keys
Siren’s e-commerce integrations populate these attributes on product line items:
| Key | Value format | Description |
|---|---|---|
categories | JSON array of strings | The product’s category names or IDs |
sku | string | The product’s SKU |
collaborators | JSON array of ints | Collaborator IDs associated with (“owning”) this product |
externalId | string | The product ID in the external platform (WooCommerce product ID, EDD download ID, etc.) |
The TransactionSource object (REST only)
Transaction sources describe the integrations that produce transactions. Each source is registered dynamically based on which platform integrations are active.
| Field | Type | Description |
|---|---|---|
id | string | Unique source type identifier (e.g., wc_order) |
name | string | Human-readable display name (e.g., WooCommerce) |
Extended fields (REST only, via ?fields=)
These fields are resolved dynamically by the REST API field resolver system and must be explicitly requested.
| Field | Type | Description |
|---|---|---|
details | object[] | Array of transaction detail objects |
detailCount | integer | Number of detail line items on the transaction |
totalValue | integer or null | Sum of each detail’s value times its quantity, at the currency’s stored scale (hundredths for money), refunds included, so the amount the customer kept. Null when the details are in more than one currency |
totalsByCurrency | object | One total for each currency on the transaction, keyed by currency code. An empty array when there are no details, when totalValue is 0 |
totalQuantity | integer | Sum of the sale’s detail quantities. Refund details aren’t counted |
refundedValue | integer or null | Money refunded so far, as a positive amount. Null when the refunds are in more than one currency |
refunds | object[] | Each refund on the transaction: refundId, refundIdFromPlatform, refundedAt, amount, currency, and its lines (id, refundOf, name, value, quantity, currency). A line’s quantity here is the units the refund returned |
currency | string or null | The details’ currency code. Null when no details exist or the details are in more than one currency |
source | string or null | External source type identifier from the mapping system (e.g., wc_order) |
sourceId | string or null | External source record ID from the mapping system |
Status lifecycle
| Status | Description |
|---|---|
complete | Default state. The transaction represents a successful commerce event. |
cancelled | The transaction has been voided. A refund of the whole order sets it through the CancelRefundedTransactions listener and rejects its conversions. The cancel bulk action sets it too. |
refunded | Set by the refund bulk action. A whole refund from an integration or the refund event sets cancelled instead, and a partial refund leaves the status as it is. |
The cancel and refund bulk actions only change the status. They write no refund details and change no conversion or obligation. To record a refund and adjust the rewards, send it to POST /event/refund.
Unlike conversions and obligations, transactions do not have a soft-delete status. The delete bulk action permanently removes records.
Accessing transaction data
# List transactions with detail counts
curl -X GET "https://your-site.com/wp-json/siren/v1/transactions?fields=id,status,dateCreated,detailCount,totalValue,currency" \
-H "Authorization: Bearer YOUR_TOKEN"
# Get a single transaction with full details
curl -X GET "https://your-site.com/wp-json/siren/v1/transactions/15?fields=id,status,details,totalValue,source,sourceId" \
-H "Authorization: Bearer YOUR_TOKEN" use Siren\Transactions\Core\Datastores\Transaction\Interfaces\TransactionDatastore;
class MyService
{
protected TransactionDatastore $transactions;
public function __construct(TransactionDatastore $transactions)
{
$this->transactions = $transactions;
}
public function getTransaction(int $id): \Siren\Transactions\Core\Models\Transaction
{
return $this->transactions->find($id);
}
} use Siren\Transactions\Core\Facades\Transactions;
$transaction = Transactions::find(42); Siren is built on an event-driven architecture. Transaction records are created as side effects of the normal sale pipeline. The
TransactionCreateServicehandles creation, firesTransactionCreateRequested(allowing listeners to modify or reject the details), and then firesTransactionCreatedon success. If you find yourself creating transactions manually, consider whether firing aSaleTriggeredevent would be more correct.
PHP domain methods
Transaction header methods
Looking up a transaction by conversion
getByConversionId(int $conversionId) retrieves the transaction linked to a specific conversion. Each conversion maps to exactly one transaction. Throws RecordNotFoundException if no transaction exists for that conversion.
use Siren\Transactions\Core\Datastores\Transaction\Interfaces\TransactionDatastore;
use PHPNomad\Datastore\Exceptions\RecordNotFoundException;
class ConversionInspector
{
protected TransactionDatastore $transactions;
public function __construct(TransactionDatastore $transactions)
{
$this->transactions = $transactions;
}
public function getTransactionForConversion(int $conversionId): ?\Siren\Transactions\Core\Models\Transaction
{
try {
return $this->transactions->getByConversionId($conversionId);
} catch (RecordNotFoundException $e) {
return null;
}
}
} use Siren\Transactions\Core\Facades\Transactions;
use PHPNomad\Datastore\Exceptions\RecordNotFoundException;
try {
$transaction = Transactions::getByConversionId($conversionId);
echo 'Transaction #' . $transaction->getId() . ' — status: ' . $transaction->getStatus();
} catch (RecordNotFoundException $e) {
echo 'No transaction found for this conversion.';
} Transaction detail methods
The transaction detail datastore manages individual line items within a transaction.
use Siren\Transactions\Core\Datastores\TransactionDetail\Interfaces\TransactionDetailDatastore;
class MyService
{
protected TransactionDetailDatastore $details;
public function __construct(TransactionDetailDatastore $details)
{
$this->details = $details;
}
} use Siren\Transactions\Core\Facades\TransactionDetails;
$detail = TransactionDetails::find(99); Fetching details for a transaction
getDetailsForTransactionId(int $transactionId) retrieves all line items belonging to a transaction. Returns an array of TransactionDetail models. Throws DatastoreErrorException on failure.
use Siren\Transactions\Core\Datastores\Transaction\Interfaces\TransactionDatastore;
use Siren\Transactions\Core\Datastores\TransactionDetail\Interfaces\TransactionDetailDatastore;
class OrderSummary
{
protected TransactionDatastore $transactions;
protected TransactionDetailDatastore $details;
public function __construct(
TransactionDatastore $transactions,
TransactionDetailDatastore $details
) {
$this->transactions = $transactions;
$this->details = $details;
}
public function summarize(int $conversionId): array
{
$transaction = $this->transactions->getByConversionId($conversionId);
$details = $this->details->getDetailsForTransactionId($transaction->getId());
$summary = [];
foreach ($details as $detail) {
$summary[] = [
'name' => $detail->getName(),
'type' => $detail->getType(),
'unitPrice' => $detail->getValue()->getValue(),
'quantity' => $detail->getQuantity(),
'currency' => $detail->getValue()->getCurrency()->getId(),
];
}
return $summary;
}
} use Siren\Transactions\Core\Facades\Transactions;
use Siren\Transactions\Core\Facades\TransactionDetails;
$transaction = Transactions::getByConversionId($conversionId);
$details = TransactionDetails::getDetailsForTransactionId($transaction->getId());
foreach ($details as $detail) {
$cents = $detail->getValue()->getValue();
$currency = $detail->getValue()->getCurrency()->getId();
echo $detail->getName() . ': ' . $cents . ' ' . $currency
. ' x' . $detail->getQuantity()
. ' (' . $detail->getType() . ')' . PHP_EOL;
} Filtering details by type
Transaction details can be filtered by type using the standard andWhere method. This is useful when you need only the product lines or only the adjustments (shipping, tax, discount, fee) for a given transaction.
use Siren\Transactions\Core\Facades\TransactionDetails;
// Get only the product and subscription line items for a transaction
$lineItems = TransactionDetails::andWhere([
['column' => 'transactionId', 'operator' => '=', 'value' => $transactionId],
['column' => 'type', 'operator' => 'IN', 'value' => ['product', 'subscription']],
]);
// Get only the adjustments (everything except product lines)
$adjustments = TransactionDetails::andWhere([
['column' => 'transactionId', 'operator' => '=', 'value' => $transactionId],
['column' => 'type', 'operator' => 'IN', 'value' => ['shipping', 'tax', 'discount', 'fee']],
]);
Transaction detail attribute methods
The transaction detail attribute datastore manages key-value metadata on individual line items.
use Siren\Transactions\Core\Datastores\TransactionDetailAttribute\Interfaces\TransactionDetailAttributeDatastore;
class MyService
{
protected TransactionDetailAttributeDatastore $attributes;
public function __construct(TransactionDetailAttributeDatastore $attributes)
{
$this->attributes = $attributes;
}
} use Siren\Transactions\Core\Facades\TransactionDetailAttributes;
$sku = TransactionDetailAttributes::getAttributeValue($detailId, 'sku'); Getting an attribute value with a default
getAttributeValue(int $transactionDetailId, string $key, $default = null) retrieves the value for a specific key on a detail, returning the $default if the attribute doesn’t exist.
// Get the SKU, defaulting to 'unknown' if not set
$sku = $this->attributes->getAttributeValue($detailId, 'sku', 'unknown');
// Get categories as a PHP array
$categories = json_decode(
$this->attributes->getAttributeValue($detailId, 'categories', '[]'),
true
); use Siren\Transactions\Core\Facades\TransactionDetailAttributes;
$sku = TransactionDetailAttributes::getAttributeValue($detailId, 'sku', 'unknown');
$categories = json_decode(
TransactionDetailAttributes::getAttributeValue($detailId, 'categories', '[]'),
true
); Getting the full attribute model
getAttribute(int $transactionDetailId, string $key) retrieves the full TransactionDetailAttribute model for a specific key. Unlike getAttributeValue, this throws RecordNotFoundException if the attribute doesn’t exist, and returns the complete model rather than just the value.
use PHPNomad\Datastore\Exceptions\RecordNotFoundException;
try {
$attribute = $this->attributes->getAttribute($detailId, 'sku');
echo 'Key: ' . $attribute->getKey() . ', Value: ' . $attribute->getValue();
} catch (RecordNotFoundException $e) {
// No SKU attribute on this detail
} use Siren\Transactions\Core\Facades\TransactionDetailAttributes;
use PHPNomad\Datastore\Exceptions\RecordNotFoundException;
try {
$attribute = TransactionDetailAttributes::getAttribute($detailId, 'sku');
echo 'Key: ' . $attribute->getKey() . ', Value: ' . $attribute->getValue();
} catch (RecordNotFoundException $e) {
// No SKU attribute on this detail
} Checking product ownership
The collaborators attribute on product line items powers the “must be owner” feature in the includeLineItems transaction compiler. This example checks whether a collaborator is listed as an owner of a specific product line.
use Siren\Transactions\Core\Facades\TransactionDetailAttributes;
$collaboratorsJson = TransactionDetailAttributes::getAttributeValue(
$detailId,
'collaborators',
'null'
);
$owners = json_decode($collaboratorsJson, true);
if (is_array($owners) && in_array($collaboratorId, $owners)) {
echo 'This collaborator owns this product.';
} else {
echo 'This collaborator does not own this product.';
}
Building a full transaction breakdown
This example retrieves a transaction for a conversion and builds a complete financial breakdown, including metadata from detail attributes.
use Siren\Transactions\Core\Facades\Transactions;
use Siren\Transactions\Core\Facades\TransactionDetails;
use Siren\Transactions\Core\Facades\TransactionDetailAttributes;
use PHPNomad\Datastore\Exceptions\RecordNotFoundException;
try {
$transaction = Transactions::getByConversionId($conversionId);
} catch (RecordNotFoundException $e) {
echo 'No transaction for this conversion.';
return;
}
$details = TransactionDetails::getDetailsForTransactionId($transaction->getId());
$totalCents = 0;
foreach ($details as $detail) {
$lineCents = $detail->getValue()->getValue() * $detail->getQuantity();
$totalCents += $lineCents;
echo $detail->getName() . ' (' . $detail->getType() . '): '
. $lineCents . ' ' . $detail->getValue()->getCurrency()->getId()
. PHP_EOL;
// Show SKU for product lines
if ($detail->getType() === 'product') {
$sku = TransactionDetailAttributes::getAttributeValue(
$detail->getId(), 'sku', '(no SKU)'
);
echo ' SKU: ' . $sku . PHP_EOL;
}
}
echo 'Total: ' . $totalCents . ' cents' . PHP_EOL;
Relationships
- Conversion (downstream). When a transaction is attributed to a collaborator (either automatically through an engagement or manually via the credit-collaborator endpoint), it produces a conversion. The conversion references the transaction via
transactionId. - Engagement (downstream, via attribution). Manual attribution through the credit-collaborator endpoint creates an engagement for the collaborator, which in turn produces the conversion.
- Obligation (downstream, via conversion). Each conversion that earns a reward creates an obligation recording what is owed to the collaborator, payable once the conversion is approved. The transaction’s value flows through the conversion into the obligation calculation.
- Transaction Details (children). Each transaction contains one or more detail line items. Details are embedded in the transaction response when the
detailsfield is requested. - Mappings (external link). Transactions originating from platform integrations are linked to their source records via the mapping system, surfaced through the
sourceandsourceIdextended fields.
REST endpoints
See the individual endpoint pages in the sidebar for full request and response details, or browse the all REST endpoints reference.