Skip to content

Commit

Permalink
Update DNS Merchant regular expression length (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Aug 28, 2024
1 parent 5e72f19 commit 43bb1c3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def default():
checkout_api = CheckoutSdk
.builder()
.secret_key('secret_key')
.public_key('public_key')
.environment(Environment.sandbox())
.public_key('public_key') # optional, only required for operations related with tokens
.environment(Environment.sandbox()) # or production()
.environment_subdomain("subdomain") # optional, Merchant-specific DNS name
.build()

payments_client = checkout_api.payments
Expand All @@ -92,8 +93,9 @@ def oauth():
.builder()
.oauth()
.client_credentials(client_id='client_id', client_secret='client_secret')
.environment(Environment.sandbox())
.scopes([OAuthScopes.GATEWAY_PAYMENT_REFUNDS, OAuthScopes.FILES])
.environment(Environment.sandbox()) # or production()
.environment_subdomain("subdomain") # optional, Merchant-specific DNS name
.scopes([OAuthScopes.GATEWAY_PAYMENT_REFUNDS, OAuthScopes.FILES]) # optional, array of scopes
.build()

payments_client = checkout_api.payments
Expand All @@ -114,8 +116,9 @@ def previous():
.builder()
.previous()
.secret_key('secret_key')
.public_key('public_key')
.environment(Environment.sandbox())
.public_key('public_key') # optional, only required for operations related with tokens
.environment(Environment.sandbox()) # or production()
.environment_subdomain("subdomain") # optional, Merchant-specific DNS name
.build()

payments_client = checkout_api.payments
Expand Down Expand Up @@ -160,9 +163,10 @@ def oauth():
.builder()
.oauth()
.client_credentials(client_id='client_id', client_secret='client_secret')
.environment(Environment.sandbox())
.http_client_builder(CustomHttpClientBuilder())
.scopes([OAuthScopes.GATEWAY_PAYMENT_REFUNDS, OAuthScopes.FILES])
.environment(Environment.sandbox()) # or production()
.environment_subdomain("subdomain") # optional, Merchant-specific DNS name
.http_client_builder(CustomHttpClientBuilder()) # optional
.scopes([OAuthScopes.GATEWAY_PAYMENT_REFUNDS, OAuthScopes.FILES]) # optional, array of scopes
.build()

payments_client = checkout_api.payments
Expand Down
2 changes: 1 addition & 1 deletion checkout_sdk/environment_subdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def add_subdomain_to_api_url_environment(environment: Environment, subdomain: st
api_url = environment.base_uri
new_environment = api_url

regex = r'^[0-9a-z]{8,11}$'
regex = r'^[0-9a-z]+$'
if re.match(regex, subdomain):
url_parts = urlparse(api_url)
if url_parts.port:
Expand Down
15 changes: 9 additions & 6 deletions tests/checkout_configuration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ def test_should_create_configuration():
@pytest.mark.parametrize(
"subdomain, expected_url",
[
("123dmain", "https://123dmain.api.sandbox.checkout.com/"),
("123domain", "https://123domain.api.sandbox.checkout.com/"),
("1234domain", "https://1234domain.api.sandbox.checkout.com/"),
("a", "https://a.api.sandbox.checkout.com/"),
("ab", "https://ab.api.sandbox.checkout.com/"),
("abc", "https://abc.api.sandbox.checkout.com/"),
("abc1", "https://abc1.api.sandbox.checkout.com/"),
("12345domain", "https://12345domain.api.sandbox.checkout.com/")
]
)
Expand Down Expand Up @@ -66,9 +67,11 @@ def test_should_create_configuration_with_subdomain(subdomain, expected_url):
"subdomain, expected_url",
[
("", "https://api.sandbox.checkout.com/"),
("123", "https://api.sandbox.checkout.com/"),
("123bad", "https://api.sandbox.checkout.com/"),
("12345domainBad", "https://api.sandbox.checkout.com/")
(" ", "https://api.sandbox.checkout.com/"),
(" ", "https://api.sandbox.checkout.com/"),
(" - ", "https://api.sandbox.checkout.com/"),
("a b", "https://api.sandbox.checkout.com/"),
("ab c1.", "https://api.sandbox.checkout.com/")
]
)
def test_should_create_configuration_with_bad_subdomain(subdomain, expected_url):
Expand Down

0 comments on commit 43bb1c3

Please sign in to comment.