curl "https://api.payload.com/transactions" \
-u secret_key_3bW9JMZtPVDOfFNzwRdfE: \
-d "fields[]=*" \
-d "fields[]=ledger"
The transaction ledger contains the associations between all transaction activity, for example the reference between an original payment and a resulting refund. Each transaction has a nested list of ledger entries with all related ledger entries for a transaction.
By default, the ledger array is not returned in a Transaction object.
The nested ledger list can be included in the response by requesting the ledger
attribute be part of the response.
{
"id": "txn_3bW9JN4OPJXdUyrK5VZQG",
"object": "transaction",
"amount": 29.99,
"created_at": "2020-01-01 21:41:04",
"payment_method_id": "pm_3bW9JMoT2CKw8DQ1yFyG8",
"status": "processed",
"type": "payment",
"ledger": [{
"amount": -29.99,
"assoc_transaction_id": "txn_3bW9JN8cF50sSYDtI5X0a",
"timestamp": "2020-01-04 18:30:09",
"entry_type": "deposit"
},{
"amount": -29.99,
"assoc_transaction_id": "txn_3bW9JN8cutWRm2iYnhjaS",
"timestamp": "2020-01-10 09:52:29",
"entry_type": "refund"
},{
"amount": 29.99,
"assoc_transaction_id": "txn_3bW9JN8dAmVVEkM5guwca",
"timestamp": "2020-01-10 18:30:23",
"entry_type": "reversal"
}]
}
Ledger entries can be either positive or negative depending on whether the associated transaction is a debit or a credit relative to the parent transaction.
The ledger entry_type
refers to the associated transaction
type
.
In the example you'll see a payment that was deposited but was later refunded. Since the payment had already been deposited, a reversal transaction was initiated to rebalance the ledger.
curl "https://api.payload.com/transactions" \
-u secret_key_3bW9JMZtPVDOfFNzwRdfE: \
-d "fields=*,ledger" \
-d "type=deposit" \
-d "processing_id=$processing_id"
To retrieve a list of deposited payments, query for transactions with a type
of
deposit