.NET Client Library
Download
Braintree-2.13.4.dll
SHA1: 632f0c78aadf4962dfaa42c6c5bc6ac88300669e
Supports .NET Framework 2.0 and higher
Updates
Current version: 2.13.4. Released February 01, 2012.
For details on changes see the change log. If we deprecate any functionality we’ll add updating instructions to the deprecations page.
Fill out this form to receive emails when we release updates to the .NET client library.
Source Code
Integration Examples
Bugs
If you run into a bug, email us at support@getbraintree.com or create an issue on the github issue tracker.
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"
};
var request = new TransactionRequest
{
Amount = 1000M,
CreditCard = new TransactionCreditCardRequest
{
Number = "4111111111111111",
ExpirationDate = "05/2012"
}
};
Result<Transaction> result = gateway.Transaction.Sale(request);
if (result.IsSuccess())
{
Transaction transaction = result.Target;
Console.WriteLine("Success!: " + transaction.Id);
}
else if (result.Transaction != null)
{
Console.WriteLine("Message: " + result.Message);
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
{
Console.WriteLine("Message: " + result.Message);
foreach (ValidationError error in result.Errors.DeepAll())
{
Console.WriteLine("Attribute: " + error.Attribute);
Console.WriteLine(" Code: " + error.Code);
Console.WriteLine(" Message: " + error.Message);
}
}
}
}
}