Skip to content

Commit

Permalink
* [EACQAPW-5561] Tinkoff Pay doesn't pass SuccessURL & FailURL in /In…
Browse files Browse the repository at this point in the history
…it (#467)
  • Loading branch information
ivanglushko authored Jul 17, 2023
1 parent 577e40c commit af733b9
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 11 deletions.
8 changes: 7 additions & 1 deletion ASDKSample/ASDKSample/BuyProductsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,13 @@ class BuyProductsViewController: UIViewController {
}

private func payWithTinkoffPay() {
let paymentOptions = PaymentOptions.create(from: createPaymentData())
let paymentCallbackURL = PaymentCallbackURL(
successURL: "https://tinkoff.ru/SuccessURL",
failureURL: "https://tinkoff.ru/FailureURL"
)

var paymentOptions = PaymentOptions.create(from: createPaymentData())
paymentOptions.paymentCallbackURL = paymentCallbackURL
let paymentFlow = PaymentFlow.full(paymentOptions: paymentOptions)

uiSDK.presentTinkoffPay(on: self, paymentFlow: paymentFlow) { [weak self] result in
Expand Down
18 changes: 9 additions & 9 deletions ASDKSample/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ PODS:
- SwiftFormat/CLI (0.49.18)
- SwiftGen (6.6.2)
- SwiftLint (0.47.0)
- TinkoffASDKCore (3.0.0)
- TinkoffASDKCore/Tests (3.0.0)
- TinkoffASDKUI (3.0.0):
- TinkoffASDKCore (3.1.0)
- TinkoffASDKCore/Tests (3.1.0)
- TinkoffASDKUI (3.1.0):
- TinkoffASDKCore
- TinkoffASDKUI/Tests (3.0.0):
- TinkoffASDKUI/Tests (3.1.0):
- TinkoffASDKCore
- TinkoffASDKYandexPay (3.0.0):
- TinkoffASDKYandexPay (3.1.0):
- TinkoffASDKCore
- TinkoffASDKUI
- YandexPaySDK/Dynamic (= 1.3.6)
- TinkoffASDKYandexPay/Tests (3.0.0):
- TinkoffASDKYandexPay/Tests (3.1.0):
- TinkoffASDKCore
- TinkoffASDKUI
- YandexPaySDK/Dynamic (= 1.3.6)
Expand Down Expand Up @@ -63,9 +63,9 @@ SPEC CHECKSUMS:
SwiftFormat: 2402d29b26746f169cce5454d5af88314cbb2e35
SwiftGen: 1366a7f71aeef49954ca5a63ba4bef6b0f24138c
SwiftLint: d41cc46a2ae58ac6d9f26954bc89f1d72e71fdef
TinkoffASDKCore: d4df213cd256bedc8114c12a0f75ff7212be0b4e
TinkoffASDKUI: af2ca72a3bb38fc6e0055dbe08bdc1b261322def
TinkoffASDKYandexPay: 69e7a4232fec3ee089dd32a1135489b7b9d9bf1e
TinkoffASDKCore: 3283eaa2fa450f1b199398b1aa7b381844d7eb16
TinkoffASDKUI: 36997b50d97676892a3adde811fe6d908e1d591a
TinkoffASDKYandexPay: eb97c35476780f351f502779c8331f19f76a5a54
YandexLoginSDK: ad9a07aca36a7748353af17c9cbbf2b83be9ba26
YandexMobileMetrica: f5368ee93f286c793d73b58da00929babfc897c1
YandexPaySDK: 94cfd7f426b8fcdee6eda91e53d281da17489e28
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
## [Unreleased]

### Fixed
* [EACQAPW-5561] Tinkoff Pay doesn't pass SuccessURL & FailURL in /Init

## [3.1.0] - 2023-06-28Z

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ extension PaymentFlow {
let newPaymentOptions = PaymentOptions(
orderOptions: paymentOptions.orderOptions,
customerOptions: paymentOptions.customerOptions,
paymentCallbackURL: paymentOptions.paymentCallbackURL,
paymentData: (paymentOptions.paymentData ?? [:]).merging(paymentData) { $1 }
)
return .full(paymentOptions: newPaymentOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public struct PaymentOptions: Equatable {
/// Ссылки для возврата на страницы успешной или неуспешной оплаты, используемые по завершении процесса оплаты во внешнем приложении
///
/// Используется только для оплаты через `Tinkoff Pay`
public let paymentCallbackURL: PaymentCallbackURL?
public var paymentCallbackURL: PaymentCallbackURL?
/// `JSON` объект, содержащий дополнительные параметры в виде `[Key: Value]`
///
/// `Key: String` – 20 знаков,
Expand Down
34 changes: 34 additions & 0 deletions TinkoffASDKUI/TinkoffASDKUITests/TestCases/PaymentFlowTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// PaymentFlowTests.swift
// TinkoffASDKUI
//
// Created by Ivan Glushko on 17.07.2023.
//

@testable import TinkoffASDKCore
@testable import TinkoffASDKUI
import XCTest

final class PaymentFlowTests: XCTestCase {

func test_mergePaymentDataIfNeeded_passes_paymentCallbackURL() {
// given
let successURL = "https://tinkoff.ru/SuccessURL"
let failURL = "tinkoffbank://Main/fail"
var paymentOptions = PaymentOptions.fake()
paymentOptions.paymentCallbackURL = PaymentCallbackURL(successURL: successURL, failureURL: failURL)
let sut = PaymentFlow.full(paymentOptions: paymentOptions)
// when
let result = sut.mergePaymentDataIfNeeded(Self.tinkoffPayData)
// then
guard case let .full(mergedOptions) = result else { XCTFail(); return }
XCTAssertEqual(mergedOptions.paymentCallbackURL?.successURL, successURL)
XCTAssertEqual(mergedOptions.paymentCallbackURL?.failureURL, failURL)
}
}

// MARK: - Constants

extension PaymentFlowTests {
static let tinkoffPayData = ["TinkoffPayWeb": "true"]
}

0 comments on commit af733b9

Please sign in to comment.