Skip to content

Commit

Permalink
Release 2.16.0: YandexPay improvements (#264)
Browse files Browse the repository at this point in the history
* [MIC-7482] CommonSheet adoption for different states (#255)

* Change CommonSheet Implementation

* Rename YandexPayPaymentActivity -> YandexPayPaymentSheet

* Update CHANGELOG

* Add secondary button event handling in controller

* Add UIKit import to CommonSheetView

* Fix extension description

* Move dismission state to presenter

* Rename CommonSheetIO

* Simplify buttons configuration

Co-authored-by: Ruslan Akhmadeev <[email protected]>

* [MIC-7555] Add finish flow handling for YandexPay payments (#260)

* Add new parameters to PaymentInfo

* Add ability to provide FinishFlow to YandexPayButtonContainer

* Rename IYandexPayPaymentFlowOutput -> YandexPayPaymentFlowDelegate

* Update code documentation

* Rename yandexPayPaymentActivity -> yandexPayPaymentSheet

* Update Sample for new YP interface

* Inject CoreSDK to BuyProductsViewController in sample
f

* Add additional YP Button to Sample

* Add YP flow resolving in Sample

* Add finish flow handling for YandexPayPaymentProcess

* Use PaymentFlow's extension customer's email resolving

* Remove unused properties in PaymentController

* Update documentation

* Update CHANGELOG

* Update tests
Update tests

* Add import UIKIt to YandexPayPaymentFlowDelegate

Co-authored-by: Ruslan Akhmadeev <[email protected]>

* [MIC-7710] Fix common sheet primary button title (#263)

* Change text in localization

* Update CHANGELOG

* Fix conflicts

Fix color handling
Fix unknown project's uuid

* Bump podfile.lock

* Fix CHANGELOG

Co-authored-by: Ruslan Akhmadeev <[email protected]>
  • Loading branch information
akhaman and Ruslan Akhmadeev authored Jan 19, 2023
1 parent e51d227 commit e025bac
Show file tree
Hide file tree
Showing 55 changed files with 1,120 additions and 1,200 deletions.
6 changes: 4 additions & 2 deletions ASDKSample/ASDKSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
4749076CE49DE1C211DB4E08 /* Pods_ASDKSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C0515196236F7F45BACBF2A /* Pods_ASDKSample.framework */; };
576E765329769FB1009AF5E2 /* UIAlertController+CardScannerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 576E765229769FB1009AF5E2 /* UIAlertController+CardScannerMock.swift */; };
57DE3DF32934C3D600FD6F1B /* YPButtonContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57DE3DF22934C3D600FD6F1B /* YPButtonContainerView.swift */; };
57D1C5C62975A9B900C6D1CA /* UITableView+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57D1C5C52975A9B900C6D1CA /* UITableView+Utils.swift */; };
57DE3DF72934ED2C00FD6F1B /* ContainerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57DE3DF62934ED2C00FD6F1B /* ContainerTableViewCell.swift */; };
57EEFB8A28F409A300809488 /* StageTestData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57EEFB8928F409A300809488 /* StageTestData.swift */; };
57EEFB8F28F486C200809488 /* SampleTokenProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57EEFB8E28F486C200809488 /* SampleTokenProvider.swift */; };
Expand Down Expand Up @@ -89,6 +90,7 @@
2CFEEE07246EA4910009E633 /* InfoPlist.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = InfoPlist.strings; sourceTree = "<group>"; };
576E765229769FB1009AF5E2 /* UIAlertController+CardScannerMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertController+CardScannerMock.swift"; sourceTree = "<group>"; };
57DE3DF22934C3D600FD6F1B /* YPButtonContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YPButtonContainerView.swift; sourceTree = "<group>"; };
57D1C5C52975A9B900C6D1CA /* UITableView+Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+Utils.swift"; sourceTree = "<group>"; };
57DE3DF62934ED2C00FD6F1B /* ContainerTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerTableViewCell.swift; sourceTree = "<group>"; };
57EEFB8928F409A300809488 /* StageTestData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StageTestData.swift; sourceTree = "<group>"; };
57EEFB8E28F486C200809488 /* SampleTokenProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleTokenProvider.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -261,7 +263,6 @@
B1A4EDDE28F3FD4B004D0C99 /* HorizontalTitleSwitchView.swift */,
B1A4EDE028F3FD73004D0C99 /* VerticalEditableView.swift */,
B1A4EDE228F3FD86004D0C99 /* CredentialsView.swift */,
57DE3DF22934C3D600FD6F1B /* YPButtonContainerView.swift */,
B1D01A1128F5A20800D429F4 /* JustButton.swift */,
);
name = Views;
Expand Down Expand Up @@ -291,6 +292,7 @@
B156F90B28F0440000ABABDD /* UIEdgeInsets+Ext.swift */,
B156F90D28F06B3700ABABDD /* UIView+Ext.swift */,
B1C97B7728F46E4000DC007B /* UIImage+Ext.swift */,
57D1C5C52975A9B900C6D1CA /* UITableView+Utils.swift */,
);
name = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -580,6 +582,7 @@
B1A4EDDB28F3FC2C004D0C99 /* ViewProtocols.swift in Sources */,
B1D01A1028F5731C00D429F4 /* AppSetting.swift in Sources */,
576E765329769FB1009AF5E2 /* UIAlertController+CardScannerMock.swift in Sources */,
57D1C5C62975A9B900C6D1CA /* UITableView+Utils.swift in Sources */,
2C4D782E23F42090003A355D /* SettingsTableViewController.swift in Sources */,
57EEFB8F28F486C200809488 /* SampleTokenProvider.swift in Sources */,
2C9C7EBF239FBCB200DE4071 /* AppDelegate.swift in Sources */,
Expand All @@ -591,7 +594,6 @@
57DE3DF72934ED2C00FD6F1B /* ContainerTableViewCell.swift in Sources */,
B1A4EDDF28F3FD4B004D0C99 /* HorizontalTitleSwitchView.swift in Sources */,
2C6560832476D18800DEA4A9 /* SegmentedTabeViewCell.swift in Sources */,
57DE3DF32934C3D600FD6F1B /* YPButtonContainerView.swift in Sources */,
2CAEC1A5246D20F20052E07C /* SwitchTableViewCell.swift in Sources */,
2CA0205F23F2C01500C2AB0E /* CartTableViewController.swift in Sources */,
B1A4EDE328F3FD86004D0C99 /* CredentialsView.swift in Sources */,
Expand Down
174 changes: 111 additions & 63 deletions ASDKSample/ASDKSample/BuyProductsViewController.swift

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ASDKSample/ASDKSample/CartTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class CartTableViewController: UITableViewController {
return
}

