Skip to content

Commit

Permalink
2.38.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Braintree committed Dec 11, 2014
1 parent 0327c78 commit fb7ab34
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 9 deletions.
44 changes: 43 additions & 1 deletion Braintree.Tests/CreditCardVerificationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public void Search_OnMultipleValueFields()

CreditCardVerificationSearchRequest searchRequest = new CreditCardVerificationSearchRequest().
CreditCardCardType.IncludedIn(CreditCardCardType.VISA, CreditCardCardType.MASTER_CARD).
Ids.IncludedIn(verification1.Id, verification2.Id);
Ids.IncludedIn(verification1.Id, verification2.Id).
Status.IncludedIn(verification1.Status);

ResourceCollection<CreditCardVerification> collection = gateway.CreditCardVerification.Search(searchRequest);

Expand Down Expand Up @@ -163,6 +164,47 @@ public void CardTypeIndicators()
Assert.AreEqual(verification.CreditCard.Payroll, Braintree.CreditCardPayroll.UNKNOWN);

}

[Test]
public void Search_OnTextFields()
{
var createRequest = new CustomerRequest
{
Email = "[email protected]",
CreditCard = new CreditCardRequest
{
Number = "4111111111111111",
ExpirationDate = "05/12",
BillingAddress = new CreditCardAddressRequest
{
PostalCode = "44444"
},
Options = new CreditCardOptionsRequest
{
VerifyCard = true
}
}
};

Result<Customer> result = gateway.Customer.Create(createRequest);
String token = result.Target.CreditCards[0].Token;
String postalCode = result.Target.CreditCards[0].BillingAddress.PostalCode;
String customerId = result.Target.Id;
String customerEmail = result.Target.Email;

CreditCardVerificationSearchRequest searchRequest = new CreditCardVerificationSearchRequest().
PaymentMethodToken.Is(token).
BillingAddressDetailsPostalCode.Is(postalCode).
CustomerId.Is(customerId).
CustomerEmail.Is(customerEmail);

ResourceCollection<CreditCardVerification> collection = gateway.CreditCardVerification.Search(searchRequest);
CreditCardVerification verification = collection.FirstItem;

Assert.AreEqual(1, collection.MaximumCount);
Assert.AreEqual(token, verification.CreditCard.Token);
Assert.AreEqual(postalCode, verification.BillingAddress.PostalCode);
}
}

}
69 changes: 69 additions & 0 deletions Braintree.Tests/TransactionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3119,6 +3119,19 @@ public void Find_ExposesDisputes()
Assert.AreEqual(dispute.Status, DisputeStatus.WON);
}

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

List<Dispute> disputes = transaction.Disputes;
Dispute dispute = disputes[0];

Assert.AreEqual(dispute.Amount, Decimal.Parse("1000.00"));
Assert.AreEqual(dispute.CurrencyIsoCode, "USD");
Assert.AreEqual(dispute.Reason, DisputeReason.RETRIEVAL);
}

[Test]
public void Find_IsDisbursedFalse()
{
Expand Down Expand Up @@ -3764,6 +3777,62 @@ public void CreateTransaction_WithPayeeEmailInOptionsParams()
Assert.IsNotNull(result.Target.PayPalDetails.DebugId);
}

