Skip to content

Commit

Permalink
2.41.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed May 7, 2015
1 parent 7e37627 commit 900b948
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 18 deletions.
38 changes: 37 additions & 1 deletion Braintree.Tests/PaymentMethodNonceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void Create_CreatesPaymentMethodNonce()
}

[Test]
public void Find_RaisesNotFoundErrorWhenTokenDoesntExist()
public void Create_RaisesNotFoundErrorWhenTokenDoesntExist()
{
try
{
Expand All @@ -56,5 +56,41 @@ public void Find_RaisesNotFoundErrorWhenTokenDoesntExist()
}
catch(NotFoundException) {}
}

[Test]
public void Find_ExposesThreeDSecureInfo()
{
PaymentMethodNonce nonce = gateway.PaymentMethodNonce.Find("threedsecurednonce");
ThreeDSecureInfo info = nonce.ThreeDSecureInfo;

Assert.AreEqual(nonce.Nonce, "threedsecurednonce");
Assert.AreEqual(nonce.Type, "CreditCard");
Assert.AreEqual(info.Enrolled, "Y");
Assert.AreEqual(info.Status, "authenticate_successful");
Assert.AreEqual(info.LiabilityShifted, true);
Assert.AreEqual(info.LiabilityShiftPossible, true);
}

[Test]
public void Find_ExposesNullThreeDSecureInfoIfBlank()
{
String nonce = TestHelper.GenerateUnlockedNonce(gateway);

PaymentMethodNonce foundNonce = gateway.PaymentMethodNonce.Find(nonce);

Assert.IsNull(foundNonce.ThreeDSecureInfo);
}

[Test]
public void Find_RaisesNotFoundErrorWhenTokenDoesntExist()
{
try
{
gateway.PaymentMethodNonce.Find("notarealnonce");
Assert.Fail("Should have raised NotFoundException");
}
catch(NotFoundException) {}
}

}
}
36 changes: 36 additions & 0 deletions Braintree.Tests/TransactionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3113,6 +3113,26 @@ public void Find_WithBadId()
}
}

[Test]
public void Find_ExposesThreeDSecureInfo()
{
Transaction transaction = gateway.Transaction.Find("threedsecuredtransaction");

ThreeDSecureInfo info = transaction.ThreeDSecureInfo;
Assert.AreEqual(info.Enrolled, "Y");
Assert.AreEqual(info.Status, "authenticate_successful");
Assert.AreEqual(info.LiabilityShifted, true);
Assert.AreEqual(info.LiabilityShiftPossible, true);
}

[Test]
public void Find_ExposesNullThreeDSecureInfoIfBlank()
{
Transaction transaction = gateway.Transaction.Find("settledtransaction");

Assert.IsNull(transaction.ThreeDSecureInfo);
}

[Test]
public void Find_ExposesDisbursementDetails()
{
Expand Down Expand Up @@ -4023,5 +4043,21 @@ public void PayPalTransactionsReturnSettlementPendingResponse()
Assert.AreEqual(TransactionStatus.SETTLEMENT_PENDING, transaction.Status);
Assert.AreEqual("Settlement Pending", transaction.ProcessorSettlementResponseText);
}

[Test]
public void PayPalTransactionsReturnRequiredFields()
{
Transaction transaction = gateway.Transaction.Find("settledtransaction");

Assert.IsNotNull(transaction.PayPalDetails.DebugId);
Assert.IsNotNull(transaction.PayPalDetails.PayerEmail);
Assert.IsNotNull(transaction.PayPalDetails.AuthorizationId);
Assert.IsNotNull(transaction.PayPalDetails.PayerId);
Assert.IsNotNull(transaction.PayPalDetails.PayerFirstName);
Assert.IsNotNull(transaction.PayPalDetails.PayerLastName);
Assert.IsNotNull(transaction.PayPalDetails.SellerProtectionStatus);
Assert.IsNotNull(transaction.PayPalDetails.CaptureId);
Assert.IsNotNull(transaction.PayPalDetails.RefundId);
}
}
}
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.40.0</AssemblyName>
<AssemblyName>Braintree-2.41.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.40.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Braintree-2.41.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.40.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Braintree-2.41.0.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down Expand Up @@ -159,6 +159,7 @@
<Compile Include="SubscriptionTransactionRequest.cs" />
<Compile Include="TextNode.cs" />
<Compile Include="Test\Nonce.cs" />
<Compile Include="ThreeDSecureInfo.cs" />
<Compile Include="TrUtil.cs" />
<Compile Include="Transaction.cs" />
<Compile Include="TransactionGateway.cs" />
Expand Down
10 changes: 10 additions & 0 deletions Braintree/NodeWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ public NodeWrapper(XmlNode node)
this.node = node;
}

public Boolean IsEmpty()
{
var attribute = node.Attributes["nil"];
if (attribute != null)
{
return XmlConvert.ToBoolean(attribute.Value);
}
return false;
}