if let sdk = try? SdkAssembly.assembleUIsdk(creds: AppSetting.shared.activeSdkCredentials) {
viewController.sdk = sdk
if let sdk = try? SdkAssembly.assembleUISDK(credential: AppSetting.shared.activeSdkCredentials) {
viewController.uiSDK = sdk
viewController.customerKey = AppSetting.shared.activeSdkCredentials.customerKey
}

Expand Down
61 changes: 37 additions & 24 deletions ASDKSample/ASDKSample/RootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ class RootViewController: UITableViewController {
private var dataSource: [Product] = []
private var onScannerResult: ((_ number: String?, _ date: String?) -> Void)?

// State
private weak var buyProductsVieController: BuyProductsViewController?

override func viewDidLoad() {
super.viewDidLoad()

Expand Down Expand Up @@ -190,12 +187,21 @@ class RootViewController: UITableViewController {
cardListViewConfigration.alertViewHelper = self
}

if let sdk = try? SdkAssembly.assembleUIsdk(creds: AppSetting.shared.activeSdkCredentials) {
// открыть экран сиска карт
addCardListView(sdk, AppSetting.shared.activeSdkCredentials.customerKey, cardListViewConfigration)
// или открыть экран добавлени карты
// addCardView(sdk, customerKey, cardListViewConfigration)
if let sdk = try? SdkAssembly.assembleUISDK(credential: AppSetting.shared.activeSdkCredentials) {
sdk.addCardNeedSetCheckTypeHandler = {
AppSetting.shared.addCardChekType
}

sdk.presentCardList(
on: self,
customerKey: AppSetting.shared.activeSdkCredentials.customerKey,
configuration: cardListViewConfigration
)
}
}

@IBAction func openAddCard(_ sender: UIBarButtonItem) {
if let sdk = try? SdkAssembly.assembleUISDK(credential: AppSetting.shared.activeSdkCredentials) {
sdk.addCardNeedSetCheckTypeHandler = {
AppSetting.shared.addCardChekType
}
Expand Down Expand Up @@ -227,7 +233,7 @@ extension RootViewController: AcquiringAlertViewProtocol {
private extension RootViewController {

private func showSpbQrCollector() {
if let sdk = try? SdkAssembly.assembleUIsdk(creds: AppSetting.shared.activeSdkCredentials) {
if let sdk = try? SdkAssembly.assembleUISDK(credential: AppSetting.shared.activeSdkCredentials) {
let viewConfigration = AcquiringViewConfiguration()
viewConfigration.viewTitle = Loc.Title.qrcode

Expand All @@ -236,22 +242,29 @@ private extension RootViewController {
}

private func showBuyProductsViewController(rowIndex: Int) {
if let sdk = try? SdkAssembly.assembleUIsdk(creds: AppSetting.shared.activeSdkCredentials) {
let product = dataSource[rowIndex]

let storyboard = UIStoryboard(name: "Main", bundle: .main)
guard let viewController = storyboard.instantiateViewController(
withIdentifier: String(describing: BuyProductsViewController.self)
) as? BuyProductsViewController
else {
return
}
let credential = AppSetting.shared.activeSdkCredentials

guard let coreSDK = try? SdkAssembly.assembleCoreSDK(credential: credential),
let uiSDK = try? SdkAssembly.assembleUISDK(credential: credential) else {
fatalError("Could not assemble SDK")
}

viewController.scaner = self
viewController.sdk = sdk
viewController.customerKey = AppSetting.shared.activeSdkCredentials.customerKey
viewController.products = [product]
navigationController?.pushViewController(viewController, animated: true)
let product = dataSource[rowIndex]

let storyboard = UIStoryboard(name: "Main", bundle: .main)

guard let viewController = storyboard.instantiateViewController(
withIdentifier: String(describing: BuyProductsViewController.self)
) as? BuyProductsViewController
else {
fatalError("Could not instantiate BuyProductsViewController")
}

viewController.scaner = self
viewController.coreSDK = coreSDK
viewController.uiSDK = uiSDK
viewController.customerKey = credential.customerKey
viewController.products = [product]
navigationController?.pushViewController(viewController, animated: true)
}
}
27 changes: 18 additions & 9 deletions ASDKSample/ASDKSample/SdkAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,32 @@ import TinkoffASDKCore
import TinkoffASDKUI

struct SdkAssembly {

static func assembleUIsdk(
creds: SdkCredentials,
static func assembleUISDK(
credential: SdkCredentials,
style: Style = DefaultStyle()
) throws -> AcquiringUISDK {
try AcquiringUISDK(configuration: createConfiguration(credential: credential), style: style)
}

let credentional = AcquiringSdkCredential(
terminalKey: creds.terminalKey,
publicKey: creds.publicKey
static func assembleCoreSDK(credential: SdkCredentials) throws -> AcquiringSdk {
try AcquiringSdk(configuration: createConfiguration(credential: credential))
}

private static func createConfiguration(credential: SdkCredentials) -> AcquiringSdkConfiguration {
let sdkCredential = AcquiringSdkCredential(
terminalKey: credential.terminalKey,
publicKey: credential.publicKey
)

let tokenProvider = SampleTokenProvider(password: creds.terminalPassword)
let tokenProvider = SampleTokenProvider(password: credential.terminalPassword)
let logger = AcquiringLoggerDefault()

let acquiringSDKConfiguration = AcquiringSdkConfiguration(credential: credentional, tokenProvider: tokenProvider)
let acquiringSDKConfiguration = AcquiringSdkConfiguration(
credential: sdkCredential,
tokenProvider: tokenProvider
)
acquiringSDKConfiguration.logger = logger

return try AcquiringUISDK(configuration: acquiringSDKConfiguration, style: style)
return acquiringSDKConfiguration
}
}
8 changes: 2 additions & 6 deletions ASDKSample/ASDKSample/UIEdgeInsets+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ extension UIEdgeInsets {
self.init(top: side, left: side, bottom: side, right: side)
}

init(vertical: CGFloat) {
self.init(top: vertical, left: 0, bottom: vertical, right: 0)
}

init(horizontal: CGFloat) {
self.init(top: 0, left: horizontal, bottom: 0, right: horizontal)
init(horizontal: CGFloat = .zero, vertical: CGFloat = .zero) {
self.init(top: vertical, left: horizontal, bottom: vertical, right: horizontal)
}
}
40 changes: 40 additions & 0 deletions ASDKSample/ASDKSample/UITableView+Utils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
//
// UITableView+Utils.swift
//
// Copyright (c) 2021 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.
//

import UIKit

extension UITableView {
func register(_ cellTypes: UITableViewCell.Type...) {
cellTypes.forEach {
register($0, forCellReuseIdentifier: "\($0)")
}
}

func dequeue<Cell: UITableViewCell>(_ type: Cell.Type, for indexPath: IndexPath? = nil) -> Cell {
let identifier = "\(type)"

// swiftlint:disable force_cast
if let indexPath = indexPath {
return dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! Cell
} else {
return dequeueReusableCell(withIdentifier: identifier) as! Cell
}
// swiftlint:enable force_cast
}
}
67 changes: 0 additions & 67 deletions ASDKSample/ASDKSample/YPButtonContainerView.swift

This file was deleted.

16 changes: 8 additions & 8 deletions ASDKSample/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ PODS:
- SwiftFormat/CLI (0.49.18)
- SwiftGen (6.6.2)
- SwiftLint (0.47.0)
- TinkoffASDKCore (2.15.0)
- TinkoffASDKCore/Tests (2.15.0)
- TinkoffASDKUI (2.15.0):
- TinkoffASDKCore (2.15.1)
- TinkoffASDKCore/Tests (2.15.1)
- TinkoffASDKUI (2.15.1):
- TinkoffASDKCore
- TinkoffASDKUI/Tests (2.15.0):
- TinkoffASDKUI/Tests (2.15.1):
- TinkoffASDKCore
- TinkoffASDKYandexPay (2.15.0):
- TinkoffASDKYandexPay (2.15.1):
- TinkoffASDKCore
- TinkoffASDKUI
- YandexPaySDK/Dynamic (~> 1.2)
Expand Down Expand Up @@ -58,9 +58,9 @@ SPEC CHECKSUMS:
SwiftFormat: 2402d29b26746f169cce5454d5af88314cbb2e35
SwiftGen: 1366a7f71aeef49954ca5a63ba4bef6b0f24138c
SwiftLint: d41cc46a2ae58ac6d9f26954bc89f1d72e71fdef
TinkoffASDKCore: 36348ed3f5f86e84f3159e3392894931a0be97e5
TinkoffASDKUI: a9a72ac2d21146d949dc9d8f72433b4fe28fd48c
TinkoffASDKYandexPay: cec7214426ed8f9663a63da72c78587296044bb9
TinkoffASDKCore: c36415be5c5fb17a30e2f481502b676c728ea4b6
TinkoffASDKUI: aae27080a6b8c8332c5b5ce3720f6b5e91a17fcd
TinkoffASDKYandexPay: d012a59f2dc73a4a3af93ff48df249f9791dfcc2
YandexLoginSDK: cd407482207b4b7da75c5f7d7fd2fdd6a604c325
YandexMobileMetrica: baf7cea47cb87fc9af963c4f747ce8dd7df3d7c0
YandexPaySDK: 77bfc6e67d889e26f1f3926c2a6cdfd5ccbb6a52
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Changelog
## [Unreleased]

### Added

* [MIC-7555] Add finish flow handling for YandexPay payments

### Changed

* [MIC-7482] CommonSheet adoption for different states

### Fixed

* [MIC-7710] CommonSheet primary button's english localization

## [2.15.1] - 2023-01-18Z

### Fixed
Expand Down
14 changes: 14 additions & 0 deletions TinkoffASDKUI/TinkoffASDKUI/Extensions/UIStackView+Utils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// UIStackView+Utils.swift
// TinkoffASDKUI
//
// Created by r.akhmadeev on 12.01.2023.
//

import UIKit

extension UIStackView {
func addArrangedSubviews(_ subviews: [UIView]) {
subviews.forEach { addArrangedSubview($0) }
}
}
Loading

0 comments on commit e025bac

Please sign in to comment.