From f9b3e1b1ad6acf00bcf4ab54cc2cf1689a99762f Mon Sep 17 00:00:00 2001 From: jqwout Date: Wed, 28 Dec 2022 13:50:50 +0300 Subject: [PATCH 1/4] =?UTF-8?q?MC-7834=20-=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B5=D1=82=D0=B2?= =?UTF-8?q?=D0=BE=D1=80=D0=BA=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 4 +-- gradle/versions.gradle | 2 +- readme.md | 21 +++++++++++- .../main/res/xml/network_security_config.xml | 5 +++ ...istry_of_digital_development_root_cert.cer | 33 +++++++++++++++++++ ui/src/main/res/raw/acq_tinkoff_root_cert.cer | 31 +++++++++++++++++ 6 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 ui/src/main/res/raw/acq_ministry_of_digital_development_root_cert.cer create mode 100644 ui/src/main/res/raw/acq_tinkoff_root_cert.cer diff --git a/gradle.properties b/gradle.properties index 17794c6a..d8c44e60 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -VERSION_NAME=2.10.1 -VERSION_CODE=17 +VERSION_NAME=2.12 +VERSION_CODE=18 GROUP=ru.tinkoff.acquiring POM_DESCRIPTION=Library which allows you to use internet acquiring in your android app diff --git a/gradle/versions.gradle b/gradle/versions.gradle index 3ed8293e..e03eac11 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -3,7 +3,7 @@ ext { versionName = isRelease ? VERSION_NAME : "$VERSION_NAME-SNAPSHOT" compileSdk = 31 - minSdk = 21 + minSdk = 24 targetSdk = 31 buildTools = '29.0.2' diff --git a/readme.md b/readme.md index e7fa3327..b1d6ebdb 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,7 @@ Acquiring SDK позволяет интегрировать [Интернет-Э - Совершение оплаты из уведомления ### Требования -Для работы Tinkoff Acquiring SDK необходим Android версии 5.0 и выше (API level 21). +Для работы Tinkoff Acquiring SDK необходим Android версии 7.0 и выше (API level 24). ### Подключение Для подключения SDK добавьте в [_build.gradle_][build-config] вашего проекта следующие зависимости: @@ -34,6 +34,25 @@ implementation 'ru.tinkoff.acquiring:threeds-wrapper:$latestVersion' implementation 'ru.tinkoff.acquiring:cardio:$latestVersion' ``` +Так же необходимо добавить в [_network-security-config_][network-security-config] содержащий +сертификаты от минцифр и доп. сертификат от тинькофф. Пример можно посмотреть в `sample` выглядит он так: +```xml + + + + + + + + + + + + + + +``` + ### Подготовка к работе Для начала работы с SDK вам понадобятся: * Terminal key diff --git a/sample/src/main/res/xml/network_security_config.xml b/sample/src/main/res/xml/network_security_config.xml index e1eb89e5..b7d75b8b 100644 --- a/sample/src/main/res/xml/network_security_config.xml +++ b/sample/src/main/res/xml/network_security_config.xml @@ -1,5 +1,10 @@ + + + + + diff --git a/ui/src/main/res/raw/acq_ministry_of_digital_development_root_cert.cer b/ui/src/main/res/raw/acq_ministry_of_digital_development_root_cert.cer new file mode 100644 index 00000000..253d971e --- /dev/null +++ b/ui/src/main/res/raw/acq_ministry_of_digital_development_root_cert.cer @@ -0,0 +1,33 @@ +-----BEGIN CERTIFICATE----- +MIIFwjCCA6qgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwcDELMAkGA1UEBhMCUlUx +PzA9BgNVBAoMNlRoZSBNaW5pc3RyeSBvZiBEaWdpdGFsIERldmVsb3BtZW50IGFu +ZCBDb21tdW5pY2F0aW9uczEgMB4GA1UEAwwXUnVzc2lhbiBUcnVzdGVkIFJvb3Qg +Q0EwHhcNMjIwMzAxMjEwNDE1WhcNMzIwMjI3MjEwNDE1WjBwMQswCQYDVQQGEwJS +VTE/MD0GA1UECgw2VGhlIE1pbmlzdHJ5IG9mIERpZ2l0YWwgRGV2ZWxvcG1lbnQg +YW5kIENvbW11bmljYXRpb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al3Ue90WgAJJZMfTshN4OI8cq +W9E4EG9wglbEtMnObHlms8F3CHmrw3k6KmUkWGoa+/ENmcVl68u/cMRl1JbW2bM+ +/3A+SAg2c6iPDlehczKx2oa95QW0SkPPWGuNA/CE8CpyANIhu9XFrj3RQ3EqeRcS +AQQod1RNuHpfETLU/A2gMmvn/w/sx7TB3W5BPs6rprOA37tutPq9u6FTZOcG1Oqj +C/B7yTqgI7rbyvox7DEXoX7rIiEqyNNUguTk/u3SZ4VXE2kmxdmSh3TQvybfbnXV +4JbCZVaqiZraqc7oZMnRoWrXRG3ztbnbes/9qhRGI7PqXqeKJBztxRTEVj8ONs1d +WN5szTwaPIvhkhO3CO5ErU2rVdUr89wKpNXbBODFKRtgxUT70YpmJ46VVaqdAhOZ +D9EUUn4YaeLaS8AjSF/h7UkjOibNc4qVDiPP+rkehFWM66PVnP1Msh93tc+taIfC +EYVMxjh8zNbFuoc7fzvvrFILLe7ifvEIUqSVIC/AzplM/Jxw7buXFeGP1qVCBEHq +391d/9RAfaZ12zkwFsl+IKwE/OZxW8AHa9i1p4GO0YSNuczzEm4= +-----END CERTIFICATE----- diff --git a/ui/src/main/res/raw/acq_tinkoff_root_cert.cer b/ui/src/main/res/raw/acq_tinkoff_root_cert.cer new file mode 100644 index 00000000..6890b432 --- /dev/null +++ b/ui/src/main/res/raw/acq_tinkoff_root_cert.cer @@ -0,0 +1,31 @@ +-----BEGIN CERTIFICATE----- +MIIFVDCCAzygAwIBAgIQchJ4p+qpbrJMjzfTwBLEajANBgkqhkiG9w0BAQsFADAy +MRkwFwYDVQQKExBKU0MgVGlua29mZiBCYW5rMRUwEwYDVQQDEwxUaW5rb2ZmIEJh +bmswHhcNMjAwNjIzMTgwNzE0WhcNMzUwNjIzMTgxNzEyWjAyMRkwFwYDVQQKExBK +U0MgVGlua29mZiBCYW5rMRUwEwYDVQQDEwxUaW5rb2ZmIEJhbmswggIiMA0GCSqG +SIb3DQEBAQUAA4ICDwAwggIKAoICAQDqZxVwD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OIke9lta2 +PG2sKlzL4RW2NOjv5bbzL1l6dn3wJUeYBzyss1AuBjcBCHYtZEeTyDQGigYq/YRj +S2z/fZMdia6iTPu3XsSERekttMi/8K3/NCIHcN79Ws0q0nOKR5RzAyxnILDggnRs +bq2Ab0H/1BcMCCLx8DOzH+3ViAMlbIEWDb5dKwUJBCMJpHjdoMV2AHFPwGPQxjv3 +WOG+RsN+oJqZmPLrrTD+PWkdho5pTG8qu2ijKRzJgsUXPiiSAPCy+UtkDd/2OL/z +EYEEkKcCXc99euWnl1w/FYIsnKwPwxPP0sNC9mcKtN2j6sdUjKa94ttSd6NrkE4F +4E36iKlWtaZIXbC4jlpyuyQwbuvRzU/l3NIX7e3fYPsz9o0eDgl7hx2jsUKimEIv +FSqFYA5n0x1jx2fgScxYDQaGGFM6Ox/BjPZvG32DbUb+9UXB/u0fjoJ7D/6Mw3H7 +vlyNOVXLq10yfyxkmJpF8IGvDK1UXhhB +-----END CERTIFICATE----- From f048298f8696e470beca90b073a97aadc0c2c2fd Mon Sep 17 00:00:00 2001 From: jQwout <37448471+jQwout@users.noreply.github.com> Date: Wed, 28 Dec 2022 17:41:27 +0300 Subject: [PATCH 2/4] Update readme.md --- readme.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/readme.md b/readme.md index 12aa7406..2fe592d9 100644 --- a/readme.md +++ b/readme.md @@ -44,12 +44,6 @@ implementation 'ru.tinkoff.acquiring:cardio:$latestVersion' - - - - - - ``` From 954b03c704e8147e609772cfb9257ee60636f273 Mon Sep 17 00:00:00 2001 From: jqwout Date: Wed, 28 Dec 2022 23:56:05 +0300 Subject: [PATCH 3/4] MC-7844 - scopes refactoring --- .../tinkoff/acquiring/sdk/TinkoffAcquiring.kt | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt index 8e8452f4..482c8ceb 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt @@ -21,9 +21,7 @@ import android.app.PendingIntent import android.content.Context import android.content.Intent import androidx.fragment.app.Fragment -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch +import kotlinx.coroutines.* import ru.tinkoff.acquiring.sdk.localization.LocalizationSource import ru.tinkoff.acquiring.sdk.models.* import ru.tinkoff.acquiring.sdk.models.options.FeaturesOptions @@ -33,6 +31,7 @@ import ru.tinkoff.acquiring.sdk.models.paysources.CardData import ru.tinkoff.acquiring.sdk.models.paysources.GooglePay import ru.tinkoff.acquiring.sdk.payment.PaymentProcess import ru.tinkoff.acquiring.sdk.requests.performSuspendRequest +import ru.tinkoff.acquiring.sdk.responses.GetTerminalPayMethodsResponse import ru.tinkoff.acquiring.sdk.responses.TerminalInfo import ru.tinkoff.acquiring.sdk.responses.TinkoffPayStatusResponse import ru.tinkoff.acquiring.sdk.threeds.ThreeDsHelper @@ -209,11 +208,11 @@ class TinkoffAcquiring( onFailure: ((Throwable) -> Unit)? = null ) { CoroutineScope(Dispatchers.IO).launch { - sdk.tinkoffPayStatus().execute({ - launch(Dispatchers.Main) { onSuccess(it) } - }, { - launch(Dispatchers.Main) { onFailure?.invoke(it) } - }) + val result = sdk.tinkoffPayStatus().performSuspendRequest() + withContext(Dispatchers.Main) { + result.fold(onSuccess = onSuccess, onFailure = { onFailure?.invoke(it) }) + cancel() + } } } @@ -221,18 +220,15 @@ class TinkoffAcquiring( * Проверка доступных спосбов оплаты */ fun checkTerminalInfo(onSuccess: (TerminalInfo?) -> Unit, - onFailure: ((Throwable) -> Unit)? = null) { - - val onFailureOrThrow = onFailure ?: { throw it } - + onFailure: ((Throwable) -> Unit)? = null + ) { CoroutineScope(Dispatchers.IO).launch { - val result = sdk.getTerminalPayMethods() .performSuspendRequest() .map { it.terminalInfo } - - launch(Dispatchers.Main) { - result.fold(onSuccess, onFailureOrThrow) + withContext(Dispatchers.Main) { + result.fold(onSuccess = onSuccess, onFailure = { onFailure?.invoke(it) }) + cancel() } } } From 3b04f323f067011ec4e9c4c44ffcd93475799a00 Mon Sep 17 00:00:00 2001 From: jqwout Date: Thu, 29 Dec 2022 13:01:24 +0300 Subject: [PATCH 4/4] MC-7844 - scopes refactoring --- .../main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/src/main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt b/ui/src/main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt index 482c8ceb..ec30f37e 100644 --- a/ui/src/main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt +++ b/ui/src/main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt @@ -42,6 +42,7 @@ import ru.tinkoff.acquiring.sdk.ui.activities.NotificationPaymentActivity import ru.tinkoff.acquiring.sdk.ui.activities.PaymentActivity import ru.tinkoff.acquiring.sdk.ui.activities.QrCodeActivity import ru.tinkoff.acquiring.sdk.ui.activities.SavedCardsActivity +import kotlin.coroutines.suspendCoroutine /** * Точка входа для взаимодействия с Acquiring SDK @@ -208,10 +209,11 @@ class TinkoffAcquiring( onFailure: ((Throwable) -> Unit)? = null ) { CoroutineScope(Dispatchers.IO).launch { + val mainScope = this val result = sdk.tinkoffPayStatus().performSuspendRequest() withContext(Dispatchers.Main) { result.fold(onSuccess = onSuccess, onFailure = { onFailure?.invoke(it) }) - cancel() + mainScope.cancel() } } } @@ -223,12 +225,13 @@ class TinkoffAcquiring( onFailure: ((Throwable) -> Unit)? = null ) { CoroutineScope(Dispatchers.IO).launch { + val mainScope = this val result = sdk.getTerminalPayMethods() .performSuspendRequest() .map { it.terminalInfo } withContext(Dispatchers.Main) { result.fold(onSuccess = onSuccess, onFailure = { onFailure?.invoke(it) }) - cancel() + mainScope.cancel() } } }