Skip to content

Commit 43bb1c3

Browse files
Update DNS Merchant regular expression length (#168)
1 parent 5e72f19 commit 43bb1c3

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ def default():
6969
checkout_api = CheckoutSdk
7070
.builder()
7171
.secret_key('secret_key')
72-
.public_key('public_key')
73-
.environment(Environment.sandbox())
72+
.public_key('public_key') # optional, only required for operations related with tokens
73+
.environment(Environment.sandbox()) # or production()
74+
.environment_subdomain("subdomain") # optional, Merchant-specific DNS name
7475
.build()
7576

7677
payments_client = checkout_api.payments
@@ -92,8 +93,9 @@ def oauth():
9293
.builder()
9394
.oauth()
9495
.client_credentials(client_id='client_id', client_secret='client_secret')
95-
.environment(Environment.sandbox())
96-
.scopes([OAuthScopes.GATEWAY_PAYMENT_REFUNDS, OAuthScopes.FILES])
96+
.environment(Environment.sandbox()) # or production()
97+
.environment_subdomain("subdomain") # optional, Merchant-specific DNS name
98+
.scopes([OAuthScopes.GATEWAY_PAYMENT_REFUNDS, OAuthScopes.FILES]) # optional, array of scopes
9799
.build()
98100

99101
payments_client = checkout_api.payments
@@ -114,8 +116,9 @@ def previous():
114116
.builder()
115117
.previous()
116118
.secret_key('secret_key')
117-
.public_key('public_key')
118-
.environment(Environment.sandbox())
119+
.public_key('public_key') # optional, only required for operations related with tokens
120+
.environment(Environment.sandbox()) # or production()
121+
.environment_subdomain("subdomain") # optional, Merchant-specific DNS name
119122
.build()
120123

121124
payments_client = checkout_api.payments
@@ -160,9 +163,10 @@ def oauth():
160163
.builder()
161164
.oauth()
162165
.client_credentials(client_id='client_id', client_secret='client_secret')
163-
.environment(Environment.sandbox())
164-
.http_client_builder(CustomHttpClientBuilder())
165-
.scopes([OAuthScopes.GATEWAY_PAYMENT_REFUNDS, OAuthScopes.FILES])
166+
.environment(Environment.sandbox()) # or production()
167+
.environment_subdomain("subdomain") # optional, Merchant-specific DNS name
168+
.http_client_builder(CustomHttpClientBuilder()) # optional
169+
.scopes([OAuthScopes.GATEWAY_PAYMENT_REFUNDS, OAuthScopes.FILES]) # optional, array of scopes
166170
.build()
167171

168172
payments_client = checkout_api.payments

checkout_sdk/environment_subdomain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def add_subdomain_to_api_url_environment(environment: Environment, subdomain: st
1313
api_url = environment.base_uri
1414
new_environment = api_url
1515

16-
regex = r'^[0-9a-z]{8,11}$'
16+
regex = r'^[0-9a-z]+$'
1717
if re.match(regex, subdomain):
1818
url_parts = urlparse(api_url)
1919
if url_parts.port:

tests/checkout_configuration_test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ def test_should_create_configuration():
3434
@pytest.mark.parametrize(
3535
"subdomain, expected_url",
3636
[
37-
("123dmain", "https://123dmain.api.sandbox.checkout.com/"),
38-
("123domain", "https://123domain.api.sandbox.checkout.com/"),
39-
("1234domain", "https://1234domain.api.sandbox.checkout.com/"),
37+
("a", "https://a.api.sandbox.checkout.com/"),
38+
("ab", "https://ab.api.sandbox.checkout.com/"),
39+
("abc", "https://abc.api.sandbox.checkout.com/"),
40+
("abc1", "https://abc1.api.sandbox.checkout.com/"),
4041
("12345domain", "https://12345domain.api.sandbox.checkout.com/")
4142
]
4243
)
@@ -66,9 +67,11 @@ def test_should_create_configuration_with_subdomain(subdomain, expected_url):
6667
"subdomain, expected_url",
6768
[
6869
("", "https://api.sandbox.checkout.com/"),
69-
("123", "https://api.sandbox.checkout.com/"),
70-
("123bad", "https://api.sandbox.checkout.com/"),
71-
("12345domainBad", "https://api.sandbox.checkout.com/")
70+
(" ", "https://api.sandbox.checkout.com/"),
71+
(" ", "https://api.sandbox.checkout.com/"),
72+
(" - ", "https://api.sandbox.checkout.com/"),
73+
("a b", "https://api.sandbox.checkout.com/"),
74+
("ab c1.", "https://api.sandbox.checkout.com/")
7275
]
7376
)
7477
def test_should_create_configuration_with_bad_subdomain(subdomain, expected_url):

0 commit comments

Comments
 (0)