Commit 5a358ea8 authored by Dostonbek Ibragimov's avatar Dostonbek Ibragimov 💻

[UPD] pay confirm continue

parent 4d59fc7a
......@@ -81,7 +81,7 @@ class AddCardFragment : BaseFragment(R.layout.fragment_add_card) {
val filteredCards = serverData.filter { it.cardHash == hash }
if (filteredCards.isEmpty()) {
viewModel.cardRegistration("998949125150", cardNumberValid!!, cardExpiryValid!!)
viewModel.cardRegistration("998990552109", cardNumberValid!!, cardExpiryValid!!)
} else {
showToastMessage(getString(uz.agr.mobiuz.R.string.agr_mobi_uz_card_exist))
}
......
......@@ -5,6 +5,7 @@ import android.net.Uri
import android.os.Bundle
import android.text.Editable
import android.text.method.DigitsKeyListener
import android.util.Log
import android.view.View
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
......@@ -16,6 +17,7 @@ import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collect
import timber.log.Timber
import uz.agr.mobiuz.ui.fast_action.animation.getColorCompat
import uz.agr.mobiuz.ui.replenish.dialog.SelectCardBottomDialogFragment
import uz.agr.sdk.core.entity.card.CardInfo
import uz.agr.sdk.core.entity.tuple.Tuple3
import uz.agr.sdk.coreui.extension.hideSoftInput
......@@ -70,7 +72,6 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
setUpUI()
collects()
}
override fun setUpUI() {
......@@ -91,11 +92,13 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
tvLinkOferta.setOnClickListener(object : uz.agr.sdk.coreui.ui.ButtonClick() {
override fun onSingleClick(v: View?) {
val uri = Uri.parse(when(pref.language){
CONSTANTS.UZ -> CONSTANTS.PAYSYS_LICENSE_UZ
CONSTANTS.RU -> CONSTANTS.PRIVACY_POLICY_RU
else -> CONSTANTS.PAYSYS_LICENSE_EN
})
val uri = Uri.parse(
when (pref.language) {
CONSTANTS.UZ -> CONSTANTS.PAYSYS_LICENSE_UZ
CONSTANTS.RU -> CONSTANTS.PRIVACY_POLICY_RU
else -> CONSTANTS.PAYSYS_LICENSE_EN
}
)
val intent = Intent(Intent.ACTION_VIEW)
intent.data = uri
startActivity(intent)
......@@ -123,6 +126,7 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
private fun setCardListAdapter(list: List<CardInfo>) {
bn.apply {
initSelectCardView(list)
addCard.isVisible = list.isEmpty()
selectCardView.isVisible = list.isNotEmpty()
if (list.isNotEmpty()) {
......@@ -131,6 +135,44 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
}
}
private fun initSelectCardView(list: List<CardInfo>) {
bn.apply {
selectCardView.init {
requireActivity().hideSoftInput()
val dialog = SelectCardBottomDialogFragment(cards = list)
dialog.setListener(object : SelectCardBottomDialogFragment.Listener {
override fun onClickAnotherCard() {
selectedCard = null
payWithAnotherCard = true
selectCardView.showNewCard()
checkValidForm()
addCardForm.isVisible = payWithAnotherCard
checkValidForm()
dialog.dismiss()
}
override fun onClickCancel() {
dialog.dismiss()
}
override fun onClickCardSelected(cardInfo: CardInfo, position: Int) {
payWithAnotherCard = false
selectCardView.showCard(cardInfo, position)
addCardForm.isVisible = payWithAnotherCard
etCardNumber.text?.clear()
etCardExpiry.text?.clear()
tvErrorMsg.isVisible = false
tvErrorMsgExpiry.isVisible = false
showSelectedCard(cardInfo, position)
checkValidForm()
dialog.dismiss()
}
})
dialog.show(childFragmentManager, SelectCardBottomDialogFragment::class.java.simpleName)
}
}
}
private fun getAllCards() {
Timber.d("getAllCards")
MobiUz.getAllCards(object : CardListenerMobi<CardInfo> {
......@@ -146,15 +188,30 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
override fun local(localData: List<CardInfo>) {
Timber.e("local: ${localData.size}")
setCardListAdapter(localData)
if (localData.isNotEmpty()) {
showSelectedCard(localData.first(), 0)
}
}
override fun server(serverData: List<CardInfo>) {
Timber.e("server: ${serverData.size}")
setCardListAdapter(serverData)
if (serverData.isNotEmpty()) {
showSelectedCard(serverData.first(), 0)
}
}
})
}
private fun showSelectedCard(cardInfo: CardInfo, position: Int) {
bn.apply {
selectedCard = cardInfo
payWithAnotherCard = false
selectCardView.showCard(cardInfo, position)
checkValidForm()
}
}
private fun onClickPay() {
bn.apply {
requireActivity().hideSoftInput()
......@@ -210,8 +267,11 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
override fun loading(boolean: Boolean) {}
override fun success(data: Boolean) {
if (payWithAnotherCard) payWithAnotherCard(cardNumberValid, cardExpiryValid, btnSwitch.isChecked, phoneNumber, vendorFormParams)
else vendorPay(selectedCard, phoneNumber, vendorFormParams)
if (payWithAnotherCard) payWithAnotherCard(
cardNumberValid, cardExpiryValid, btnSwitch.isChecked, /*pref.userPhone.filter { it.isDigit() }*/"998990552109",
vendorFormParams
)
else vendorPay(selectedCard, /*pref.userPhone.filter { it.isDigit() }*/"998990552109", vendorFormParams)
}
})
}
......@@ -219,6 +279,7 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
private fun vendorPay(selectedCard: CardInfo?, phoneNumber: String, vendorFormParams: HashMap<String, String>) {
if (selectedCard != null) {
MobiUz.onClickPay(phoneNumber, selectedCard, vendorFormParams, requireContext(), object : VendorPayConfirm {
override fun showConfirmPage(transactionId: Long, phoneNumber: String, timeOut: Int) {
// todo Shohboz aka uchun
......@@ -231,6 +292,8 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
CONSTANTS.TRANSACTION_ID to transactionId
)
)
Log.e("TTT", "confirm")
}
override fun showError(message: String) {
......@@ -248,7 +311,7 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
R.id.paymentSuccessfulFragment,
bundleOf(
CONSTANTS.PHONE to phoneNumber,
CONSTANTS.PAY_AMOUNT to amountValid
CONSTANTS.PAY_AMOUNT to bn.etAmount.text.toString().filter { it.isDigit() },
)
)
}
......@@ -302,7 +365,6 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
CONSTANTS.PAY_CARD_NUMBER to cardNumber
)
)
// todo Shohboz aka uchun
}
override fun showError(message: String) {
......@@ -318,7 +380,7 @@ class ReplenishBalanceFragment : BaseFragment(R.layout.fragment_replenish_balanc
R.id.paymentSuccessfulFragment,
bundleOf(
CONSTANTS.PHONE to "998" + bn.etPhone.unmaskedText,
CONSTANTS.PAY_AMOUNT to amountValid,
CONSTANTS.PAY_AMOUNT to bn.etAmount.text.toString().filter { it.isDigit() },
CONSTANTS.PAY_SAVE_CARD to saveCard,
CONSTANTS.PAY_CARD_NUMBER to cardNumber
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment