Skip to content

Commit

Permalink
MC-7844 - scopes refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jQwout committed Dec 29, 2022
1 parent 954b03c commit 3b04f32
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ui/src/main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
}
Expand All @@ -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()
}
}
}
Expand Down

0 comments on commit 3b04f32

Please sign in to comment.