Skip to content

Commit

Permalink
2.34.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Sep 10, 2014
1 parent 18f32ab commit 0217e9c
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 7 deletions.
17 changes: 17 additions & 0 deletions Braintree.Tests/SettlementBatchSummaryTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using NUnit.Framework;
using Braintree;
using System.Threading;

namespace Braintree.Tests
{
Expand Down Expand Up @@ -69,6 +71,21 @@ public void Generate_ReturnsTransactionsSettledOnAGivenDay()
Assert.AreEqual(1, visas.Count);
}

[Test]
public void Generate_AcceptsDatesInNonUSFormats()
{
CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
CultureInfo australianCulture = new CultureInfo("en-AU");
Thread.CurrentThread.CurrentCulture = australianCulture;

DateTime date = new DateTime(2014, 8, 20);
var result = gateway.SettlementBatchSummary.Generate(date);

Assert.IsTrue(result.IsSuccess());
Assert.AreEqual(australianCulture, Thread.CurrentThread.CurrentCulture);
Thread.CurrentThread.CurrentCulture = originalCulture;
}

[Test]
public void Generate_CanBeGroupedByACustomField()
{
Expand Down
2 changes: 2 additions & 0 deletions Braintree.Tests/SubscriptionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public void Create_SubscriptionWithoutTrial()
Assert.IsTrue(subscription.BillingPeriodStartDate.HasValue);
Assert.IsTrue(subscription.NextBillingDate.HasValue);
Assert.IsTrue(subscription.FirstBillingDate.HasValue);
Assert.IsTrue(subscription.CreatedAt.HasValue);
Assert.IsTrue(subscription.UpdatedAt.HasValue);
Assert.IsTrue(subscription.PaidThroughDate.HasValue);
}

Expand Down
12 changes: 12 additions & 0 deletions Braintree.Tests/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ public static void Settle(BraintreeService service, String transactionId)
Assert.IsTrue(response.IsSuccess());
}

public static void SettlementDecline(BraintreeService service, String transactionId)
{
NodeWrapper response = new NodeWrapper(service.Put("/transactions/" + transactionId + "/settlement_decline"));
Assert.IsTrue(response.IsSuccess());
}

public static void SettlementPending(BraintreeService service, String transactionId)
{
NodeWrapper response = new NodeWrapper(service.Put("/transactions/" + transactionId + "/settlement_pending"));
Assert.IsTrue(response.IsSuccess());
}

public static void Escrow(BraintreeService service, String transactionId)
{
NodeWrapper response = new NodeWrapper(service.Put("/transactions/" + transactionId + "/escrow"));
Expand Down
92 changes: 92 additions & 0 deletions Braintree.Tests/TransactionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,23 @@ public void Sale_ReturnsPaymentInstrumentTypeForPayPal()
Assert.AreEqual(PaymentInstrumentType.PAYPAL_ACCOUNT, transaction.PaymentInstrumentType);
}

[Test]
public void Sale_ReturnsDebugIdForPayPal()
{
String nonce = TestHelper.GenerateOneTimePayPalNonce(gateway);
TransactionRequest request = new TransactionRequest
{
Amount = SandboxValues.TransactionAmount.AUTHORIZE,
PaymentMethodNonce = nonce
};
Result<Transaction> result = gateway.Transaction.Sale(request);
Assert.IsTrue(result.IsSuccess());
Transaction transaction = result.Target;

Assert.IsNotNull(transaction.PayPalDetails);
Assert.IsNotNull(transaction.PayPalDetails.DebugId);
}

[Test]
public void Sale_WithAllAttributes()
{
Expand Down Expand Up @@ -3532,6 +3549,30 @@ public void CreateTransaction_WithPaymentMethodNonce()
Assert.IsTrue(result.IsSuccess());
}

