Skip to content

Commit

Permalink
2.36.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Oct 10, 2014
1 parent aa49316 commit 8be5443
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Braintree.Tests/MerchantAccountTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public void Update_UpdatesAllFields()
Assert.AreEqual("3125551212", merchantAccount.FundingDetails.MobilePhone);
Assert.AreEqual("122100024", merchantAccount.FundingDetails.RoutingNumber);
Assert.AreEqual("8798", merchantAccount.FundingDetails.AccountNumberLast4);
Assert.AreEqual("Job Leoggs OH", merchantAccount.FundingDetails.Descriptor);
}

[Test]
Expand Down Expand Up @@ -370,6 +371,7 @@ private MerchantAccountRequest createRequest(String id)
MobilePhone = "3125551212",
RoutingNumber = "122100024",
AccountNumber = "43759348798",
Descriptor = "Job Leoggs OH",
},
TosAccepted = true,
Id = id,
Expand Down
26 changes: 26 additions & 0 deletions Braintree.Tests/PaymentMethodTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@ public void Create_CreatesCreditCardWithNonce()
Assert.IsInstanceOfType(typeof(CreditCard), paymentMethodResult.Target);
}

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

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

Assert.IsTrue(paymentMethodResult.IsSuccess());
Assert.IsNotNull(paymentMethodResult.Target.Token);
Assert.IsNotNull(paymentMethodResult.Target.ImageUrl);
Assert.IsInstanceOfType(typeof(ApplePayCard), paymentMethodResult.Target);
ApplePayCard applePayCard = (ApplePayCard) paymentMethodResult.Target;
Assert.IsNotNull(applePayCard.CardType);
Assert.IsNotNull(applePayCard.ExpirationMonth);
Assert.IsNotNull(applePayCard.ExpirationYear);
Assert.IsNotNull(applePayCard.CreatedAt);
Assert.IsNotNull(applePayCard.UpdatedAt);
Assert.IsNotNull(applePayCard.Subscriptions);
}

[Test]
public void Create_CanMakeDefaultAndSetToken()
{
Expand Down
21 changes: 19 additions & 2 deletions Braintree.Tests/TransactionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,24 @@ public void Sale_ErrorWithNullThreeDSecureToken()
Assert.AreEqual(ValidationErrorCode.TRANSACTION_THREE_D_SECURE_TOKEN_IS_INVALID, result.Errors.ForObject("Transaction").OnField("Three-D-Secure-Token")[0].Code);
}

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

Assert.IsNotNull(result.Target.ApplePayDetails);
Assert.IsNotNull(result.Target.ApplePayDetails.CardType);
Assert.IsNotNull(result.Target.ApplePayDetails.ExpirationMonth);
Assert.IsNotNull(result.Target.ApplePayDetails.ExpirationYear);
Assert.IsNotNull(result.Target.ApplePayDetails.CardholderName);
}

[Test]
public void Sale_Declined()
{
Expand Down Expand Up @@ -3694,6 +3712,7 @@ public void SubmitForSettlement_PayPalTransaction()

Result<Transaction> settlementResult = gateway.Transaction.SubmitForSettlement(result.Target.Id);
Assert.IsTrue(settlementResult.IsSuccess());
Assert.AreEqual(TransactionStatus.SETTLING, settlementResult.Target.Status);
}

[Test]
Expand All @@ -3713,8 +3732,6 @@ public void Refund_PayPalTransaction()
Assert.IsTrue(result.IsSuccess());
var id = result.Target.Id;

TestHelper.Settle(service, id);

Result<Transaction> refundResult = gateway.Transaction.Refund(id);
Assert.IsTrue(refundResult.IsSuccess());
}
Expand Down
39 changes: 39 additions & 0 deletions Braintree/ApplePayCard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;

