Skip to content

Commit

Permalink
SK-1691 Update sample for card brand choice feature
Browse files Browse the repository at this point in the history
  • Loading branch information
skyflow-vivek committed Sep 24, 2024
1 parent 03bc7b8 commit b4bdf82
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions samples/src/main/java/com/Skyflow/CardBrandChoiceActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,17 @@ class CardBrandChoiceActivity : AppCompatActivity() {
Log.d(TAG, "blur: state $state")
}

var calledUpdate = false
var scheme = arrayOf<CardType>()
cardNumber.on(EventName.CHANGE) { state ->
Log.d(TAG, "change: state $state")
val value = state.getString("value")
if (value.length < 8 && calledUpdate) {
calledUpdate = false
cardNumber.update(CollectElementOptions(cardMetadata = CardMetadata(arrayOf())))
} else if (value.length >= 8 && !calledUpdate) {
calledUpdate = true
if (value.length < 8 && scheme.isNotEmpty()) {
scheme = arrayOf()
cardNumber.update(CollectElementOptions(cardMetadata = CardMetadata(scheme)))
} else if (value.length >= 8 && scheme.isEmpty()) {
binLookup(value, object : Callback {
override fun onSuccess(responseBody: Any) {
println(responseBody as JSONArray)
val scheme = getCardSchemes(responseBody)
scheme = getCardSchemes(responseBody as JSONArray)
runOnUiThread(kotlinx.coroutines.Runnable {
cardNumber.update(
CollectElementOptions(cardMetadata = CardMetadata(scheme))
Expand Down

0 comments on commit b4bdf82

Please sign in to comment.