Skip to content

Commit

Permalink
2.43.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Jun 4, 2015
1 parent a92abae commit f739d77
Show file tree
Hide file tree
Showing 14 changed files with 235 additions and 12 deletions.
24 changes: 21 additions & 3 deletions Braintree.Tests/CustomerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void Find_FindsCustomerWithGivenId()
}

[Test]
public void Find_IncludesPaymentMethods()
public void Find_IncludesApplePayCardsInPaymentMethods()
{
var createRequest = new CustomerRequest
{
Expand All @@ -104,8 +104,26 @@ public void Find_IncludesPaymentMethods()
Customer customer = gateway.Customer.Find(createdCustomer.Id);
Assert.IsNotNull(customer.ApplePayCards);
Assert.IsNotNull(customer.PaymentMethods);
Assert.IsNotNull(customer.ApplePayCards[0].Token);
Assert.AreEqual(customer.ApplePayCards[0], customer.PaymentMethods[0]);
ApplePayCard card = customer.ApplePayCards[0];
Assert.IsNotNull(card.Token);
Assert.AreEqual(card, customer.PaymentMethods[0]);
}

[Test]
public void Find_IncludesAndroidPayCardsInPaymentMethods()
{
var createRequest = new CustomerRequest
{
PaymentMethodNonce = Nonce.AndroidPay
};
Customer createdCustomer = gateway.Customer.Create(createRequest).Target;
Customer customer = gateway.Customer.Find(createdCustomer.Id);
Assert.IsNotNull(customer.AndroidPayCards);
Assert.IsNotNull(customer.PaymentMethods);
AndroidPayCard card = customer.AndroidPayCards[0];
Assert.IsNotNull(card.Token);
Assert.IsNotNull(card.GoogleTransactionId);
Assert.AreEqual(card, customer.PaymentMethods[0]);
}

[Test]
Expand Down
4 changes: 2 additions & 2 deletions Braintree.Tests/MerchantAccountTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public void Create_AcceptsBankFundingDestination()
{
var request = createRequest(null);
request.Funding.Destination = FundingDestination.BANK;
request.Funding.AccountNumber = "43759348798";
request.Funding.RoutingNumber = "122100024";
Result<MerchantAccount> result = gateway.MerchantAccount.Create(request);
Assert.IsTrue(result.IsSuccess());
}
Expand Down Expand Up @@ -369,8 +371,6 @@ private MerchantAccountRequest createRequest(String id)
Destination = FundingDestination.EMAIL,
Email = "[email protected]",
MobilePhone = "3125551212",
RoutingNumber = "122100024",
AccountNumber = "43759348798",
Descriptor = "Job Leoggs OH",
},
TosAccepted = true,
Expand Down
50 changes: 50 additions & 0 deletions Braintree.Tests/PaymentMethodTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,40 @@ public void Create_CreatesApplePayCardWithNonce()
Assert.IsNotNull(applePayCard.PaymentInstrumentName);
}

[Test]
public void Create_CreatesAndroidPayCardWithNonce()
{
Result<Customer> result = gateway.Customer.Create(new CustomerRequest());
Assert.IsTrue(result.IsSuccess());

var request = new PaymentMethodRequest
{
CustomerId = result.Target.Id,
PaymentMethodNonce = Nonce.AndroidPay
};
Result<PaymentMethod> paymentMethodResult = gateway.PaymentMethod.Create(request);

Assert.IsTrue(paymentMethodResult.IsSuccess());
Assert.IsNotNull(paymentMethodResult.Target.Token);
Assert.IsNotNull(paymentMethodResult.Target.ImageUrl);
Assert.IsInstanceOfType(typeof(AndroidPayCard), paymentMethodResult.Target);
AndroidPayCard androidPayCard = (AndroidPayCard) paymentMethodResult.Target;
Assert.IsNotNull(androidPayCard.IsDefault);
Assert.IsNotNull(androidPayCard.CardType);
Assert.IsNotNull(androidPayCard.VirtualCardType);
Assert.IsNotNull(androidPayCard.SourceCardType);
Assert.IsNotNull(androidPayCard.Last4);
Assert.IsNotNull(androidPayCard.VirtualCardLast4);
Assert.IsNotNull(androidPayCard.SourceCardLast4);
Assert.IsNotNull(androidPayCard.Bin);
Assert.IsNotNull(androidPayCard.ExpirationMonth);
Assert.IsNotNull(androidPayCard.ExpirationYear);
Assert.IsNotNull(androidPayCard.GoogleTransactionId);
Assert.IsNotNull(androidPayCard.CreatedAt);
Assert.IsNotNull(androidPayCard.UpdatedAt);
Assert.IsNotNull(androidPayCard.Subscriptions);
}