[Test]
public void CreateTransaction_WithPayeeEmail()
{
String nonce = TestHelper.GenerateOneTimePayPalNonce(gateway);
TransactionRequest request = new TransactionRequest
{
Amount = SandboxValues.TransactionAmount.AUTHORIZE,
PaymentMethodNonce = nonce,
PayPalAccount = new TransactionPayPalRequest()
{
PayeeEmail = "[email protected]"
}
};
Result<Transaction> result = gateway.Transaction.Sale(request);
Assert.IsTrue(result.IsSuccess());
Assert.IsNotNull(result.Target.PayPalDetails.PayerEmail);
Assert.IsNotNull(result.Target.PayPalDetails.PaymentId);
Assert.IsNotNull(result.Target.PayPalDetails.AuthorizationId);
Assert.IsNotNull(result.Target.PayPalDetails.ImageUrl);
Assert.AreEqual("[email protected]", result.Target.PayPalDetails.PayeeEmail);
Assert.IsNull(result.Target.PayPalDetails.Token);
Assert.IsNotNull(result.Target.PayPalDetails.DebugId);
}

[Test]
public void CreateTransaction_WithOneTimePayPalNonce()
{
Expand All @@ -3548,6 +3589,7 @@ public void CreateTransaction_WithOneTimePayPalNonce()
Assert.IsNotNull(result.Target.PayPalDetails.AuthorizationId);
Assert.IsNotNull(result.Target.PayPalDetails.ImageUrl);
Assert.IsNull(result.Target.PayPalDetails.Token);
Assert.IsNotNull(result.Target.PayPalDetails.DebugId);
}

[Test]
Expand All @@ -3569,6 +3611,7 @@ public void CreateTransaction_WithOneTimePayPalNonceAndAttemptToVault()
Assert.IsNotNull(result.Target.PayPalDetails.PaymentId);
Assert.IsNotNull(result.Target.PayPalDetails.AuthorizationId);
Assert.IsNull(result.Target.PayPalDetails.Token);
Assert.IsNotNull(result.Target.PayPalDetails.DebugId);
}

[Test]
Expand All @@ -3590,6 +3633,7 @@ public void CreateTransaction_WithFuturePayPalNonceAndAttemptToVault()
Assert.IsNotNull(result.Target.PayPalDetails.PaymentId);
Assert.IsNotNull(result.Target.PayPalDetails.AuthorizationId);
Assert.IsNotNull(result.Target.PayPalDetails.Token);
Assert.IsNotNull(result.Target.PayPalDetails.DebugId);
}

[Test]
Expand Down Expand Up @@ -3646,5 +3690,53 @@ public void Refund_PayPalTransaction()
Result<Transaction> refundResult = gateway.Transaction.Refund(id);
Assert.IsTrue(refundResult.IsSuccess());
}

[Test]
public void PayPalTransactionsReturnSettlementDeclinedResponse()
{
var request = new TransactionRequest
{
Amount = 1000M,
PaymentMethodNonce = Nonce.PayPalFuturePayment,
Options = new TransactionOptionsRequest
{
SubmitForSettlement = true
}
};

var transactionResult = gateway.Transaction.Sale(request);
Assert.IsTrue(transactionResult.IsSuccess());

TestHelper.SettlementDecline(service, transactionResult.Target.Id);
Transaction transaction = gateway.Transaction.Find(transactionResult.Target.Id);

Assert.AreEqual("4001", transaction.ProcessorSettlementResponseCode);
Assert.AreEqual(TransactionStatus.SETTLEMENT_DECLINED, transaction.Status);
Assert.AreEqual("Settlement Declined", transaction.ProcessorSettlementResponseText);
}

