Permalink
Browse files

braintree .net client library 1.0.0

  • Loading branch information...
0 parents commit 71487bbc9839e8bf368638d397513c07ba2b358c @braintreeps braintreeps committed Feb 23, 2010
Showing with 4,396 additions and 0 deletions.
  1. +13 −0 Braintree.Tests.VisualState.xml
  2. +9 −0 Braintree.Tests.nunit
  3. +174 −0 Braintree.Tests/AddressTest.cs
  4. +74 −0 Braintree.Tests/Braintree.Tests.csproj
  5. +13 −0 Braintree.Tests/Braintree.Tests.csproj.VisualState.xml
  6. +57 −0 Braintree.Tests/ConfigurationTest.cs
  7. +264 −0 Braintree.Tests/CreditCardTest.cs
  8. +71 −0 Braintree.Tests/CreditCardVerificationTest.cs
  9. +28 −0 Braintree.Tests/CryptoTest.cs
  10. +377 −0 Braintree.Tests/CustomerTest.cs
  11. +72 −0 Braintree.Tests/QueryStringTest.cs
  12. +40 −0 Braintree.Tests/TestHelper.cs
  13. +802 −0 Braintree.Tests/TransactionTest.cs
  14. +223 −0 Braintree.Tests/ValidationErrorsTest.cs
  15. +22 −0 Braintree.Tests/WebServiceGatewayTest.cs
  16. +3 −0 Braintree.Tests/app.config
  17. +26 −0 Braintree.sln
  18. +166 −0 Braintree.sln.cache
  19. BIN Braintree.suo
  20. +39 −0 Braintree/Address.cs
  21. +36 −0 Braintree/AddressGateway.cs
  22. +63 −0 Braintree/AddressRequest.cs
  23. +88 −0 Braintree/Braintree.csproj
  24. +9 −0 Braintree/Braintree.csproj.VisualState.xml
  25. +1 −0 Braintree/Braintree.csproj.user
  26. +59 −0 Braintree/BraintreeGateway.cs
  27. +27 −0 Braintree/Configuration.cs
  28. +61 −0 Braintree/CreditCard.cs
  29. +54 −0 Braintree/CreditCardGateway.cs
  30. +38 −0 Braintree/CreditCardOptionsRequest.cs
  31. +66 −0 Braintree/CreditCardRequest.cs
  32. +31 −0 Braintree/CreditCardVerification.cs
  33. +25 −0 Braintree/Crypto.cs
  34. +62 −0 Braintree/Customer.cs
  35. +54 −0 Braintree/CustomerGateway.cs
  36. +68 −0 Braintree/CustomerRequest.cs
  37. +18 −0 Braintree/Environment.cs
  38. +168 −0 Braintree/NodeWrapper.cs
  39. +10 −0 Braintree/NotFoundError.cs
  40. +29 −0 Braintree/PagedCollection.cs
  41. +33 −0 Braintree/Properties/AssemblyInfo.cs
  42. +82 −0 Braintree/QueryString.cs
  43. +58 −0 Braintree/Request.cs
  44. +55 −0 Braintree/Result.cs
  45. +20 −0 Braintree/SandboxValues.cs
  46. +40 −0 Braintree/TrUtil.cs
  47. +88 −0 Braintree/Transaction.cs
  48. +108 −0 Braintree/TransactionGateway.cs
  49. +47 −0 Braintree/TransactionOptionsRequest.cs
  50. +79 −0 Braintree/TransactionRequest.cs
  51. +48 −0 Braintree/TransparentRedirectRequest.cs
  52. +18 −0 Braintree/ValidationError.cs
  53. +87 −0 Braintree/ValidationErrors.cs
  54. +104 −0 Braintree/WebServiceGateway.cs
  55. +3 −0 Braintree/app.config
  56. +25 −0 LICENSE
  57. +49 −0 README.md
  58. +12 −0 default.ps1
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<VisualState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ShowCheckBoxes="false">
+ <TopNode>[0-1000]C:\Users\pair\braintree-dotnet\Braintree.Tests.nunit</TopNode>
+ <SelectedNode>[0-1000]C:\Users\pair\braintree-dotnet\Braintree.Tests.nunit</SelectedNode>
+ <ExcludeCategories>false</ExcludeCategories>
+ <Nodes>
+ <Node UniqueName="[0-1005]C:\Users\pair\braintree-dotnet\Braintree.Tests\bin\Release\Braintree.Tests.dll" Expanded="true" />
+ <Node UniqueName="[0-1006]Braintree" Expanded="true" />
+ <Node UniqueName="[0-1007]Braintree.Tests" Expanded="true" />
+ <Node UniqueName="[0-1001]Braintree.Tests.Class1Test" Expanded="true" />
+ <Node UniqueName="[0-1003]Braintree.Tests.CustomerTest" Expanded="true" />
+ </Nodes>
+</VisualState>
@@ -0,0 +1,9 @@
+<NUnitProject>
+ <Settings activeconfig="Release" />
+ <Config name="Debug" binpathtype="Auto">
+ <assembly path="Braintree.Tests\bin\Debug\Braintree.Tests.dll" />
+ </Config>
+ <Config name="Release" binpathtype="Auto">
+ <assembly path="Braintree.Tests\bin\Release\Braintree.Tests.dll" />
+ </Config>
+</NUnitProject>
@@ -0,0 +1,174 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using NUnit.Framework;
+using Braintree;
+
+namespace Braintree.Tests
+{
+ [TestFixture]
+ class AddressTest
+ {
+ private BraintreeGateway gateway;
+
+ [SetUp]
+ public void Setup()
+ {
+ gateway = new BraintreeGateway
+ {
+ Environment = Environment.DEVELOPMENT,
+ MerchantID = "integration_merchant_id",
+ PublicKey = "integration_public_key",
+ PrivateKey = "integration_private_key"
+ };
+ }
+
+ [Test]
+ public void Create_CreatesAddressForGivenCustomerID()
+ {
+ String id = Guid.NewGuid().ToString();
+ Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
+
+ var addressRequest = new AddressRequest
+ {
+ CustomerID = customer.ID,
+ FirstName = "Michael",
+ LastName = "Angelo",
+ Company = "Angelo Co.",
+ StreetAddress = "1 E Main St",
+ ExtendedAddress = "Apt 3",
+ Locality = "Chicago",
+ Region = "IL",
+ PostalCode = "60622",
+ CountryName = "United States of America"
+ };
+
+ Address address = gateway.Address.Create(customer.ID, addressRequest).Target;
+
+ Assert.AreEqual("Michael", address.FirstName);
+ Assert.AreEqual("Angelo", address.LastName);
+ Assert.AreEqual("Angelo Co.", address.Company);
+ Assert.AreEqual("1 E Main St", address.StreetAddress);
+ Assert.AreEqual("Apt 3", address.ExtendedAddress);
+ Assert.AreEqual("Chicago", address.Locality);
+ Assert.AreEqual("IL", address.Region);
+ Assert.AreEqual("60622", address.PostalCode);
+ Assert.AreEqual("United States of America", address.CountryName);
+ }
+
+ [Test]
+ public void Find_FindsAddress()
+ {
+ String id = Guid.NewGuid().ToString();
+ Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
+
+ var addressRequest = new AddressRequest
+ {
+ CustomerID = customer.ID,
+ FirstName = "Michael",
+ LastName = "Angelo",
+ Company = "Angelo Co.",
+ StreetAddress = "1 E Main St",
+ ExtendedAddress = "Apt 3",
+ Locality = "Chicago",
+ Region = "IL",
+ PostalCode = "60622",
+ CountryName = "United States of America"
+ };
+
+ Address createdAddress = gateway.Address.Create(customer.ID, addressRequest).Target;
+ Address address = gateway.Address.Find(customer.ID, createdAddress.ID).Target;
+
+ Assert.AreEqual("Michael", address.FirstName);
+ Assert.AreEqual("Angelo", address.LastName);
+ Assert.AreEqual("Angelo Co.", address.Company);
+ Assert.AreEqual("1 E Main St", address.StreetAddress);
+ Assert.AreEqual("Apt 3", address.ExtendedAddress);
+ Assert.AreEqual("Chicago", address.Locality);
+ Assert.AreEqual("IL", address.Region);
+ Assert.AreEqual("60622", address.PostalCode);
+ Assert.AreEqual("United States of America", address.CountryName);
+ }
+
+ [Test]
+ public void Update_UpdatesAddressForGivenCustomerIDAndAddressID()
+ {
+ String id = Guid.NewGuid().ToString();
+ Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
+
+ var addressCreateRequest = new AddressRequest
+ {
+ CustomerID = customer.ID,
+ FirstName = "Dave",
+ LastName = "Inchy",
+ Company = "Leon Ardo Co.",
+ StreetAddress = "1 E State St",
+ ExtendedAddress = "Apt 4",
+ Locality = "Boston",
+ Region = "MA",
+ PostalCode = "11111",
+ CountryName = "Canada"
+ };
+
+ Address originalAddress = gateway.Address.Create(customer.ID, addressCreateRequest).Target;
+
+ var addressUpdateRequest = new AddressRequest
+ {
+ CustomerID = customer.ID,
+ FirstName = "Michael",
+ LastName = "Angelo",
+ Company = "Angelo Co.",
+ StreetAddress = "1 E Main St",
+ ExtendedAddress = "Apt 3",
+ Locality = "Chicago",
+ Region = "IL",
+ PostalCode = "60622",
+ CountryName = "United States of America"
+ };
+
+ Address address = gateway.Address.Update(customer.ID, originalAddress.ID, addressUpdateRequest).Target;
+
+ Assert.AreEqual("Michael", address.FirstName);
+ Assert.AreEqual("Angelo", address.LastName);
+ Assert.AreEqual("Angelo Co.", address.Company);
+ Assert.AreEqual("1 E Main St", address.StreetAddress);
+ Assert.AreEqual("Apt 3", address.ExtendedAddress);
+ Assert.AreEqual("Chicago", address.Locality);
+ Assert.AreEqual("IL", address.Region);
+ Assert.AreEqual("60622", address.PostalCode);
+ Assert.AreEqual("United States of America", address.CountryName);
+ }
+
+ [Test]
+ public void Delete_DeletesTheAddress()
+ {
+ Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
+
+ var addressRequest = new AddressRequest
+ {
+ CustomerID = customer.ID,
+ StreetAddress = "1 E Main St",
+ ExtendedAddress = "Apt 3",
+ };
+
+ Address createdAddress = gateway.Address.Create(customer.ID, addressRequest).Target;
+ Assert.AreEqual(createdAddress.ID, gateway.Address.Find(customer.ID, createdAddress.ID).Target.ID);
+ gateway.Address.Delete(customer.ID, createdAddress.ID);
+ Assert.Throws<NotFoundError>(() => gateway.Address.Find(customer.ID, createdAddress.ID));
+ }
+
+ [Test]
+ public void Create_ReturnsAnErrorResult()
+ {
+ Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
+ AddressRequest request = new AddressRequest() { CountryName = "United States of Hammer" };
+
+ Result<Address> createResult = gateway.Address.Create(customer.ID, request);
+ Assert.IsFalse(createResult.IsSuccess());
+ Dictionary<String, String> parameters = createResult.Parameters;
+ Assert.AreEqual("integration_merchant_id", parameters["merchant_id"]);
+ Assert.AreEqual(customer.ID, parameters["customer_id"]);
+ Assert.AreEqual("United States of Hammer", parameters["address[country_name]"]);
+ }
+ }
+}
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{60234E7B-1181-4EFF-96EE-624B4524D788}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Braintree.Tests</RootNamespace>
+ <AssemblyName>Braintree.Tests</AssemblyName>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkSubset>
+ </TargetFrameworkSubset>
+ <StartupObject>
+ </StartupObject>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <ItemGroup>
+ <Reference Include="nunit.framework, Version=2.5.2.9222, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AddressTest.cs" />
+ <Compile Include="ConfigurationTest.cs" />
+ <Compile Include="CreditCardTest.cs" />
+ <Compile Include="CreditCardVerificationTest.cs" />
+ <Compile Include="CryptoTest.cs" />
+ <Compile Include="CustomerTest.cs" />
+ <Compile Include="QueryStringTest.cs" />
+ <Compile Include="TestHelper.cs" />
+ <Compile Include="TransactionTest.cs" />
+ <Compile Include="ValidationErrorsTest.cs" />
+ <Compile Include="WebServiceGatewayTest.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Braintree\Braintree.csproj">
+ <Project>{D0A473FA-E30B-4AF8-BB78-C1D81C9CAAB5}</Project>
+ <Name>Braintree</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+</Project>
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<VisualState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ShowCheckBoxes="false">
+ <TopNode>[0-1000]C:\Users\pair\braintree-dotnet\Braintree.Tests\Braintree.Tests.csproj</TopNode>
+ <SelectedNode>[0-1008]Braintree.Tests.CustomerTest.Delete_DeletesTheCustomer</SelectedNode>
+ <ExcludeCategories>false</ExcludeCategories>
+ <Nodes>
+ <Node UniqueName="[0-1000]C:\Users\pair\braintree-dotnet\Braintree.Tests\Braintree.Tests.csproj" Expanded="true" />
+ <Node UniqueName="[0-1009]C:\Users\pair\braintree-dotnet\Braintree.Tests\bin\Debug\Braintree.Tests.dll" Expanded="true" />
+ <Node UniqueName="[0-1010]Braintree" Expanded="true" />
+ <Node UniqueName="[0-1011]Braintree.Tests" Expanded="true" />
+ <Node UniqueName="[0-1001]Braintree.Tests.CustomerTest" Expanded="true" />
+ </Nodes>
+</VisualState>
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using Braintree;
+
+namespace Braintree.Tests
+{
+ [TestFixture]
+ class ConfigurationTest
+ {
+ [Test]
+ public void BaseMerchantURL_ReturnsDevelopmentURL()
+ {
+ Configuration.Environment = Environment.DEVELOPMENT;
+ Configuration.MerchantID = "integration_merchant_id";
+ Configuration.PublicKey = "integration_public_key";
+ Configuration.PrivateKey = "integration_private_key";
+
+ Assert.AreEqual("http://192.168.65.1:3000/merchants/integration_merchant_id", Configuration.BaseMerchantURL());
+ }
+
+ [Test]
+ public void BaseMerchantURL_ReturnsSandboxURL()
+ {
+ Configuration.Environment = Environment.SANDBOX;
+ Configuration.MerchantID = "integration_merchant_id";
+ Configuration.PublicKey = "integration_public_key";
+ Configuration.PrivateKey = "integration_private_key";
+
+ Assert.AreEqual("https://sandbox.braintreegateway.com:443/merchants/integration_merchant_id", Configuration.BaseMerchantURL());
+ }
+
+ [Test]
+ public void BaseMerchantURL_ReturnsProductionURL()
+ {
+ Configuration.Environment = Environment.PRODUCTION;
+ Configuration.MerchantID = "integration_merchant_id";
+ Configuration.PublicKey = "integration_public_key";
+ Configuration.PrivateKey = "integration_private_key";
+
+
+ Assert.AreEqual("https://www.braintreegateway.com:443/merchants/integration_merchant_id", Configuration.BaseMerchantURL());
+ }
+
+ [Test]
+ public void GetAuthorizationHeader_ReturnsBase64EncodePublicAndPrivateKeys()
+ {
+ Configuration.Environment = Environment.DEVELOPMENT;
+ Configuration.MerchantID = "integration_merchant_id";
+ Configuration.PublicKey = "integration_public_key";
+ Configuration.PrivateKey = "integration_private_key";
+ Assert.AreEqual("Basic aW50ZWdyYXRpb25fcHVibGljX2tleTppbnRlZ3JhdGlvbl9wcml2YXRlX2tleQ==", Configuration.GetAuthorizationHeader());
+
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 71487bb

Please sign in to comment.