Skip to content

Commit

Permalink
5.25.0
Browse files Browse the repository at this point in the history
Co-authored-by: dakirby <[email protected]>
Co-authored-by: Sara Vasquez <[email protected]>
  • Loading branch information
3 people committed Mar 26, 2024
1 parent 242ad34 commit 431e774
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 5.25.0
- Add `domains` parameter support to `ClientTokenRequest`

## 5.24.0
- Add `UNDER_REVIEW` to `DisputeStatus`
- Add `DISPUTE_UNDER_REVIEW` to `WebhookKind`
Expand Down
9 changes: 2 additions & 7 deletions src/Braintree/Braintree.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@
<PropertyGroup>
<Description>Braintree Client Library</Description>
<Copyright>Copyright © Braintree, a division of PayPal, Inc. 2021</Copyright>
<VersionPrefix>5.24.0</VersionPrefix>
<VersionPrefix>5.25.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 `UNDER_REVIEW` to `DisputeStatus`
- Add `DISPUTE_UNDER_REVIEW` to `WebhookKind`
- Add `DebitNetwork` to `Transaction`
- Add `TransactionDebitNetwork` enum to `Transaction`
- Add `DebitNetwork` to `TransactionSearchRequest` to search by debitNetworks
- Add `ProcessDebitAsCredit` to `TransactionOptionsCreditCardRequest`
- Add `domains` parameter support to `ClientTokenRequest`
</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/braintree/braintree_dotnet</PackageProjectUrl>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
Expand Down
8 changes: 5 additions & 3 deletions src/Braintree/ClientTokenRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public class ClientTokenRequest : Request
private readonly int DEFAULT_VERSION = 2;

public string CustomerId { get; set; }
public int Version { get; set; }
public ClientTokenOptionsRequest Options { get; set; }
public string[] Domains { get; set; }
public string MerchantAccountId { get; set; }
public ClientTokenOptionsRequest Options { get; set; }
public int Version { get; set; }

public ClientTokenRequest()
{
Expand All @@ -35,9 +36,10 @@ protected virtual RequestBuilder BuildRequest(string root)
var builder = new RequestBuilder(root);

if (CustomerId != null) builder.AddElement("customer-id", CustomerId);
if (Version != 0) builder.AddElement("version", Version);
if (Domains != null) builder.AddElement("domains", Domains);
if (MerchantAccountId != null) builder.AddElement("merchant-account-id", MerchantAccountId);
if (Options != null) builder.AddElement("options", Options);
if (Version != 0) builder.AddElement("version", Version);

return builder;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Braintree/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("5.24.0.0")]
[assembly: AssemblyFileVersion("5.24.0.0")]
[assembly: AssemblyVersion("5.25.0.0")]
[assembly: AssemblyFileVersion("5.25.0.0")]
2 changes: 2 additions & 0 deletions src/Braintree/ValidationErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ public enum ValidationErrorCode

CLIENT_TOKEN_CUSTOMER_DOES_NOT_EXIST = 92804,
CLIENT_TOKEN_FAIL_ON_DUPLICATE_PAYMENT_METHOD_REQUIRES_CUSTOMER_ID = 92803,
CLIENT_TOKEN_INVALID_DOMAIN_FORMAT = 92011,
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_TOO_MANY_DOMAINS = 92810,
CLIENT_TOKEN_UNSUPPORTED_VERSION = 92806,
CLIENT_TOKEN_VERIFY_CARD_REQUIRES_CUSTOMER_ID = 92802,

Expand Down
40 changes: 40 additions & 0 deletions test/Braintree.Tests.Integration/ClientTokenIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,46 @@ public void Setup()
};
}

[Test]
public void Generate_ValidDomainsAccepted()
{
var ClientTokenRequest = new ClientTokenRequest
{
Domains = new string[] {"example.com"}
};
var encodedClientToken = gateway.ClientToken.Generate(ClientTokenRequest);
Assert.NotNull(encodedClientToken);
}

[Test]
public void Generate_InvalidDomainsNotAccepted()
{
var ClientTokenRequest = new ClientTokenRequest
{
Domains = new string[] {"example"}
};
ArgumentException invalidFormatException = Assert.Throws<ArgumentException>(() => gateway.ClientToken.Generate(ClientTokenRequest));
Assert.AreEqual(invalidFormatException.Message, "Client token domains must be valid domain names (RFC 1035), e.g. example.com");
}

[Test]
public void Generate_TooManyDomainsNotAccepted()
{
var ClientTokenRequest = new ClientTokenRequest
{
Domains = new string[] {
"example1.com",
"example2.com",
"example3.com",
"example4.com",
"example5.com",
"example6.com"
}
};
ArgumentException tooManyException = Assert.Throws<ArgumentException>(() => gateway.ClientToken.Generate(ClientTokenRequest));
Assert.AreEqual(tooManyException.Message, "Cannot specify more than 5 client token domains");
}

[Test]
public void Generate_GeneratesFingerprintAcceptedByGateway()
{
Expand Down
28 changes: 28 additions & 0 deletions test/Braintree.Tests/ClientTokenRequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using NUnit.Framework;

using System;

namespace Braintree.Tests
{
[TestFixture]
public class ClientTokenRequestTest
{
[Test]
[System.Obsolete]
public void ToXml_Includes_All_Values()
{
var request = new ClientTokenRequest()
{
CustomerId = "abc123",
Domains = new string[] {"example.com"},
MerchantAccountId = "987654321",
Version = 2
};

Assert.IsTrue(request.ToXml().Contains("<customer-id>abc123</customer-id>"));
Assert.IsTrue(request.ToXml().Contains("<domains type=\"array\"><item>example.com</item></domains>"));
Assert.IsTrue(request.ToXml().Contains("<merchant-account-id>987654321</merchant-account-id>"));
Assert.IsTrue(request.ToXml().Contains("<version>2</version>"));
}
}
}

0 comments on commit 431e774

Please sign in to comment.