Skip to content


Subversion checkout URL

You can clone with
Download ZIP
C# Other
Latest commit 6f5b15d @braintreeps braintreeps 2.52.0
Failed to load latest commit information.
Braintree.Tests 2.52.0
Braintree 2.52.0
.gitignore 2.39.0
Braintree.Tests.VisualState.xml braintree .net client library 1.0.0
Braintree.Tests.nunit braintree .net client library 1.0.0
Braintree.sln 2.15.1
Braintree.sln.cache braintree .net client library 1.0.0 2.52.0
LICENSE 2.30.1 2.51.0
Rakefile 2.51.0
braintree.shfbproj 2.4.0 2.21.0

Braintree .NET Client Library

The Braintree assembly provides integration access to the Braintree Gateway.


  • none

Quick Start Example

using System;
using Braintree;

namespace BraintreeExample
    class Program
        static void Main(string[] args)
            var gateway = new BraintreeGateway
                Environment = Braintree.Environment.SANDBOX,
                MerchantId = "the_merchant_id",
                PublicKey = "a_public_key",
                PrivateKey = "a_private_key"

            TransactionRequest request = new TransactionRequest
                Amount = 1000.00M,
                PaymentMethodNonce = nonceFromTheClient,
                Options = new TransactionOptionsRequest
                    SubmitForSettlement = true

            Result<Transaction> result = gateway.Transaction.Sale(request);

            if (result.IsSuccess())
                Transaction transaction = result.Target;
                Console.WriteLine("Success!: " + transaction.Id);
            else if (result.Transaction != null)
                Transaction transaction = result.Transaction;
                Console.WriteLine("Error processing transaction:");
                Console.WriteLine("  Status: " + transaction.Status);
                Console.WriteLine("  Code: " + transaction.ProcessorResponseCode);
                Console.WriteLine("  Text: " + transaction.ProcessorResponseText);
                foreach (ValidationError error in result.Errors.DeepAll())
                    Console.WriteLine("Attribute: " + error.Attribute);
                    Console.WriteLine("  Code: " + error.Code);
                    Console.WriteLine("  Message: " + error.Message);



The unit specs can be run by anyone on any system, but the integration specs are meant to be run against a local development server of our gateway code. These integration specs are not meant for public consumption and will likely fail if run on your system. To run unit tests use rake (rake test:unit) or run the unit tests manually. Here is an example of how to run unit tests using xbuild and mono:

xbuild Braintree.sln
mono Braintree.Tests/lib/NUnit-2.4.8-net-2.0/bin/nunit-console.exe -exclude=Integration Braintree.Tests/bin/Debug/Braintree.Tests.dll

Open Source Attribution

A list of open source projects that help power Braintree can be found here.


See the LICENSE file.

Something went wrong with that request. Please try again.