[Test]
public void CreateTransaction_WithPayeeEmailInOptionsPaypal()
{
var nonce = TestHelper.GenerateOneTimePayPalNonce(gateway);
var request = new TransactionRequest
{
Amount = SandboxValues.TransactionAmount.AUTHORIZE,
PaymentMethodNonce = nonce,
Options = new TransactionOptionsRequest()
{
PayPal = new TransactionOptionsPayPalRequest()
{
PayeeEmail = "[email protected]"
}
}
};

var 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_WithPayPalCustomField()
{
var nonce = TestHelper.GenerateOneTimePayPalNonce(gateway);
var request = new TransactionRequest
{
Amount = SandboxValues.TransactionAmount.AUTHORIZE,
PaymentMethodNonce = nonce,
Options = new TransactionOptionsRequest()
{
PayPal = new TransactionOptionsPayPalRequest()
{
CustomField = "custom field stuff"
}
}
};

var 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("custom field stuff", result.Target.PayPalDetails.CustomField);
Assert.IsNull(result.Target.PayPalDetails.Token);
Assert.IsNotNull(result.Target.PayPalDetails.DebugId);
}

[Test]
public void CreateTransaction_WithOneTimePayPalNonce()
{
Expand Down
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.37.0</AssemblyName>
<AssemblyName>Braintree-2.38.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.37.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Braintree-2.38.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.37.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Braintree-2.38.0.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down Expand Up @@ -158,6 +158,7 @@
<Compile Include="Transaction.cs" />
<Compile Include="TransactionGateway.cs" />
<Compile Include="TransactionOptionsRequest.cs" />
<Compile Include="TransactionOptionsPayPalRequest.cs" />
<Compile Include="TransactionPayPalRequest.cs" />
<Compile Include="TransactionRequest.cs" />
<Compile Include="TransactionSearchRequest.cs" />
Expand Down
1 change: 0 additions & 1 deletion Braintree/BraintreeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ private XmlNode GetXmlResponse(String URL, String method, Request requestBody)

var response = request.GetResponse() as HttpWebResponse;


XmlNode doc = ParseResponseStream(GetResponseStream(response));
response.Close();

Expand Down
35 changes: 35 additions & 0 deletions Braintree/CreditCardVerificationSearchRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,40 @@ public DateRangeNode<CreditCardVerificationSearchRequest> CreatedAt
return new DateRangeNode<CreditCardVerificationSearchRequest>("created-at", this);
}
}
public TextNode<CreditCardVerificationSearchRequest> PaymentMethodToken
{
get
{
return new TextNode<CreditCardVerificationSearchRequest>("payment-method-token", this);
}
}
public TextNode<CreditCardVerificationSearchRequest> BillingAddressDetailsPostalCode
{
get
{
return new TextNode<CreditCardVerificationSearchRequest>("billing-address-details-postal-code", this);
}
}
public TextNode<CreditCardVerificationSearchRequest> CustomerId
{
get
{
return new TextNode<CreditCardVerificationSearchRequest>("customer-id", this);
}
}
public TextNode<CreditCardVerificationSearchRequest> CustomerEmail
{
get
{
return new TextNode<CreditCardVerificationSearchRequest>("customer-email", this);
}
}
public MultipleValueNode<CreditCardVerificationSearchRequest, Braintree.VerificationStatus> Status
{
get
{
return new MultipleValueNode<CreditCardVerificationSearchRequest, Braintree.VerificationStatus>("status", this);
}
}
}
}
3 changes: 2 additions & 1 deletion Braintree/Dispute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ public class DisputeReason : Enumeration
public static readonly DisputeReason PRODUCT_NOT_RECEIVED = new DisputeReason("product_not_received");
public static readonly DisputeReason PRODUCT_UNSATISFACTORY = new DisputeReason("product_unsatisfactory");
public static readonly DisputeReason TRANSACTION_AMOUNT_DIFFERS = new DisputeReason("transaction_amount_differs");
public static readonly DisputeReason RETRIEVAL = new DisputeReason("retrieval");


public static readonly DisputeReason[] ALL = {
CANCELLED_RECURRING_TRANSACTION, CREDIT_NOT_PROCESSED, DUPLICATE, FRAUD, GENERAL, INVALID_ACCOUNT, NOT_RECOGNIZED, PRODUCT_NOT_RECEIVED, PRODUCT_UNSATISFACTORY, TRANSACTION_AMOUNT_DIFFERS
CANCELLED_RECURRING_TRANSACTION, CREDIT_NOT_PROCESSED, DUPLICATE, FRAUD, GENERAL, INVALID_ACCOUNT, NOT_RECOGNIZED, PRODUCT_NOT_RECEIVED, PRODUCT_UNSATISFACTORY, TRANSACTION_AMOUNT_DIFFERS, RETRIEVAL
};

protected DisputeReason(String name) : base(name) {}
Expand Down
2 changes: 2 additions & 0 deletions Braintree/PayPalDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class PayPalDetails
public String ImageUrl { get; protected set; }
public String DebugId { get; protected set; }
public String PayeeEmail { get; protected set; }
public String CustomField { get; protected set; }

protected internal PayPalDetails(NodeWrapper node)
{
Expand All @@ -21,6 +22,7 @@ protected internal PayPalDetails(NodeWrapper node)
ImageUrl = node.GetString("image-url");
DebugId = node.GetString("debug-id");
PayeeEmail = node.GetString("payee-email");
CustomField = node.GetString("custom-field");
}
}
}
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.37.0.0")]
[assembly: AssemblyFileVersion("2.37.0.0")]
[assembly: AssemblyVersion("2.38.0.0")]
[assembly: AssemblyFileVersion("2.38.0.0")]
27 changes: 27 additions & 0 deletions Braintree/TransactionOptionsPayPalRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;

