-
Notifications
You must be signed in to change notification settings - Fork 1
[PIMOB-4287]: adding base url prefix to Frames SDK for multi-region #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zane-smith-cko
merged 13 commits into
master
from
feature/PIMOB-4287_add_subdomain_prefix
Mar 11, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ed27d58
PIMOB-4287: add subdomain prefix to base url for multi region support
zane-smith-cko 8c5b4c9
PIMOB-4287: rename base url prefix var, include global subdomain in c…
zane-smith-cko 80963da
PIMOB-4287: update kdoc
zane-smith-cko 2861377
PIMOB-4287: add & fix unit tests, rename variable name for baseurl pr…
zane-smith-cko 0a5ee24
PIMOB-4287: lint format check
zane-smith-cko 57e489a
PIMOB-4287: remove unused secret key
zane-smith-cko 36d532b
PIMOB-4287: add kdoc for cvv component, update test file to include a…
zane-smith-cko 3dd091f
PIMOB-4287 ktlint formating
zane-smith-cko 95aa941
PIMOB-4287: ktlint format
zane-smith-cko 19a922e
PIMOB-4287: hide secret keys
zane-smith-cko 41b06d2
PIMOB-4287: fix ci/cd + build prefix url from constants
zane-smith-cko dd8eaee
PIMOB-4287: fix local prop keys parsing for both app run configuratio…
zane-smith-cko 5d030fb
PIMOB-4287: edit kdocs and remove nullable extension type
zane-smith-cko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
checkout/src/main/java/com/checkout/base/model/Environment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| package com.checkout.base.model | ||
|
|
||
| import com.checkout.base.util.EnvironmentConstants | ||
|
|
||
| public enum class Environment(public val url: String) { | ||
| PRODUCTION(EnvironmentConstants.PRODUCTION_SERVER_URL), | ||
| SANDBOX(EnvironmentConstants.SANDBOX_SERVER_URL), | ||
| public enum class Environment { | ||
| PRODUCTION, | ||
| SANDBOX, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 22 additions & 2 deletions
24
checkout/src/main/java/com/checkout/logging/utils/EnvironmentExtension.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,33 @@ | ||
| package com.checkout.logging.utils | ||
|
|
||
| import com.checkout.base.model.Environment | ||
| import com.checkout.base.util.EnvironmentConstants.PRODUCTION_LOGGING | ||
| import com.checkout.base.util.EnvironmentConstants.PRODUCTION_SERVER_URL | ||
| import com.checkout.base.util.EnvironmentConstants.SANDBOX_LOGGING | ||
| import com.checkout.base.util.EnvironmentConstants.SANDBOX_SERVER_URL | ||
| import com.checkout.base.util.HTTPS_PROTOCOL | ||
|
|
||
| internal fun Environment.toBaseUrl(baseUrlPrefix: String? = null) = when (this) { | ||
| Environment.PRODUCTION -> PRODUCTION_SERVER_URL.applyPrefix(baseUrlPrefix) | ||
| Environment.SANDBOX -> SANDBOX_SERVER_URL.applyPrefix(baseUrlPrefix) | ||
| } | ||
zane-smith-cko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| internal fun Environment.toLoggingEnvironment() = when (this) { | ||
| Environment.PRODUCTION -> com.checkout.eventlogger.Environment.PRODUCTION | ||
| Environment.SANDBOX -> com.checkout.eventlogger.Environment.SANDBOX | ||
| } | ||
|
|
||
| internal fun Environment.toLoggingName() = when (this) { | ||
| Environment.PRODUCTION -> "production" | ||
| Environment.SANDBOX -> "sandbox" | ||
| Environment.PRODUCTION -> PRODUCTION_LOGGING | ||
| Environment.SANDBOX -> SANDBOX_LOGGING | ||
| } | ||
|
|
||
| private fun String.applyPrefix(prefix: String?): String { | ||
| val validatedPrefix = prefix?.baseUrlPrefixValidator() ?: return this | ||
| return this.replace(HTTPS_PROTOCOL, "$HTTPS_PROTOCOL$validatedPrefix.") | ||
| } | ||
|
|
||
| private fun String.baseUrlPrefixValidator() = this | ||
| .takeIf { prefix -> | ||
| prefix.isNotEmpty() && prefix.all { char -> char in 'a'..'z' || char in 'A'..'Z' || char in '0'..'9' } | ||
| } | ||
zane-smith-cko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
checkout/src/test/java/com/checkout/EnvironmentExtensionTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| package com.checkout | ||
|
|
||
| import com.checkout.base.model.Environment | ||
| import com.checkout.base.util.EnvironmentConstants | ||
| import com.checkout.base.util.EnvironmentConstants.PRODUCTION_SERVER_URL | ||
| import com.checkout.logging.utils.toBaseUrl | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Test | ||
|
|
||
| internal class EnvironmentExtensionTest { | ||
|
|
||
| @Test | ||
| fun `when toBaseUrl PRODUCTION with null subDomainPrefix returns production server URL`() { | ||
| val result = Environment.PRODUCTION.toBaseUrl(null) | ||
| assertEquals(EnvironmentConstants.PRODUCTION_SERVER_URL, result) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when toBaseUrl PRODUCTION with no subDomainPrefix argument returns production server URL`() { | ||
| val result = Environment.PRODUCTION.toBaseUrl() | ||
| assertEquals(EnvironmentConstants.PRODUCTION_SERVER_URL, result) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when toBaseUrl PRODUCTION with subDomainPrefix returns custom production URL`() { | ||
| val result = Environment.PRODUCTION.toBaseUrl("custom") | ||
| assertEquals("https://custom.api.checkout.com/tokens", result) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when toBaseUrl PRODUCTION with alphanumeric subDomainPrefix returns custom production URL`() { | ||
| val result = Environment.PRODUCTION.toBaseUrl("mySubdomain123") | ||
| assertEquals("https://mySubdomain123.api.checkout.com/tokens", result) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when toBaseUrl SANDBOX with null subDomainPrefix returns sandbox server URL`() { | ||
| val result = Environment.SANDBOX.toBaseUrl(null) | ||
| assertEquals(EnvironmentConstants.SANDBOX_SERVER_URL, result) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when toBaseUrl SANDBOX with no subDomainPrefix argument returns sandbox server URL`() { | ||
| val result = Environment.SANDBOX.toBaseUrl() | ||
| assertEquals(EnvironmentConstants.SANDBOX_SERVER_URL, result) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when toBaseUrl SANDBOX with subDomainPrefix returns custom sandbox URL`() { | ||
| val result = Environment.SANDBOX.toBaseUrl("custom") | ||
| assertEquals("https://custom.api.sandbox.checkout.com/tokens", result) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when toBaseUrl SANDBOX with alphanumeric subDomainPrefix returns custom sandbox URL`() { | ||
| val result = Environment.SANDBOX.toBaseUrl("test99") | ||
| assertEquals("https://test99.api.sandbox.checkout.com/tokens", result) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when toBaseUrl with empty string subDomainPrefix uses default URL for production`() { | ||
| val result = Environment.PRODUCTION.toBaseUrl("") | ||
| assertEquals("https://api.checkout.com/tokens", result) | ||
| } | ||
|
|
||
| @Test | ||
| fun `toBaseUrl PRODUCTION returns default URL for any non-alphanumeric prefix`() { | ||
zane-smith-cko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| val invalidPrefixList = listOf( | ||
| "invalid_prefix", | ||
| "invalid-prefix", | ||
| "invalid.prefix", | ||
zane-smith-cko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "invalid@prefix", | ||
| "invalid!prefix", | ||
| "invalid#prefix", | ||
| "invalid\$prefix", | ||
| "invalid%prefix", | ||
| "invalid^prefix", | ||
| "invalid&prefix", | ||
| "invalid*prefix", | ||
| "invalid(prefix", | ||
| "invalid)prefix", | ||
| "invalid prefix", | ||
| ) | ||
|
|
||
| invalidPrefixList.forEach { invalidPrefix -> | ||
| val result = Environment.PRODUCTION.toBaseUrl(invalidPrefix) | ||
| assertEquals( | ||
| PRODUCTION_SERVER_URL, | ||
| result, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.