Skip to content

Commit

Permalink
Merge pull request #153 from veritrans/feat/CC_error_cvv
Browse files Browse the repository at this point in the history
Error Card Dialogue Detail and Incorrect Flow when delete card.
  • Loading branch information
uziwuzzy authored Feb 21, 2023
2 parents 6c07522 + 3f7dd36 commit b71d40d
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ internal class CreditCardActivity : BaseActivity() {
}

private var onPromoReset: () -> Unit = {}
private var isCreditCardChanged = false

private val savedTokenList: SnapshotStateList<FormData>? by lazy {
creditCard?.savedTokens?.mapIndexed { index, savedToken ->
Expand Down Expand Up @@ -448,15 +449,30 @@ internal class CreditCardActivity : BaseActivity() {
promoId = state.promoId
)
} else {
viewModel?.chargeUsingCreditCard(
formData = selectedFormData as SavedCreditCardFormData,
snapToken = snapToken,
cardCvv = state.cvv,
customerEmail = state.customerEmail.text,
transactionDetails = transactionDetails,
installmentTerm = installmentTerm,
promoId = state.promoId
)
if (savedTokenListState != null && savedTokenListState.size > 1) {
viewModel?.chargeUsingCreditCard(
formData = selectedFormData as SavedCreditCardFormData,
snapToken = snapToken,
cardCvv = state.cvv,
customerEmail = state.customerEmail.text,
transactionDetails = transactionDetails,
installmentTerm = installmentTerm,
promoId = state.promoId
)
} else {
viewModel?.chargeUsingCreditCard(
transactionDetails = transactionDetails,
cardNumber = state.cardNumber,
cardExpiry = state.expiry,
cardCvv = state.cvv,
isSavedCard = state.isSavedCardChecked,
customerEmail = state.customerEmail.text,
customerPhone = state.customerPhone.text,
installmentTerm = installmentTerm,
snapToken = snapToken,
promoId = state.promoId
)
}
}
isFirstInit = false
}
Expand Down Expand Up @@ -509,6 +525,10 @@ internal class CreditCardActivity : BaseActivity() {
)
savedTokenListState?.remove(it)
isDeleteConfirmationShownState = false
isCreditCardChanged = true
state.cardNumber = TextFieldValue()
state.expiry = TextFieldValue()
state.cvv = TextFieldValue()
}
},
onCancelClicked = {
Expand Down Expand Up @@ -759,23 +779,21 @@ internal class CreditCardActivity : BaseActivity() {
CustomerPhoneLayout(state = state)
}

savedTokenListState?.let {
if (savedTokenListState != null && savedTokenListState.size > 1) {
SavedCardLayout(
viewModel = viewModel,
isTransactionDenied = isTransactionDenied,
state = state,
selectedFormData = selectedFormData,
isPointBankShownState = isPointBankShownState,
savedTokenListState = it,
savedTokenListState = savedTokenListState,
bankCodeId = bankCodeState,
onCardNumberValueChange = onCardNumberValueChange,
onSavedCardRadioSelected = onSavedCardRadioSelected,
onSavedCardPointBankCheckedChange = onSavedCardPointBankCheckedChange,
onItemRemoveClicked = onItemRemoveClicked
)
}

if (savedTokenListState == null) {
} else {
NormalCardFormLayout(
state = state,
isTransactionDenied = isTransactionDenied,
Expand Down Expand Up @@ -1017,6 +1035,11 @@ internal class CreditCardActivity : BaseActivity() {
.observeOn(AndroidSchedulers.mainThread())
}

override fun onBackPressed() {
if (isCreditCardChanged) setResult(UiKitConstants.ACTIVITY_CC_CHANGES)
super.onBackPressed()
}

@Preview
@Composable
private fun ForPreview() {
Expand Down
Loading

0 comments on commit b71d40d

Please sign in to comment.