namespace Braintree
{
public class ApplePayCard : PaymentMethod
{
public String CardType { get; protected set; }
public String Last4 { get; protected set; }
public String ExpirationMonth { get; protected set; }
public String ExpirationYear { get; protected set; }
public String Token { 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 ApplePayCard(NodeWrapper node, BraintreeService service)
{
CardType = node.GetString("card-type");
Last4 = node.GetString("last-4");
ExpirationMonth = node.GetString("expiration-month");
ExpirationYear = node.GetString("expiration-year");
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);
}
}
}
}
22 changes: 22 additions & 0 deletions Braintree/ApplePayDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

namespace Braintree
{
public class ApplePayDetails
{
public String CardType { get; protected set; }
public String CardholderName { get; protected set; }
public String ExpirationMonth { get; protected set; }
public String ExpirationYear { get; protected set; }
public String Token { get; protected set; }

protected internal ApplePayDetails(NodeWrapper node)
{
CardType = node.GetString("card-type");
CardholderName = node.GetString("cardholder-name");
ExpirationMonth = node.GetString("expiration-month");
ExpirationYear = node.GetString("expiration-year");
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.35.0</AssemblyName>
<AssemblyName>Braintree-2.36.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.35.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Braintree-2.36.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.35.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Braintree-2.36.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="ApplePayCard.cs" />
<Compile Include="ApplePayDetails.cs" />
<Compile Include="ApplicantDetails.cs" />
<Compile Include="ApplicantDetailsRequest.cs" />
<Compile Include="ClientTokenGateway.cs" />
Expand Down
2 changes: 2 additions & 0 deletions Braintree/FundingRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class FundingRequest : Request
public String MobilePhone { get; set; }
public String RoutingNumber { get; set; }
public String AccountNumber { get; set; }
public String Descriptor { get; set; }

public override String ToXml()
{
Expand Down Expand Up @@ -41,6 +42,7 @@ protected virtual RequestBuilder BuildRequest(String root)
builder.AddElement("mobile-phone", MobilePhone);
builder.AddElement("routing-number", RoutingNumber);
builder.AddElement("account-number", AccountNumber);
builder.AddElement("descriptor", Descriptor);
return builder;
}
}
Expand Down
2 changes: 2 additions & 0 deletions Braintree/MerchantAccountFundingDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class MerchantAccountFundingDetails
public String AccountNumberLast4 { get; protected set; }
public String Email { get; protected set; }
public String MobilePhone { get; protected set; }
public String Descriptor { get; protected set; }

protected internal MerchantAccountFundingDetails(NodeWrapper node)
{
Expand All @@ -22,6 +23,7 @@ protected internal MerchantAccountFundingDetails(NodeWrapper node)
AccountNumberLast4 = node.GetString("account-number-last-4");
Email = node.GetString("email");
MobilePhone = node.GetString("mobile-phone");
Descriptor = node.GetString("descriptor");
}
}
}
8 changes: 8 additions & 0 deletions Braintree/PaymentMethodGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public Result<PaymentMethod> Create(PaymentMethodRequest request)
{
return new ResultImpl<CreditCard>(response, service);
}
else if (response.GetName() == "apple-pay-card")
{
return new ResultImpl<ApplePayCard>(response, service);
}
else
{
return new ResultImpl<UnknownPaymentMethod>(response, service);
Expand All @@ -42,6 +46,10 @@ public Result<PaymentMethod> Update(string token, PaymentMethodRequest request)
{
return new ResultImpl<CreditCard>(response, service);
}
else if (response.GetName() == "apple-pay-card")
{
return new ResultImpl<ApplePayCard>(response, service);
}
else
{
return new ResultImpl<UnknownPaymentMethod>(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.35.0.0")]
[assembly: AssemblyFileVersion("2.35.0.0")]
[assembly: AssemblyVersion("2.36.0.0")]
[assembly: AssemblyFileVersion("2.36.0.0")]
4 changes: 4 additions & 0 deletions Braintree/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ private T newInstanceFromResponse(NodeWrapper node, BraintreeService service)
{
return new Address(node) as T;
}
else if (typeof(T) == typeof(ApplePayCard))
{
return new ApplePayCard(node, service) as T;
}
else if (typeof(T) == typeof(CreditCard))
{
return new CreditCard(node, service) as T;
Expand Down
7 changes: 7 additions & 0 deletions Braintree/SandboxValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public class TransactionAmount
public const Decimal FAILED = 3000;
}

public class Nonce
{
public const String APPLE_PAY_VISA = "fake-apple-pay-visa-nonce";
public const String APPLE_PAY_MASTERCARD = "fake-apple-pay-mastercard-nonce";
public const String APPLE_PAY_AMEX = "fake-apple-pay-amex-nonce";
}

public class VenmoSdk
{
public const String VISA_PAYMENT_METHOD_CODE = "stub-4111111111111111";
Expand Down
6 changes: 6 additions & 0 deletions Braintree/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public class Transaction
public Dictionary<String, String> CustomFields { get; protected set; }
public Decimal? ServiceFeeAmount { get; protected set; }
public DisbursementDetails DisbursementDetails { get; protected set; }
public ApplePayDetails ApplePayDetails { get; protected set; }
public PayPalDetails PayPalDetails { get; protected set; }
public PaymentInstrumentType PaymentInstrumentType { get; protected set; }

Expand Down Expand Up @@ -249,6 +250,11 @@ protected internal Transaction(NodeWrapper node, BraintreeService service)
{
PayPalDetails = new PayPalDetails(paypalNode);
}
var applePayNode = node.GetNode("apple-pay");
if (applePayNode != null)
{
ApplePayDetails = new ApplePayDetails(applePayNode);
}

BillingAddress = new Address(node.GetNode("billing"));
ShippingAddress = new Address(node.GetNode("shipping"));
Expand Down
19 changes: 19 additions & 0 deletions Braintree/ValidationErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ public enum ValidationErrorCode
ADDRESS_STREET_ADDRESS_IS_TOO_LONG = 81812,
ADDRESS_TOO_MANY_ADDRESSES_PER_CUSTOMER = 91818,

APPLE_PAY_CARDS_ARE_NOT_ACCEPTED = 83501,
APPLE_PAY_CUSTOMER_ID_IS_REQUIRED_FOR_VAULTING = 83502,
APPLE_PAY_TOKEN_IS_IN_USE = 93503,
APPLE_PAY_PAYMENT_METHOD_NONCE_CONSUMED = 93504,
APPLE_PAY_PAYMENT_METHOD_NONCE_UNKNOWN = 93505,
APPLE_PAY_PAYMENT_METHOD_NONCE_LOCKED = 93506,
APPLE_PAY_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = 83518,
APPLE_PAY_CANNOT_UPDATE_APPLE_PAY_CARD_USING_PAYMENT_METHOD_NONCE = 93507,
APPLE_PAY_NUMBER_IS_REQUIRED = 93508,
APPLE_PAY_EXPIRATION_MONTH_IS_REQUIRED = 93509,
APPLE_PAY_EXPIRATION_YEAR_IS_REQUIRED = 93510,
APPLE_PAY_CRYPTOGRAM_IS_REQUIRED = 93511,
APPLE_PAY_DECRYPTION_FAILED = 83512,
APPLE_PAY_DISABLED = 93513,
APPLE_PAY_MERCHANT_NOT_CONFIGURED = 93514,
APPLE_PAY_MERCHANT_KEYS_ALREADY_CONFIGURED = 93515,
APPLE_PAY_MERCHANT_KEYS_NOT_CONFIGURED = 93516,
APPLE_PAY_CERTIFICATE_INVALID = 93517,

AUTHORIZATION_FINGERPRINT_INVALID_CREATED_AT = 93204,
AUTHORIZATION_FINGERPRINT_INVALID_FORMAT = 93202,
AUTHORIZATION_FINGERPRINT_INVALID_PUBLIC_KEY = 93205,
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.36.0
* Allow descriptor to be passed in Funding Details options params for Merchant Account create and update.

## 2.35.0
* Add additionalProcessorResponse to transaction

Expand Down

0 comments on commit 8be5443

Please sign in to comment.