Skip to content

Commit

Permalink
4.28.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 a59bfd6 commit 81f2b2b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 4.28.0
* Add `domains` parameter support to `ClientToken.generate`

## 4.27.0
* Add `UnderReview` status to `Dispute`
* Add `DisputeUnderReview` to `WebhookNotification.Kind`
Expand Down
3 changes: 2 additions & 1 deletion braintree/client_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def generate(params=None, gateway=None):
def generate_signature():
return [
"customer_id",
"merchant_account_id",
"proxy_merchant_id",
"version",
"merchant_account_id",
{"domains": ["__any_key__"]},
{"options": ["make_default", "verify_card", "fail_on_duplicate_payment_method"]}
]
10 changes: 6 additions & 4 deletions braintree/error_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ class AuthorizationFingerprint(object):
OptionsNotAllowedWithoutCustomer = "93207"

class ClientToken(object):
MakeDefaultRequiresCustomerId = "92801"
VerifyCardRequiresCustomerId = "92802"
FailOnDuplicatePaymentMethodRequiresCustomerId = "92803"
CustomerDoesNotExist = "92804"
FailOnDuplicatePaymentMethodRequiresCustomerId = "92803"
InvalidDomainFormat = "92011"
MakeDefaultRequiresCustomerId = "92801"
MerchantAccountDoesNotExist = "92807"
ProxyMerchantDoesNotExist = "92805"
TooManyDomains = "92810"
UnsupportedVersion = "92806"
MerchantAccountDoesNotExist = "92807"
VerifyCardRequiresCustomerId = "92802"

class CreditCard(object):
BillingAddressConflict = "91701"
Expand Down
2 changes: 1 addition & 1 deletion braintree/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __flattened_signature(signature, parent=None):
@staticmethod
def __remove_wildcard_keys(allowed_keys, invalid_keys):
wildcard_keys = [
re.sub(r"(?<=[^\\])_", "\\_", re.escape(key)).replace(r"\[\_\_any\_key\_\_\]", r"\[[\w-]+\]")
re.sub(r"(?<=[^\\])_", "\\_", re.escape(key)).replace(r"\[\_\_any\_key\_\_\]", r"\[[\w.-]+\]")
for key in allowed_keys
if re.search(r"\[__any_key__\]", key)
]
Expand Down
2 changes: 1 addition & 1 deletion braintree/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Version = "4.27.0"
Version = "4.28.0"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="braintree",
version="4.27.0",
version="4.28.0",
description="Braintree Python Library",
long_description=long_description,
author="Braintree",
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/test_client_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ def test_allows_client_token_version_to_be_specified(self):
version = json.loads(client_token)["version"]
self.assertEqual(1, version)

def test_allows_client_token_domains_to_be_specified(self):
client_token = ClientToken.generate({"domains": ["example.com"]})
self.assertIsNotNone(client_token)

def test_error_for_invalid_domain_format(self):
self.assertRaises(ValueError, ClientToken.generate, {"domains": ["example"]
})

def test_error_for_too_many_domains(self):
self.assertRaises(ValueError, ClientToken.generate,
{"domains": [
"example1.com",
"example2.com",
"example3.com",
"example4.com",
"example5.com",
"example6.com",
]}
)

def test_error_in_generate_raises_value_error(self):
self.assertRaises(ValueError, ClientToken.generate, {
"customer_id": "i_am_not_a_real_customer"
Expand Down

0 comments on commit 81f2b2b

Please sign in to comment.