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.
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
- Enter your own API keys
- Use the header row fields to define which values you want in the report
- Find additional values in our reference section, particularly in the Transaction, Customer, and PaymentMethod response objects
- The date range of the search can also be widened, narrowed, or shifted to reflect your needs
- 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 limit
Transaction searches return a maximum of 50,000 results; all other searches return a maximum of 10,000 results.