Skip to content

Commit

Permalink
Used payment result to reset paymentInProgress
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-SD committed Aug 22, 2024
1 parent 5b82075 commit e8b0646
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import com.adyen.checkout.flutter.components.instant.InstantComponentManager
import com.adyen.checkout.flutter.components.view.ComponentLoadingBottomSheet
import com.adyen.checkout.flutter.session.SessionHolder
import com.adyen.checkout.flutter.utils.Constants
import com.adyen.checkout.flutter.utils.Constants.Companion.CARD_SESSION_COMPONENT_KEY
import com.adyen.checkout.flutter.utils.Constants.Companion.CARD_ADVANCED_COMPONENT_KEY
import com.adyen.checkout.redirect.RedirectComponent
import io.flutter.embedding.engine.plugins.FlutterPlugin
import org.json.JSONObject
Expand Down Expand Up @@ -152,6 +154,7 @@ class ComponentPlatformApi(
resultCode: String?,
componentId: String
) {
resetPaymentInProgress(componentId)
val model =
ComponentCommunicationModel(
ComponentCommunicationType.RESULT,
Expand All @@ -177,6 +180,7 @@ class ComponentPlatformApi(
error: ErrorDTO?,
componentId: String
) {
resetPaymentInProgress(componentId)
val model =
ComponentCommunicationModel(
ComponentCommunicationType.RESULT,
Expand Down Expand Up @@ -211,4 +215,11 @@ class ComponentPlatformApi(
currentComponent?.handleIntent(intent)
}
}

// Reset isPaymentInProgress to false again. We can remove this when the pay button handles the pressed state itself.
private fun resetPaymentInProgress(componentId: String) {
when (componentId) {
CARD_ADVANCED_COMPONENT_KEY, CARD_SESSION_COMPONENT_KEY -> cardComponentManager.setPaymentInProgress(false)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ internal class CardComponentManager(
)
}

fun setPaymentInProgress(isLoading: Boolean) = currentCardComponent?.setPaymentInProgress(isLoading)

private fun setCurrentCardComponent(currentCardComponent: BaseCardComponent) {
this.currentCardComponent = currentCardComponent
assignCurrentComponent(currentCardComponent.cardComponent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class DynamicComponentView
postDelayed(500) {
ignoreLayoutChanges = false
isHintAnimationEnabledOnTextInputFields(this, true)
setPaymentInProgress(false)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Constants {
const val GOOGLE_PAY_ADVANCED_COMPONENT_KEY = "GOOGLE_PAY_ADVANCED_COMPONENT"
const val INSTANT_SESSION_COMPONENT_KEY = "INSTANT_SESSION_COMPONENT"
const val INSTANT_ADVANCED_COMPONENT_KEY = "INSTANT_ADVANCED_COMPONENT"
const val CARD_SESSION_COMPONENT_KEY = "CARD_SESSION_COMPONENT"
const val CARD_ADVANCED_COMPONENT_KEY = "CARD_ADVANCED_COMPONENT"
const val GOOGLE_PAY_COMPONENT_REQUEST_CODE = 486351
const val SDK_PAYMENT_CANCELED_IDENTIFIER = "Payment canceled"
const val ADVANCED_PAYMENT_DATA_KEY = "data"
Expand Down

0 comments on commit e8b0646

Please sign in to comment.