Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

2.11.0

  • Loading branch information...
commit bd44e0208c9dad55938b2c26dd65bce51668734c 1 parent a02b614
@braintreeps braintreeps authored
View
24 Braintree.Tests/SubscriptionTest.cs
@@ -74,6 +74,26 @@ public void Create_SubscriptionWithoutTrial()
}
[Test]
+ public void Create_SubscriptionReturnsATransactionWithSubscriptionBillingPeriod()
+ {
+ Plan plan = Plan.PLAN_WITHOUT_TRIAL;
+
+ SubscriptionRequest request = new SubscriptionRequest
+ {
+ PaymentMethodToken = creditCard.Token,
+ PlanId = plan.Id
+ };
+
+ Result<Subscription> result = gateway.Subscription.Create(request);
+ Assert.IsTrue(result.IsSuccess());
+ Subscription subscription = result.Target;
+ Transaction transaction = subscription.Transactions[0];
+
+ Assert.AreEqual(subscription.BillingPeriodStartDate, transaction.Subscription.BillingPeriodStartDate);
+ Assert.AreEqual(subscription.BillingPeriodEndDate, transaction.Subscription.BillingPeriodEndDate);
+ }
+
+ [Test]
public void Create_ReturnsDeclinedTransaction()
{
Plan plan = Plan.PLAN_WITHOUT_TRIAL;
@@ -1799,7 +1819,7 @@ public void Update_WithDescriptor()
Descriptor = new DescriptorRequest
{
Name = "999*999",
- Phone = "9999999"
+ Phone = "1234567890"
}
};
Result<Subscription> result = gateway.Subscription.Update(createResult.Target.Id, updateRequest);
@@ -1807,7 +1827,7 @@ public void Update_WithDescriptor()
Assert.IsTrue(result.IsSuccess());
Subscription subscription = result.Target;
Assert.AreEqual("999*999", subscription.Descriptor.Name);
- Assert.AreEqual("9999999", subscription.Descriptor.Phone);
+ Assert.AreEqual("1234567890", subscription.Descriptor.Phone);
}
[Test]
View
245 Braintree.Tests/TransactionTest.cs
@@ -558,31 +558,31 @@ public void Search_OnCreatedAt()
Transaction transaction = gateway.Transaction.Sale(request).Target;
DateTime createdAt = transaction.CreatedAt.Value;
- DateTime threeHoursEarlier = createdAt.AddHours(-3);
- DateTime oneHourEarlier = createdAt.AddHours(-1);
- DateTime oneHourLater = createdAt.AddHours(1);
+ DateTime threeDaysEarlier = createdAt.AddDays(-3);
+ DateTime oneDayEarlier = createdAt.AddDays(-1);
+ DateTime oneDayLater = createdAt.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- CreatedAt.Between(oneHourEarlier, oneHourLater);
+ CreatedAt.Between(oneDayEarlier, oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- CreatedAt.GreaterThanOrEqualTo(oneHourEarlier);
+ CreatedAt.GreaterThanOrEqualTo(oneDayEarlier);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- CreatedAt.LessThanOrEqualTo(oneHourLater);
+ CreatedAt.LessThanOrEqualTo(oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- CreatedAt.Between(threeHoursEarlier, oneHourEarlier);
+ CreatedAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
}
@@ -602,12 +602,12 @@ public void Search_OnCreatedAtUsingLocalTime()
Transaction transaction = gateway.Transaction.Sale(request).Target;
- DateTime oneHourEarlier = DateTime.Now.AddHours(-1);
- DateTime oneHourLater = DateTime.Now.AddHours(1);
+ DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
+ DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- CreatedAt.Between(oneHourEarlier, oneHourLater);
+ CreatedAt.Between(oneDayEarlier, oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
}
@@ -627,31 +627,31 @@ public void Search_OnAuthorizedAt()
Transaction transaction = gateway.Transaction.Sale(request).Target;
- DateTime threeHoursEarlier = DateTime.Now.AddHours(-3);
- DateTime oneHourEarlier = DateTime.Now.AddHours(-1);
- DateTime oneHourLater = DateTime.Now.AddHours(1);
+ DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
+ DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
+ DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- AuthorizedAt.Between(oneHourEarlier, oneHourLater);
+ AuthorizedAt.Between(oneDayEarlier, oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- AuthorizedAt.GreaterThanOrEqualTo(oneHourEarlier);
+ AuthorizedAt.GreaterThanOrEqualTo(oneDayEarlier);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- AuthorizedAt.LessThanOrEqualTo(oneHourLater);
+ AuthorizedAt.LessThanOrEqualTo(oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- AuthorizedAt.Between(threeHoursEarlier, oneHourEarlier);
+ AuthorizedAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
}
@@ -659,17 +659,17 @@ public void Search_OnAuthorizedAt()
[Test]
public void Search_OnAuthorizationExpiredAt()
{
- DateTime threeHoursEarlier = DateTime.Now.AddHours(-3);
- DateTime oneHourEarlier = DateTime.Now.AddHours(-1);
- DateTime oneHourLater = DateTime.Now.AddHours(1);
+ DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
+ DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
+ DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
- AuthorizedAt.Between(threeHoursEarlier, oneHourEarlier);
+ AuthorizedAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
- AuthorizationExpiredAt.Between(oneHourEarlier, oneHourLater);
+ AuthorizationExpiredAt.Between(oneDayEarlier, oneDayLater);
var results = gateway.Transaction.Search(searchRequest);
Assert.IsTrue(results.MaximumCount > 0);
@@ -691,31 +691,31 @@ public void Search_OnFailedAt()
Transaction transaction = gateway.Transaction.Sale(request).Transaction;
- DateTime threeHoursEarlier = DateTime.Now.AddHours(-3);
- DateTime oneHourEarlier = DateTime.Now.AddHours(-1);
- DateTime oneHourLater = DateTime.Now.AddHours(1);
+ DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
+ DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
+ DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- FailedAt.Between(oneHourEarlier, oneHourLater);
+ FailedAt.Between(oneDayEarlier, oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- FailedAt.GreaterThanOrEqualTo(oneHourEarlier);
+ FailedAt.GreaterThanOrEqualTo(oneDayEarlier);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- FailedAt.LessThanOrEqualTo(oneHourLater);
+ FailedAt.LessThanOrEqualTo(oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- FailedAt.Between(threeHoursEarlier, oneHourEarlier);
+ FailedAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
}
@@ -744,31 +744,31 @@ public void Search_OnGatewayRejectedAt()
Transaction transaction = processingRulesGateway.Transaction.Sale(request).Transaction;
- DateTime threeHoursEarlier = DateTime.Now.AddHours(-3);
- DateTime oneHourEarlier = DateTime.Now.AddHours(-1);
- DateTime oneHourLater = DateTime.Now.AddHours(1);
+ DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
+ DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
+ DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- GatewayRejectedAt.Between(oneHourEarlier, oneHourLater);
+ GatewayRejectedAt.Between(oneDayEarlier, oneDayLater);
Assert.AreEqual(1, processingRulesGateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- GatewayRejectedAt.GreaterThanOrEqualTo(oneHourEarlier);
+ GatewayRejectedAt.GreaterThanOrEqualTo(oneDayEarlier);
Assert.AreEqual(1, processingRulesGateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- GatewayRejectedAt.LessThanOrEqualTo(oneHourLater);
+ GatewayRejectedAt.LessThanOrEqualTo(oneDayLater);
Assert.AreEqual(1, processingRulesGateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- GatewayRejectedAt.Between(threeHoursEarlier, oneHourEarlier);
+ GatewayRejectedAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, processingRulesGateway.Transaction.Search(searchRequest).MaximumCount);
}
@@ -788,31 +788,31 @@ public void Search_OnProcessorDeclinedAt()
Transaction transaction = gateway.Transaction.Sale(request).Transaction;
- DateTime threeHoursEarlier = DateTime.Now.AddHours(-3);
- DateTime oneHourEarlier = DateTime.Now.AddHours(-1);
- DateTime oneHourLater = DateTime.Now.AddHours(1);
+ DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
+ DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
+ DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- ProcessorDeclinedAt.Between(oneHourEarlier, oneHourLater);
+ ProcessorDeclinedAt.Between(oneDayEarlier, oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- ProcessorDeclinedAt.GreaterThanOrEqualTo(oneHourEarlier);
+ ProcessorDeclinedAt.GreaterThanOrEqualTo(oneDayEarlier);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- ProcessorDeclinedAt.LessThanOrEqualTo(oneHourLater);
+ ProcessorDeclinedAt.LessThanOrEqualTo(oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- ProcessorDeclinedAt.Between(threeHoursEarlier, oneHourEarlier);
+ ProcessorDeclinedAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
}
@@ -838,31 +838,31 @@ public void Search_OnSettledAt()
Settle(transaction.Id);
transaction = gateway.Transaction.Find(transaction.Id);
- DateTime threeHoursEarlier = DateTime.Now.AddHours(-3);
- DateTime oneHourEarlier = DateTime.Now.AddHours(-1);
- DateTime oneHourLater = DateTime.Now.AddHours(1);
+ DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
+ DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
+ DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- SettledAt.Between(oneHourEarlier, oneHourLater);
+ SettledAt.Between(oneDayEarlier, oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- SettledAt.GreaterThanOrEqualTo(oneHourEarlier);
+ SettledAt.GreaterThanOrEqualTo(oneDayEarlier);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- SettledAt.LessThanOrEqualTo(oneHourLater);
+ SettledAt.LessThanOrEqualTo(oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- SettledAt.Between(threeHoursEarlier, oneHourEarlier);
+ SettledAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
}
@@ -886,31 +886,31 @@ public void Search_OnSubmittedForSettlementAt()
Transaction transaction = gateway.Transaction.Sale(request).Target;
- DateTime threeHoursEarlier = DateTime.Now.AddHours(-3);
- DateTime oneHourEarlier = DateTime.Now.AddHours(-1);
- DateTime oneHourLater = DateTime.Now.AddHours(1);
+ DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
+ DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
+ DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- SubmittedForSettlementAt.Between(oneHourEarlier, oneHourLater);
+ SubmittedForSettlementAt.Between(oneDayEarlier, oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- SubmittedForSettlementAt.GreaterThanOrEqualTo(oneHourEarlier);
+ SubmittedForSettlementAt.GreaterThanOrEqualTo(oneDayEarlier);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- SubmittedForSettlementAt.LessThanOrEqualTo(oneHourLater);
+ SubmittedForSettlementAt.LessThanOrEqualTo(oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- SubmittedForSettlementAt.Between(threeHoursEarlier, oneHourEarlier);
+ SubmittedForSettlementAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
}
@@ -931,31 +931,31 @@ public void Search_OnVoidedAt()
Transaction transaction = gateway.Transaction.Sale(request).Target;
transaction = gateway.Transaction.Void(transaction.Id).Target;
- DateTime threeHoursEarlier = DateTime.Now.AddHours(-3);
- DateTime oneHourEarlier = DateTime.Now.AddHours(-1);
- DateTime oneHourLater = DateTime.Now.AddHours(1);
+ DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
+ DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
+ DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- VoidedAt.Between(oneHourEarlier, oneHourLater);
+ VoidedAt.Between(oneDayEarlier, oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- VoidedAt.GreaterThanOrEqualTo(oneHourEarlier);
+ VoidedAt.GreaterThanOrEqualTo(oneDayEarlier);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- VoidedAt.LessThanOrEqualTo(oneHourLater);
+ VoidedAt.LessThanOrEqualTo(oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- VoidedAt.Between(threeHoursEarlier, oneHourEarlier);
+ VoidedAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
}
@@ -979,21 +979,21 @@ public void Search_OnMultipleStatuses()
Transaction transaction = gateway.Transaction.Sale(request).Target;
- DateTime threeHoursEarlier = DateTime.Now.AddHours(-3);
- DateTime oneHourEarlier = DateTime.Now.AddHours(-1);
- DateTime oneHourLater = DateTime.Now.AddHours(1);
+ DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
+ DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
+ DateTime oneDayLater = DateTime.Now.AddDays(1);
TransactionSearchRequest searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- AuthorizedAt.Between(oneHourEarlier, oneHourLater).
- SubmittedForSettlementAt.Between(oneHourEarlier, oneHourLater);
+ AuthorizedAt.Between(oneDayEarlier, oneDayLater).
+ SubmittedForSettlementAt.Between(oneDayEarlier, oneDayLater);
Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
searchRequest = new TransactionSearchRequest().
Id.Is(transaction.Id).
- AuthorizedAt.Between(threeHoursEarlier, oneHourEarlier).
- SubmittedForSettlementAt.Between(threeHoursEarlier, oneHourEarlier);
+ AuthorizedAt.Between(threeDaysEarlier, oneDayEarlier).
+ SubmittedForSettlementAt.Between(threeDaysEarlier, oneDayEarlier);
Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
}
@@ -1340,6 +1340,76 @@ public void Sale_WithStoreInVaultWithoutSpecifyingToken()
}
[Test]
+ public void Sale_WithStoreInVaultOnSuccessWhenTransactionSuccessful()
+ {
+ TransactionRequest request = new TransactionRequest
+ {
+ Amount = SandboxValues.TransactionAmount.AUTHORIZE,
+ CreditCard = new TransactionCreditCardRequest
+ {
+ Number = SandboxValues.CreditCardNumber.VISA,
+ ExpirationDate = "05/2009",
+ },
+ Customer = new CustomerRequest
+ {
+ FirstName = "Jane"
+ },
+ Options = new TransactionOptionsRequest
+ {
+ StoreInVaultOnSuccess = true
+ }
+ };
+
+ Result<Transaction> result = gateway.Transaction.Sale(request);
+ Assert.IsTrue(result.IsSuccess());
+ Transaction transaction = result.Target;
+
+ CreditCard creditCard = transaction.CreditCard;
+ Assert.IsNotNull(creditCard.Token);
+ Assert.AreEqual("05/2009", transaction.GetVaultCreditCard().ExpirationDate);
+
+ Customer customer = transaction.Customer;
+ Assert.IsNotNull(customer.Id);
+ Assert.AreEqual("Jane", transaction.GetVaultCustomer().FirstName);
+ }
+
+
+
+ [Test]
+ public void Sale_WithStoreInVaultOnSuccessWhenTransactionFails()
+ {
+ TransactionRequest request = new TransactionRequest
+ {
+ Amount = SandboxValues.TransactionAmount.DECLINE,
+ CreditCard = new TransactionCreditCardRequest
+ {
+ Number = SandboxValues.CreditCardNumber.VISA,
+ ExpirationDate = "05/2009",
+ },
+ Customer = new CustomerRequest
+ {
+ FirstName = "Jane"
+ },
+ Options = new TransactionOptionsRequest
+ {
+ StoreInVaultOnSuccess = true
+ }
+ };
+
+ Result<Transaction> result = gateway.Transaction.Sale(request);
+ Assert.IsFalse(result.IsSuccess());
+ Transaction transaction = result.Transaction;
+
+ CreditCard creditCard = transaction.CreditCard;
+ Assert.IsNull(creditCard.Token);
+ Assert.IsNull(transaction.GetVaultCreditCard());
+
+ Customer customer = transaction.Customer;
+ Assert.IsNull(customer.Id);
+ Assert.IsNull(transaction.GetVaultCustomer());
+ }
+
+ [Test]
public void Sale_WithStoreInVaultForBillingAndShipping()
{
TransactionRequest request = new TransactionRequest
@@ -1587,6 +1657,39 @@ public void Sale_WithPaymentMethodToken()
}
[Test]
+ public void Sale_WithPaymentMethodTokenAndCvv()
+ {
+ Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
+ CreditCardRequest creditCardRequest = new CreditCardRequest
+ {
+ CustomerId = customer.Id,
+ Number = "5105105105105100",
+ ExpirationDate = "05/12"
+ };
+
+ CreditCard creditCard = gateway.CreditCard.Create(creditCardRequest).Target;
+
+ TransactionRequest request = new TransactionRequest
+ {
+ Amount = SandboxValues.TransactionAmount.AUTHORIZE,
+ PaymentMethodToken = creditCard.Token,
+ CreditCard = new TransactionCreditCardRequest
+ {
+ CVV = "301"
+ }
+ };
+
+ Result<Transaction> result = gateway.Transaction.Sale(request);
+ Assert.IsTrue(result.IsSuccess());
+ Transaction transaction = result.Target;
+
+ Assert.AreEqual("S", transaction.CvvResponseCode);
+ Assert.AreEqual(creditCard.Token, transaction.CreditCard.Token);
+ Assert.AreEqual("510510", transaction.CreditCard.Bin);
+ Assert.AreEqual("05/2012", transaction.CreditCard.ExpirationDate);
+ }
+
+ [Test]
public void Sale_UsesShippingAddressFromVault()
{
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
View
6 Braintree/Braintree.csproj
@@ -9,7 +9,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Braintree</RootNamespace>
- <AssemblyName>Braintree-2.10.0</AssemblyName>
+ <AssemblyName>Braintree-2.11.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.10.0.xml</DocumentationFile>
+ <DocumentationFile>bin\Debug\Braintree-2.11.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.10.0.xml</DocumentationFile>
+ <DocumentationFile>bin\Debug\Braintree-2.11.0.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
View
6 Braintree/Descriptor.cs
@@ -11,8 +11,10 @@ public class Descriptor
internal Descriptor(NodeWrapper node)
{
- Name = node.GetString("name");
- Phone = node.GetString("phone");
+ if (node != null) {
+ Name = node.GetString("name");
+ Phone = node.GetString("phone");
+ }
}
}
}
View
4 Braintree/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@
// Build Number
// Revision
//
-[assembly: AssemblyVersion("2.10.0.0")]
-[assembly: AssemblyFileVersion("2.10.0.0")]
+[assembly: AssemblyVersion("2.11.0.0")]
+[assembly: AssemblyFileVersion("2.11.0.0")]
View
2  Braintree/Transaction.cs
@@ -118,6 +118,7 @@ public class Transaction
public TransactionStatus Status { get; protected set; }
public StatusEvent[] StatusHistory { get; protected set; }
public String SubscriptionId { get; protected set; }
+ public Subscription Subscription { get; protected set; }
public Decimal? TaxAmount { get; protected set; }
public Boolean? TaxExempt { get; protected set; }
public TransactionType Type { get; protected set; }
@@ -171,6 +172,7 @@ internal Transaction(NodeWrapper node, BraintreeService service)
TaxExempt = node.GetBoolean("tax-exempt");
CustomFields = node.GetDictionary("custom-fields");
CreditCard = new CreditCard(node.GetNode("credit-card"), service);
+ Subscription = new Subscription(node.GetNode("subscription"), service);
Customer = new Customer(node.GetNode("customer"), service);
CurrencyIsoCode = node.GetString("currency-iso-code");
CvvResponseCode = node.GetString("cvv-response-code");
View
2  Braintree/TransactionOptionsRequest.cs
@@ -9,6 +9,7 @@ namespace Braintree
public class TransactionOptionsRequest : Request
{
public Boolean? StoreInVault { get; set; }
+ public Boolean? StoreInVaultOnSuccess { get; set; }
public Boolean? AddBillingAddressToPaymentMethod { get; set; }
public Boolean? StoreShippingAddressInVault { get; set; }
public Boolean? SubmitForSettlement { get; set; }
@@ -27,6 +28,7 @@ protected virtual RequestBuilder BuildRequest(String root)
{
return new RequestBuilder(root).
AddElement("store-in-vault", StoreInVault).
+ AddElement("store-in-vault-on-success", StoreInVaultOnSuccess).
AddElement("add-billing-address-to-payment-method", AddBillingAddressToPaymentMethod).
AddElement("store-shipping-address-in-vault", StoreShippingAddressInVault).
AddElement("submit-for-settlement", SubmitForSettlement);
View
1  Braintree/ValidationErrorCode.cs
@@ -25,6 +25,7 @@ public enum ValidationErrorCode
ADDRESS_REGION_IS_TOO_LONG = 81810,
ADDRESS_STREET_ADDRESS_IS_REQUIRED = 81811,
ADDRESS_STREET_ADDRESS_IS_TOO_LONG = 81812,
+ ADDRESS_TOO_MANY_ADDRESSES_PER_CUSTOMER = 91818,
CREDIT_CARD_BILLING_ADDRESS_CONFLICT = 91701,
CREDIT_CARD_BILLING_ADDRESS_ID_IS_INVALID = 91702,
View
6 CHANGELOG.md
@@ -1,3 +1,9 @@
+## 2.11.0
+
+* Added Subscription to Transaction
+* Added flag to store in vault only when a transaction is successful
+* Added new error code
+
## 2.10.0
* Added a new transaction state, AUTHORIZATION_EXPIRED.
View
3  Rakefile
@@ -1,6 +1,3 @@
-require "rubygems"
-load File.dirname(__FILE__) + "/cruise.rake"
-
task :default => :test
task :clean do
View
70 cruise.rake
@@ -1,70 +0,0 @@
-require 'timeout'
-require 'socket'
-
-CRUISE_BUILD = "CRUISE_BUILD=#{ENV['CRUISE_BUILD']}"
-GATEWAY_ROOT = File.dirname(__FILE__) + "/../gateway" unless defined?(GATEWAY_ROOT)
-PORT = ENV['GATEWAY_PORT'] || 3000
-PID_FILE = "/tmp/gateway_server_#{PORT}.pid"
-
-desc "prep the gateway (including git clone and db reset) and run tests"
-task :cruise do
- begin
- Rake::Task["prep_gateway"].invoke
- Rake::Task["test"].invoke
- ensure
- Rake::Task["stop_gateway"].invoke
- end
-end
-
-task :prep_gateway do
- Dir.chdir(GATEWAY_ROOT) do
- sh "rake log:clear"
- sh "git pull"
- sh "env RAILS_ENV=integration #{CRUISE_BUILD} rake db:migrate:reset --trace"
- sh "env RAILS_ENV=integration #{CRUISE_BUILD} ruby script/populate_data"
- Rake::Task[:start_gateway].invoke
- end
-end
-
-task :start_gateway do
- Dir.chdir(GATEWAY_ROOT) do
- spawn_server(PID_FILE, PORT, "integration")
- end
-end
-
-task :stop_gateway do
- Dir.chdir(GATEWAY_ROOT) do
- shutdown_server(PID_FILE)
- end
-end
-
-def spawn_server(pid_file, port, environment="test")
- FileUtils.rm(pid_file) if File.exist?(pid_file)
- command = "mongrel_rails start --environment #{environment} --daemon --port #{port} --pid #{pid_file}"
-
- sh command
- puts "== waiting for web server - port: #{port}"
- TCPSocket.wait_for_service :host => "127.0.0.1", :port => port
-end
-
-def shutdown_server(pid_file)
- 10.times { unless File.exists?(pid_file); sleep 1; end }
- puts "\n== killing web server - pid: #{File.read(pid_file).to_i}"
- Process.kill "TERM", File.read(pid_file).to_i
-end
-
-TCPSocket.class_eval do
- def self.wait_for_service(options)
- Timeout::timeout(options[:timeout] || 20) do
- loop do
- begin
- socket = TCPSocket.new(options[:host], options[:port])
- socket.close
- return
- rescue Errno::ECONNREFUSED
- sleep 0.5
- end
- end
- end
- end
-end
View
9 cruise_config.rb
@@ -1,9 +0,0 @@
-Project.configure do |project|
- project.scheduler.polling_interval = 1.minute
-
- case project.name
- when "client_library_dotnet_integration_master"
- project.build_command = "CRUISE_BUILD=#{project.name} GATEWAY_PORT=6010 rake cruise"
- project.triggered_by :gateway_master
- end
-end
View
70 default.ps1
@@ -1,70 +0,0 @@
-properties {
- $base_dir = Split-Path -Path $MyInvocation.MyCommand.ScriptBlock.File
- $sandcastle_base = "C:\Program Files (x86)\Sandcastle"
- $sandcastle_presentation = "$sandcastle_base\Presentation\vs2005"
-
- $nunit = "C:\Program Files (x86)\NUnit 2.5.2\bin\net-2.0\nunit-console.exe"
- $msbuild = "C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild"
- $mrefbuilder = "$sandcastle_base\ProductionTools\MrefBuilder.exe"
- $xsltransform = "$sandcastle_base\ProductionTools\XslTransform.exe"
- $buildassembler = "$sandcastle_base\ProductionTools\BuildAssembler.exe"
-
- $assembly = "$base_dir\Braintree\bin\Debug\Braintree-1.1.1.dll"
- $test_assembly = "$base_dir\Braintree.Tests\bin\Debug\Braintree.Tests.dll"
- $reflection = "$base_dir\reflection.xml"
- $manifest = "$base_dir\manifest.xml"
- $toc = "$base_dir\toc.xml"
-
- $production_transforms = "$sandcastle_base\ProductionTransforms"
-
- $sandcastle_config = "$base_dir\sandcastle.config"
-}
-
-task default -depends Test
-
-task Clean {
- if (Test-Path "$base_dir\Output")
- {
- Remove-Item "$base_dir\Output" -Recurse
- }
-}
-
-task Test -depends Compile {
- & $nunit .\Braintree.Tests\bin\debug\Braintree.Tests.dll
-}
-
-task Compile {
- & $msbuild
-}
-
-task GenerateDocs -depends Compile, Clean {
- mkdir "$base_dir\Output"
- mkdir "$base_dir\Output\html"
- Copy-Item "$sandcastle_presentation\configuration\sandcastle.config" $sandcastle_config
- Copy-Item "$sandcastle_presentation\icons" "$base_dir\Output" -Recurse
- Copy-Item "$sandcastle_presentation\Scripts" "$base_dir\Output" -Recurse
- Copy-Item "$sandcastle_presentation\Styles" "$base_dir\Output" -Recurse
-
- # Generate reflection.xml
- & $mrefbuilder $assembly /out:$reflection
- $reflection_transforms = "$production_transforms\ApplyVSDocModel.xsl", "$production_transforms\AddFriendlyFilenames.xsl"
- foreach ($transform in $reflection_transforms)
- {
- Copy-Item $reflection "temp.xml"
- & $xsltransform "temp.xml" /xsl:$transform /out:$reflection
- Remove-Item "temp.xml"
- }
-
- # Generate toc.xml
- & $xsltransform $reflection /xsl:"$production_transforms\CreateVSToc.xsl" /out:$toc
-
- # Generate manifest.xml
- & $xsltransform $reflection /xsl:"$production_transforms\ReflectionToManifest.xsl" /out:$manifest
-
- # Generate HTML docs
- & $buildassembler $manifest /config:$sandcastle_config
-
- Remove-Item $reflection
- Remove-Item $manifest
- Remove-Item $sandcastle_config
-}
Please sign in to comment.
Something went wrong with that request. Please try again.