public virtual String GetString(String path)
{
if (GetNode(path) == null) return null;
Expand Down
12 changes: 12 additions & 0 deletions Braintree/PayPalDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ public class PayPalDetails
public String DebugId { get; protected set; }
public String PayeeEmail { get; protected set; }
public String CustomField { get; protected set; }
public String PayerId { get; protected set; }
public String PayerFirstName { get; protected set; }
public String PayerLastName { get; protected set; }
public String SellerProtectionStatus { get; protected set; }
public String CaptureId { get; protected set; }
public String RefundId { get; protected set; }

protected internal PayPalDetails(NodeWrapper node)
{
Expand All @@ -23,6 +29,12 @@ protected internal PayPalDetails(NodeWrapper node)
DebugId = node.GetString("debug-id");
PayeeEmail = node.GetString("payee-email");
CustomField = node.GetString("custom-field");
PayerId = node.GetString("payer-id");
PayerFirstName = node.GetString("payer-first-name");
PayerLastName = node.GetString("payer-last-name");
SellerProtectionStatus = node.GetString("seller-protection-status");
CaptureId = node.GetString("capture-id");
RefundId = node.GetString("refund-id");
}
}
}
8 changes: 8 additions & 0 deletions Braintree/PaymentMethodNonce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ namespace Braintree
public class PaymentMethodNonce
{
public String Nonce { get; protected set; }
public String Type { get; protected set; }
public ThreeDSecureInfo ThreeDSecureInfo { get; protected set; }

protected internal PaymentMethodNonce(NodeWrapper node, BraintreeService service)
{
Nonce = node.GetString("nonce");
Type = node.GetString("type");

var threeDSecureInfoNode = node.GetNode("three-d-secure-info");
if (threeDSecureInfoNode != null && !threeDSecureInfoNode.IsEmpty()){
ThreeDSecureInfo = new ThreeDSecureInfo(threeDSecureInfoNode);
}
}
}
}
8 changes: 8 additions & 0 deletions Braintree/PaymentMethodNonceGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,13 @@ public Result<PaymentMethodNonce> Create(string token)

return new ResultImpl<PaymentMethodNonce>(response, service);
}

public virtual PaymentMethodNonce Find(String nonce)
{
NodeWrapper response = new NodeWrapper(service.Get("/payment_method_nonces/" + nonce));

return new PaymentMethodNonce(response, service);
}

}
}
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.40.0.0")]
[assembly: AssemblyFileVersion("2.40.0.0")]
[assembly: AssemblyVersion("2.41.0.0")]
[assembly: AssemblyFileVersion("2.41.0.0")]
1 change: 1 addition & 0 deletions Braintree/Test/Nonce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Nonce
public const String ApplePayMastercard = "fake-apple-pay-mastercard-nonce";
public const String ApplePayAmex = "fake-apple-pay-amex-nonce";
public const String AbstractTransactable = "fake-abstract-transactable-nonce";
public const String Europe = "fake-europe-bank-account-nonce";
public const String Coinbase = "fake-coinbase-nonce";
}
}
24 changes: 24 additions & 0 deletions Braintree/ThreeDSecureInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;

namespace Braintree
{
public class ThreeDSecureInfo
{
public String Status { get; protected set; }
public String Enrolled { get; protected set; }
public Boolean? LiabilityShifted { get; protected set; }
public Boolean? LiabilityShiftPossible { get; protected set; }

public ThreeDSecureInfo(NodeWrapper node)
{
if (node == null) return;

Enrolled = node.GetString("enrolled");
Status = node.GetString("status");
LiabilityShifted = node.GetBoolean("liability-shifted");
LiabilityShiftPossible = node.GetBoolean("liability-shift-possible");
}
}
}

12 changes: 10 additions & 2 deletions Braintree/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ protected TransactionCreatedUsing(String name) : base(name) {}
public class PaymentInstrumentType : Enumeration
{
public static readonly PaymentInstrumentType PAYPAL_ACCOUNT = new PaymentInstrumentType("paypal_account");
public static readonly PaymentInstrumentType SEPA_BANK_ACCOUNT= new PaymentInstrumentType("sepa_bank_account");
public static readonly PaymentInstrumentType EUROPE_BANK_ACCOUNT= new PaymentInstrumentType("europe_bank_account");
public static readonly PaymentInstrumentType CREDIT_CARD = new PaymentInstrumentType("credit_card");
public static readonly PaymentInstrumentType COINBASE_ACCOUNT= new PaymentInstrumentType("coinbase_account");
public static readonly PaymentInstrumentType APPLE_PAY_CARD = new PaymentInstrumentType("apple_pay_card");
public static readonly PaymentInstrumentType ANY = new PaymentInstrumentType("any");
public static readonly PaymentInstrumentType UNKNOWN = new PaymentInstrumentType("unknown");

public static readonly PaymentInstrumentType[] ALL = { PAYPAL_ACCOUNT, SEPA_BANK_ACCOUNT, CREDIT_CARD, ANY, UNKNOWN };
public static readonly PaymentInstrumentType[] ALL = { PAYPAL_ACCOUNT, EUROPE_BANK_ACCOUNT, CREDIT_CARD, COINBASE_ACCOUNT, APPLE_PAY_CARD, ANY, UNKNOWN };

protected PaymentInstrumentType(String name) : base(name) {}
}
Expand Down Expand Up @@ -184,6 +186,7 @@ public class Transaction
public CoinbaseDetails CoinbaseDetails { get; protected set; }
public PaymentInstrumentType PaymentInstrumentType { get; protected set; }
public RiskData RiskData { get; protected set; }
public ThreeDSecureInfo ThreeDSecureInfo { get; protected set; }

private BraintreeService Service;

Expand Down Expand Up @@ -296,6 +299,11 @@ protected internal Transaction(NodeWrapper node, BraintreeService service)
if (riskDataNode != null){
RiskData = new RiskData(riskDataNode);
}

var threeDSecureInfoNode = node.GetNode("three-d-secure-info");
if (threeDSecureInfoNode != null && !threeDSecureInfoNode.IsEmpty()){
ThreeDSecureInfo = new ThreeDSecureInfo(threeDSecureInfoNode);
}
}

/// <summary>
Expand Down
Loading

0 comments on commit 900b948

Please sign in to comment.