Skip to content

Commit

Permalink
обновлены документация для методов.
Browse files Browse the repository at this point in the history
рефакторинг
  • Loading branch information
v.budnikov committed Aug 19, 2020
1 parent 8ee8464 commit 97365ca
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 184 deletions.
2 changes: 1 addition & 1 deletion TinkoffASDKCore.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = 'TinkoffASDKCore'
spec.version = '2.0.2'
spec.version = '2.0.3'
spec.summary = 'Мобильный SDK'
spec.description = 'Позволяет настроить прием платежей в нативной форме приложений для платформы iOS'
spec.homepage = 'https://github.com/TinkoffCreditSystems/AcquiringSdk_IOS'
Expand Down
22 changes: 17 additions & 5 deletions TinkoffASDKCore/TinkoffASDKCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
2C193C4C243CB35000058DDC /* PaymentQRCodeRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C193C4B243CB35000058DDC /* PaymentQRCodeRequest.swift */; };
2C25379C2385682B000B9724 /* PaymentStatusRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C25379B2385682B000B9724 /* PaymentStatusRequest.swift */; };
2C25379E23856FAE000B9724 /* PaymentCancelRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C25379D23856FAE000B9724 /* PaymentCancelRequest.swift */; };
2C2A05AA24EBED2000E5242E /* HTTPURLResponse+TinkoffASDKCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2A05A924EBED2000E5242E /* HTTPURLResponse+TinkoffASDKCore.swift */; };
2C2A05AC24EBED6800E5242E /* HTTPResponseError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2A05AB24EBED6800E5242E /* HTTPResponseError.swift */; };
2C2A05AE24EBFAF800E5242E /* AcquiringSdkConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2A05AD24EBFAF800E5242E /* AcquiringSdkConfiguration.swift */; };
2C2E311423B4D59000AF9256 /* StageTestData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CC2A096238D5AD5008F8045 /* StageTestData.swift */; };
2C3B062A23717F9F003F100D /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C3B062923717F9F003F100D /* Utils.swift */; };
2C65607B2476932B00DEA4A9 /* CheckRandomAmountRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C65607A2476932B00DEA4A9 /* CheckRandomAmountRequest.swift */; };
Expand Down Expand Up @@ -49,6 +52,9 @@
2C193C4B243CB35000058DDC /* PaymentQRCodeRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentQRCodeRequest.swift; sourceTree = "<group>"; };
2C25379B2385682B000B9724 /* PaymentStatusRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentStatusRequest.swift; sourceTree = "<group>"; };
2C25379D23856FAE000B9724 /* PaymentCancelRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentCancelRequest.swift; sourceTree = "<group>"; };
2C2A05A924EBED2000E5242E /* HTTPURLResponse+TinkoffASDKCore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HTTPURLResponse+TinkoffASDKCore.swift"; sourceTree = "<group>"; };
2C2A05AB24EBED6800E5242E /* HTTPResponseError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPResponseError.swift; sourceTree = "<group>"; };
2C2A05AD24EBFAF800E5242E /* AcquiringSdkConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AcquiringSdkConfiguration.swift; sourceTree = "<group>"; };
2C3B062923717F9F003F100D /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
2C65607A2476932B00DEA4A9 /* CheckRandomAmountRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckRandomAmountRequest.swift; sourceTree = "<group>"; };
2C70ADE42367328400E74FEB /* AcquiringModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AcquiringModels.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -136,12 +142,15 @@
2C70ADE32367325D00E74FEB /* Models */,
2CB5F86E2360A9A100208488 /* Request */,
2CB5F86A23603DD000208488 /* AcquiringSdk.swift */,
2C2A05AD24EBFAF800E5242E /* AcquiringSdkConfiguration.swift */,
2C9FE701248F9022009E9649 /* AcquiringLogger.swift */,
2C71D8F7236AEFB00014EAFF /* NetworkTransport.swift */,
2C3B062923717F9F003F100D /* Utils.swift */,
2C2A05AB24EBED6800E5242E /* HTTPResponseError.swift */,
2C2A05A924EBED2000E5242E /* HTTPURLResponse+TinkoffASDKCore.swift */,
2C88015123914355007C8BFE /* Localizable.strings */,
2CB5F85323603D9F00208488 /* Info.plist */,
2CB5F85223603D9F00208488 /* TinkoffASDKCore.h */,
2C9FE701248F9022009E9649 /* AcquiringLogger.swift */,
);
path = TinkoffASDKCore;
sourceTree = "<group>";
Expand Down Expand Up @@ -292,9 +301,11 @@
2C65607B2476932B00DEA4A9 /* CheckRandomAmountRequest.swift in Sources */,
2C25379E23856FAE000B9724 /* PaymentCancelRequest.swift in Sources */,
2C9AECDA23840D8300ACEAA0 /* PaymentChargeRequest.swift in Sources */,
2C2A05AC24EBED6800E5242E /* HTTPResponseError.swift in Sources */,
2C9FE704248F90D3009E9649 /* AcquiringRequest.swift in Sources */,
2C71D8F8236AEFB00014EAFF /* NetworkTransport.swift in Sources */,
2C3B062A23717F9F003F100D /* Utils.swift in Sources */,
2C2A05AA24EBED2000E5242E /* HTTPURLResponse+TinkoffASDKCore.swift in Sources */,
2C25379C2385682B000B9724 /* PaymentStatusRequest.swift in Sources */,
2C9FE702248F9022009E9649 /* AcquiringLogger.swift in Sources */,
2CB5F8702360A9FC00208488 /* PaymentInitRequest.swift in Sources */,
Expand All @@ -305,6 +316,7 @@
2C16EAF823B0DB2E00A5C771 /* CardListDataProvider.swift in Sources */,
2CF1EDB1240F9CCB00155665 /* Check3dsVersionRequest.swift in Sources */,
2C193C4C243CB35000058DDC /* PaymentQRCodeRequest.swift in Sources */,
2C2A05AE24EBFAF800E5242E /* AcquiringSdkConfiguration.swift in Sources */,
2C2E311423B4D59000AF9256 /* StageTestData.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -472,7 +484,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 31;
CURRENT_PROJECT_VERSION = 32;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -485,7 +497,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.0.2;
MARKETING_VERSION = 2.0.3;
PRODUCT_BUNDLE_IDENTIFIER = tinkoff.ASDKCore;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -501,7 +513,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 31;
CURRENT_PROJECT_VERSION = 32;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -514,7 +526,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.0.2;
MARKETING_VERSION = 2.0.3;
PRODUCT_BUNDLE_IDENTIFIER = tinkoff.ASDKCore;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
89 changes: 7 additions & 82 deletions TinkoffASDKCore/TinkoffASDKCore/AcquiringSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import Foundation
import UIKit


public enum AcquiringSdkError: Error {

case publicKey(String)
Expand All @@ -28,83 +29,9 @@ public enum AcquiringSdkError: Error {

}


public enum AcquiringSdkLanguage: String {

case ru

case en

}


public enum AcquiringSdkEnvironment: String {

case test = "rest-api-test.tcsbank.ru"

case prod = "securepay.tinkoff.ru"

}


public struct AcquiringSdkCredential {

public var terminalKey: String
public var password: String
public var publicKey: String

/// - Parameters:
/// - terminalKey: ключ терминала. Выдается после подключения к **Тинькофф Эквайринг API**
/// - password: пароль от терминала. Выдается вместе с `terminalKey`
/// - publicKey: публичный ключ. Выдается вместе с `terminalKey`
/// - Returns: AcquiringSdkCredential
public init(terminalKey: String, password: String, publicKey: String) {
self.terminalKey = terminalKey
self.password = password
self.publicKey = publicKey
}

}


/// Кофигурация для экземпляра SDK
public class AcquiringSdkConfiguration: NSObject {

public var fpsEnabled: Bool = false

public private(set) var credential: AcquiringSdkCredential

public private(set) var serverEnvironment: AcquiringSdkEnvironment

/// Язык платёжной формы. На каком языке сервер будет присылать тексты ошибок клиенту
///
/// - `ru` - форма оплаты на русском языке;
/// - `en` - форма оплаты на английском языке.
///
/// По умолчанию (если параметр не передан) - форма оплаты считается на русском языке
public private(set) var language: AcquiringSdkLanguage?

/// Логирование работы, реализаия `ASDKApiLoggerDelegate`
public var logger: LoggerDelegate?

/// Показывать ошибки после выполнения запроса
public var showErrorAlert: Bool = true

///
/// - Parameters:
/// - credential: учетные данные `AcquiringSdkConfiguration` Выдается после подключения к **Тинькофф Эквайринг API**
/// - server: `AcquiringSdkEnvironment` по умолчанию используется `test` - тестовый сервер
/// - Returns: AcquiringSdkConfiguration
public init(credential: AcquiringSdkCredential, server: AcquiringSdkEnvironment = .test) {
self.credential = credential
self.serverEnvironment = server
}

}

///
/// `AcquiringSdk` позволяет конфигурировать SDK и осуществлять взаимодействие с **Тинькофф Эквайринг API** https://oplata.tinkoff.ru/landing/develop/
public class AcquiringSdk: NSObject {
public final class AcquiringSdk: NSObject {

public var fpsEnabled: Bool = false

Expand Down Expand Up @@ -248,7 +175,7 @@ public class AcquiringSdk: NSObject {
///
/// - Parameters:
/// - data: `PaymentFinishRequestData`
/// - completionHandler: результат операции `Check3dsVersionResponse` в случае удачного ответа и `Error` - в случе ошибки.
/// - completionHandler: результат операции `Check3dsVersionResponse` в случае удачного ответа и `Error` - в случе ошибки.
public func check3dsVersion(data: PaymentFinishRequestData, completionHandler: @escaping (_ result: Result<Check3dsVersionResponse, Error>) -> Void) -> Cancellable {
let requestData = PaymentFinishRequestData.init(paymentId: data.paymentId, paymentSource: data.paymentSource)
let request = Check3dsVersionRequest.init(data: requestData)
Expand All @@ -266,7 +193,7 @@ public class AcquiringSdk: NSObject {
///
/// - Parameters:
/// - data: `PaymentFinishRequestData`
/// - completionHandler: результат операции `PaymentFinishResponse` в случае удачного проведеня платежа и `Error` - в случе ошибки.
/// - completionHandler: результат операции `PaymentFinishResponse` в случае удачного проведеня платежа и `Error` - в случе ошибки.
public func paymentFinish(data: PaymentFinishRequestData, completionHandler: @escaping (_ result: Result<PaymentFinishResponse, Error>) -> Void) -> Cancellable {
let request = PaymentFinishRequest.init(data: data)
updateCardDataRequestParams(&request.parameters)
Expand All @@ -280,7 +207,7 @@ public class AcquiringSdk: NSObject {
}

///
/// Подтверждает инициированный платеж передачей рекуррентным платежом
/// Подтверждает инициированный платеж передачей информации о рекуррентном платеже
public func chargePayment(data: PaymentChargeRequestData, completionHandler: @escaping (_ result: Result<PaymentStatusResponse, Error>) -> Void) -> Cancellable {
let request = PaymentChargeRequest.init(data: data)
let requestTokenParams: JSONObject = tokenParams(request: request)
Expand All @@ -305,8 +232,6 @@ public class AcquiringSdk: NSObject {
}
}

// MARK: -

///
/// Отмена платежа
/// - Parameters:
Expand All @@ -323,7 +248,7 @@ public class AcquiringSdk: NSObject {
}
}

// MARK: Cписок карт
// MARK: - Cписок карт

///
/// - Parameters:
Expand Down Expand Up @@ -404,7 +329,7 @@ public class AcquiringSdk: NSObject {
}
}

// MARK: Система быстрых платежей, оплата по QR-коду
// MARK: - Система быстрых платежей, оплата по QR-коду

/// Сгенерировать QR-код для оплаты
///
Expand Down
95 changes: 95 additions & 0 deletions TinkoffASDKCore/TinkoffASDKCore/AcquiringSdkConfiguration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//
// AcquiringSdkConfiguration.swift
// TinkoffASDKCore
//
// Copyright (c) 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.
//

import Foundation
import UIKit


public enum AcquiringSdkLanguage: String {

case ru

case en

}


public enum AcquiringSdkEnvironment: String {

case test = "rest-api-test.tcsbank.ru"

case prod = "securepay.tinkoff.ru"

}


public struct AcquiringSdkCredential {

public var terminalKey: String
public var password: String
public var publicKey: String

/// - Parameters:
/// - terminalKey: ключ терминала. Выдается после подключения к **Тинькофф Эквайринг API**
/// - password: пароль от терминала. Выдается вместе с `terminalKey`
/// - publicKey: публичный ключ. Выдается вместе с `terminalKey`
/// - Returns: AcquiringSdkCredential
public init(terminalKey: String, password: String, publicKey: String) {
self.terminalKey = terminalKey
self.password = password
self.publicKey = publicKey
}

}


/// Кофигурация для экземпляра SDK
public class AcquiringSdkConfiguration: NSObject {

public var fpsEnabled: Bool = false

public private(set) var credential: AcquiringSdkCredential

public private(set) var serverEnvironment: AcquiringSdkEnvironment

/// Язык платёжной формы. На каком языке сервер будет присылать тексты ошибок клиенту
///
/// - `ru` - форма оплаты на русском языке;
/// - `en` - форма оплаты на английском языке.
///
/// По умолчанию (если параметр не передан) - форма оплаты считается на русском языке
public private(set) var language: AcquiringSdkLanguage?

/// Логирование работы, реализаия `ASDKApiLoggerDelegate`
public var logger: LoggerDelegate?

/// Показывать ошибки после выполнения запроса
public var showErrorAlert: Bool = true

///
/// - Parameters:
/// - credential: учетные данные `AcquiringSdkConfiguration` Выдается после подключения к **Тинькофф Эквайринг API**
/// - server: `AcquiringSdkEnvironment` по умолчанию используется `test` - тестовый сервер
/// - Returns: AcquiringSdkConfiguration
public init(credential: AcquiringSdkCredential, server: AcquiringSdkEnvironment = .test) {
self.credential = credential
self.serverEnvironment = server
}

}
Loading

0 comments on commit 97365ca

Please sign in to comment.