Skip to content

Commit

Permalink
Merge pull request #295 from tinkoff-mobile-tech/v3.0.0
Browse files Browse the repository at this point in the history
V3.0.0
  • Loading branch information
harcoPro authored Jul 18, 2023
2 parents 3c85dad + 55ab722 commit 8de009c
Show file tree
Hide file tree
Showing 411 changed files with 20,810 additions and 5,395 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/app_center.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: publish demo to AppCenter

on:
workflow_dispatch:
inputs:
diff_with_origin:
description: 'diff with origin'
required: true
default: 'origin/master'

jobs:
build:
Expand All @@ -16,12 +21,24 @@ jobs:
java-version: '11'
- name: build release
run: ./gradlew :sample:assembleDebug
- name: get the realease Notes
run: |
NEW_CHANGES=$(./gradlew -q :realeaseNotes -PdiffWithOrigin='${{ github.event.inputs.diff_with_origin }}')
echo "NEW_CHANGES<<EOF" >> $GITHUB_ENV
echo "$NEW_CHANGES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: upload artefact to App Center
uses: wzieba/AppCenter-Github-Action@v1
with:
appName: Tinkoff-Mobile-Core/Tinkoff-Acquiring
token: ${{secrets.APP_CENTER_TOKEN}}
group: Collaborators
file: sample/build/outputs/apk/debug/sample-debug.apk
notifyTesters: false
debug: false
notifyTesters: true
debug: false
releaseNotes: |+
Branch name : ${{ github.head_ref || github.ref_name }}
Last changes :
${{ env.NEW_CHANGES }}
2 changes: 1 addition & 1 deletion .github/workflows/merge_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ on:

jobs:
check:
uses: tinkoff-mobile-tech/workflows/.github/workflows/android_lib.merge_request.yml@v1
uses: tinkoff-mobile-tech/workflows/.github/workflows/android_lib.merge_request.yml@v1
25 changes: 21 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.dokka'
apply from: 'gradle/versions.gradle'

buildscript {
apply from: 'gradle/versions.gradle'

repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}

Expand All @@ -17,6 +15,14 @@ buildscript {
}
}

plugins {
id 'org.ajoberstar.grgit' version '5.0.0'
}

apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.dokka'
apply from: 'gradle/versions.gradle'

