Skip to content

* [EACQAPW-5616] Fully Refactored additional DATA on /Init /FinishAuthorize and /AttachCard #507

Merged
merged 4 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions ASDKSample/ASDKSample/BuyProductsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ extension BuyProductsViewController: ICardScannerDelegate {
}

extension BuyProductsViewController: IRecurrentPaymentFailiureDelegate {
func recurrentPaymentNeedRepeatInit(additionalData: [String: String], completion: @escaping (Result<PaymentId, Error>) -> Void) {
func recurrentPaymentNeedRepeatInit(additionalInitData: AdditionalData, completion: @escaping (Result<PaymentId, Error>) -> Void) {
var initData = createPaymentData()

let newPaymentData = initData.paymentFormData?.merging(additionalData) { $1 }
initData.paymentFormData = newPaymentData
var newAdditionalData = initData.additionalData ?? .empty()
newAdditionalData.merging(additionalInitData.data)
initData.additionalData = newAdditionalData

coreSDK.initPayment(data: initData) { result in
if let paymentId = try? result.map({ $0.paymentId }).get() {
Expand Down Expand Up @@ -614,10 +614,14 @@ private extension PaymentOptions {
CustomerOptions(customerKey: $0, email: "[email protected]")
}

var initAddData = initData.additionalData ?? .empty()
initAddData.merging(["/InitKey": "/InitValue"])

return PaymentOptions(
orderOptions: orderOptions,
customerOptions: customerOptions,
paymentData: initData.paymentFormData ?? [:]
paymentInitData: initAddData,
paymentFinishData: AdditionalData(data: ["/FinishKey": "/FinishValue"])
)
}
}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

### Changed
* [EACQAPW-5617] Now Receipt initializer checks validity of mandatory fields
* [EACQAPW-5616] Fully Refactored additional DATA on /Init /FinishAuthorize and /AttachCard

### Fixed

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
//
// ThreeDSDeviceData.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 Foundation

public enum ThreeDSDeviceData {
case browser(ThreeDsDataBrowser)
case sdk(ThreeDsDataSDK)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,24 @@ import Foundation
import class UIKit.UIScreen

public protocol IThreeDSDeviceInfoProvider {
func createDeviceInfo(threeDSCompInd: String) -> ThreeDSDeviceInfo

func createThreeDsDataBrowser(threeDSCompInd: String) -> ThreeDsDataBrowser

func createThreeDsDataSDK(
sdkAppID: String,
sdkEphemPubKey: String,
sdkReferenceNumber: String,
sdkTransID: String,
sdkMaxTimeout: String,
sdkEncData: String
) -> ThreeDsDataSDK
}

public extension IThreeDSDeviceInfoProvider {
var deviceInfo: ThreeDSDeviceInfo {
createDeviceInfo(threeDSCompInd: "Y")

/// threeDSCompInd: "Y"
func createThreeDsDataBrowser() -> ThreeDsDataBrowser {
return createThreeDsDataBrowser(threeDSCompInd: "Y")
}
}

Expand All @@ -45,26 +57,36 @@ final class ThreeDSDeviceInfoProvider: IThreeDSDeviceInfoProvider {
self.sdkUiProvider = sdkUiProvider
}

func createDeviceInfo(threeDSCompInd: String) -> ThreeDSDeviceInfo {
ThreeDSDeviceInfo(
// BRW
public func createThreeDsDataSDK(
sdkAppID: String,
sdkEphemPubKey: String,
sdkReferenceNumber: String,
sdkTransID: String,
sdkMaxTimeout: String,
sdkEncData: String
) -> ThreeDsDataSDK {
ThreeDsDataSDK(
sdkAppID: sdkAppID,
sdkEphemPubKey: sdkEphemPubKey,
sdkReferenceNumber: sdkReferenceNumber,
sdkTransID: sdkTransID,
sdkMaxTimeout: sdkMaxTimeout,
sdkEncData: sdkEncData,
sdkInterface: sdkUiProvider.sdkInterface(),
sdkUiType: sdkUiProvider.sdkUiTypes().map { $0.rawValue }.joined(separator: ",")
)
}

public func createThreeDsDataBrowser(threeDSCompInd: String) -> ThreeDsDataBrowser {
ThreeDsDataBrowser(
threeDSCompInd: threeDSCompInd,
javaEnabled: "true",
colorDepth: 32,
colorDepth: "\(32)",
language: (languageProvider.language ?? .ru).rawValue,
timezone: TimeZone.current.secondsFromGMT() / 60,
screenHeight: Int(UIScreen.main.bounds.height * UIScreen.main.scale),
screenWidth: Int(UIScreen.main.bounds.width * UIScreen.main.scale),
cresCallbackUrl: urlBuilder.url(ofType: .confirmation3DSTerminationV2URL).absoluteString,
// SDK
sdkAppID: nil,
sdkEphemPubKey: nil,
sdkReferenceNumber: nil,
sdkTransID: nil,
sdkMaxTimeout: nil,
sdkEncData: nil,
sdkInterface: sdkUiProvider.sdkInterface(),
sdkUiType: sdkUiProvider.sdkUiTypes().map { $0.rawValue }.joined(separator: ",")
timezone: "\(TimeZone.current.secondsFromGMT() / 60)",
screenHeight: "\(Int(UIScreen.main.bounds.height * UIScreen.main.scale))",
screenWidth: "\(Int(UIScreen.main.bounds.width * UIScreen.main.scale))",
cresCallbackUrl: urlBuilder.url(ofType: .confirmation3DSTerminationV2URL).absoluteString
)
}
}
Loading
Loading