Skip to content

Commit

Permalink
Merge pull request #70 from TinkoffCreditSystems/2.5.1
Browse files Browse the repository at this point in the history
2.5.1
  • Loading branch information
IlnarH authored Nov 25, 2021
2 parents e94931f + 07d7530 commit bd0f2da
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 14 deletions.
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=2.5.0
VERSION_NAME=2.5.1
VERSION_CODE=15
GROUP=ru.tinkoff.acquiring

Expand Down
7 changes: 7 additions & 0 deletions ui/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.tinkoff.acquiring.sdk">

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" android:host="qr.nspk.ru"/>
</intent>
</queries>

<application
android:allowBackup="false"
android:supportsRtl="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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<Any?>?) {
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<Any?>): List<String> {
// 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<String>().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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions ui/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@

<string name="googlepay_button_content_description">Google Pay</string>

<string name="acq_fps_chooser_title">Выберите приложение</string>

</resources>
2 changes: 2 additions & 0 deletions ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

<string name="googlepay_button_content_description">Google Pay</string>

<string name="acq_fps_chooser_title">Choose app</string>

<string name="acq_fps" translatable="false">fps</string>

</resources>

0 comments on commit bd0f2da

Please sign in to comment.