allprojects {
repositories {
google()
Expand All @@ -28,6 +34,17 @@ allprojects {
}
}

tasks.register("realeaseNotes") {
doLast {
def branch = grgit.branch.current().fullName
def log = grgit
.log { range branch, diffWithOrigin }
.findAll { !it.shortMessage.startsWith("Merge") }
.collect { it.shortMessage }
.join("\n\n")
print log
}
}
dokkaHtmlMultiModule.configure {
outputDirectory.set(new File("$buildDir/dokka"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright © 2020 Tinkoff Bank
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package ru.tinkoff.cardio

import android.app.Activity.RESULT_CANCELED
import android.app.Activity.RESULT_OK
import android.content.Context
import android.content.Intent
import io.card.payment.CardIOActivity
import io.card.payment.CreditCard
import ru.tinkoff.acquiring.sdk.cardscanners.delegate.CardScannerContract
import ru.tinkoff.acquiring.sdk.cardscanners.delegate.ScannedCardResult
import ru.tinkoff.acquiring.sdk.cardscanners.models.AsdkScannedCardData
import ru.tinkoff.acquiring.sdk.cardscanners.models.ScannedCardData
import java.util.*

/**
* @author Mariya Chernyadieva
*/
object CameraCardIOScannerContract : CardScannerContract() {

override fun createIntent(context: Context, input: Unit): Intent {
return createIntent(context)
}

override fun parseResult(resultCode: Int, intent: Intent?): ScannedCardResult {
return when (resultCode) {
RESULT_OK -> ScannedCardResult.Success(parseIntentData(intent!!))
RESULT_CANCELED -> ScannedCardResult.Cancel
else -> ScannedCardResult.Failure(null)
}
}

private fun parseIntentData(data: Intent): ScannedCardData {
val cardNumber: String
var expireDate = ""
val cardholderName = ""

val scanResult = data.getParcelableExtra<CreditCard>(CardIOActivity.EXTRA_SCAN_RESULT)
cardNumber = scanResult!!.formattedCardNumber
if (scanResult.expiryMonth != 0 && scanResult.expiryYear != 0) {
val locale = Locale.getDefault()
val expiryYear = scanResult.expiryYear % 100
expireDate = String.format(locale, "%02d%02d", scanResult.expiryMonth, expiryYear)
}

return AsdkScannedCardData(cardNumber, expireDate, cardholderName)
}

private fun createIntent(context: Context): Intent {
val scanIntent = Intent(context, CardIOActivity::class.java)
return scanIntent.apply {
putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true)
putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false)
putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false)
putExtra(CardIOActivity.EXTRA_SUPPRESS_CONFIRMATION, true)
}
}
}
12 changes: 12 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 3.0.0

#### Fixed
#### Changes
- add MirPay payment method
- redesing sdk screens
- !up targetSdk version to 33!
- new payment process entities ([migration](/migration.md))
- new methods for screen launching ([migration](/migration.md))
- new card scan methods `CardScannerNewApi.kt`
#### Additions

## 2.13.2

#### Fixed
Expand Down
26 changes: 24 additions & 2 deletions core/src/main/java/ru/tinkoff/acquiring/sdk/AcquiringSdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import ru.tinkoff.acquiring.sdk.loggers.JavaLogger
import ru.tinkoff.acquiring.sdk.loggers.Logger
import ru.tinkoff.acquiring.sdk.requests.*
import ru.tinkoff.acquiring.sdk.responses.TinkoffPayStatusResponse
import ru.tinkoff.acquiring.sdk.utils.EnvironmentMode
import ru.tinkoff.acquiring.sdk.utils.SampleAcquiringTokenGenerator
import ru.tinkoff.acquiring.sdk.utils.keycreators.KeyCreator
import ru.tinkoff.acquiring.sdk.utils.keycreators.StringKeyCreator
Expand Down Expand Up @@ -222,6 +223,17 @@ class AcquiringSdk(

fun tinkoffPayLink(paymentId: Long, version: String, request: (TinkoffPayLinkRequest.() -> Unit)? = null): TinkoffPayLinkRequest {
return TinkoffPayLinkRequest(paymentId.toString(), version).apply {
terminalKey = this@AcquiringSdk.terminalKey
request?.invoke(this)
}
}

/**
* Метод получения Deeplink-a для оплаты с помощью MirPay
*/
fun mirPayLink(paymentId: Long, request: (MirPayLinkRequest.() -> Unit)? = null): MirPayLinkRequest {
return MirPayLinkRequest(paymentId.toString()).apply {
terminalKey = this@AcquiringSdk.terminalKey
request?.invoke(this)
}
}
Expand Down Expand Up @@ -260,6 +272,11 @@ class AcquiringSdk(

companion object {

/**
* Позволяет установить мод для окружения по умолчанию (дебаг)
*/
var environmentMode: EnvironmentMode = EnvironmentMode.IsDebugMode

/**
* Объект, который будет использоваться для генерации токена при формировании запросов к api
* ([документация по формированию токена](https://www.tinkoff.ru/kassa/develop/api/request-sign/)).
Expand All @@ -284,12 +301,17 @@ class AcquiringSdk(
*/
var isDeveloperMode = false

/**
* Позволяет переключать SDK с тестового режима(на другой контур) и обратно. В тестовом режиме деньги с карты не
* списываются. По-умолчанию выключен
*/
var isPreprodMode = false

/**
* Позволяет переключать SDK на иной апи-контур, работает только в дебаг режиме
*/
var customUrl : String? = null


/**
* Логирует сообщение
*/
Expand Down Expand Up @@ -347,4 +369,4 @@ fun interface AcquiringTokenGenerator {
.digest(source.toByteArray())
.joinToString("") { "%02x".format(it) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package ru.tinkoff.acquiring.sdk.exceptions

import ru.tinkoff.acquiring.sdk.network.AcquiringApi
import ru.tinkoff.acquiring.sdk.responses.AcquiringResponse

/**
Expand All @@ -40,4 +41,15 @@ class AcquiringApiException : Exception {
constructor(response: AcquiringResponse) : super("") {
this.response = response
}
}

fun Throwable.asAcquiringApiException() = (this as? AcquiringApiException)

fun Exception.checkCustomerNotFoundError(): Boolean {
return getErrorCodeIfApiError() == AcquiringApi.API_ERROR_CODE_CUSTOMER_NOT_FOUND
}

fun Exception.getErrorCodeIfApiError() : String? {
val api = (this as? AcquiringApiException) ?: return null
return api.response?.errorCode
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ package ru.tinkoff.acquiring.sdk.exceptions
*
* @author Mariya Chernyadieva
*/
class AcquiringSdkException(throwable: Throwable, val paymentId: Long? = null) : RuntimeException(throwable.message, throwable)
class AcquiringSdkException(throwable: Throwable, paymentId: Long? = null) : RuntimeException(throwable.message, throwable)
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ import ru.tinkoff.acquiring.sdk.models.enums.ResponseStatus
*/
class AcquiringSdkTimeoutException(
val throwable: Throwable,
val paymentId: Long?,
val status: ResponseStatus?,
val paymentId: Long? = null,
val status: ResponseStatus? = null,
) : RuntimeException(throwable.message, throwable)
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ enum class ResponseStatus {
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ru.tinkoff.acquiring.sdk.models.paysources

import ru.tinkoff.acquiring.sdk.models.PaymentSource

/**
* Тип оплаты с помощью SBP Pay
*
*
* Created by i.golovachev
*/
object SbpPay : PaymentSource
50 changes: 13 additions & 37 deletions core/src/main/java/ru/tinkoff/acquiring/sdk/network/AcquiringApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ object AcquiringApi {
const val SUBMIT_3DS_AUTHORIZATION_V2 = "Submit3DSAuthorizationV2"
const val COMPLETE_3DS_METHOD_V2 = "Complete3DSMethodv2"
const val GET_TERMINAL_PAY_METHODS = "GetTerminalPayMethods"
const val MIR_PAY_GET_DEEPLINK_METHOD = "MirPay/GetDeepLink"

const val API_ERROR_CODE_3DSV2_NOT_SUPPORTED = "106"
const val API_ERROR_CODE_CUSTOMER_NOT_FOUND = "7"
Expand All @@ -57,40 +58,9 @@ object AcquiringApi {
/**
* Коды ошибок, сообщение которых можно показать конечным пользователям
*/
val errorCodesForUserShowing = listOf(
"53",
"206",
"224",
"225",
"252",
"99",
"101",
"1006",
"1012",
"1013",
"1014",
"1015",
"1030",
"1033",
"1034",
"1035",
"1036",
"1037",
"1038",
"1039",
"1040",
"1041",
"1042",
"1043",
"1051",
"1054",
"1057",
"1065",
"1082",
"1089",
"1091",
"1096"
)
val errorCodesForUserShowing = listOf("53", "206", "224", "225", "252", "99", "101",
"1006", "1012", "1013", "1014", "1015", "1030", "1033", "1034", "1035", "1036", "1037", "1038",
"1039", "1040", "1041", "1042", "1043", "1051", "1054", "1057", "1065", "1082", "1089", "1091", "1096")

/**
* Коды ошибок, вызванные временными неполадками системы
Expand All @@ -106,7 +76,7 @@ object AcquiringApi {
internal const val API_REQUEST_METHOD_POST = "POST"
internal const val API_REQUEST_METHOD_GET = "GET"

internal const val JSON = "application/json"
const val JSON = "application/json"
internal const val FORM_URL_ENCODED = "application/x-www-form-urlencoded"
internal const val TIMEOUT = 40000L

Expand All @@ -117,6 +87,9 @@ object AcquiringApi {
private const val API_URL_RELEASE = "https://securepay.tinkoff.ru/$API_VERSION"
private const val API_URL_DEBUG = "https://rest-api-test.tinkoff.ru/$API_VERSION"

private const val API_URL_PREPROD_OLD = "https://qa-mapi.tcsbank.ru/rest"
private const val API_URL_PREPROD = "https://qa-mapi.tcsbank.ru/$API_VERSION"

private val oldMethodsList = listOf("Submit3DSAuthorization")

/**
Expand All @@ -141,6 +114,9 @@ object AcquiringApi {
return oldMethodsList.contains(apiMethod)
}

private fun useCustomOrDefault(default: String, custom: String?, oldOrV2: String = "v2") =
custom?.let { "$it/$oldOrV2" } ?: default
private fun useCustomOrDefault(default: String, custom: String?, oldOrV2: String = API_VERSION) =
custom?.let {
if (it.contains(oldOrV2)) it
else "$it/$oldOrV2"
} ?: default
}
Loading

0 comments on commit 8de009c

Please sign in to comment.