Checkout icon

Upgrade to Android Components 4.0.0

Find out more about the major changes in this release.

To be able to use Android Components 4.0.0, make sure your integration supports the changes described on this page.

Checkout API version

While Android Components 4.0.0 is backwards compatible with older Checkout API versions, we recommend that you use Checkout API v67 or later.

General

  • Drop-in and Components require that you provide a client key in the Configuration.Builder constructor.
  • We migrated from the Android Support Library to AndroidX.
  • The minimum supported Android API version is now 21.
  • We moved our library from jCenter to Maven Central.

Packages

  • Replace com.adyen.checkout.base imports with com.adyen.checkout.components.
  • Replace com.adyen.checkout.base.component imports with com.adyen.checkout.components.base.

Drop-in

Configuration

Remove the resultIntent parameter from the DropInConfiguration.Builder constructor. You can either remove it completely, or pass it to the DropIn.startPayment method instead.

Handling the result of the Drop-in depends on whether you specified a resultIntent when calling DropIn.startPayment:

Service

  • Remove the android.permission.BIND_JOB_SERVICE from the AndroidManifest.xml entry of DropInService, since it is now a regular bound Service instead of a JobIntentService.
  • The SimplifiedDropInService has been removed. We recommend that you extend the DropInService instead, and that you only pass the action object to the app, not the whole API response.
  • Replace CallResult with the DropInServiceResult sealed class:

    Removed Use instead
    CallResult(CallResult.ResultType.FINISHED, result) DropInServiceResult.Finished(result)
    CallResult(CallResult.ResultType.ACTION, actionJSON) DropInServiceResult.Action(actionJSON)
    CallResult(CallResult.ResultType.ERROR, reason) DropInServiceResult.Error(reason = reason)
    CallResult(CallResult.ResultType.ERROR_WITH_MESSAGE, errorMessage) DropInServiceResult.Error(reason = reason, errorMessage = errorMessage)
    CallResult(CallResult.ResultType.ERROR_WITH_MESSAGE, errorMessage, dismissDropIn = true) DropInServiceResult.Error(reason = reason, errorMessage = errorMessage, dismissDropIn = true)
    CallResult(CallResult.ResultType.WAIT, result) Replaced by Asynchronous handling.

Asynchronous handling

  1. Remove makePaymentsCall and makeDetailsCall, and override onPaymentsCallRequested and onDetailsCallRequested instead.
  2. Remove any CallResult.ResultType.WAIT occurrences and asyncCallback calls.
  3. Call the sendResult method to perform an asynchronous callback.
  4. Make sure to manage the threads manually in onPaymentsCallRequested and onDetailsCallRequested. Unlike makePaymentsCall and makeDetailsCall, these methods run on the main thread by default.
    override fun onPaymentsCallRequested(paymentComponentState: PaymentComponentState<*>, paymentComponentJson: JSONObject) {
        launch(Dispatchers.IO) {
            // Send the data to your server.
            val response = sendPaymentsRequest(paymentComponentJson)
        }
    }

    // This should be wherever you get the response back from your server.
    fun handleYourPaymentsResponse(response: YourResponse) {
        // Parse the response, extract the corresponding DropInServiceResult and return it.
        val result: DropInServiceResult = handleResponse(response)
        // Replaces the asyncCallback method.
        sendResult(result)
    }

    override fun onDetailsCallRequested(actionComponentData: ActionComponentData, actionComponentJson: JSONObject) {
        launch(Dispatchers.IO) {
            // Send the data to your server.
            val response = sendPaymentsDetailsRequest(actionComponentJson)
        }
    }

    // This should be wherever you get the response back from your server.
    fun handleYourPaymentsDetailsResponse(response: YourResponse) {
        // Parse the response, extract the corresponding DropInServiceResult and return it.
        val result: DropInServiceResult = handleResponse(response)
        // Replaces the asyncCallback method.
        sendResult(result)
    }

You can also check the ExampleAsyncDropInService for an example implementation.

Components

  • Fix your module imports: each payment method has only one module now. The card-base and card-ui modules have been merged into a single card module, and similarly for other payment methods.
  • Provide a configuration for any Action Component Provider that you are using.
  • Make note of the isReady flag in ComponentState: some components (like CardComponent) might require some initialization time even if all the inputs are valid. The isValid flag is still only valid if both the UI is valid and the component is initialized and ready. Use the isInputValid flag if you only want to check if the UI is valid.
  • By default, payment component providers do not have the isAvailable method, and you can treat them as always available. Only providers for payment methods that require an availability check (currently Google Pay and WeChat Pay) have the isAvailable method.

Card

In CardConfiguration.Builder:

  • Replace setHolderNameRequire with setHolderNameRequired.
  • Replace the publicKey with your clientKey.

    Because publicKey and clientKey are both strings, not making this change will not result in an error in your IDE. The issue will only be picked up during runtime validation.

3D Secure

  • The Adyen3DS2Component supports the new 3D Secure 2 flow introduced in Checkout API v67. The old flow is still supported if you are using an API version earlier than 67.
  • Use the Adyen3DS2Component.handleIntent method to handle 3D Secure redirects. When the 3D Secure 2 redirect response is returned to your app, call threedsComponent.handleIntent and pass the received intent in the parameters. The component will then notify your observer (from threedsComponent.observe) with the data that you need to pass to your server.

Redirect

  • Replace handleRedirectResponse with handleIntent in RedirectComponent.

Bancontact

  • In BcmcConfiguration.Builder, replace the publicKey with your clientKey .

    Because publicKey and clientKey are both strings, not making this change will not result in an error in your IDE. The issue will only be picked up during runtime validation.

  • For Bancontact mobile, if you were using a workaround to replace the bcmc_mobile payment method type with bcmc_mobile_app, remove the workaround and handle the action with the QR Code Component.

QR Code

  • Use the QRCodeComponent to handle actions with a qrCode type (for example Bancontact mobile, Swish, and Pix).
  • Use the QRCodeComponent.PROVIDER.canHandleAction to check whether this component can handle the action you received.
  • Use the QRCodeComponent.PROVIDER.requiresView to check whether a view is required:
    • Some payment methods (currently only Pix) will require a view to be shown. Use QRCodeView and attach it to the component.
    • Other payment methods (for example Bancontact mobile) only work as a redirect.

Google Pay

  • You can remove com.google.android.gms:play-services-wallet from your build.gradle file. We added the Google Pay SDK dependency as api, so it is also available