Shell Python Node PHP C# Ruby

Unified Payout & Ledger

curl "https://api.payload.com/transactions" \
    -u secret_key_3bW9JMZtPVDOfFNzwRdfE: \
    -d "fields[]=*" \
    -d "fields[]=ledger"
payment = pl.Payment.select( pl.attr.ledger, *pl.Transaction )
    .get('txn_3bW9JN8jkM9mP3qQCO5mC')
payment = Payload::Payment.
  select('*', 'ledger').
  get('txn_3bW9JN8jkM9mP3qQCO5mC')
    $payment = Payload\Transaction::select('*', 'ledger')
    ->get('txn_3bW9JN8jkM9mP3qQCO5mC');
const payment = await pl.select(pl.Payment, pl.Payment.ledger)
    .get('txn_3bW9JN8jkM9mP3qQCO5mC')
var trans = await pl.Payment
  .FilterBy("*", pl.Attr.ledger)
    .GetAsync("txn_3bW9JN8jkM9mP3qQCO5mC");

Transaction 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.

Reading the Ledger Records

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.

List of Deposited Payments

curl "https://api.payload.com/transactions" \
    -u secret_key_3bW9JMZtPVDOfFNzwRdfE: \
    -d "fields=*,ledger" \
    -d "type=deposit" \
    -d "processing_id=$processing_id"
trans = pl.Transaction.select(
        pl.attr.ledger,
        *pl.Transaction
    ).filter_by(
        type='deposit',
        processing_id=processing_account.id
    )
trans = Payload::Transaction.
  select('*', 'ledger').
  filter_by(
    type: 'deposit',
      processing_id: processing_account.id
  ).
  all()
$trans = Payload\Transaction::select(
        '*', 'ledger'
    )->filter_by(array(
        'type'=>'deposit',
        'processing_id'=>$processing_account->id
    ))->all();
const trans = await pl.select(pl.Transaction, pl.Transaction.ledger).filterBy({
    'type': 'deposit',
    'processing_id': processing_account.id,
})
var trans = await pl.Transaction
  .Select(new [] { "*", pl.Attr.ledger })
  .FilterBy(new {
        processing_id = processing_account.id,
        type = "deposit"
    })
  .AllAsync();

To retrieve a list of deposited payments, query for transactions with a type of deposit