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. C#
using Braintree;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PP.BT.BootCamp.Web.Reporting
{
  public partial class WebForm1 : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      BraintreeGateway gateway = new BraintreeGateway
      {
        Environment = Braintree.Environment.SANDBOX,
        MerchantId = "", //the_merchant_id
        PublicKey = "", //a_public_key
        PrivateKey = "", //a_private_key
      };

      //year:The year (1 through 9999).
      //month:The month (1 through 12).
      //day: The day (1 through the number of days in month).
      var startDate = new DateTime(2014, 3, 16);
      var endDate = startDate.AddHours(23).AddMinutes(59).AddSeconds(59);
      var result = gateway.Transaction.Search(new TransactionSearchRequest().CreatedAt.Between(startDate, endDate));
      var sb = new StringBuilder();

      foreach (var row in result.Cast<Transaction>().ToList())
      {
        sb.AppendLine(string.Format("{0},{1},{2},{3},{4},{5},{6}", row.Id, row.Type, row.Amount, row.Status, row.CreatedAt, row.ServiceFeeAmount, row.MerchantAccountId));
      }

      Response.Write(sb.ToString());
    }
  }
}

Search limitanchor

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

See also