{"title":"Upgrade to Android Components 4.0.0","category":"default","creationDate":1795889610,"content":"<p>To be able to use Android Components 4.0.0, make sure your integration supports the changes described on this page.<\/p>\n<h2>Checkout API version<\/h2>\n<p>While Android Components 4.0.0 is backwards compatible with older Checkout API versions, we recommend that you use <a href=\"\/online-payments\/release-notes#releaseNote=2021-03-01-checkout-api-67\">Checkout API v67<\/a> or later.<\/p>\n<h2>General<\/h2>\n<ul>\n<li>Drop-in and Components require that you provide a <a href=\"\/development-resources\/client-side-authentication\/migrate-from-origin-key-to-client-key?tab=android_3#switch-to-using-the-client-key\">client key<\/a> in the <code>Configuration.Builder<\/code> constructor.<\/li>\n<li>We migrated from the Android Support Library to AndroidX.<\/li>\n<li>The minimum supported Android API version is now <a href=\"https:\/\/developer.android.com\/reference\/android\/os\/Build.VERSION_CODES#LOLLIPOP\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">21<\/a>.<\/li>\n<li>We moved our library from <a href=\"https:\/\/jfrog.com\/blog\/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">jCenter<\/a> to <a href=\"https:\/\/repo1.maven.org\/maven2\/com\/adyen\/checkout\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Maven Central<\/a>.<\/li>\n<\/ul>\n<h3>Packages<\/h3>\n<ul>\n<li>Replace <code>com.adyen.checkout.base<\/code> imports with <code>com.adyen.checkout.components<\/code>.<\/li>\n<li>Replace <code>com.adyen.checkout.base.component<\/code> imports with <code>com.adyen.checkout.components.base<\/code>.<\/li>\n<\/ul>\n<h2>Drop-in<\/h2>\n<h3>Configuration<\/h3>\n<p>Remove the <code>resultIntent<\/code> parameter from the <code>DropInConfiguration.Builder<\/code> constructor. You can either remove it completely, or pass it to the <code>DropIn.startPayment<\/code> method instead.<\/p>\n<p>Handling the result of the Drop-in depends on whether you specified a <code>resultIntent<\/code> when calling <code>DropIn.startPayment<\/code>:<\/p>\n\n<div id=\"tabJsQHy\">\n    <div data-component-wrapper=\"tabs\">\n        <tabs\n                        :items=\"[{&quot;title&quot;:&quot;With `resultIntent`&quot;,&quot;content&quot;:&quot;\\n&lt;p&gt;Call &lt;code&gt;DropIn.getDropInResultFromIntent&lt;\/code&gt; inside &lt;code&gt;onCreate&lt;\/code&gt; within the newly launched activity:&lt;\/p&gt;\\n&lt;pre&gt;&lt;code class=\\&quot;language-kotlin\\&quot;&gt;class ResultActivity : Activity() {\\n   override fun onCreate(savedInstanceState: Bundle?) {\\n       super.onCreate(savedInstanceState)\\n       val result = DropIn.getDropInResultFromIntent(intent)\\n   }\\n}&lt;\/code&gt;&lt;\/pre&gt;\\n&lt;p&gt;To handle the error and cancelled by user scenarios, call &lt;code&gt;DropIn.handleActivityResult&lt;\/code&gt; inside &lt;code&gt;onActivityResult&lt;\/code&gt; within the activity that initiated the payment (&lt;code&gt;DropIn.startPayment&lt;\/code&gt;). The result is obtained in the &lt;code&gt;DropInResult&lt;\/code&gt; wrapper class:&lt;\/p&gt;\\n&lt;pre&gt;&lt;code class=\\&quot;language-kotlin\\&quot;&gt;class CheckoutActivity : Activity() {\\n    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {\\n        super.onActivityResult(requestCode, resultCode, data)\\n        val dropInResult = DropIn.handleActivityResult(requestCode, resultCode, data) ?: return\\n        when (dropInResult) {\\n            is DropInResult.Error -&amp;gt; handleError(dropInResult.reason)\\n            is DropInResult.CancelledByUser -&amp;gt; handleCancelled()\\n            is DropInResult.Finished -&amp;gt; { \/\/ No need to handle this case, it will not occur if resultIntent is specified\\n            }\\n        }\\n    }\\n}&lt;\/code&gt;&lt;\/pre&gt;\\n&quot;,&quot;altTitle&quot;:null,&quot;oldTabId&quot;:&quot;with_`resultintent`_0_1&quot;,&quot;relation&quot;:&quot;&quot;},{&quot;title&quot;:&quot;Without `resultIntent`&quot;,&quot;content&quot;:&quot;\\n&lt;p&gt;Call &lt;code&gt;DropIn.handleActivityResult&lt;\/code&gt; inside &lt;code&gt;onActivityResult&lt;\/code&gt; within the activity that initiated the payment (&lt;code&gt;DropIn.startPayment&lt;\/code&gt;). The result is obtained in the &lt;code&gt;DropInResult&lt;\/code&gt; wrapper class:&lt;\/p&gt;\\n&lt;pre&gt;&lt;code class=\\&quot;language-kotlin\\&quot;&gt;class CheckoutActivity : Activity() {\\n    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {\\n        super.onActivityResult(requestCode, resultCode, data)\\n        val dropInResult = DropIn.handleActivityResult(requestCode, resultCode, data) ?: return\\n        when (dropInResult) {\\n            is DropInResult.Finished -&amp;gt; handleFinished(dropInResult.result)\\n            is DropInResult.Error -&amp;gt; handleError(dropInResult.reason)\\n            is DropInResult.CancelledByUser -&amp;gt; handleCancelled()\\n        }\\n    }\\n}&lt;\/code&gt;&lt;\/pre&gt;\\n&quot;,&quot;altTitle&quot;:null,&quot;oldTabId&quot;:&quot;without_`resultintent`_1_2&quot;,&quot;relation&quot;:&quot;&quot;}]\"\n            :should-update-when-url-changes='false'>\n        <\/tabs>\n    <\/div>\n<\/div>\n\n<h3>Service<\/h3>\n<ul>\n<li>Remove the <code>android.permission.BIND_JOB_SERVICE<\/code> from the <code>AndroidManifest.xml<\/code> entry of <code>DropInService<\/code>, since it is now a regular bound <code>Service<\/code> instead of a <code>JobIntentService<\/code>.<\/li>\n<li>The <code>SimplifiedDropInService<\/code> has been removed. We recommend that you extend the <code>DropInService<\/code> instead, and that you only pass the <code>action<\/code> object to the app, not the whole API response.<\/li>\n<li>\n<p>Replace <code>CallResult<\/code> with the <code>DropInServiceResult<\/code> sealed class:<\/p>\n<table>\n<thead>\n<tr>\n<th>Removed<\/th>\n<th>Use instead<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>CallResult(CallResult.ResultType.FINISHED, result)<\/code><\/td>\n<td><code>DropInServiceResult.Finished(result)<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>CallResult(CallResult.ResultType.ACTION, actionJSON)<\/code><\/td>\n<td><code>DropInServiceResult.Action(actionJSON)<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>CallResult(CallResult.ResultType.ERROR, reason)<\/code><\/td>\n<td><code>DropInServiceResult.Error(reason = reason)<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>CallResult(CallResult.ResultType.ERROR_WITH_MESSAGE, errorMessage)<\/code><\/td>\n<td><code>DropInServiceResult.Error(reason = reason, errorMessage = errorMessage)<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>CallResult(CallResult.ResultType.ERROR_WITH_MESSAGE, errorMessage, dismissDropIn = true)<\/code><\/td>\n<td><code>DropInServiceResult.Error(reason = reason, errorMessage = errorMessage, dismissDropIn = true)<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>CallResult(CallResult.ResultType.WAIT, result)<\/code><\/td>\n<td>Replaced by <a href=\"#asynchronous-handling\">Asynchronous handling<\/a>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<h3 id=\"asynchronous-handling\">Asynchronous handling<\/h3>\n<ol>\n<li>Remove <code>makePaymentsCall<\/code> and <code>makeDetailsCall<\/code>, and override <code>onPaymentsCallRequested<\/code> and <code>onDetailsCallRequested<\/code> instead.<\/li>\n<li>Remove any <code>CallResult.ResultType.WAIT<\/code> occurrences and <code>asyncCallback<\/code> calls.<\/li>\n<li>Call the <code>sendResult<\/code> method to perform an asynchronous callback.<\/li>\n<li>Make sure to manage the threads manually in <code>onPaymentsCallRequested<\/code> and <code>onDetailsCallRequested<\/code>. Unlike <code>makePaymentsCall<\/code> and <code>makeDetailsCall<\/code>, these methods run on the main thread by default.<\/li>\n<\/ol>\n<pre><code class=\"language-kotlin\">    override fun onPaymentsCallRequested(paymentComponentState: PaymentComponentState&lt;*&gt;, paymentComponentJson: JSONObject) {\n        launch(Dispatchers.IO) {\n            \/\/ Send the data to your server.\n            val response = sendPaymentsRequest(paymentComponentJson)\n        }\n    }\n\n    \/\/ This should be wherever you get the response back from your server.\n    fun handleYourPaymentsResponse(response: YourResponse) {\n        \/\/ Parse the response, extract the corresponding DropInServiceResult and return it.\n        val result: DropInServiceResult = handleResponse(response)\n        \/\/ Replaces the asyncCallback method.\n        sendResult(result)\n    }\n\n    override fun onDetailsCallRequested(actionComponentData: ActionComponentData, actionComponentJson: JSONObject) {\n        launch(Dispatchers.IO) {\n            \/\/ Send the data to your server.\n            val response = sendPaymentsDetailsRequest(actionComponentJson)\n        }\n    }\n\n    \/\/ This should be wherever you get the response back from your server.\n    fun handleYourPaymentsDetailsResponse(response: YourResponse) {\n        \/\/ Parse the response, extract the corresponding DropInServiceResult and return it.\n        val result: DropInServiceResult = handleResponse(response)\n        \/\/ Replaces the asyncCallback method.\n        sendResult(result)\n    }<\/code><\/pre>\n<p>You can also check the <code>ExampleAsyncDropInService<\/code> for an example implementation.<\/p>\n<h2>Components<\/h2>\n<ul>\n<li>Fix your module imports: each payment method has only one module now. The <code>card-base<\/code> and <code>card-ui<\/code> modules have been merged into a single <code>card<\/code> module, and similarly for other payment methods.<\/li>\n<li>Provide a configuration for any Action Component Provider that you are using.<\/li>\n<li>Make note of the <code>isReady<\/code> flag in <code>ComponentState<\/code>: some components (like <code>CardComponent<\/code>) might require some initialization time even if all the inputs are valid. The <code>isValid<\/code> flag is still only valid if both the UI is valid and the component is initialized and ready. Use the <code>isInputValid<\/code> flag if you only want to check if the UI is valid.<\/li>\n<li>By default, payment component providers do not have the <code>isAvailable<\/code> 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 <code>isAvailable<\/code> method.<\/li>\n<\/ul>\n<h3>Card<\/h3>\n<p>In <code>CardConfiguration.Builder<\/code>:<\/p>\n<ul>\n<li>Replace <code>setHolderNameRequire<\/code> with <code>setHolderNameRequired<\/code>.<\/li>\n<li>Replace the <code>publicKey<\/code> with your <code>clientKey<\/code>.\n<div class=\"notices yellow\">\n<p>Because <code>publicKey<\/code> and <code>clientKey<\/code> 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.<\/p>\n<\/div><\/li>\n<\/ul>\n<h3>3D Secure<\/h3>\n<ul>\n<li>The <code>Adyen3DS2Component<\/code> supports the <a href=\"\/online-payments\/3d-secure\/native-3ds2\/android-component#handle-redirect\">new 3D Secure 2 flow<\/a> introduced in <a href=\"\/online-payments\/release-notes#releaseNote=2021-03-01-checkout-api-67\">Checkout API v67<\/a>. The old flow is still supported if you are using an API version earlier than 67.<\/li>\n<li>Use the <code>Adyen3DS2Component.handleIntent<\/code> method to <a href=\"\/online-payments\/3d-secure\/native-3ds2\/android-component#handle-redirect\">handle 3D Secure redirects<\/a>. When the 3D Secure 2 redirect response is returned to your app, call <code>threedsComponent.handleIntent<\/code> and pass the received <code>intent<\/code> in the parameters. The component will then notify your observer (from <code>threedsComponent.observe<\/code>) with the data that you need to pass to your server.<\/li>\n<\/ul>\n<h3>Redirect<\/h3>\n<ul>\n<li>Replace <code>handleRedirectResponse<\/code> with <code>handleIntent<\/code> in <code>RedirectComponent<\/code>.<\/li>\n<\/ul>\n<h3>Bancontact<\/h3>\n<ul>\n<li>In <code>BcmcConfiguration.Builder<\/code>, replace the <code>publicKey<\/code> with your <code>clientKey<\/code> .\n<div class=\"notices yellow\">\n<p>Because <code>publicKey<\/code> and <code>clientKey<\/code> 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.<\/p>\n<\/div><\/li>\n<li>For Bancontact mobile, if you were using a workaround to replace the <code>bcmc_mobile<\/code> payment method type with <code>bcmc_mobile_app<\/code>, remove the workaround and <a href=\"\/payment-methods\/bancontact\/bancontact-mobile\/android-component#handle-the-redirect\">handle the action with the QR Code Component<\/a>.<\/li>\n<\/ul>\n<h3 id=\"qr-code\">QR Code<\/h3>\n<ul>\n<li><a href=\"\/payment-methods\/bancontact\/bancontact-mobile\/android-component#handle-the-redirect\">Use the <code>QRCodeComponent<\/code><\/a> to handle actions with a <code>qrCode<\/code> type (for example Bancontact mobile, Swish, and Pix).<\/li>\n<li>Use the <code>QRCodeComponent.PROVIDER.canHandleAction<\/code> to check whether this component can handle the action you received.<\/li>\n<li>Use the <code>QRCodeComponent.PROVIDER.requiresView<\/code> to check whether a view is required:\n<ul>\n<li>Some payment methods (currently only Pix) will require a view to be shown. Use <code>QRCodeView<\/code> and <code>attach<\/code> it to the component.<\/li>\n<li>Other payment methods (for example Bancontact mobile) only work as a redirect.<\/li>\n<\/ul><\/li>\n<\/ul>\n<h3>Google Pay<\/h3>\n<ul>\n<li>You can remove <code>com.google.android.gms:play-services-wallet<\/code> from your <code>build.gradle<\/code> file. We added the Google Pay SDK dependency as <code>api<\/code>, so it is also available<\/li>\n<\/ul>","url":"https:\/\/docs.adyen.com\/online-payments\/upgrade-your-integration\/upgrade-to-android-4-0-0","articleFields":{"description":"Find out more about the major changes in this release.","feedback_component":true},"algolia":{"url":"https:\/\/docs.adyen.com\/online-payments\/upgrade-your-integration\/upgrade-to-android-4-0-0","title":"Upgrade to Android Components 4.0.0","content":"To be able to use Android Components 4.0.0, make sure your integration supports the changes described on this page.\nCheckout API version\nWhile Android Components 4.0.0 is backwards compatible with older Checkout API versions, we recommend that you use Checkout API v67 or later.\nGeneral\n\nDrop-in and Components require that you provide a client key in the Configuration.Builder constructor.\nWe migrated from the Android Support Library to AndroidX.\nThe minimum supported Android API version is now 21.\nWe moved our library from jCenter to Maven Central.\n\nPackages\n\nReplace com.adyen.checkout.base imports with com.adyen.checkout.components.\nReplace com.adyen.checkout.base.component imports with com.adyen.checkout.components.base.\n\nDrop-in\nConfiguration\nRemove the resultIntent parameter from the DropInConfiguration.Builder constructor. You can either remove it completely, or pass it to the DropIn.startPayment method instead.\nHandling the result of the Drop-in depends on whether you specified a resultIntent when calling DropIn.startPayment:\n\n\n    \n        \n        \n    \n\n\nService\n\nRemove 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.\nThe 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.\n\nReplace CallResult with the DropInServiceResult sealed class:\n\n\n\nRemoved\nUse instead\n\n\n\n\nCallResult(CallResult.ResultType.FINISHED, result)\nDropInServiceResult.Finished(result)\n\n\nCallResult(CallResult.ResultType.ACTION, actionJSON)\nDropInServiceResult.Action(actionJSON)\n\n\nCallResult(CallResult.ResultType.ERROR, reason)\nDropInServiceResult.Error(reason = reason)\n\n\nCallResult(CallResult.ResultType.ERROR_WITH_MESSAGE, errorMessage)\nDropInServiceResult.Error(reason = reason, errorMessage = errorMessage)\n\n\nCallResult(CallResult.ResultType.ERROR_WITH_MESSAGE, errorMessage, dismissDropIn = true)\nDropInServiceResult.Error(reason = reason, errorMessage = errorMessage, dismissDropIn = true)\n\n\nCallResult(CallResult.ResultType.WAIT, result)\nReplaced by Asynchronous handling.\n\n\n\n\n\nAsynchronous handling\n\nRemove makePaymentsCall and makeDetailsCall, and override onPaymentsCallRequested and onDetailsCallRequested instead.\nRemove any CallResult.ResultType.WAIT occurrences and asyncCallback calls.\nCall the sendResult method to perform an asynchronous callback.\nMake sure to manage the threads manually in onPaymentsCallRequested and onDetailsCallRequested. Unlike makePaymentsCall and makeDetailsCall, these methods run on the main thread by default.\n\n    override fun onPaymentsCallRequested(paymentComponentState: PaymentComponentState&lt;*&gt;, paymentComponentJson: JSONObject) {\n        launch(Dispatchers.IO) {\n            \/\/ Send the data to your server.\n            val response = sendPaymentsRequest(paymentComponentJson)\n        }\n    }\n\n    \/\/ This should be wherever you get the response back from your server.\n    fun handleYourPaymentsResponse(response: YourResponse) {\n        \/\/ Parse the response, extract the corresponding DropInServiceResult and return it.\n        val result: DropInServiceResult = handleResponse(response)\n        \/\/ Replaces the asyncCallback method.\n        sendResult(result)\n    }\n\n    override fun onDetailsCallRequested(actionComponentData: ActionComponentData, actionComponentJson: JSONObject) {\n        launch(Dispatchers.IO) {\n            \/\/ Send the data to your server.\n            val response = sendPaymentsDetailsRequest(actionComponentJson)\n        }\n    }\n\n    \/\/ This should be wherever you get the response back from your server.\n    fun handleYourPaymentsDetailsResponse(response: YourResponse) {\n        \/\/ Parse the response, extract the corresponding DropInServiceResult and return it.\n        val result: DropInServiceResult = handleResponse(response)\n        \/\/ Replaces the asyncCallback method.\n        sendResult(result)\n    }\nYou can also check the ExampleAsyncDropInService for an example implementation.\nComponents\n\nFix 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.\nProvide a configuration for any Action Component Provider that you are using.\nMake 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.\nBy 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.\n\nCard\nIn CardConfiguration.Builder:\n\nReplace setHolderNameRequire with setHolderNameRequired.\nReplace the publicKey with your clientKey.\n\nBecause 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.\n\n\n3D Secure\n\nThe 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.\nUse 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.\n\nRedirect\n\nReplace handleRedirectResponse with handleIntent in RedirectComponent.\n\nBancontact\n\nIn BcmcConfiguration.Builder, replace the publicKey with your clientKey .\n\nBecause 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.\n\nFor 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.\n\nQR Code\n\nUse the QRCodeComponent to handle actions with a qrCode type (for example Bancontact mobile, Swish, and Pix).\nUse the QRCodeComponent.PROVIDER.canHandleAction to check whether this component can handle the action you received.\nUse the QRCodeComponent.PROVIDER.requiresView to check whether a view is required:\n\nSome payment methods (currently only Pix) will require a view to be shown. Use QRCodeView and attach it to the component.\nOther payment methods (for example Bancontact mobile) only work as a redirect.\n\n\nGoogle Pay\n\nYou 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\n","type":"page","locale":"en","boost":17,"hierarchy":{"lvl0":"Home","lvl1":"Online payments","lvl2":"Upgrade your integration","lvl3":"Upgrade to Android Components 4.0.0"},"hierarchy_url":{"lvl0":"https:\/\/docs.adyen.com\/","lvl1":"https:\/\/docs.adyen.com\/online-payments","lvl2":"https:\/\/docs.adyen.com\/online-payments\/upgrade-your-integration","lvl3":"\/online-payments\/upgrade-your-integration\/upgrade-to-android-4-0-0"},"levels":4,"category":"Online Payments","category_color":"green","tags":["Upgrade","Android","Components","4.0.0"]}}