[Test]
public void PayPalTransactionsReturnSettlementPendingResponse()
{
var request = new TransactionRequest
{
Amount = 1000M,
PaymentMethodNonce = Nonce.PayPalFuturePayment,
Options = new TransactionOptionsRequest
{
SubmitForSettlement = true
}
};

var transactionResult = gateway.Transaction.Sale(request);
Assert.IsTrue(transactionResult.IsSuccess());

TestHelper.SettlementPending(service, transactionResult.Target.Id);
Transaction transaction = gateway.Transaction.Find(transactionResult.Target.Id);

Assert.AreEqual("4002", transaction.ProcessorSettlementResponseCode);
Assert.AreEqual(TransactionStatus.SETTLEMENT_PENDING, transaction.Status);
Assert.AreEqual("Settlement Pending", transaction.ProcessorSettlementResponseText);
}
}
}
7 changes: 4 additions & 3 deletions Braintree/Braintree.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Braintree</RootNamespace>
<AssemblyName>Braintree-2.33.0</AssemblyName>
<AssemblyName>Braintree-2.34.0</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkSubset>
Expand All @@ -23,7 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Braintree-2.33.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Braintree-2.34.0.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand All @@ -33,7 +33,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Braintree-2.33.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Braintree-2.34.0.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down Expand Up @@ -153,6 +153,7 @@
<Compile Include="Transaction.cs" />
<Compile Include="TransactionGateway.cs" />
<Compile Include="TransactionOptionsRequest.cs" />
<Compile Include="TransactionPayPalRequest.cs" />
<Compile Include="TransactionRequest.cs" />
<Compile Include="TransactionSearchRequest.cs" />
<Compile Include="TransparentRedirectGateway.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Braintree/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public String GatewayURL
case "development":
return DevelopmentUrl();
case "qa":
return "https://qa-master.braintreegateway.com";
return "https://gateway.qa.braintreepayments.com";
case "sandbox":
return "https://api.sandbox.braintreegateway.com:443";
case "production":
Expand Down
4 changes: 4 additions & 0 deletions Braintree/PayPalDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class PayPalDetails
public String AuthorizationId { get; protected set; }
public String Token { get; protected set; }
public String ImageUrl { get; protected set; }
public String DebugId { get; protected set; }
public String PayeeEmail { get; protected set; }

protected internal PayPalDetails(NodeWrapper node)
{
Expand All @@ -17,6 +19,8 @@ protected internal PayPalDetails(NodeWrapper node)
AuthorizationId = node.GetString("authorization-id");
Token = node.GetString("token");
ImageUrl = node.GetString("image-url");
DebugId = node.GetString("debug-id");
PayeeEmail = node.GetString("payee-email");
}
}
}
4 changes: 2 additions & 2 deletions Braintree/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.33.0.0")]
[assembly: AssemblyFileVersion("2.33.0.0")]
[assembly: AssemblyVersion("2.34.0.0")]
[assembly: AssemblyFileVersion("2.34.0.0")]
8 changes: 8 additions & 0 deletions Braintree/SettlementBatchSummaryRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Threading;