[Test]
public void Create_CreatesAbstractPaymentMethod()
{
Expand Down Expand Up @@ -574,6 +608,22 @@ public void Find_FindsApplePayCard()
Assert.IsInstanceOfType(typeof(ApplePayCard), found);
}

[Test]
public void Find_FindsAndroidPayCard()
{
var request = new PaymentMethodRequest
{
CustomerId = gateway.Customer.Create(new CustomerRequest()).Target.Id,
PaymentMethodNonce = Nonce.AndroidPay
};
Result<PaymentMethod> result = gateway.PaymentMethod.Create(request);
Assert.IsTrue(result.IsSuccess());

PaymentMethod found = gateway.PaymentMethod.Find(result.Target.Token);
Assert.AreEqual(result.Target.Token, found.Token);
Assert.IsInstanceOfType(typeof(AndroidPayCard), found);
}

[Test]
public void Find_FindsAbstractPaymentMethod()
{
Expand Down
30 changes: 30 additions & 0 deletions Braintree.Tests/TransactionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1801,6 +1801,36 @@ public void Sale_WithApplePayNonce()
Assert.IsNotNull(result.Target.ApplePayDetails.PaymentInstrumentName);
}

[Test]
public void Sale_WithAndroidPayCardNonce()
{
TransactionRequest request = new TransactionRequest
{
Amount = SandboxValues.TransactionAmount.AUTHORIZE,
PaymentMethodNonce = Nonce.AndroidPay
};
Result<Transaction> result = gateway.Transaction.Sale(request);
Assert.IsTrue(result.IsSuccess());

Assert.IsNotNull(result.Target.AndroidPayDetails);

Assert.IsInstanceOfType(typeof(AndroidPayDetails), result.Target.AndroidPayDetails);
AndroidPayDetails androidPayDetails = (AndroidPayDetails) result.Target.AndroidPayDetails;

Assert.IsNull(androidPayDetails.Token);
Assert.IsNotNull(androidPayDetails.ImageUrl);
Assert.IsNotNull(androidPayDetails.CardType);
Assert.IsNotNull(androidPayDetails.VirtualCardType);
Assert.IsNotNull(androidPayDetails.SourceCardType);
Assert.IsNotNull(androidPayDetails.Last4);
Assert.IsNotNull(androidPayDetails.VirtualCardLast4);
Assert.IsNotNull(androidPayDetails.SourceCardLast4);
Assert.IsNotNull(androidPayDetails.Bin);
Assert.IsNotNull(androidPayDetails.ExpirationMonth);
Assert.IsNotNull(androidPayDetails.ExpirationYear);
Assert.IsNotNull(androidPayDetails.GoogleTransactionId);
}

