Skip to content

Commit

Permalink
5.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Mar 4, 2021
1 parent aab54d4 commit c198d01
Show file tree
Hide file tree
Showing 17 changed files with 461 additions and 64 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# unreleased
## 5.4.0
- Add missing `ExpirationMonth`, `ExpirationYear`, and `IsNetworkTokenized` fields in `PaymentMethodNonceDetails` (thanks @glennsdavis for `ExpirationMonth` and `ExpirationYear`!)
- Add `ThreeDSecureAuthenticationInfo` and `ThreeDSecureLookupInfo` classes
- Add `AcsTransactionId`, `ParesStatus`, `ThreeDSecureTransactionId`, `Lookup`, and `Authentication` to `ThreeDSecureInfo`
- Add `DecisionReasons` and `TransactionRiskScore` fields to `RiskData`
- Add overload on `SubmitForSettlementAsync` method to include `TransactionRequest` (thanks @edtyl3r!)
- Add `ExpirationMonth` and `ExpirationYear` to `PaymentMethodNonceDetails` (thanks @glennsdavis!)

## 5.3.0
- Add `scaExemption` to `Transaction`
Expand Down
20 changes: 7 additions & 13 deletions src/Braintree/Braintree.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@

<PropertyGroup>
<Description>Braintree Client Library</Description>
<Copyright>Copyright © Braintree, a division of PayPal, Inc. 2020</Copyright>
<VersionPrefix>5.3.0</VersionPrefix>
<Copyright>Copyright © Braintree, a division of PayPal, Inc. 2021</Copyright>
<VersionPrefix>5.4.0</VersionPrefix>
<Authors>Braintree</Authors>
<!-- We target NET standard 2.0 so that we can support NET Core 2.1. When NET Core 2.1 reaches EOL, we can update to Net Standard 2.1 -->
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
<AssemblyName>Braintree</AssemblyName>
<PackageId>Braintree</PackageId>
<PackageTags>braintree;paypal;venmo;intenational;payments;gateway;currencies;money;visa;mastercard;bitcoin;maestro;apple pay;android pay;amex;jcb;diners club;discover;american express</PackageTags>
<PackageReleaseNotes>
- Add scaExemption to Transaction
- Deprecate DeviceSessionId and FraudMerchantId in the CreditCardRequest and TransactionRequest classes
- Add currencyIsoCode field to TransactionRequest
- Add verificationCurrencyIsoCode field to CreditCardOptionsRequest and PaymentMethodOptionsRequest
- Add validation error codes:
- CREDIT_CARD_OPTIONS_VERIFICATION_INVALID_PRESENTMENT_CURRENCY
- TRANSACTION_INVALID_PRESENTMENT_CURRENCY
- Add Installments to TransactionRequest
- Add Count to InstallmentRequest
- Add Installments and RefundedInstallments to Transaction
- Add Adjustment to Installment
- Add missing `ExpirationMonth`, `ExpirationYear`, and `IsNetworkTokenized` fields in `PaymentMethodNonceDetails` (thanks @glennsdavis for `ExpirationMonth` and `ExpirationYear`!)
- Add `ThreeDSecureAuthenticationInfo` and `ThreeDSecureLookupInfo` classes
- Add `AcsTransactionId`, `ParesStatus`, `ThreeDSecureTransactionId`, `Lookup`, and `Authentication` to `ThreeDSecureInfo`
- Add `DecisionReasons` and `TransactionRiskScore` fields to `RiskData`
- Add overload on `SubmitForSettlementAsync` method to include `TransactionRequest` (thanks @edtyl3r!)
</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/braintree/braintree_dotnet</PackageProjectUrl>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
Expand Down
22 changes: 13 additions & 9 deletions src/Braintree/PaymentMethodNonceDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,30 @@ namespace Braintree
{
public class PaymentMethodNonceDetails
{
public virtual bool? IsNetworkTokenized { get; protected set; }
public virtual string Bin { get; protected set; }
public virtual string LastTwo { get; protected set; }
public virtual string LastFour { get; protected set; }
//NEXT_MAJOR_VERSION CardType should be an enum (see CreditCard class)
public virtual string CardType { get; protected set; }
public virtual string ExpirationYear { get; protected set; }
public virtual string ExpirationMonth { get; protected set; }
public virtual string ExpirationYear { get; protected set; }
public virtual string LastFour { get; protected set; }
public virtual string LastTwo { get; protected set; }
public virtual string Username { get; protected set; }
public virtual string VenmoUserId { get; protected set; }
public virtual PaymentMethodNonceDetailsPayerInfo PayerInfo { get; protected set; }

protected internal PaymentMethodNonceDetails(NodeWrapper node)
{
IsNetworkTokenized = node.GetBoolean("is-network-tokenized");
Bin = node.GetString("bin");
CardType = node.GetString("card-type");
LastTwo = node.GetString("last-two");
LastFour = node.GetString("last-four");
ExpirationYear = node.GetString("expiration-year");
ExpirationMonth = node.GetString("expiration-month");
ExpirationYear = node.GetString("expiration-year");
LastFour = node.GetString("last-four");
LastTwo = node.GetString("last-two");
Username = node.GetString("username");
VenmoUserId = node.GetString("venmo-user-id");

var payerInfoNode = node.GetNode("payer-info");
if (payerInfoNode != null)
{
Expand All @@ -34,12 +37,13 @@ protected internal PaymentMethodNonceDetails(NodeWrapper node)

protected internal PaymentMethodNonceDetails(dynamic details)
{
IsNetworkTokenized = details.isNetworkTokenized;
Bin = details.bin;
CardType = details.cardType;
LastTwo = details.lastTwo;
LastFour = details.lastFour;
ExpirationYear = details.expirationYear;
ExpirationMonth = details.expirationMonth;
ExpirationYear = details.expirationYear;
LastFour = details.lastFour;
LastTwo = details.lastTwo;
Username = details.username;
VenmoUserId = details.venmoUserId;

Expand Down
6 changes: 3 additions & 3 deletions src/Braintree/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Braintree")]
[assembly: AssemblyProduct("Braintree Payment Gateway Client API")]
[assembly: AssemblyCopyright("Copyright © Braintree, a division of PayPal, Inc. 2020")]
[assembly: AssemblyCopyright("Copyright © Braintree, a division of PayPal, Inc. 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Braintree.Tests")]
Expand All @@ -32,5 +32,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("5.3.0.0")]
[assembly: AssemblyFileVersion("5.3.0.0")]
[assembly: AssemblyVersion("5.4.0.0")]
[assembly: AssemblyFileVersion("5.4.0.0")]
14 changes: 13 additions & 1 deletion src/Braintree/RiskData.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
using System;
using System.Collections.Generic;

namespace Braintree
{
public class RiskData
{
public virtual string id { get; protected set; }
// NEXT_MAJOR_VERSION these should all be Pascal case,
// but we can't add those now without setting off a
// CLS-compliance error (CS3005)
public virtual string decision { get; protected set; }
public virtual List<string> DecisionReasons { get; protected set; }
public virtual bool? deviceDataCaptured { get; protected set; }
public virtual string fraudServiceProvider { get; protected set; }
public virtual string id { get; protected set; }
public virtual string TransactionRiskScore { get; protected set; }

public RiskData(NodeWrapper node)
{
Expand All @@ -18,6 +24,12 @@ public RiskData(NodeWrapper node)
decision = node.GetString("decision");
fraudServiceProvider = node.GetString("fraud-service-provider");
deviceDataCaptured = node.GetBoolean("device-data-captured");
TransactionRiskScore = node.GetString("transaction-risk-score");
DecisionReasons = new List<string>();
foreach (var stringNode in node.GetList("decision-reasons/item"))
{
DecisionReasons.Add(stringNode.GetString("."));
}
}

[Obsolete("Mock Use Only")]
Expand Down
30 changes: 30 additions & 0 deletions src/Braintree/ThreeDSecureAuthenticationInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
namespace Braintree
{
public class ThreeDSecureAuthenticationInfo
{
public virtual string TransStatus { get; protected set; }
public virtual string TransStatusReason { get; protected set; }

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

TransStatus = node.GetString("trans-status");
TransStatusReason = node.GetString("trans-status-reason");
}

public ThreeDSecureAuthenticationInfo(dynamic info)
{
if (info == null)
return;

TransStatus = info.transStatus;
TransStatusReason = info.transStatusReason;
}

[Obsolete("Mock Use Only")]
protected internal ThreeDSecureAuthenticationInfo() { }
}
}
52 changes: 39 additions & 13 deletions src/Braintree/ThreeDSecureInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,79 @@ namespace Braintree
{
public class ThreeDSecureInfo
{
public virtual string Status { get; protected set; }
public virtual string Enrolled { get; protected set; }
public virtual bool? LiabilityShifted { get; protected set; }
public virtual ThreeDSecureAuthenticationInfo Authentication { get; protected set; }
public virtual ThreeDSecureLookupInfo Lookup { get; protected set; }
public virtual bool? LiabilityShiftPossible { get; protected set; }
public virtual bool? LiabilityShifted { get; protected set; }
public virtual string AcsTransactionId { get; protected set; }
public virtual string Cavv { get; protected set; }
public virtual string Xid { get; protected set; }
public virtual string DsTransactionId { get; protected set; }
public virtual string EciFlag { get; protected set; }
public virtual string ThreeDSecureVersion { get; protected set; }
public virtual string Enrolled { get; protected set; }
public virtual string ParesStatus { get; protected set; }
public virtual string Status { get; protected set; }
public virtual string ThreeDSecureAuthenticationId { get; protected set; }
public virtual string ThreeDSecureServerTransactionId { get; protected set; }
public virtual string ThreeDSecureVersion { get; protected set; }
public virtual string Xid { 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");
AcsTransactionId = node.GetString("acs-transaction-id");
Cavv = node.GetString("cavv");
Xid = node.GetString("xid");
DsTransactionId = node.GetString("ds-transaction-id");
EciFlag = node.GetString("eci-flag");
ThreeDSecureVersion = node.GetString("three-d-secure-version");
Enrolled = node.GetString("enrolled");
LiabilityShiftPossible = node.GetBoolean("liability-shift-possible");
LiabilityShifted = node.GetBoolean("liability-shifted");
ParesStatus = node.GetString("pares-status");
Status = node.GetString("status");
ThreeDSecureAuthenticationId = node.GetString("three-d-secure-authentication-id");
ThreeDSecureServerTransactionId = node.GetString("three-d-secure-server-transaction-id");
ThreeDSecureVersion = node.GetString("three-d-secure-version");
Xid = node.GetString("xid");

var AuthenticationNode = node.GetNode("authentication");
if (AuthenticationNode != null)
{
Authentication = new ThreeDSecureAuthenticationInfo(AuthenticationNode);
}

var LookupNode = node.GetNode("lookup");
if (LookupNode != null)
{
Lookup = new ThreeDSecureLookupInfo(LookupNode);
}
}

// this is used when constructing ThreeDSecureInfo within another response
// (like a PaymentMethodNonce class)
public ThreeDSecureInfo(dynamic info)
{
if (info == null)
return;

AcsTransactionId = info.acsTransactionId;
Enrolled = info.enrolled;
Status = info.status;
LiabilityShifted = info.liabilityShifted;
LiabilityShiftPossible = info.liabilityShiftPossible;
ParesStatus = info.paresStatus;
Cavv = info.cavv;
Xid = info.xid;
DsTransactionId = info.dsTransactionId;
EciFlag = info.eciFlag;
ThreeDSecureVersion = info.threeDSecureVersion;
ThreeDSecureAuthenticationId = info.threeDSecureAuthenticationId;
ThreeDSecureServerTransactionId = info.threeDSecureServerTransactionId;
Authentication = new ThreeDSecureAuthenticationInfo(info.authentication);
Lookup = new ThreeDSecureLookupInfo(info.lookup);
}

[Obsolete("Mock Use Only")]
protected internal ThreeDSecureInfo() { }
}
}

}
30 changes: 30 additions & 0 deletions src/Braintree/ThreeDSecureLookupInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
namespace Braintree
{
public class ThreeDSecureLookupInfo
{
public virtual string TransStatus { get; protected set; }
public virtual string TransStatusReason { get; protected set; }

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

TransStatus = node.GetString("trans-status");
TransStatusReason = node.GetString("trans-status-reason");
}

public ThreeDSecureLookupInfo(dynamic info)
{
if (info == null)
return;

TransStatus = info.transStatus;
TransStatusReason = info.transStatusReason;
}

[Obsolete("Mock Use Only")]
protected internal ThreeDSecureLookupInfo() { }
}
}
13 changes: 8 additions & 5 deletions test/Braintree.Tests.Integration/CreditCardIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public void Setup()
service = new BraintreeService(gateway.Configuration);
}

public void AdvancedFraudSetup()
public void FraudProtectionEnterpriseSetup()
{
gateway = new BraintreeGateway
{
Environment = Environment.DEVELOPMENT,
MerchantId = "advanced_fraud_integration_merchant_id",
PublicKey = "advanced_fraud_integration_public_key",
PrivateKey = "advanced_fraud_integration_private_key"
MerchantId = "fraud_protection_enterprise_integration_merchant_id",
PublicKey = "fraud_protection_enterprise_integration_public_key",
PrivateKey = "fraud_protection_enterprise_integration_private_key"
};

service = new BraintreeService(gateway.Configuration);
Expand Down Expand Up @@ -899,7 +899,7 @@ public void VerifyValidCreditCard()
[Test]
public void VerifyValidCreditCardWithVerificationRiskData()
{
AdvancedFraudSetup();
FraudProtectionEnterpriseSetup();
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
CreditCardRequest request = new CreditCardRequest
{
Expand All @@ -925,6 +925,9 @@ public void VerifyValidCreditCardWithVerificationRiskData()

Assert.IsNotNull(verification.RiskData);
Assert.IsNotNull(verification.RiskData.decision);
Assert.IsNotNull(verification.RiskData.DecisionReasons);
Assert.IsNotNull(verification.RiskData.fraudServiceProvider);
Assert.IsNotNull(verification.RiskData.id);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public void Find_ExposesThreeDSecureInfo()
Assert.AreEqual("1.0.2", info.ThreeDSecureVersion);
Assert.AreEqual("test_xid", info.Xid);
Assert.IsNotNull(info.ThreeDSecureAuthenticationId);
Assert.IsNotNull(info.Authentication);
Assert.IsNotNull(info.Lookup);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public void LookupThreeDSecure_IsSuccesfulWithPartialCustomerInfo()
Assert.IsNotNull(paymentMethod.ThreeDSecureInfo);
Assert.IsTrue(paymentMethod.ThreeDSecureInfo.LiabilityShiftPossible);
Assert.IsFalse(paymentMethod.ThreeDSecureInfo.LiabilityShifted);
Assert.IsNull(paymentMethod.ThreeDSecureInfo.Lookup.TransStatus);
Assert.IsNotNull(lookup.AcsUrl);
Assert.IsNotNull(lookup.ThreeDSecureVersion);
Assert.IsNotNull(lookup.TransactionId);
Expand Down
Loading

0 comments on commit c198d01

Please sign in to comment.