braintree .net client library
C# Other
Latest commit 5fafadf Jan 23, 2017 @braintreeps braintreeps 3.5.0
Permalink
Failed to load latest commit information.
src/Braintree 3.5.0 Jan 23, 2017
test 3.5.0 Jan 23, 2017
.gitignore 3.0.0 Sep 6, 2016
ACKNOWLEDGEMENTS.md 3.1.0 Nov 10, 2016
Braintree.sln 3.0.1 Sep 8, 2016
CHANGELOG.md 3.5.0 Jan 23, 2017
LICENSE 3.0.0 Sep 6, 2016
README.md 3.5.0 Jan 23, 2017
Rakefile 3.4.0 Jan 5, 2017
global.json 3.0.0 Sep 6, 2016

README.md

Braintree .NET Server Library

The Braintree assembly provides integration access to the Braintree Gateway.

Please Note

The Payment Card Industry (PCI) Council has mandated that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, Braintree is updating its services to require TLS 1.2 for all HTTPS connections. Braintree will also require HTTP/1.1 for all connections. Please see our technical documentation for more information.

Dependencies

  • .NET Core 1.0 or .NET Framework 4.5.2+

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);
            }
            else
            {
                foreach (ValidationError error in result.Errors.DeepAll())
                {
                    Console.WriteLine("Attribute: " + error.Attribute);
                    Console.WriteLine("  Code: " + error.Code);
                    Console.WriteLine("  Message: " + error.Message);
                }
            }
        }
    }
}

Documentation

Tests

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 the dotnet CLI tool from within /test/Braintree.Tests:

On Mac OS X or Unix-like environment

dotnet restore
dotnet build -f netcoreapp1.0
dotnet test . -f netcoreapp1.0

On a Windows environment

dotnet restore
dotnet build
dotnet test .

License

See the LICENSE file.