[Test]
public void Sale_Declined()
{
Expand Down
51 changes: 51 additions & 0 deletions Braintree/AndroidPayCard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;

namespace Braintree
{
public class AndroidPayCard : PaymentMethod
{
public String CardType { get; protected set; }
public String Last4 { get; protected set; }
public String SourceCardType { get; protected set; }
public String SourceCardLast4 { get; protected set; }
public String VirtualCardType { get; protected set; }
public String VirtualCardLast4 { get; protected set; }
public String ExpirationMonth { get; protected set; }
public String ExpirationYear { get; protected set; }
public String Token { get; protected set; }
public String GoogleTransactionId { get; protected set; }
public String Bin { get; protected set; }
public Boolean? IsDefault { get; protected set; }
public String ImageUrl { get; protected set; }
public DateTime? CreatedAt { get; protected set; }
public DateTime? UpdatedAt { get; protected set; }
public Subscription[] Subscriptions { get; protected set; }

protected internal AndroidPayCard(NodeWrapper node, BraintreeService service)
{
CardType = node.GetString("virtual-card-type");
VirtualCardType = node.GetString("virtual-card-type");
SourceCardType = node.GetString("source-card-type");
Last4 = node.GetString("virtual-card-last-4");
SourceCardLast4 = node.GetString("source-card-last-4");
VirtualCardLast4 = node.GetString("virtual-card-last-4");
Bin = node.GetString("bin");
ExpirationMonth = node.GetString("expiration-month");
ExpirationYear = node.GetString("expiration-year");
GoogleTransactionId = node.GetString("google-transaction-id");
Token = node.GetString("token");
IsDefault = node.GetBoolean("default");
ImageUrl = node.GetString("image-url");

CreatedAt = node.GetDateTime("created-at");
UpdatedAt = node.GetDateTime("updated-at");

var subscriptionXmlNodes = node.GetList("subscriptions/subscription");
Subscriptions = new Subscription[subscriptionXmlNodes.Count];
for (int i = 0; i < subscriptionXmlNodes.Count; i++)
{
Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], service);
}
}
}
}
36 changes: 36 additions & 0 deletions Braintree/AndroidPayDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;

namespace Braintree
{
public class AndroidPayDetails
{
public String Bin { get; protected set; }
public String ExpirationMonth { get; protected set; }
public String ExpirationYear { get; protected set; }
public String GoogleTransactionId { get; protected set; }
public String ImageUrl { get; protected set; }
public String SourceCardLast4 { get; protected set; }
public String SourceCardType { get; protected set; }
public String VirtualCardLast4 { get; protected set; }
public String VirtualCardType { get; protected set; }
public String CardType { get; protected set; }
public String Last4 { get; protected set; }
public String Token { get; protected set; }

protected internal AndroidPayDetails(NodeWrapper node)
{
Bin = node.GetString("bin");
ExpirationMonth = node.GetString("expiration-month");
ExpirationYear = node.GetString("expiration-year");
GoogleTransactionId = node.GetString("google-transaction-id");
ImageUrl = node.GetString("image-url");
SourceCardType = node.GetString("source-card-type");
SourceCardLast4 = node.GetString("source-card-last-4");
VirtualCardLast4 = node.GetString("virtual-card-last-4");
VirtualCardType = node.GetString("virtual-card-type");
CardType = node.GetString("virtual-card-type");
Last4 = node.GetString("virtual-card-last-4");
Token = node.GetString("token");
}
}
}
8 changes: 5 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.42.0</AssemblyName>
<AssemblyName>Braintree-2.43.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.42.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Braintree-2.43.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.42.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Braintree-2.43.0.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand All @@ -53,6 +53,8 @@
<Compile Include="Address.cs" />
<Compile Include="AddressGateway.cs" />
<Compile Include="AddressRequest.cs" />
<Compile Include="AndroidPayCard.cs" />
<Compile Include="AndroidPayDetails.cs" />
<Compile Include="ApplePayCard.cs" />
<Compile Include="ApplePayDetails.cs" />
<Compile Include="ApplicantDetails.cs" />
Expand Down
11 changes: 10 additions & 1 deletion Braintree/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Customer
public CreditCard[] CreditCards { get; protected set; }
public PayPalAccount[] PayPalAccounts { get; protected set; }
public ApplePayCard[] ApplePayCards { get; protected set; }
public AndroidPayCard[] AndroidPayCards { get; protected set; }
public CoinbaseAccount[] CoinbaseAccounts { get; protected set; }
public PaymentMethod[] PaymentMethods { get; protected set; }
public Address[] Addresses { get; protected set; }
Expand Down Expand Up @@ -89,18 +90,26 @@ protected internal Customer(NodeWrapper node, BraintreeService service)
ApplePayCards[i] = new ApplePayCard(applePayXmlNodes[i], service);
}

