You are not required to migrate, but if you do, then 5.9.0 introduced a simplified integration for Google Pay to make migration easier. This new integration excludes the use of the deprecated onActivityResult
and includes the Google Pay button. Follow the steps below to migrate from previous 5.x.x versions to 5.9.x:
Overview
- Remove deprecated Activity Result code
- Display Google Pay button
- Google Pay availability check
Remove deprecated Activity Result code
Add AdyenComponentView
to your layout and attach the component to it.
<com.adyen.checkout.ui.core.AdyenComponentView android:id="@+id/componentView" android:layout_width="match_parent" android:layout_height="wrap_content" />
// Attach the component to the view binding.componentView.attach(googlePayComponent, lifecycleOwner) // Or if you use Jetpack Compose AdyenComponent(googlePayComponent)
Now you no longer need activity result related code, so you can clean it up. For example you can remove:
// This function can be deleted override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) googlePayComponent.handleActivityResult(resultCode, data) }
Display Google Pay button
If you want to keep displaying a button yourself, then you have to replace the call to googlePayComponent.startGooglePayScreen(…)
with googlePayComponent.submit()
.
To let the component display the Google Pay button inside the AdyenComponentView
remove your own button and adjust your configuration:
CheckoutConfiguration( environment = environment, clientKey = clientKey, … ) { googlePay { setSubmitButtonVisible(true) setGooglePayButtonStyling(…) // Optionally style the button } }
The com.google.pay.button:compose-pay-button
dependency can now also be removed from your build.gradle
.
Google Pay availability check
You no longer need to call GooglePayComponent.PROVIDER.isAvailable(…)
.
The GooglePayComponent
now checks if Google Pay is available when you initialize it. If Google Pay is not available, you get a GooglePayUnavailableException
in onError
.