We believe you should have total control of your data. That’s why Braintree’s API gives you the flexibility to generate your own custom reports, allowing you to focus on what’s important to your business without being subject to the limits of our standard reports. You can start setting up your own reporting as soon as you’ve integrated with Braintree.

note

As you scale your business, you may outgrow our standard reports, and having your own reporting in place is crucial. We strongly recommend that you build out custom reporting that fully encompasses your interactions with Braintree, including all transactions and customers you create.

Sample reporting script

This script is a sample of one of many ways that you can generate your own custom reports via the API by:

  • Using the Braintree API to search for all transactions with a particular status
  • Iterating over those results and pulling specific transaction values
  • Adding those details for each transaction to a new row of the output CSV

Remember to

  1. Enter your own API keys
  2. Use the header row fields to define which values you want in the report
PHP
Click to copy
Copied
<?php
date_default_timezone_set('America/Chicago');
require_once 'braintree-php/lib/Braintree.php';

Braintree_Configuration::environment('[choose sandbox or production]');
Braintree_Configuration::merchantId('[enter merchant ID]');
Braintree_Configuration::publicKey('[enter public key]');
Braintree_Configuration::privateKey('[enter private key]');

$output = fopen('transaction_report.csv', 'w');

fputcsv($output, ['id', 'type', 'amount', 'status', 'created_at', 'service_fee_amount', 'merchant_account_id']);

$now = new DateTime();
$yesterday = $now->modify('-1 day');

$transactions = Braintree_Transaction::search([
  Braintree_TransactionSearch::settledAt()->greaterThanOrEqualTo($yesterday)
]);

foreach($transactions as $transaction) {
    $id = $transaction->id;
    $type = $transaction->type;
    $amount = $transaction->amount;
    $status = $transaction->status;
    $createdAt = $transaction->createdAt->format('d/m/Y H:i:s');
    $serviceFeeAmount = $transaction->serviceFeeAmount;
    $merchantAccountId = $transaction->merchantAccountId;

    $csvrow = [$id, $type, $amount, $status, $createdAt, $serviceFeeAmount, $merchantAccountId];
    fputcsv($output, $csvrow);
}

Search limit

Transaction searches return a maximum of 20,000 results; all other searches return a maximum of 10,000 results.

See also

Still have questions?

If you can’t find an answer, contact our Support team.