namespace Braintree
{
public class TransactionOptionsPayPalRequest : Request
{
public string CustomField { get; set; }
public string PayeeEmail { get; set; }

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

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

private RequestBuilder BuildRequest(string root)
{
return new RequestBuilder(root).
AddElement("custom-field", CustomField).
AddElement("payee-email", PayeeEmail);
}
}
}
4 changes: 3 additions & 1 deletion Braintree/TransactionOptionsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class TransactionOptionsRequest : Request
public Boolean? SubmitForSettlement { get; set; }
public String VenmoSdkSession { get; set; }
public String PayeeEmail { get; set; }
public TransactionOptionsPayPalRequest PayPal { get; set; }

public override String ToXml(String root)
{
Expand All @@ -37,7 +38,8 @@ protected virtual RequestBuilder BuildRequest(String root)
AddElement("store-shipping-address-in-vault", StoreShippingAddressInVault).
AddElement("submit-for-settlement", SubmitForSettlement).
AddElement("venmo-sdk-session", VenmoSdkSession).
AddElement("payee-email", PayeeEmail);
AddElement("payee-email", PayeeEmail).
AddElement("paypal", PayPal);
}
}
}
22 changes: 22 additions & 0 deletions Braintree/ValidationErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public enum ValidationErrorCode
APPLE_PAY_MERCHANT_KEYS_ALREADY_CONFIGURED = 93515,
APPLE_PAY_MERCHANT_KEYS_NOT_CONFIGURED = 93516,
APPLE_PAY_CERTIFICATE_INVALID = 93517,
APPLE_PAY_CERTIFICATE_MISMATCH = 93519,
APPLE_PAY_INVALID_TOKEN = 83520,
APPLE_PAY_PRIVATE_KEY_MISMATCH = 93521,
APPLE_PAY_KEY_MISMATCH_STORING_CERTIFICATE = 93522,

AUTHORIZATION_FINGERPRINT_INVALID_CREATED_AT = 93204,
AUTHORIZATION_FINGERPRINT_INVALID_FORMAT = 93202,
Expand All @@ -66,6 +70,7 @@ public enum ValidationErrorCode
CLIENT_TOKEN_CUSTOMER_DOES_NOT_EXIST = 92804,
CLIENT_TOKEN_FAIL_ON_DUPLICATE_PAYMENT_METHOD_REQUIRES_CUSTOMER_ID = 92803,
CLIENT_TOKEN_MAKE_DEFAULT_REQUIRES_CUSTOMER_ID = 92801,
CLIENT_TOKEN_MERCHANT_ACCOUNT_DOES_NOT_EXIST = 92807,
CLIENT_TOKEN_PROXY_MERCHANT_DOES_NOT_EXIST = 92805,
CLIENT_TOKEN_UNSUPPORTED_VERSION = 92806,
CLIENT_TOKEN_VERIFY_CARD_REQUIRES_CUSTOMER_ID = 92802,
Expand Down Expand Up @@ -97,7 +102,11 @@ public enum ValidationErrorCode
CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_IS_INVALID = 91723,
CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_NOT_ALLOWED = 91729,
CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_ID_IS_INVALID = 91728,
CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_CANNOT_BE_NEGATIVE = 91739,
CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_FORMAT_IS_INVALID = 91740,
CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_NOT_SUPPORTED_BY_PROCESSOR = 91741,
CREDIT_CARD_PAYMENT_METHOD_CONFLICT = 81725,
CREDIT_CARD_PAYMENT_METHOD_IS_NOT_A_CREDIT_CARD = 91738,
CREDIT_CARD_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = 91734,
CREDIT_CARD_PAYMENT_METHOD_NONCE_CONSUMED = 91731,
CREDIT_CARD_PAYMENT_METHOD_NONCE_LOCKED = 91733,
Expand Down Expand Up @@ -248,6 +257,9 @@ public enum ValidationErrorCode
PAYMENT_METHOD_NONCE_IS_INVALID = 93102,
PAYMENT_METHOD_NONCE_IS_REQUIRED = 93103,
PAYMENT_METHOD_PAYMENT_METHOD_PARAMS_ARE_REQUIRED = 93101,
PAYMENT_METHOD_PAYMENT_METHOD_NONCE_CONSUMED = 93107,
PAYMENT_METHOD_PAYMENT_METHOD_NONCE_UNKNOWN = 93108,
PAYMENT_METHOD_PAYMENT_METHOD_NONCE_LOCKED = 93109,

