Reports

Customanchor

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 scriptanchor

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 toanchor

  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 limitanchor

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

See also