var androidPayCardXmlNodes = node.GetList("android-pay-cards/android-pay-card");
AndroidPayCards = new AndroidPayCard[androidPayCardXmlNodes.Count];
for (int i = 0; i < androidPayCardXmlNodes.Count; i++)
{
AndroidPayCards[i] = new AndroidPayCard(androidPayCardXmlNodes[i], service);
}

var coinbaseXmlNodes = node.GetList("coinbase-accounts/coinbase-account");
CoinbaseAccounts = new CoinbaseAccount[coinbaseXmlNodes.Count];
for (int i = 0; i < coinbaseXmlNodes.Count; i++)
{
CoinbaseAccounts[i] = new CoinbaseAccount(coinbaseXmlNodes[i], service);
}

PaymentMethods = new PaymentMethod[CreditCards.Length + PayPalAccounts.Length + ApplePayCards.Length + CoinbaseAccounts.Length];
PaymentMethods = new PaymentMethod[CreditCards.Length + PayPalAccounts.Length + ApplePayCards.Length + CoinbaseAccounts.Length + AndroidPayCards.Length];
CreditCards.CopyTo(PaymentMethods, 0);
PayPalAccounts.CopyTo(PaymentMethods, CreditCards.Length);
ApplePayCards.CopyTo(PaymentMethods, CreditCards.Length + PayPalAccounts.Length);
CoinbaseAccounts.CopyTo(PaymentMethods, CreditCards.Length + PayPalAccounts.Length + ApplePayCards.Length);
AndroidPayCards.CopyTo(PaymentMethods, CreditCards.Length + PayPalAccounts.Length + ApplePayCards.Length + CoinbaseAccounts.Length);

var addressXmlNodes = node.GetList("addresses/address");
Addresses = new Address[addressXmlNodes.Count];
Expand Down
12 changes: 12 additions & 0 deletions Braintree/PaymentMethodGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public Result<PaymentMethod> Create(PaymentMethodRequest request)
{
return new ResultImpl<ApplePayCard>(response, service);
}
else if (response.GetName() == "android-pay-card")
{
return new ResultImpl<AndroidPayCard>(response, service);
}
else if (response.GetName() == "coinbase-account")
{
return new ResultImpl<CoinbaseAccount>(response, service);
Expand All @@ -54,6 +58,10 @@ public Result<PaymentMethod> Update(string token, PaymentMethodRequest request)
{
return new ResultImpl<ApplePayCard>(response, service);
}
else if (response.GetName() == "android-pay-card")
{
return new ResultImpl<AndroidPayCard>(response, service);
}
else
{
return new ResultImpl<UnknownPaymentMethod>(response, service);
Expand Down Expand Up @@ -84,6 +92,10 @@ public PaymentMethod Find(String token)
{
return new ApplePayCard(response, service);
}
else if (response.GetName() == "android-pay-card")
{
return new AndroidPayCard(response, service);
}
else if (response.GetName() == "coinbase-account")
{
return new CoinbaseAccount(response, service);
Expand Down
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.42.0.0")]
[assembly: AssemblyFileVersion("2.42.0.0")]
[assembly: AssemblyVersion("2.43.0.0")]
[assembly: AssemblyFileVersion("2.43.0.0")]
4 changes: 4 additions & 0 deletions Braintree/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ private T newInstanceFromResponse(NodeWrapper node, BraintreeService service)
{
return new ApplePayCard(node, service) as T;
}
else if (typeof(T) == typeof(AndroidPayCard))
{
return new AndroidPayCard(node, service) as T;
}
else if (typeof(T) == typeof(CreditCard))
{
return new CreditCard(node, service) as T;
Expand Down
1 change: 1 addition & 0 deletions Braintree/Test/Nonce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Nonce
public const String ApplePayVisa = "fake-apple-pay-visa-nonce";
public const String ApplePayMastercard = "fake-apple-pay-mastercard-nonce";
public const String ApplePayAmex = "fake-apple-pay-amex-nonce";
public const String AndroidPay = "fake-android-pay-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";
Expand Down
Loading

0 comments on commit f739d77

Please sign in to comment.