Skip to content
This repository was archived by the owner on Aug 29, 2024. It is now read-only.

Commit 29ed90b

Browse files
authored
Public release 1.3.3
Public release 1.3.3
2 parents d97b83c + 96106fd commit 29ed90b

File tree

150 files changed

+1838
-1386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+1838
-1386
lines changed

Sources/VGSCheckoutSDK/Core/Checkout/UseCases/Payment/ViewControllers/PayWithNewCard/VGSPayWithCardViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ extension VGSPayWithCardViewController: VGSCheckoutBaseCardViewControllerDelegat
111111
let state: VGSAddCardFlowState
112112
switch strongSelf.viewModel.configuration.payoptFlow {
113113
case .addCard:
114-
state = VGSAddCardFlowState.requestSubmitted(requestResult)
114+
state = VGSAddCardFlowState.checkoutDidFinish(.newCard(requestResult, cardInfo))
115115
case .transfers:
116116
state = VGSAddCardFlowState.checkoutTransferDidFinish(requestResult)
117117
}

Sources/VGSCheckoutSDK/Core/Checkout/UseCases/Payment/Workers/APIWorkers/PaymentsAPIWorker/VGSPaymentsAPIWorker.swift

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ internal final class VGSPayoptAddCardAPIWorker {
2626
/// Transfers path.
2727
private let transfersPath = "/transfers"
2828

29+
// swiftlint:disable all
30+
31+
/// Sub-account id JSON key
32+
private let SUB_ACCOUNT_KEY = "sub_account_id"
33+
34+
// swiftlint:enable all
35+
2936
/// Checkout service.
3037
private weak var checkoutService: VGSCheckoutBasicPayoptServiceProtocol?
3138

@@ -37,9 +44,13 @@ internal final class VGSPayoptAddCardAPIWorker {
3744
vgsCollect.apiClient.customHeader = ["Authorization": "Bearer \(configuration.accessToken)"]
3845
}
3946

40-
internal func createFinID(with newCardInfo: VGSCheckoutNewPaymentCardInfo, completion: @escaping VGSCheckoutRequestResultCompletion) {
47+
internal func createFinID(with newCardInfo: VGSCheckoutNewPaymentCardInfo, completion: @escaping VGSCheckoutRequestResultCompletion) {
4148

42-
vgsCollect.sendData(path: finInstrumentsPath, method: .post) {[weak self] response in
49+
var extraData = [String: Any]()
50+
if let id = configuration.subAccountId {
51+
extraData[SUB_ACCOUNT_KEY] = id
52+
}
53+
vgsCollect.sendData(path: finInstrumentsPath, method: .post, extraData: extraData) {[weak self] response in
4354
guard let strongSelf = self else {return}
4455

4556
var extraData = [String: Any]()
@@ -103,12 +114,16 @@ internal final class VGSPayoptAddCardAPIWorker {
103114
guard let config = configuration as? VGSCheckoutPaymentConfiguration else {
104115
fatalError("Cannot send transfers in invalid flow.")
105116
}
106-
let transderPayload: [String: Any] = [
117+
var transferPayload: [String: Any] = [
107118
"order_id": config.orderId,
108119
"source": finId
109-
]
120+
]
121+
if let id = config.subAccountId {
122+
transferPayload[SUB_ACCOUNT_KEY] = id
123+
}
124+
110125
// Use API client sendRequest since we don't need to send collected data again.
111-
vgsCollect.apiClient.sendRequest(path: transfersPath, method: .post, value: transderPayload) { response in
126+
vgsCollect.apiClient.sendRequest(path: transfersPath, method: .post, value: transferPayload) { response in
112127
switch response {
113128
case .success(let code, let data, let response):
114129
/// Additional checkout flow info.

Sources/VGSCheckoutSDK/Core/Checkout/UseCases/SaveCard/DataWorkers/PaymentOptimizationAPIWorkers/VGSSaveCardPayoptAddCardAPIWorker.swift

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ internal class VGSSaveCardPayoptAddCardAPIWorker: VGSSaveCardAPIWorkerProtocol {
1111
/// Configuration.
1212
internal let configuration: VGSCheckoutAddCardConfiguration
1313

14+
// swiftlint:disable all
15+
16+
/// Sub-account id JSON key
17+
private let SUB_ACCOUNT_KEY = "sub_account_id"
18+
19+
// swiftlint:enable all
20+
1421
// MARK: - Initialization
1522

1623
/// Initializer.
@@ -30,28 +37,13 @@ internal class VGSSaveCardPayoptAddCardAPIWorker: VGSSaveCardAPIWorkerProtocol {
3037

3138
vgsCollect.apiClient.customHeader = ["Authorization": "Bearer \(configuration.accessToken)"]
3239

40+
var extraData = [String: Any]()
41+
if let id = configuration.subAccountId {
42+
extraData[SUB_ACCOUNT_KEY] = id
43+
}
3344
let path = "/financial_instruments"
3445

35-
vgsCollect.sendData(path: path, method: .post) { response in
36-
switch response {
37-
case .success(let code, let data, let response):
38-
let requestResult: VGSCheckoutRequestResult = .success(code, data, response, nil)
39-
completion(requestResult)
40-
case .failure(let code, let data, let response, let error):
41-
let requestResult: VGSCheckoutRequestResult = .failure(code, data, response, error, nil)
42-
completion(requestResult)
43-
}
44-
}
45-
}
46-
47-
/// Saves card to create financial instrument.
48-
/// - Parameter completion: `VGSCheckoutRequestResultCompletion` object, completion block.
49-
internal func saveCard(with completion: @escaping VGSCheckoutRequestResultCompletion) {
50-
vgsCollect.apiClient.customHeader = ["Authorization": "Bearer \(configuration.accessToken)"]
51-
52-
let path = "/financial_instruments"
53-
54-
vgsCollect.sendData(path: path, method: .post) { response in
46+
vgsCollect.sendData(path: path, method: .post, extraData: extraData) { response in
5547
switch response {
5648
case .success(let code, let data, let response):
5749
let requestResult: VGSCheckoutRequestResult = .success(code, data, response, nil)
@@ -63,33 +55,6 @@ internal class VGSSaveCardPayoptAddCardAPIWorker: VGSSaveCardAPIWorkerProtocol {
6355
}
6456
}
6557

66-
/// Initiates transfer with fin instrument id and order.
67-
/// - Parameters:
68-
/// - finInstrumentId: `String` object, financial instrument id from payopt.
69-
/// - payment: `VGSCheckoutPayment`, payment data.
70-
/// - completion: `VGSCheckoutRequestResultCompletion` object, completion block.
71-
// internal func initiateTransfer(with finInstrumentId: String, payment: VGSCheckoutPayment, completion: @escaping VGSCheckoutRequestResultCompletion) {
72-
//
73-
// // FIXME: - remove hardcoded order_id
74-
// let transderPayload: [String: Any] = [
75-
// "order_id" : "orderId",
76-
// "financial_instrument_id": finInstrumentId
77-
// ]
78-
//
79-
// let path = "/transfers"
80-
//
81-
// vgsCollect.sendData(path: path, method: .post) { response in
82-
// switch response {
83-
// case .success(let code, let data, let response):
84-
// let requestResult: VGSCheckoutRequestResult = .success(code, data, response, nil)
85-
// completion(requestResult)
86-
// case .failure(let code, let data, let response, let error):
87-
// let requestResult: VGSCheckoutRequestResult = .failure(code, data, response, error, nil)
88-
// completion(requestResult)
89-
// }
90-
// }
91-
// }
92-
9358
/// Financial instrument id from success payopt financial instrument response.
9459
/// - Parameter data: `Data?` object, response data.
9560
/// - Returns: `String?` object, financial instrument id or `nil`.

Sources/VGSCheckoutSDK/Core/Configuration/PaymentOrchestration/AddCard/VGSCheckoutAddCardConfiguration.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public struct VGSCheckoutAddCardConfiguration: VGSCheckoutBasicConfigurationProt
3939

4040
/// `String?`, organization vault inbound route id, could be `nil` when vault has only one route.
4141
public let routeId: String?
42+
43+
/// `String?`, organization sub-acccount id, default `nil`.
44+
public var subAccountId: String?
4245

4346
/// Enable save card option. If enabled - button with option to save card for future payments will be displayed. Default is `true`. Default **save card button** state is `selected`. **NOTE** User choice for save card option will not be stored on VGS side.
4447
public var isSaveCardOptionEnabled: Bool = true

Sources/VGSCheckoutSDK/Core/Configuration/PaymentOrchestration/Payment/VGSCheckoutPaymentConfiguration.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ internal struct VGSCheckoutPaymentConfiguration: VGSCheckoutBasicConfigurationPr
3636

3737
/// `String?`, organization vault inbound route id.
3838
public let routeId: String?
39+
40+
/// `String?`, organization sub-account id, default `nil`.
41+
public var subAccountId: String?
3942

4043
/// Order id.
4144
internal let orderId: String

Sources/VGSCheckoutSDK/Core/Configuration/PaymentOrchestration/VGSCheckoutPayoptBasicConfiguration.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ internal protocol VGSCheckoutPayoptBasicConfiguration {
5252
/// Access token.
5353
var accessToken: String {get}
5454

55+
/// Organization sub-account id.
56+
var subAccountId: String? {get set}
57+
5558
/// Default Inbound route route id created in vault during default integration with payopt on dashboard.
5659
static var defaultPayoptRouteId: String {get}
5760
}

Sources/VGSCheckoutSDK/Helpers/CollectUtils/Extensions/Utils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal class Utils {
4646

4747
/// VGS Checkout SDK Version.
4848
/// Necessary since SPM doesn't track info plist correctly: https://forums.swift.org/t/add-info-plist-on-spm-bundle/40274/5
49-
static let vgsCheckoutVersion: String = "1.3.2"
49+
static let vgsCheckoutVersion: String = "1.3.3"
5050
}
5151

5252
extension Dictionary {

VGSCheckoutDemoApp/VGSCheckoutDemoAppUITests/UseCasesTests/BillingAddress/VGSCheckoutAddressSectionTests.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,43 @@ class VGSCheckoutAddressSectionTests: VGSCheckoutSaveCardBaseTestCase {
4444
// Check success alert.
4545
verifySuccessAlertExists()
4646
}
47+
48+
/// Test add card config when billing address section is hidden.
49+
func testAddCardConfigWhenAddressHidden() {
50+
// Hide billing address section.
51+
app.launchArguments.append(VGSCheckoutUITestsFeature.billingAddressIsHidden.launchArgument)
52+
53+
// Launch app.
54+
app.launch()
55+
56+
// Navigate to Add card config use case.
57+
navigateToPayoptAddCardUseCase()
58+
59+
// Open checkout screen.
60+
startPayoptAddCardCheckout()
61+
62+
// Swipe up to bottom.
63+
app.swipeUp()
64+
65+
// Verify address hints are hidden.
66+
verifyAllAddressFieldsAreHidden()
67+
68+
// Swipe down to up.
69+
app.swipeDown()
70+
71+
// Wait.
72+
wait(forTimeInterval: 0.3)
73+
74+
// Fill in card data.
75+
fillInCorrectCardData()
76+
77+
// Wait for keyboard dismiss.
78+
wait(forTimeInterval: 0.5)
79+
80+
// Tap to save card data.
81+
tapToSaveCardInCheckout()
82+
83+
// Check success alert.
84+
verifySuccessAddCardConfigAlertExists()
85+
}
4786
}

0 commit comments

Comments
 (0)