Permalink
Browse files

2.12.0

  • Loading branch information...
1 parent bd44e02 commit 2f67029ed10a459ef9c662ce04a692cc0efc91c7 @braintreeps braintreeps committed Aug 24, 2011
View
@@ -15,3 +15,4 @@
.DS_Store
/test-results
/Braintree/TestResult.xml
+/Braintree.Tests/TestResult.xml
@@ -76,6 +76,7 @@
<Compile Include="TransparentRedirectTest.cs" />
<Compile Include="BraintreeServiceTest.cs" />
<Compile Include="StringUtilTest.cs" />
+ <Compile Include="SettlementBatchSummaryTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Braintree\Braintree.csproj">
@@ -1,13 +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>
+ <SelectedNode>[0-1045]Braintree.Tests.SettlementBatchSummaryTest.Generate_ReturnsAnEmptyCollectionIfThereIsNoData</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" />
+ <Node UniqueName="[0-1314]C:\Users\pair\braintree-dotnet\Braintree.Tests\bin\Debug\Braintree.Tests.dll" Expanded="true" />
+ <Node UniqueName="[0-1315]Braintree" Expanded="true" />
+ <Node UniqueName="[0-1316]Braintree.Tests" Expanded="true" />
+ <Node UniqueName="[0-1044]Braintree.Tests.SettlementBatchSummaryTest" Expanded="true" />
</Nodes>
</VisualState>
@@ -10,17 +10,6 @@ namespace Braintree.Tests
public class BraintreeServiceTest
{
[Test]
- public void QASSLCertificateSuccessful()
- {
- try {
- new BraintreeService(new Configuration(Environment.QA, "dummy", "dummy", "dummy")).Get("/");
- Assert.Fail ("Expected an AuthenticationException but none was thrown.");
- } catch (Braintree.Exceptions.AuthenticationException) {
- // expected
- }
- }
-
- [Test]
public void SandboxSSLCertificateSuccessful()
{
try {
@@ -93,6 +93,15 @@ public void ToXML_EscapesGeneratedXMLForSearchCriteria()
}
[Test]
+ public void ToXML_DefaultsNullCriteriaToEmptyString()
+ {
+ SubscriptionSearchRequest request = new SubscriptionSearchRequest().
+ PlanId.Is(null);
+
+ TestHelper.AssertIncludes("<plan-id><is></is></plan-id>", request.ToXml());
+ }
+
+ [Test]
public void ToXML_EscapesGeneratedXMLForCustomFields()
{
TransactionRequest request = new TransactionRequest
@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using Braintree;
+
+namespace Braintree.Tests
+{
+ [TestFixture]
+ public class SettlementBatchSummaryTest
+ {
+ private BraintreeGateway gateway;
+ private BraintreeService service;
+
+ [SetUp]
+ public void Setup()
+ {
+ gateway = new BraintreeGateway
+ {
+ Environment = Environment.DEVELOPMENT,
+ MerchantId = "integration_merchant_id",
+ PublicKey = "integration_public_key",
+ PrivateKey = "integration_private_key"
+ };
+
+ service = new BraintreeService(gateway.Configuration);
+ }
+
+ [Test]
+ public void Generate_ReturnsAnEmptyCollectionIfThereIsNoData()
+ {
+ Result<SettlementBatchSummary> result = gateway.SettlementBatchSummary.Generate(DateTime.Parse("1979-01-01"));
+ Assert.AreEqual(0, result.Target.Records.Count);
+ }
+
+ [Test]
+ public void Generate_ReturnsTransactionsSettledOnAGivenDay()
+ {
+ TransactionRequest request = new TransactionRequest
+ {
+ Amount = 1000M,
+ CreditCard = new TransactionCreditCardRequest
+ {
+ Number = "4111111111111111",
+ ExpirationDate = "05/2012",
+ CardholderName = "Tom Smith",
+ },
+ Options = new TransactionOptionsRequest
+ {
+ SubmitForSettlement = true
+ },
+ };
+
+ Transaction transaction = gateway.Transaction.Sale(request).Target;
+ TestHelper.Settle(service, transaction.Id);
+ transaction = gateway.Transaction.Find(transaction.Id);
+
+ var result = gateway.SettlementBatchSummary.Generate(DateTime.Now);
+ var visas = new List<IDictionary<String,String>>();
+ foreach (var row in result.Target.Records)
+ {
+ if (Braintree.CreditCardCardType.VISA.ToString().Equals(row["card_type"]))
+ {
+ visas.Add(row);
+
+ }
+ }
+
+ Assert.AreEqual(1, visas.Count);
+ }
+
+ [Test]
+ public void Generate_CanBeGroupedByACustomField()
+ {
+ TransactionRequest request = new TransactionRequest
+ {
+ Amount = 1000M,
+ CreditCard = new TransactionCreditCardRequest
+ {
+ Number = "4111111111111111",
+ ExpirationDate = "05/2012",
+ CardholderName = "Tom Smith",
+ },
+ Options = new TransactionOptionsRequest
+ {
+ SubmitForSettlement = true
+ },
+ CustomFields = new Dictionary<String, String>
+ {
+ { "store_me", "custom value" }
+ }
+ };
+
+ Transaction transaction = gateway.Transaction.Sale(request).Target;
+ TestHelper.Settle(service, transaction.Id);
+ transaction = gateway.Transaction.Find(transaction.Id);
+
+ var result = gateway.SettlementBatchSummary.Generate(DateTime.Now, "store_me");
+ var customValues = new List<IDictionary<String, String>>();
+ foreach (var row in result.Target.Records)
+ {
+ if ("custom value".Equals(row["store_me"]))
+ {
+ customValues.Add(row);
+
+ }
+ }
+
+ Assert.AreEqual(1, customValues.Count);
+ }
+ }
+}
+
@@ -65,5 +65,11 @@ public static Boolean IncludesSubscription(ResourceCollection<Subscription> coll
}
return false;
}
+
+ public static void Settle(BraintreeService service, String transactionId)
+ {
+ NodeWrapper response = new NodeWrapper(service.Put("/transactions/" + transactionId + "/settle"));
+ Assert.IsTrue(response.IsSuccess());
+ }
}
}
@@ -131,7 +131,7 @@ public void Search_OnAllTextFields()
};
Transaction transaction = gateway.Transaction.Sale(request).Target;
- Settle(transaction.Id);
+ TestHelper.Settle(service, transaction.Id);
transaction = gateway.Transaction.Find(transaction.Id);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
@@ -472,7 +472,7 @@ public void Search_OnTransactionType()
Transaction saleTransaction = gateway.Transaction.Sale(request).Target;
- Settle(saleTransaction.Id);
+ TestHelper.Settle(service, saleTransaction.Id);
Transaction refundTransaction = gateway.Transaction.Refund(saleTransaction.Id).Target;
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
@@ -664,7 +664,7 @@ public void Search_OnAuthorizationExpiredAt()
DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
- AuthorizedAt.Between(threeDaysEarlier, oneDayEarlier);
+ AuthorizationExpiredAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
@@ -835,7 +835,7 @@ public void Search_OnSettledAt()
};
Transaction transaction = gateway.Transaction.Sale(request).Target;
- Settle(transaction.Id);
+ TestHelper.Settle(service, transaction.Id);
transaction = gateway.Transaction.Find(transaction.Id);
DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
@@ -1053,7 +1053,7 @@ public void Sale_WithAllAttributes()
Email = "dan@example.com",
Phone = "419-555-1234",
Fax = "419-555-1235",
- Website = "http://braintreepaymentsolutions.com"
+ Website = "http://braintreepayments.com"
},
BillingAddress = new AddressRequest
{
@@ -1120,7 +1120,7 @@ public void Sale_WithAllAttributes()
Assert.AreEqual("dan@example.com", customer.Email);
Assert.AreEqual("419-555-1234", customer.Phone);
Assert.AreEqual("419-555-1235", customer.Fax);
- Assert.AreEqual("http://braintreepaymentsolutions.com", customer.Website);
+ Assert.AreEqual("http://braintreepayments.com", customer.Website);
Assert.IsNull(transaction.GetVaultBillingAddress());
Address billingAddress = transaction.BillingAddress;
@@ -2330,7 +2330,7 @@ public void Refund_WithABasicTransaction()
};
Transaction transaction = gateway.Transaction.Sale(request).Target;
- Settle(transaction.Id);
+ TestHelper.Settle(service, transaction.Id);
Result<Transaction> result;
try
@@ -2373,7 +2373,7 @@ public void Refund_WithAPartialAmount()
};
Transaction transaction = gateway.Transaction.Sale(request).Target;
- Settle(transaction.Id);
+ TestHelper.Settle(service, transaction.Id);
Result<Transaction> result = gateway.Transaction.Refund(transaction.Id, Decimal.Parse("500.00"));
Assert.IsTrue(result.IsSuccess());
@@ -2399,7 +2399,7 @@ public void Refund_MultipleRefundsWithPartialAmounts()
};
Transaction transaction = gateway.Transaction.Sale(request).Target;
- Settle(transaction.Id);
+ TestHelper.Settle(service, transaction.Id);
Transaction refund1 = gateway.Transaction.Refund(transaction.Id, 500M).Target;
Assert.AreEqual(TransactionType.CREDIT, refund1.Type);
@@ -2415,12 +2415,6 @@ public void Refund_MultipleRefundsWithPartialAmounts()
Assert.Contains(refund2.Id, refundedTransaction.RefundIds);
}
- private void Settle(String transactionId)
- {
- NodeWrapper response = new NodeWrapper(service.Put("/transactions/" + transactionId + "/settle"));
- Assert.IsTrue(response.IsSuccess());
- }
-
[Test]
public void Settle_RefundFailsWithNonSettledTransaction()
{
@@ -46,4 +46,4 @@ protected virtual RequestBuilder BuildRequest(String root)
AddElement("token", Token);
}
}
-}
+}
@@ -23,4 +23,4 @@ public T Is(Boolean value)
return IncludedIn(value.ToString());
}
}
-}
+}
@@ -9,7 +9,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Braintree</RootNamespace>
- <AssemblyName>Braintree-2.11.0</AssemblyName>
+ <AssemblyName>Braintree-2.12.0</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkSubset>
@@ -23,7 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <DocumentationFile>bin\Debug\Braintree-2.11.0.xml</DocumentationFile>
+ <DocumentationFile>bin\Debug\Braintree-2.12.0.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -33,7 +33,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <DocumentationFile>bin\Debug\Braintree-2.11.0.xml</DocumentationFile>
+ <DocumentationFile>bin\Debug\Braintree-2.12.0.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
@@ -101,6 +101,7 @@
<Compile Include="SearchCriteria.cs" />
<Compile Include="SearchNode.cs" />
<Compile Include="SearchRequest.cs" />
+ <Compile Include="SettlementBatchSummaryRequest.cs" />
<Compile Include="StatusEvent.cs" />
<Compile Include="Subscription.cs" />
<Compile Include="SubscriptionGateway.cs" />
@@ -130,6 +131,8 @@
<Compile Include="BooleanMultipleValueNode.cs" />
<Compile Include="Descriptor.cs" />
<Compile Include="CustomerSearchRequest.cs" />
+ <Compile Include="SettlementBatchSummaryGateway.cs" />
+ <Compile Include="SettlementBatchSummary.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
@@ -111,6 +111,11 @@ public virtual CreditCardGateway CreditCard
get { return new CreditCardGateway(new BraintreeService(Configuration)); }
}
+ public virtual SettlementBatchSummaryGateway SettlementBatchSummary
+ {
+ get { return new SettlementBatchSummaryGateway(new BraintreeService(Configuration)); }
+ }
+
public virtual SubscriptionGateway Subscription
{
get { return new SubscriptionGateway(new BraintreeService(Configuration)); }
Oops, something went wrong.

0 comments on commit 2f67029

Please sign in to comment.