From 07d7530c522a687611a2933d6835b07609efd9a6 Mon Sep 17 00:00:00 2001 From: "i.khafizov" Date: Wed, 24 Nov 2021 17:34:31 +0300 Subject: [PATCH] 2.5.1 --- changelog.md | 11 ++++ gradle.properties | 2 +- ui/src/main/AndroidManifest.xml | 7 +++ .../sdk/ui/activities/PaymentActivity.kt | 52 ++++++++++++++----- .../sdk/ui/activities/ThreeDsActivity.kt | 2 +- ui/src/main/res/values-ru/strings.xml | 2 + ui/src/main/res/values/strings.xml | 2 + 7 files changed, 64 insertions(+), 14 deletions(-) diff --git a/changelog.md b/changelog.md index 6f182d43..17b88008 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,14 @@ +## 2.5.1 + +#### Fixed +Fixed problem with preserved transparent activity when paying with FPS using existing paymentId +#### Changes +Reworked logic of obtaining bank apps available for FPS payment to show all available bank apps +regardless of default settings +Changed mode of encoding CReq params with Base64 to NO_PADDING according to 3DS 2.0 requirements +(https://www.emvco.com/terms-of-use/?u=wp-content/uploads/documents/3DSA_Bulletin_No_07_3rd_Ed_-_Base64_Base64url-Encoding_Final-2021-07-07-1.pdf) +#### Additions + ## 2.5.0 #### Fixed diff --git a/gradle.properties b/gradle.properties index 575df6e0..e94efc50 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.5.0 +VERSION_NAME=2.5.1 VERSION_CODE=15 GROUP=ru.tinkoff.acquiring diff --git a/ui/src/main/AndroidManifest.xml b/ui/src/main/AndroidManifest.xml index 626c6baf..fa19f3c9 100644 --- a/ui/src/main/AndroidManifest.xml +++ b/ui/src/main/AndroidManifest.xml @@ -17,6 +17,13 @@ + + + + + + + diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/PaymentActivity.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/PaymentActivity.kt index f5913d59..59fca428 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/PaymentActivity.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/PaymentActivity.kt @@ -23,6 +23,7 @@ import android.os.Build import android.os.Bundle import android.view.View import androidx.lifecycle.Observer +import ru.tinkoff.acquiring.sdk.R import ru.tinkoff.acquiring.sdk.exceptions.AcquiringSdkException import ru.tinkoff.acquiring.sdk.exceptions.NetworkException import ru.tinkoff.acquiring.sdk.models.AsdkState @@ -100,7 +101,7 @@ internal class PaymentActivity : TransparentActivity() { } } SBP_BANK_CHOOSE_REQUEST_CODE -> { - if (data == null && asdkState is FpsState) { + if (data == null && (asdkState is FpsState || asdkState is BrowseFpsBankState)) { finishWithCancel() } else { data?.getStringExtra(EXTRA_SBP_BANK_PACKAGE_NAME)?.let { packageName -> @@ -161,33 +162,60 @@ internal class PaymentActivity : TransparentActivity() { when (screenState) { is FinishWithErrorScreenState -> finishWithError(screenState.error) is ErrorScreenState -> { - if (asdkState is FpsState) { + if (asdkState is FpsState || asdkState is BrowseFpsBankState) { finishWithError(AcquiringSdkException(NetworkException(screenState.message))) } else { showError(screenState.message) } } - is FpsBankFormShowedScreenState -> if (asdkState is FpsState) finishWithCancel() + is FpsBankFormShowedScreenState -> { + if (asdkState is FpsState || asdkState is BrowseFpsBankState) { + finishWithCancel() + } + } else -> Unit } } @SuppressLint("QueryPermissionsNeeded") private fun openBankChooser(deepLink: String, banks: Set?) { - var intent = Intent(Intent.ACTION_VIEW) - intent.data = Uri.parse(deepLink) - - if (!banks.isNullOrEmpty() && Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { - val activities = packageManager.queryIntentActivities(intent, 0) - val supportedBanks = activities.filter { banks.contains(it.activityInfo.packageName) } - .map { it.activityInfo.packageName } - intent = BankChooseActivity.createIntent(this, options, supportedBanks, deepLink) + if (!banks.isNullOrEmpty()) { + val supportedBanks = getBankApps(deepLink, banks) + val intent = BankChooseActivity.createIntent(this, options, supportedBanks, deepLink) startActivityForResult(intent, SBP_BANK_CHOOSE_REQUEST_CODE) } else { - startActivityForResult(intent, SBP_BANK_REQUEST_CODE) + val intent = Intent(Intent.ACTION_VIEW) + intent.data = Uri.parse(deepLink) + val chooserIntent = Intent.createChooser(intent, getString(R.string.acq_fps_chooser_title)) + startActivityForResult(chooserIntent, SBP_BANK_REQUEST_CODE) } } + @SuppressLint("QueryPermissionsNeeded") + private fun getBankApps(link: String, banks: Set): List { + // get sbp packages + val sbpIntent = Intent(Intent.ACTION_VIEW) + sbpIntent.setDataAndNormalize(Uri.parse(link)) + val sbpPackages = packageManager.queryIntentActivities(sbpIntent, 0) + .map { it.activityInfo.packageName } + + val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("http://")) + val browserPackages = packageManager.queryIntentActivities(browserIntent, 0) + .map { it.activityInfo.packageName } + // filter out browsers + val nonBrowserSbpPackages = sbpPackages.filter { it !in browserPackages } + + // get bank packages + val bankPackages = packageManager.getInstalledApplications(0) + .map { it.packageName }.filter { it in banks } + + // merge two lists + return mutableListOf().apply { + addAll(nonBrowserSbpPackages) + addAll(bankPackages) + }.distinct() + } + private fun openDeepLinkInBank(packageName: String) { val payload = (paymentViewModel.screenChangeEventLiveData.value?.value as BrowseFpsBankScreenState).deepLink val intent = Intent(Intent.ACTION_VIEW) diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/ThreeDsActivity.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/ThreeDsActivity.kt index b7b5c568..ca6e65c3 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/ThreeDsActivity.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/ui/activities/ThreeDsActivity.kt @@ -192,7 +192,7 @@ internal class ThreeDsActivity : BaseAcquiringActivity() { put("challengeWindowSize", WINDOW_SIZE_CODE) put("messageType", MESSAGE_TYPE) } - return Base64.encodeToString(creqData.toString().toByteArray(), Base64.DEFAULT).trim() + return Base64.encodeToString(creqData.toString().toByteArray(), Base64.NO_PADDING).trim() } private fun requestState() { diff --git a/ui/src/main/res/values-ru/strings.xml b/ui/src/main/res/values-ru/strings.xml index c02d0666..ea027a84 100644 --- a/ui/src/main/res/values-ru/strings.xml +++ b/ui/src/main/res/values-ru/strings.xml @@ -22,4 +22,6 @@ Google Pay + Выберите приложение + \ No newline at end of file diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index 1b650714..9a3bc3ff 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -21,6 +21,8 @@ Google Pay + Choose app + fps