Skip to content

Commit

Permalink
Merge pull request #64 from TinkoffCreditSystems/2.4.1
Browse files Browse the repository at this point in the history
Added ability to make an SBP payment with existing paymentId
  • Loading branch information
IlnarH authored Oct 4, 2021
2 parents f5abcd9 + 6dede2f commit 6031959
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.4.1

#### Fixed
#### Changes
#### Additions
Added ability to make an SBP payment with existing paymentId (TinkoffAcquiring.payWithSbp(paymentId: Long))

## 2.4.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.4.0
VERSION_NAME=2.4.1
VERSION_CODE=15
GROUP=ru.tinkoff.acquiring

Expand Down
10 changes: 10 additions & 0 deletions ui/src/main/java/ru/tinkoff/acquiring/sdk/TinkoffAcquiring.kt
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ class TinkoffAcquiring(
openPaymentScreen(fragment, options, requestCode, FpsState)
}

/**
* Запуск SDK для оплаты через Систему быстрых платежей
*
* @param paymentId уникальный идентификатор транзакции в системе банка,
* полученный после проведения инициации платежа
*/
fun payWithSbp(paymentId: Long): PaymentProcess {
return PaymentProcess(sdk).createInitializedSbpPaymentProcess(paymentId)
}

/**
* Запуск экрана Acquiring SDK для привязки новой карты
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class PaymentProcess internal constructor(private val sdk: AcquiringSdk) {
/**
* Создает объект процесса для проведения оплаты с помощью Системы быстрых платежей
* @return сконфигурированный объект для проведения оплаты
*
* @see createInitializedSbpPaymentProcess
*/
fun createSbpPaymentProcess(paymentOptions: PaymentOptions): PaymentProcess {
paymentOptions.validateRequiredFields()
Expand All @@ -121,6 +123,21 @@ class PaymentProcess internal constructor(private val sdk: AcquiringSdk) {
return this
}

/**
* Создает объект процесса для проведения оплаты с помощью Системы быстрых платежей с использованием
* существующего [paymentId].
* @return сконфигурированный объект для проведения оплаты
*
* @see createSbpPaymentProcess
*/
fun createInitializedSbpPaymentProcess(paymentId: Long): PaymentProcess {
this.paymentId = paymentId
this.paymentType = InitializedSbpPaymentType

sendToListener(PaymentState.CREATED)
return this
}

/**
* Позволяет подписаться на события процесса
* @return сконфигурированный объект для проведения оплаты
Expand All @@ -146,6 +163,7 @@ class PaymentProcess internal constructor(private val sdk: AcquiringSdk) {
when (paymentType) {
SbpPaymentType, CardPaymentType -> callInitRequest(initRequest!!)
FinishPaymentType -> finishPayment(paymentId!!, paymentSource)
InitializedSbpPaymentType -> callGetQr(paymentId!!)
}
sendToListener(PaymentState.STARTED)
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ package ru.tinkoff.acquiring.sdk.payment
internal sealed class PaymentType

internal object SbpPaymentType: PaymentType()
internal object InitializedSbpPaymentType: PaymentType()
internal object CardPaymentType : PaymentType()
internal object FinishPaymentType : PaymentType()

0 comments on commit 6031959

Please sign in to comment.