From 23674120c5fae77d3d331abc06698ee7c0c819f1 Mon Sep 17 00:00:00 2001 From: Josue Date: Mon, 24 Nov 2025 01:16:51 -0600 Subject: [PATCH 1/9] feat: add environment option --- .../elements/service/ApiClientProvider.kt | 12 +++++- .../service/BasisTheoryElementsBuilder.kt | 8 +++- .../basistheory/elements/service/ProxyApi.kt | 10 +++-- .../elements/service/ProxyApiTests.kt | 41 ++++++++++++++++++- 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt b/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt index fd252ad..f706c8c 100644 --- a/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt +++ b/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt @@ -1,6 +1,7 @@ package com.basistheory.elements.service import com.basistheory.BasisTheoryApiClient +import com.basistheory.core.Environment import com.basistheory.resources.enrichments.EnrichmentsClient import com.basistheory.resources.sessions.SessionsClient import com.basistheory.resources.tokenintents.TokenIntentsClient @@ -10,7 +11,8 @@ import kotlinx.coroutines.Dispatchers internal class ApiClientProvider( private val apiUrl: String = "https://api.basistheory.com", - private val defaultApiKey: String? = null + private val defaultApiKey: String? = null, + private val environment: String? = "production" ) { fun getTokensApi(apiKeyOverride: String? = null): TokensClient = getApiClient(apiKeyOverride).tokens() @@ -36,8 +38,14 @@ internal class ApiClientProvider( return BasisTheoryApiClient.builder() .apiKey(apiKey) - .url(apiUrl) + .environment(getJavaSdkEnvironment(environment)) .httpClient(createHttpClientWithDeviceInfo()) .build() } + + private fun getJavaSdkEnvironment(environment: String?): Environment { + if (environment?.lowercase() == "test") Environment.TEST + + return Environment.PRODUCTION + } } \ No newline at end of file diff --git a/lib/src/main/java/com/basistheory/elements/service/BasisTheoryElementsBuilder.kt b/lib/src/main/java/com/basistheory/elements/service/BasisTheoryElementsBuilder.kt index 409a5e5..da3e04b 100644 --- a/lib/src/main/java/com/basistheory/elements/service/BasisTheoryElementsBuilder.kt +++ b/lib/src/main/java/com/basistheory/elements/service/BasisTheoryElementsBuilder.kt @@ -6,6 +6,7 @@ import kotlinx.coroutines.Dispatchers class BasisTheoryElementsBuilder { private var _apiKey: String? = null private var _apiUrl: String = "https://api.basistheory.com" + private var _environment: String = "production" private var _dispatcher: CoroutineDispatcher = Dispatchers.IO fun apiKey(value: String): BasisTheoryElementsBuilder { @@ -18,6 +19,11 @@ class BasisTheoryElementsBuilder { return this } + fun environment(value: String): BasisTheoryElementsBuilder { + _environment = value + return this + } + fun dispatcher(value: CoroutineDispatcher): BasisTheoryElementsBuilder { _dispatcher = value return this @@ -25,7 +31,7 @@ class BasisTheoryElementsBuilder { fun build(): BasisTheoryElements = BasisTheoryElements( - ApiClientProvider(_apiUrl, _apiKey), + ApiClientProvider(_apiUrl, _apiKey, _environment), _dispatcher ) } \ No newline at end of file diff --git a/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt b/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt index c17a004..abff50b 100644 --- a/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt +++ b/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt @@ -1,7 +1,6 @@ package com.basistheory.elements.service import com.basistheory.elements.model.ElementValueReference -import com.basistheory.elements.model.exceptions.ApiException import com.basistheory.elements.util.getEncodedDeviceInfo import com.basistheory.elements.util.isPrimitiveType import com.basistheory.elements.util.replaceElementRefs @@ -19,7 +18,6 @@ import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.RequestBody.Companion.toRequestBody - interface Proxy { suspend fun get(proxyRequest: ProxyRequest, apiKeyOverride: String? = null): Any? @@ -54,7 +52,8 @@ class ProxyApi( val dispatcher: CoroutineDispatcher = Dispatchers.IO, val apiBaseUrl: String = "https://api.basistheory.com", val apiKey: String, - val httpClient: OkHttpClient = OkHttpClient() + val httpClient: OkHttpClient = OkHttpClient(), + val environment: String = "production" ) : Proxy { override suspend fun get(proxyRequest: ProxyRequest, apiKeyOverride: String?): Any? = @@ -94,7 +93,9 @@ class ProxyApi( } } - val urlBuilder = (apiBaseUrl + "/proxy" + (proxyRequest.path.orEmpty())) + val finalApiBaseUrl = + if (environment.lowercase() == "test") "https://api.btsandbox.com" else apiBaseUrl + val urlBuilder = (finalApiBaseUrl + "/proxy" + (proxyRequest.path.orEmpty())) .toHttpUrlOrNull()?.newBuilder() ?: throw IllegalArgumentException("Invalid URL") proxyRequest.queryParams?.toPairs()?.forEach { (key, value) -> @@ -112,6 +113,7 @@ class ProxyApi( val requestBody = when { method.equals("GET", ignoreCase = true) || method.equals("DELETE", ignoreCase = true) -> null + isTextPlain -> processedBody?.toString().orEmpty() .toRequestBody("text/plain; charset=utf-8".toMediaTypeOrNull()) diff --git a/lib/src/test/java/com/basistheory/elements/service/ProxyApiTests.kt b/lib/src/test/java/com/basistheory/elements/service/ProxyApiTests.kt index 0682176..6e03dc3 100644 --- a/lib/src/test/java/com/basistheory/elements/service/ProxyApiTests.kt +++ b/lib/src/test/java/com/basistheory/elements/service/ProxyApiTests.kt @@ -76,9 +76,9 @@ class ProxyApiTests { fun setup() { proxyApi = ProxyApi( dispatcher = Dispatchers.IO, - apiBaseUrl = "https://api.basistheory.com", apiKey = "124", - httpClient = mockHttpClient + httpClient = mockHttpClient, + environment = "production" ) proxyRequest = ProxyRequest() @@ -140,6 +140,43 @@ class ProxyApiTests { expectThat(result).isA() } + @Test + fun `should use uat url when environment is test`() { + proxyApi = ProxyApi( + dispatcher = Dispatchers.IO, + apiKey = "124", + httpClient = mockHttpClient, + environment = "test" + ) + + val queryParamValue = UUID.randomUUID().toString() + proxyRequest = proxyRequest.apply { + path = "/payment" + headers = mapOf( + "BT-PROXY-URL" to "https://echo.basistheory.com/post", + "Content-Type" to "text/plain" + ) + queryParams = mapOf("param" to queryParamValue) + body = "Hello World" + } + + val requestSlot = setupMocks("\"Hello World\"") + + val result = runBlocking { + proxyApi.post(proxyRequest) + } + + verify(exactly = 1) { mockHttpClient.newCall(any()) } + verify(exactly = 1) { mockCall.execute() } + + expectThat(requestSlot.captured) { + get { url.toString() } + .isEqualTo("https://api.btsandbox.com/proxy/payment?param=${queryParamValue}") + } + + expectThat(result).isA() + } + @Test fun `should transform complex proxy response to element value references`() { val responseJson = """ From 65bcc70cd921f4da003f129350cdf2934e9bfea8 Mon Sep 17 00:00:00 2001 From: Josue Date: Mon, 24 Nov 2025 01:17:36 -0600 Subject: [PATCH 2/9] update pr template --- .github/PULL_REQUEST_TEMPLATE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b694c99..37da2cd 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,17 +6,17 @@ ## Testing required outside of automated testing? -- [ ] Not Applicable +- [x] Not Applicable ### Screenshots (if appropriate): -- [ ] Not Applicable +- [x] Not Applicable ## Rollback / Rollforward Procedure -- [ ] Roll Forward +- [x] Roll Forward - [ ] Roll Back ## Reviewer Checklist From df90f43d1b9974b9853ca1a50daf04ba051f250e Mon Sep 17 00:00:00 2001 From: Josue Date: Thu, 4 Dec 2025 16:57:29 -0600 Subject: [PATCH 3/9] fixing build --- gradle/libs.versions.toml | 2 +- .../elements/service/ApiClientProvider.kt | 10 ++-------- .../service/BasisTheoryElementsBuilder.kt | 5 +++-- .../com/basistheory/elements/service/ProxyApi.kt | 7 ++++--- .../basistheory/elements/util/EnvironmentUtils.kt | 15 +++++++++++++++ .../elements/view/CardNumberElement.kt | 3 --- .../basistheory/elements/service/ProxyApiTests.kt | 7 ++++--- 7 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 lib/src/main/java/com/basistheory/elements/util/EnvironmentUtils.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 28ce45e..ca6d733 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ activityCompose = "1.9.3" androidGifDrawable = "1.2.27" androidGradlePlugin = "8.9.1" appcompat = "1.7.0" -basistheoryJava = "4.0.0" +basistheoryJava = "4.1.0" commonsLang3 = "3.17.0" constraintlayout = "2.2.0" desugar_jdk_libs = "2.1.4" diff --git a/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt b/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt index f706c8c..9e03077 100644 --- a/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt +++ b/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt @@ -12,7 +12,7 @@ import kotlinx.coroutines.Dispatchers internal class ApiClientProvider( private val apiUrl: String = "https://api.basistheory.com", private val defaultApiKey: String? = null, - private val environment: String? = "production" + private val environment: Environment? = Environment.DEFAULT ) { fun getTokensApi(apiKeyOverride: String? = null): TokensClient = getApiClient(apiKeyOverride).tokens() @@ -38,14 +38,8 @@ internal class ApiClientProvider( return BasisTheoryApiClient.builder() .apiKey(apiKey) - .environment(getJavaSdkEnvironment(environment)) + .environment(environment) .httpClient(createHttpClientWithDeviceInfo()) .build() } - - private fun getJavaSdkEnvironment(environment: String?): Environment { - if (environment?.lowercase() == "test") Environment.TEST - - return Environment.PRODUCTION - } } \ No newline at end of file diff --git a/lib/src/main/java/com/basistheory/elements/service/BasisTheoryElementsBuilder.kt b/lib/src/main/java/com/basistheory/elements/service/BasisTheoryElementsBuilder.kt index da3e04b..3c54ad0 100644 --- a/lib/src/main/java/com/basistheory/elements/service/BasisTheoryElementsBuilder.kt +++ b/lib/src/main/java/com/basistheory/elements/service/BasisTheoryElementsBuilder.kt @@ -1,12 +1,13 @@ package com.basistheory.elements.service +import com.basistheory.core.Environment import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers class BasisTheoryElementsBuilder { private var _apiKey: String? = null private var _apiUrl: String = "https://api.basistheory.com" - private var _environment: String = "production" + private var _environment: Environment = Environment.DEFAULT private var _dispatcher: CoroutineDispatcher = Dispatchers.IO fun apiKey(value: String): BasisTheoryElementsBuilder { @@ -19,7 +20,7 @@ class BasisTheoryElementsBuilder { return this } - fun environment(value: String): BasisTheoryElementsBuilder { + fun environment(value: Environment): BasisTheoryElementsBuilder { _environment = value return this } diff --git a/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt b/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt index abff50b..be424fb 100644 --- a/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt +++ b/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt @@ -1,6 +1,8 @@ package com.basistheory.elements.service +import com.basistheory.core.Environment import com.basistheory.elements.model.ElementValueReference +import com.basistheory.elements.util.getApiUrl import com.basistheory.elements.util.getEncodedDeviceInfo import com.basistheory.elements.util.isPrimitiveType import com.basistheory.elements.util.replaceElementRefs @@ -53,7 +55,7 @@ class ProxyApi( val apiBaseUrl: String = "https://api.basistheory.com", val apiKey: String, val httpClient: OkHttpClient = OkHttpClient(), - val environment: String = "production" + val environment: Environment = Environment.DEFAULT ) : Proxy { override suspend fun get(proxyRequest: ProxyRequest, apiKeyOverride: String?): Any? = @@ -93,8 +95,7 @@ class ProxyApi( } } - val finalApiBaseUrl = - if (environment.lowercase() == "test") "https://api.btsandbox.com" else apiBaseUrl + val finalApiBaseUrl = environment.getApiUrl() val urlBuilder = (finalApiBaseUrl + "/proxy" + (proxyRequest.path.orEmpty())) .toHttpUrlOrNull()?.newBuilder() ?: throw IllegalArgumentException("Invalid URL") diff --git a/lib/src/main/java/com/basistheory/elements/util/EnvironmentUtils.kt b/lib/src/main/java/com/basistheory/elements/util/EnvironmentUtils.kt new file mode 100644 index 0000000..662e46b --- /dev/null +++ b/lib/src/main/java/com/basistheory/elements/util/EnvironmentUtils.kt @@ -0,0 +1,15 @@ +package com.basistheory.elements.util + +import com.basistheory.core.Environment + +const val ApiUrl: String = "https://api.basistheory.com" +const val ApiTestUrl: String = "https://api.test.basistheory.com" + +fun Environment.getApiUrl(): String = + when (this) { + Environment.US -> ApiUrl + Environment.EU -> ApiUrl + Environment.TEST -> ApiTestUrl + Environment.DEFAULT -> ApiUrl + else -> ApiUrl + } \ No newline at end of file diff --git a/lib/src/main/java/com/basistheory/elements/view/CardNumberElement.kt b/lib/src/main/java/com/basistheory/elements/view/CardNumberElement.kt index c535e53..4dcbb9f 100644 --- a/lib/src/main/java/com/basistheory/elements/view/CardNumberElement.kt +++ b/lib/src/main/java/com/basistheory/elements/view/CardNumberElement.kt @@ -8,14 +8,11 @@ import com.basistheory.elements.event.EventDetails import com.basistheory.elements.model.BinDetails import com.basistheory.elements.model.CardMetadata import com.basistheory.elements.model.InputType -import com.basistheory.elements.service.ApiClientProvider import com.basistheory.elements.service.CardBrandEnricher import com.basistheory.elements.util.BinDetailsCache import com.basistheory.elements.view.mask.ElementMask import com.basistheory.elements.view.transform.RegexReplaceElementTransform import com.basistheory.elements.view.validation.LuhnValidator -import com.basistheory.resources.enrichments.requests.EnrichmentsGetCardDetailsRequest -import com.basistheory.types.CardDetailsResponse import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job diff --git a/lib/src/test/java/com/basistheory/elements/service/ProxyApiTests.kt b/lib/src/test/java/com/basistheory/elements/service/ProxyApiTests.kt index 6e03dc3..bd76715 100644 --- a/lib/src/test/java/com/basistheory/elements/service/ProxyApiTests.kt +++ b/lib/src/test/java/com/basistheory/elements/service/ProxyApiTests.kt @@ -1,5 +1,6 @@ package com.basistheory.elements.service +import com.basistheory.core.Environment import com.basistheory.elements.model.ElementValueReference import com.basistheory.elements.util.getEncodedDeviceInfo import io.mockk.CapturingSlot @@ -78,7 +79,7 @@ class ProxyApiTests { dispatcher = Dispatchers.IO, apiKey = "124", httpClient = mockHttpClient, - environment = "production" + environment = Environment.US ) proxyRequest = ProxyRequest() @@ -146,7 +147,7 @@ class ProxyApiTests { dispatcher = Dispatchers.IO, apiKey = "124", httpClient = mockHttpClient, - environment = "test" + environment = Environment.TEST ) val queryParamValue = UUID.randomUUID().toString() @@ -171,7 +172,7 @@ class ProxyApiTests { expectThat(requestSlot.captured) { get { url.toString() } - .isEqualTo("https://api.btsandbox.com/proxy/payment?param=${queryParamValue}") + .isEqualTo("https://api.test.basistheory.com/proxy/payment?param=${queryParamValue}") } expectThat(result).isA() From 2802cecc00072bf239ab7a3ad24f8880978c82fc Mon Sep 17 00:00:00 2001 From: Josue Date: Fri, 5 Dec 2025 13:07:25 -0600 Subject: [PATCH 4/9] fixing tests --- .../basistheory/elements/service/ApiClientProvider.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt b/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt index 9e03077..a395d18 100644 --- a/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt +++ b/lib/src/main/java/com/basistheory/elements/service/ApiClientProvider.kt @@ -36,10 +36,15 @@ internal class ApiClientProvider( val apiKey = apiKeyOverride ?: defaultApiKey requireNotNull(apiKey) - return BasisTheoryApiClient.builder() + val apiClient = BasisTheoryApiClient.builder() .apiKey(apiKey) .environment(environment) - .httpClient(createHttpClientWithDeviceInfo()) - .build() + .httpClient(createHttpClientWithDeviceInfo()); + + if (apiUrl != "https://api.basistheory.com" && environment === Environment.DEFAULT) { + apiClient.url(apiUrl) + } + + return apiClient.build() } } \ No newline at end of file From 6d6e8dd6b611d44a08e2aafd22d2a4b5f2392f3d Mon Sep 17 00:00:00 2001 From: Josue Date: Fri, 5 Dec 2025 15:35:28 -0600 Subject: [PATCH 5/9] fixing proxy test --- .../com/basistheory/elements/example/view/card/CardFragment.kt | 2 -- lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/example/src/main/java/com/basistheory/elements/example/view/card/CardFragment.kt b/example/src/main/java/com/basistheory/elements/example/view/card/CardFragment.kt index 59af988..118f6bf 100644 --- a/example/src/main/java/com/basistheory/elements/example/view/card/CardFragment.kt +++ b/example/src/main/java/com/basistheory/elements/example/view/card/CardFragment.kt @@ -1,7 +1,6 @@ package com.basistheory.elements.example.view.card import android.os.Bundle -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -11,7 +10,6 @@ import com.basistheory.elements.constants.CoBadgedSupport import com.basistheory.elements.example.databinding.FragmentCardBinding import com.basistheory.elements.example.util.tokenExpirationTimestamp import com.basistheory.elements.example.viewmodel.CardFragmentViewModel -import com.basistheory.elements.service.BasisTheoryElements import com.basistheory.elements.view.CardBrandSelectorOptions class CardFragment : Fragment() { diff --git a/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt b/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt index be424fb..c68a319 100644 --- a/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt +++ b/lib/src/main/java/com/basistheory/elements/service/ProxyApi.kt @@ -95,7 +95,7 @@ class ProxyApi( } } - val finalApiBaseUrl = environment.getApiUrl() + val finalApiBaseUrl = if (apiBaseUrl !== "https://api.basistheory.com") apiBaseUrl else environment.getApiUrl() val urlBuilder = (finalApiBaseUrl + "/proxy" + (proxyRequest.path.orEmpty())) .toHttpUrlOrNull()?.newBuilder() ?: throw IllegalArgumentException("Invalid URL") From 3ed7e9f4b7ca61661880de9e49ef20cf843d7be3 Mon Sep 17 00:00:00 2001 From: Josue Date: Tue, 9 Dec 2025 16:59:40 -0600 Subject: [PATCH 6/9] upgrade macos runner --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 87a85fd..b5f88c9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -29,7 +29,7 @@ jobs: run: ./gradlew testDebugUnitTest acceptance: - runs-on: macos-13 + runs-on: macos-14 environment: PR env: From e1770c072672216562426ff0cd5c631bada9e8c3 Mon Sep 17 00:00:00 2001 From: Josue Date: Tue, 9 Dec 2025 17:12:19 -0600 Subject: [PATCH 7/9] upgrade macos runner --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b5f88c9..bc92981 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -29,7 +29,7 @@ jobs: run: ./gradlew testDebugUnitTest acceptance: - runs-on: macos-14 + runs-on: macos-15 environment: PR env: From 8fd5bf50f7ee5b7470d023b1692bcdf343b91195 Mon Sep 17 00:00:00 2001 From: Josue Date: Tue, 9 Dec 2025 17:19:11 -0600 Subject: [PATCH 8/9] upgrade macos runner --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index bc92981..3afefaa 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -29,7 +29,7 @@ jobs: run: ./gradlew testDebugUnitTest acceptance: - runs-on: macos-15 + runs-on: macos-15-intel environment: PR env: From 0c0370c984d8a9e416ceddfe7a3eb0534de2f03f Mon Sep 17 00:00:00 2001 From: Josue Date: Tue, 9 Dec 2025 19:02:14 -0600 Subject: [PATCH 9/9] trying to fix tests --- .../com/basistheory/elements/example/util/TokenExpiration.kt | 2 +- .../java/com/basistheory/elements/view/CardNumberElement.kt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/example/src/main/java/com/basistheory/elements/example/util/TokenExpiration.kt b/example/src/main/java/com/basistheory/elements/example/util/TokenExpiration.kt index ffb0a24..f995faf 100644 --- a/example/src/main/java/com/basistheory/elements/example/util/TokenExpiration.kt +++ b/example/src/main/java/com/basistheory/elements/example/util/TokenExpiration.kt @@ -4,5 +4,5 @@ import org.threeten.bp.Instant import org.threeten.bp.temporal.ChronoUnit fun tokenExpirationTimestamp() = Instant.now() - .plus(5, ChronoUnit.MINUTES) + .plus(30, ChronoUnit.MINUTES) .toString() \ No newline at end of file diff --git a/lib/src/main/java/com/basistheory/elements/view/CardNumberElement.kt b/lib/src/main/java/com/basistheory/elements/view/CardNumberElement.kt index 9d3ca78..df4d21f 100644 --- a/lib/src/main/java/com/basistheory/elements/view/CardNumberElement.kt +++ b/lib/src/main/java/com/basistheory/elements/view/CardNumberElement.kt @@ -23,6 +23,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch +import kotlin.coroutines.cancellation.CancellationException class CardNumberElement @JvmOverloads constructor( context: Context, @@ -130,6 +131,8 @@ class CardNumberElement @JvmOverloads constructor( BinDetailsCache.put(bin, binDetails) updateBinDetails(binDetails) } + } catch (e: CancellationException) { + Log.i("CardNumberElement", "Fetch BIN details job cancelled") } catch (e: Exception) { Log.e("CardNumberElement", "Error fetching BIN details", e) }