Repository: gini/gini-mobile-ios
Pull request #826: Pp 1103 i os implement sdk flag for instant payment
Author: login: mrkulik
Created: 2025-04-04T07:39:39Z | Merged: 2025-04-07T11:24:04Z



Diff:
diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankConfiguration.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankConfiguration.swift
index c89a007772..db92372c04 100644
--- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankConfiguration.swift
+++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankConfiguration.swift
@@ -345,6 +345,13 @@ public final class GiniBankConfiguration: NSObject {
     /// that implements the protocol.
     public var transactionDocsDataCoordinator: TransactionDocsDataProtocol = TransactionDocsDataCoordinator()
 
+    // MARK: - Instant Payment feature
+
+    /**
+     * Indicates whether the Instant Payment feature is enabled.
+     */
+    public var instantPaymentEnabled: Bool = false
+
     /**
      Set the entry point used for launching the Gini Bank SDK.
      Default value is `GiniEntryPoint.button`.
diff --git a/BankSDK/GiniBankSDKExample/GiniBankSDKExample/SettingsViewController/SettingsViewController+SwitchOptionModel.swift b/BankSDK/GiniBankSDKExample/GiniBankSDKExample/SettingsViewController/SettingsViewController+SwitchOptionModel.swift
index 40ac979773..5c033afe42 100644
--- a/BankSDK/GiniBankSDKExample/GiniBankSDKExample/SettingsViewController/SettingsViewController+SwitchOptionModel.swift
+++ b/BankSDK/GiniBankSDKExample/GiniBankSDKExample/SettingsViewController/SettingsViewController+SwitchOptionModel.swift
@@ -56,6 +56,7 @@ struct SwitchOptionModel {
         case skontoHelpNavigationBarBottomAdapter
         case skontoEnabled
         case transactionDocsEnabled
+        case instantPaymentEnabled
         case closeSDK
 
 		var title: String {
@@ -152,6 +153,8 @@ struct SwitchOptionModel {
 				return "Custom Gini error logger"
 			case .debugModeOn:
 				return "Debug mode"
+            case .instantPaymentEnabled:
+                return "Instant Payment feature"
             case .closeSDK:
                 return "Close SDK"
             }
diff --git a/BankSDK/GiniBankSDKExample/GiniBankSDKExample/SettingsViewController/SettingsViewModel.swift b/BankSDK/GiniBankSDKExample/GiniBankSDKExample/SettingsViewController/SettingsViewModel.swift
index ff68f6e482..3b4c42388e 100644
--- a/BankSDK/GiniBankSDKExample/GiniBankSDKExample/SettingsViewController/SettingsViewModel.swift
+++ b/BankSDK/GiniBankSDKExample/GiniBankSDKExample/SettingsViewController/SettingsViewModel.swift
@@ -113,6 +113,8 @@ final class SettingsViewModel {
                                                                      isSwitchOn: giniConfiguration.skontoEnabled)))
         featureTogglesSection.items.append(.switchOption(data: .init(type: .transactionDocsEnabled,
                                                                      isSwitchOn: giniConfiguration.transactionDocsEnabled)))
+        featureTogglesSection.items.append(.switchOption(data: .init(type: .instantPaymentEnabled,
+                                                                     isSwitchOn: giniConfiguration.instantPaymentEnabled)))
         return featureTogglesSection
     }
 
@@ -353,6 +355,8 @@ final class SettingsViewModel {
             giniConfiguration.skontoHelpNavigationBarBottomAdapter = data.isSwitchOn ? CustomBottomNavigationBarAdapter() : nil
         case .closeSDK:
             Self.shouldCloseSDKAfterTenSeconds = data.isSwitchOn
+        case .instantPaymentEnabled:
+            giniConfiguration.instantPaymentEnabled = data.isSwitchOn
         }
     }
 
diff --git a/BankSDK/GiniBankSDKExample/Tests/UnitTests/SettingsViewControllerTests.swift b/BankSDK/GiniBankSDKExample/Tests/UnitTests/SettingsViewControllerTests.swift
index 41a3fe18a2..8f98ced5aa 100644
--- a/BankSDK/GiniBankSDKExample/Tests/UnitTests/SettingsViewControllerTests.swift
+++ b/BankSDK/GiniBankSDKExample/Tests/UnitTests/SettingsViewControllerTests.swift
@@ -2104,6 +2104,45 @@ extension SettingsViewModelTests {
         }
     }
 
+    // MARK: - Instant Payment
+
+    func testInstantPaymentSwitchOn() {
+        guard let index = getSwitchOptionIndex(for: .instantPaymentEnabled) else {
+            XCTFail("`instantPaymentEnabled` option not found in sectionData")
+            return
+        }
+        
+        if case .switchOption(var data) = contentData[index.section].items[index.row] {
+            guard data.type == .instantPaymentEnabled else {
+                XCTFail("Expected type `instantPaymentEnabled`, found a different one: \(data.type)")
+                return
+            }
+            data.isSwitchOn = true
+            configuration.instantPaymentEnabled = data.isSwitchOn
+            
+            XCTAssertTrue(configuration.instantPaymentEnabled,
+                          "instantPaymentEnabled should be true in the gini configuration")
+        }
+    }
+
+    func testInstantPaymentSwitchOff() {
+        guard let index = getSwitchOptionIndex(for: .instantPaymentEnabled) else {
+            XCTFail("`instantPaymentEnabled` option not found in sectionData")
+            return
+        }
+        
+        if case .switchOption(var data) = contentData[index.section].items[index.row] {
+            guard data.type == .instantPaymentEnabled else {
+                XCTFail("Expected type `instantPaymentEnabled`, found a different one: \(data.type)")
+                return
+            }
+            data.isSwitchOn = false
+            configuration.instantPaymentEnabled = data.isSwitchOn
+            
+            XCTAssertFalse(configuration.instantPaymentEnabled,
+                           "instantPaymentEnabled should be false in the gini configuration")
+        }
+    }
 }
 
 extension SettingsViewModelTests: GiniCaptureErrorLoggerDelegate {


Reviews:
user: login: ValentinaIancu-Gini
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-04T10:30:26Z
user: login: ValentinaIancu-Gini
body: @mrkulik Please check my last small clarification questions. Thank you!
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-07T09:58:40Z
user: login: ValentinaIancu-Gini
body: @mrkulik Thank you! All good now!
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-07T11:09:27Z

Review comments:
diff_hunk: @@ -152,6 +153,8 @@ struct SwitchOptionModel {
 				return "Custom Gini error logger"
 			case .debugModeOn:
 				return "Debug mode"
+            case .instantPayment:
path: BankSDK/GiniBankSDKExample/GiniBankSDKExample/SettingsViewController/SettingsViewController+SwitchOptionModel.swift
user: login: ValentinaIancu-Gini
body: [Suggestion] @mrkulik for consistency, please rename this to `instantPaymentEnabled`.
created_at: 2025-04-04T10:29:03Z
author_association: CONTRIBUTOR
diff_hunk: @@ -2104,6 +2104,45 @@ extension SettingsViewModelTests {
         }
     }
 
+    // MARK: - Instant Payment
+
+    func testInstantPaymentSwitchOn() {
+        guard let index = getSwitchOptionIndex(for: .instantPaymentEnabled) else {
+            XCTFail("`instantPayment` option not found in sectionData")
+            return
+        }
+        
+        if case .switchOption(var data) = contentData[index.section].items[index.row] {
+            guard data.type == .instantPaymentEnabled else {
+                XCTFail("Expected type `instantPayment`, found a different one: \(data.type)")
+                return
+            }
+            data.isSwitchOn = true
+            configuration.instantPaymentEnabled = data.isSwitchOn
+            
+            XCTAssertTrue(configuration.instantPaymentEnabled,
+                          "instantPayment should be enabled in the gini configuration")
+        }
+    }
+
+    func testInstantPaymentSwitchOff() {
+        guard let index = getSwitchOptionIndex(for: .instantPaymentEnabled) else {
+            XCTFail("`instantPayment` option not found in sectionData")
+            return
+        }
+        
+        if case .switchOption(var data) = contentData[index.section].items[index.row] {
+            guard data.type == .instantPaymentEnabled else {
+                XCTFail("Expected type `instantPayment`, found a different one: \(data.type)")
path: BankSDK/GiniBankSDKExample/Tests/UnitTests/SettingsViewControllerTests.swift
user: login: ValentinaIancu-Gini
body: [Clarification] @mrkulik should be here `instantPaymentEnabled` instead of `instantPayment`?
created_at: 2025-04-07T09:57:48Z
author_association: CONTRIBUTOR
diff_hunk: @@ -2104,6 +2104,45 @@ extension SettingsViewModelTests {
         }
     }
 
+    // MARK: - Instant Payment
+
+    func testInstantPaymentSwitchOn() {
+        guard let index = getSwitchOptionIndex(for: .instantPaymentEnabled) else {
+            XCTFail("`instantPayment` option not found in sectionData")
+            return
+        }
+        
+        if case .switchOption(var data) = contentData[index.section].items[index.row] {
+            guard data.type == .instantPaymentEnabled else {
+                XCTFail("Expected type `instantPayment`, found a different one: \(data.type)")
path: BankSDK/GiniBankSDKExample/Tests/UnitTests/SettingsViewControllerTests.swift
user: login: ValentinaIancu-Gini
body: [Clarification] @mrkulik should be here `instantPaymentEnabled` instead of `instantPayment`?
created_at: 2025-04-07T09:57:52Z
author_association: CONTRIBUTOR
diff_hunk: @@ -2104,6 +2104,45 @@ extension SettingsViewModelTests {
         }
     }
 
+    // MARK: - Instant Payment
+
+    func testInstantPaymentSwitchOn() {
+        guard let index = getSwitchOptionIndex(for: .instantPaymentEnabled) else {
+            XCTFail("`instantPayment` option not found in sectionData")
+            return
+        }
+        
+        if case .switchOption(var data) = contentData[index.section].items[index.row] {
+            guard data.type == .instantPaymentEnabled else {
+                XCTFail("Expected type `instantPayment`, found a different one: \(data.type)")
+                return
+            }
+            data.isSwitchOn = true
+            configuration.instantPaymentEnabled = data.isSwitchOn
+            
+            XCTAssertTrue(configuration.instantPaymentEnabled,
+                          "instantPayment should be enabled in the gini configuration")
+        }
+    }
+
+    func testInstantPaymentSwitchOff() {
+        guard let index = getSwitchOptionIndex(for: .instantPaymentEnabled) else {
+            XCTFail("`instantPayment` option not found in sectionData")
path: BankSDK/GiniBankSDKExample/Tests/UnitTests/SettingsViewControllerTests.swift
user: login: ValentinaIancu-Gini
body: [Clarification] @mrkulik should be here `instantPaymentEnabled` instead of `instantPayment`?
created_at: 2025-04-07T09:58:10Z
author_association: CONTRIBUTOR

PR comments:
user: login: sonarqubecloud[bot]
created_at: 2025-04-07T10:32:38Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=gini_gini-mobile-ios&pullRequest=826) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=gini_gini-mobile-ios&pullRequest=826&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=gini_gini-mobile-ios&pullRequest=826&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=gini_gini-mobile-ios&pullRequest=826&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=gini_gini-mobile-ios&pullRequest=826&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=gini_gini-mobile-ios&pullRequest=826&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=gini_gini-mobile-ios&pullRequest=826)


author_association: NONE
user: login: mrkulik
created_at: 2025-04-07T11:23:55Z
body: @ValentinaIancu-Gini thank you!
author_association: CONTRIBUTOR