Reports

Custom

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 scriptAnchorIcon

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 toAnchorIcon

  1. Enter your own API keys
  2. Use the header row fields to define which values you want in the report
  1. Ruby
require "braintree";
require "csv";

gateway = Braintree::Gateway.new(
    :environment => :[choose sandbox or production],
    :merchant_id => "[enter merchant ID]",
    :public_key => "[enter public key]",
    :private_key => "[enter private key]"
);

header_row = ["id", "type", "amount", "status", "created_at", "service_fee_amount", "merchant_account_id"];

search_results = gateway.transaction.search do |search|
    search.settled_at >= Time.now - 60 * 60 * 24  # a day ago
end;

CSV.open("transaction_report.csv", "w") do |csv|
    csv << header_row;
    search_results.each do |transaction|
        transaction_details_row = header_row.map { |attribute| transaction.send(attribute) };
        csv << transaction_details_row;
    end;
end;

Search limitAnchorIcon

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

See alsoAnchorIcon

If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more

If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more