PAYPAL_ACCOUNT_CANNOT_HAVE_BOTH_ACCESS_TOKEN_AND_CONSENT_CODE = 82903,
PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT = 82902,
Expand All @@ -259,6 +271,10 @@ public enum ValidationErrorCode
PAYPAL_ACCOUNT_PAYPAL_ACCOUNTS_ARE_NOT_ACCEPTED = 82904,
PAYPAL_ACCOUNT_PAYPAL_COMMUNICATION_ERROR = 92910,
PAYPAL_ACCOUNT_TOKEN_IS_IN_USE = 92906,
PAYPAL_ACCOUNT_AUTH_EXPIRED = 92911,
PAYPAL_ACCOUNT_CANNOT_HAVE_FUNDING_SOURCE_WITHOUT_ACCESS_TOKEN = 92912,
PAYPAL_ACCOUNT_INVALID_FUNDING_SOURCE_SELECTION = 92913,
PAYPAL_ACCOUNT_CANNOT_UPDATE_PAYPAL_ACCOUNT_USING_PAYMENT_METHOD_NONCE = 92914,

SEPA_BANK_ACCOUNT_ACCOUNT_HOLDER_NAME_IS_REQUIRED = 93003,
SEPA_BANK_ACCOUNT_BIC_IS_REQUIRED = 93002,
Expand Down Expand Up @@ -366,6 +382,7 @@ public enum ValidationErrorCode
TRANSACTION_CANNOT_RELEASE_FROM_ESCROW = 91561,
TRANSACTION_CANNOT_SIMULATE_SETTLEMENT = 91575,
TRANSACTION_CANNOT_SUBMIT_FOR_SETTLEMENT = 91507,
TRANSACTION_CANNOT_REFUND_SETTLING_TRANSACTION = 91574,
TRANSACTION_CHANNEL_IS_TOO_LONG = 91550,
TRANSACTION_CREDIT_CARD_IS_REQUIRED = 91508,
TRANSACTION_CUSTOMER_DEFAULT_PAYMENT_METHOD_CARD_TYPE_IS_NOT_ACCEPTED = 81509,
Expand Down Expand Up @@ -393,7 +410,10 @@ public enum ValidationErrorCode
TRANSACTION_PAYMENT_METHOD_NONCE_UNKNOWN = 91565,
TRANSACTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = 91517,
TRANSACTION_PAYMENT_METHOD_TOKEN_IS_INVALID = 91518,
TRANSACTION_PAYMENT_INSTRUMENT_NOT_SUPPORTED_BY_MERCHANT_ACCOUNT = 91577,
TRANSACTION_PAYPAL_NOT_ENABLED = 91576,
TRANSACTION_PAY_PAL_AUTH_EXPIRED = 91579,
TRANSACTION_OPTIONS_PAY_PAL_CUSTOM_FIELD_TOO_LONG = 91580,
TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_CANNOT_BE_SET = 91519,
TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_IS_INVALID = 81520,
TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_CREDITS = 91546,
Expand All @@ -406,8 +426,10 @@ public enum ValidationErrorCode
TRANSACTION_SERVICE_FEE_AMOUNT_IS_TOO_LARGE = 91556,
TRANSACTION_SERVICE_FEE_AMOUNT_NOT_ALLOWED_ON_MASTER_MERCHANT_ACCOUNT = 91557,
TRANSACTION_SERVICE_FEE_IS_NOT_ALLOWED_ON_CREDITS = 91552,
TRANSACTION_SERVICE_FEE_NOT_ACCEPTED_FOR_PAYPAL = 91578,
TRANSACTION_SETTLEMENT_AMOUNT_IS_LESS_THAN_SERVICE_FEE_AMOUNT = 91551,
TRANSACTION_SETTLEMENT_AMOUNT_IS_TOO_LARGE = 91522,
TRANSACTION_SHIPPING_ADDRESS_DOESNT_MATCH_CUSTOMER = 91581,
TRANSACTION_SUBSCRIPTION_DOES_NOT_BELONG_TO_CUSTOMER = 91529,
TRANSACTION_SUBSCRIPTION_ID_IS_INVALID = 91528,
TRANSACTION_SUBSCRIPTION_STATUS_MUST_BE_PAST_DUE = 91531,
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.38.0
* Allow PayPal fields in transaction.options.paypal
* Add error code constants

## 2.37.0
* Add risk_data to Transaction and Verification with Kount decision and id
* Add verification_amount an option when creating a credit card
Expand Down

0 comments on commit fb7ab34

Please sign in to comment.