namespace Braintree
{
Expand Down Expand Up @@ -32,8 +34,14 @@ public override String ToXml()

public virtual RequestBuilder BuildRequest(String root)
{
CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

var builder = new RequestBuilder(root);
builder.AddElement("settlement-date", SettlementDate.ToShortDateString());

Thread.CurrentThread.CurrentCulture = originalCulture;

if (GroupByCustomField != null)
{
builder.AddElement("group-by-custom-field", GroupByCustomField);
Expand Down
4 changes: 4 additions & 0 deletions Braintree/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public class Subscription
public List<Discount> Discounts { get; protected set; }
public Int32? FailureCount { get; protected set; }
public DateTime? FirstBillingDate { get; protected set; }
public DateTime? CreatedAt { get; protected set; }
public DateTime? UpdatedAt { get; protected set; }
public Boolean? HasTrialPeriod { get; protected set; }
public String Id { get; protected set; }
public Boolean? NeverExpires { get; protected set; }
Expand Down Expand Up @@ -115,6 +117,8 @@ public Subscription(NodeWrapper node, BraintreeService service)
Descriptor = new Descriptor(node.GetNode("descriptor"));
FailureCount = node.GetInteger("failure-count");
FirstBillingDate = node.GetDateTime("first-billing-date");
CreatedAt = node.GetDateTime("created-at");
UpdatedAt = node.GetDateTime("updated-at");
Id = node.GetString("id");
NextBillAmount = node.GetDecimal("next-bill-amount");
NextBillingDate = node.GetDateTime("next-billing-date");
Expand Down
8 changes: 7 additions & 1 deletion Braintree/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ public class TransactionStatus : Enumeration
public static readonly TransactionStatus SUBMITTED_FOR_SETTLEMENT = new TransactionStatus("submitted_for_settlement");
public static readonly TransactionStatus VOIDED = new TransactionStatus("voided");
public static readonly TransactionStatus UNRECOGNIZED = new TransactionStatus("unrecognized");
public static readonly TransactionStatus SETTLEMENT_DECLINED = new TransactionStatus("settlement_declined");
public static readonly TransactionStatus SETTLEMENT_PENDING = new TransactionStatus("settlement_pending");

public static readonly TransactionStatus[] ALL = {
AUTHORIZATION_EXPIRED, AUTHORIZED, AUTHORIZING, FAILED, GATEWAY_REJECTED, PROCESSOR_DECLINED,
SETTLED, SETTLING, SUBMITTED_FOR_SETTLEMENT, VOIDED, UNRECOGNIZED
SETTLED, SETTLEMENT_DECLINED, SETTLEMENT_PENDING, SETTLING, SUBMITTED_FOR_SETTLEMENT, VOIDED, UNRECOGNIZED
};

protected TransactionStatus(String name) : base(name) {}
Expand Down Expand Up @@ -144,6 +146,8 @@ public class Transaction
public String ProcessorAuthorizationCode { get; protected set; }
public String ProcessorResponseCode { get; protected set; }
public String ProcessorResponseText { get; protected set; }
public String ProcessorSettlementResponseCode { get; protected set; }
public String ProcessorSettlementResponseText { get; protected set; }
public String VoiceReferralNumber { get; protected set; }
public String PurchaseOrderNumber { get; protected set; }
public Boolean? Recurring { get; protected set; }
Expand Down Expand Up @@ -212,6 +216,8 @@ protected internal Transaction(NodeWrapper node, BraintreeService service)
ProcessorAuthorizationCode = node.GetString("processor-authorization-code");
ProcessorResponseCode = node.GetString("processor-response-code");
ProcessorResponseText = node.GetString("processor-response-text");
ProcessorSettlementResponseCode = node.GetString("processor-settlement-response-code");
ProcessorSettlementResponseText = node.GetString("processor-settlement-response-text");
VoiceReferralNumber = node.GetString("voice-referral-number");
PurchaseOrderNumber = node.GetString("purchase-order-number");
Recurring = node.GetBoolean("recurring");
Expand Down
34 changes: 34 additions & 0 deletions Braintree/TransactionPayPalRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;

namespace Braintree
{
public class TransactionPayPalRequest : Request
{
public String PayeeEmail { get; set; }

public override String ToXml()
{
return ToXml("paypal-account");
}

public override String ToXml(String root)
{
return BuildRequest(root).ToXml();
}

public override String ToQueryString()
{
return ToQueryString("paypal-account");
}

public override String ToQueryString(String root)
{
return BuildRequest(root).ToQueryString();
}

protected virtual RequestBuilder BuildRequest(String root)
{
return new RequestBuilder(root).AddElement("payee-email", PayeeEmail);
}
}
}
2 changes: 2 additions & 0 deletions Braintree/TransactionRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class TransactionRequest : Request
public DescriptorRequest Descriptor { get; set; }
public AddressRequest BillingAddress { get; set; }
public AddressRequest ShippingAddress { get; set; }
public TransactionPayPalRequest PayPalAccount { get; set; }
public Decimal TaxAmount { get; set; }
public Boolean? TaxExempt { get; set; }
public TransactionType Type { get; set; }
Expand Down Expand Up @@ -127,6 +128,7 @@ protected virtual RequestBuilder BuildRequest(String root)
builder.AddElement("descriptor", Descriptor);
builder.AddElement("billing", BillingAddress);
builder.AddElement("shipping", ShippingAddress);
builder.AddElement("paypal-account", PayPalAccount);
builder.AddElement("options", Options);
builder.AddElement("venmo-sdk-payment-method-code", VenmoSdkPaymentMethodCode);
if (_threeDSecureTransaction) {
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.34.0
* Added paypal specific fields to transaction calls
* Added SettlementPending, SettlementDeclined transaction statuses

## 2.33.0

* Add descriptor url support
Expand Down

0 comments on commit 0217e9c

Please sign in to comment.