diff --git a/CHANGELOG.md b/CHANGELOG.md index f6752439..66952305 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/src/Braintree/Braintree.csproj b/src/Braintree/Braintree.csproj index de0a5e9d..5cc8bc17 100644 --- a/src/Braintree/Braintree.csproj +++ b/src/Braintree/Braintree.csproj @@ -4,7 +4,7 @@ Braintree Client Library Copyright © Braintree, a division of PayPal, Inc. 2021 - 5.24.0 + 5.25.0 Braintree net452;netstandard2.0 @@ -12,12 +12,7 @@ Braintree braintree;paypal;venmo;intenational;payments;gateway;currencies;money;visa;mastercard;bitcoin;maestro;apple pay;android pay;amex;jcb;diners club;discover;american express - - 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` https://github.com/braintree/braintree_dotnet false diff --git a/src/Braintree/ClientTokenRequest.cs b/src/Braintree/ClientTokenRequest.cs index 549f8d13..59e6dc5f 100644 --- a/src/Braintree/ClientTokenRequest.cs +++ b/src/Braintree/ClientTokenRequest.cs @@ -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() { @@ -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; } diff --git a/src/Braintree/Properties/AssemblyInfo.cs b/src/Braintree/Properties/AssemblyInfo.cs index c9ef7e3a..6fdfb2fd 100644 --- a/src/Braintree/Properties/AssemblyInfo.cs +++ b/src/Braintree/Properties/AssemblyInfo.cs @@ -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")] diff --git a/src/Braintree/ValidationErrorCode.cs b/src/Braintree/ValidationErrorCode.cs index 5dd69e23..6639593c 100644 --- a/src/Braintree/ValidationErrorCode.cs +++ b/src/Braintree/ValidationErrorCode.cs @@ -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, diff --git a/test/Braintree.Tests.Integration/ClientTokenIntegrationTest.cs b/test/Braintree.Tests.Integration/ClientTokenIntegrationTest.cs index 0d327d6d..b6e00c95 100644 --- a/test/Braintree.Tests.Integration/ClientTokenIntegrationTest.cs +++ b/test/Braintree.Tests.Integration/ClientTokenIntegrationTest.cs @@ -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(() => 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(() => gateway.ClientToken.Generate(ClientTokenRequest)); + Assert.AreEqual(tooManyException.Message, "Cannot specify more than 5 client token domains"); + } + [Test] public void Generate_GeneratesFingerprintAcceptedByGateway() { diff --git a/test/Braintree.Tests/ClientTokenRequestTest.cs b/test/Braintree.Tests/ClientTokenRequestTest.cs new file mode 100644 index 00000000..ac687693 --- /dev/null +++ b/test/Braintree.Tests/ClientTokenRequestTest.cs @@ -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("abc123")); + Assert.IsTrue(request.ToXml().Contains("example.com")); + Assert.IsTrue(request.ToXml().Contains("987654321")); + Assert.IsTrue(request.ToXml().Contains("2")); + } + } +} \ No newline at end of file