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

Commit d97b83c

Browse files
authored
Public release 1.3.2
Public release 1.3.2
2 parents 9b627a6 + 7d11a93 commit d97b83c

File tree

142 files changed

+896
-331
lines changed

Some content is hidden

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

142 files changed

+896
-331
lines changed

Sources/VGSCheckoutSDK/Core/Checkout/UseCases/SaveCard/AddressDetails/VGSAddressDataSectionViewModel.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,13 @@ final internal class VGSAddressDataSectionViewModel: VGSBaseFormSectionProtocol,
115115
let validCountries = checkoutConfigurationType.validCountries
116116
let firstCountryISO = VGSAddressCountriesDataProvider.provideFirstCountryISO(for: validCountries)
117117

118-
// Update collect and validation helpers country without postal code.
119-
VGSAddressDataFormConfigurationManager.updatePostalCodeViewIfNeeded(with: firstCountryISO, addressFormView: billingAddressFormView, vgsCollect: vgsCollect, formValidationHelper: formValidationHelper)
118+
if checkoutConfigurationType.isPostalCodeVisible {
119+
// Update collect and validation helpers country without postal code.
120+
VGSAddressDataFormConfigurationManager.updatePostalCodeViewIfNeeded(with: firstCountryISO, addressFormView: billingAddressFormView, vgsCollect: vgsCollect, formValidationHelper: formValidationHelper)
121+
122+
updatePostalCodeField(with: firstCountryISO)
123+
}
120124

121-
updatePostalCodeField(with: firstCountryISO)
122125
updateFormState()
123126
}
124127

@@ -288,19 +291,25 @@ extension VGSAddressDataSectionViewModel: VGSTextFieldViewDelegate {
288291
if let newCountry = VGSCountriesISO(rawValue: currentCountryCode) {
289292

290293
// Update collect and validation helpers country without postal code.
294+
295+
if checkoutConfigurationType.isPostalCodeVisible {
291296
VGSAddressDataFormConfigurationManager.updatePostalCodeViewIfNeeded(with: newCountry, addressFormView: billingAddressFormView, vgsCollect: vgsCollect, formValidationHelper: formValidationHelper)
292297

298+
293299
// Uncomment this code to enable other countries without AWS support
294300
// VGSAddressDataFormConfigurationManager.updateAddressForm(with: newCountry, checkoutConfigurationType: checkoutConfigurationType, addressFormView: billingAddressFormView, vgsCollect: vgsCollect, formValidationHelper: formValidationHelper)
295301

296302
//updateStateField(with: newCountry)
297303
updatePostalCodeField(with: newCountry)
304+
}
298305

299306
// Postal code field configuration has been already updated on previous textChange delegate call. Simulate delegate editing event to refresh state with new configuration.
300307
pickerTextField.delegate?.vgsTextFieldDidChange?(pickerTextField)
301308

302-
if validationBehavior == .onFocus {
303-
formValidationHelper.revalidatePostalCodeFieldIfNeeded()
309+
if checkoutConfigurationType.isPostalCodeVisible {
310+
if validationBehavior == .onFocus {
311+
formValidationHelper.revalidatePostalCodeFieldIfNeeded()
312+
}
304313
}
305314

306315
// Revalidate the entire form - on switching countries previous postal code can be invalid now.

Sources/VGSCheckoutSDK/Core/Configuration/BasicConfig/VGSCheckoutBasicConfigurationProtocol.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,23 @@ internal enum VGSCheckoutConfigurationType {
133133
internal var isAddressVisible: Bool {
134134
switch self {
135135
case .custom(let configuration):
136-
return configuration.billingAddressVisibility == .visible
136+
return configuration.formConfiguration.isBillingAddressVisible
137137
case .payoptAddCard(let configuration):
138-
return configuration.billingAddressVisibility == .visible
138+
return configuration.formConfiguration.isBillingAddressVisible
139139
case .payoptTransfers(let configuration):
140-
return configuration.billingAddressVisibility == .visible
140+
return configuration.formConfiguration.isBillingAddressVisible
141+
}
142+
}
143+
144+
/// `true` if postal code field is visible.
145+
internal var isPostalCodeVisible: Bool {
146+
switch self {
147+
case .custom(let configuration):
148+
return configuration.billingAddressPostalCodeFieldOptions.visibility == .visible
149+
case .payoptAddCard(let configuration):
150+
return configuration.billingAddressPostalCodeFieldOptions.visibility == .visible
151+
case .payoptTransfers(let configuration):
152+
return configuration.billingAddressPostalCodeFieldOptions.visibility == .visible
141153
}
142154
}
143155
}

Sources/VGSCheckoutSDK/Core/Configuration/CustomConfig/Vaullt/VaultFormConfiguration/VGSCustomFormConfiguration.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,27 @@ internal struct VGSCustomFormConfiguration {
2222
/// no:doc
2323
init() {}
2424
}
25+
26+
/// no:doc
27+
internal extension VGSCustomFormConfiguration {
28+
29+
/// `true` if billing address is visible.
30+
var isBillingAddressVisible: Bool {
31+
let isAddressVisible = billingAddressVisibility == .visible
32+
33+
if isAddressVisible == false {
34+
return false
35+
}
36+
37+
let addressFieldsOptions = [addressOptions.countryOptions, addressOptions.addressLine1Options, addressOptions.addressLine2Options, addressOptions.cityOptions, addressOptions.postalCodeOptions].compactMap {return $0 as? VGSCheckoutAddressOptionsProtocol}
38+
39+
// Check if has visible address fields.
40+
let visibleAddressFields = addressFieldsOptions.filter({$0.visibility == .visible})
41+
42+
if visibleAddressFields.isEmpty {
43+
return false
44+
}
45+
46+
return true
47+
}
48+
}

Sources/VGSCheckoutSDK/Core/Configuration/PaymentOrchestration/FormConfiguration/VGSPaymentOrchestrationFormConfiguration.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,27 @@ internal struct VGSPaymentOrchestrationFormConfiguration {
1919
/// no:doc
2020
internal init() {}
2121
}
22+
23+
/// no:doc
24+
internal extension VGSPaymentOrchestrationFormConfiguration {
25+
26+
/// `true` if billing address is visible.
27+
var isBillingAddressVisible: Bool {
28+
let isAddressVisible = billingAddressVisibility == .visible
29+
30+
if isAddressVisible == false {
31+
return false
32+
}
33+
34+
let addressFieldsOptions = [addressOptions.countryOptions, addressOptions.addressLine1Options, addressOptions.addressLine2Options, addressOptions.cityOptions, addressOptions.postalCodeOptions].compactMap {return $0 as? VGSCheckoutAddressOptionsProtocol}
35+
36+
// Check if has visible address fields.
37+
let visibleAddressFields = addressFieldsOptions.filter({$0.visibility == .visible})
38+
39+
if visibleAddressFields.isEmpty {
40+
return false
41+
}
42+
43+
return true
44+
}
45+
}

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.1"
49+
static let vgsCheckoutVersion: String = "1.3.2"
5050
}
5151

5252
extension Dictionary {

VGSCheckoutDemoApp/VGSCheckoutDemoApp.xcodeproj/project.pbxproj

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
4472AC2427FAAC2A005A0870 /* PaymentOrchestrationCustomBackendAPIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4472AC2227FAAC2A005A0870 /* PaymentOrchestrationCustomBackendAPIClient.swift */; };
4141
4472AC2527FAAC2A005A0870 /* CheckoutAddCardVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4472AC2327FAAC2A005A0870 /* CheckoutAddCardVC.swift */; };
4242
44B601CE27F455B800F2CCFA /* VGSCheckoutOnlyPostalCodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44B601CD27F455B800F2CCFA /* VGSCheckoutOnlyPostalCodeTests.swift */; };
43+
44C1E5FB2888FC2C00FF34A8 /* VGSCheckoutAddressSectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C1E5FA2888FC2C00FF34A8 /* VGSCheckoutAddressSectionTests.swift */; };
44+
44C1E5FD288907F100FF34A8 /* VGSCheckoutUITestsAddressFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C1E5FC288907F100FF34A8 /* VGSCheckoutUITestsAddressFields.swift */; };
45+
44C1E5FF288909A200FF34A8 /* VGSCheckoutUITestsAddressField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C1E5FE288909A200FF34A8 /* VGSCheckoutUITestsAddressField.swift */; };
46+
44C1E60128890F7B00FF34A8 /* VGSCheckoutUITestsFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C1E60028890F7B00FF34A8 /* VGSCheckoutUITestsFeature.swift */; };
47+
44C1E603288922A900FF34A8 /* VGSCheckoutBillingAddressFieldsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C1E602288922A900FF34A8 /* VGSCheckoutBillingAddressFieldsTests.swift */; };
48+
44C1E605288933E300FF34A8 /* VGSCheckoutSaveCardBaseTestCase+AddressExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C1E604288933E300FF34A8 /* VGSCheckoutSaveCardBaseTestCase+AddressExtensions.swift */; };
49+
44C1E60828893DB400FF34A8 /* VGSCheckoutSaveCardBaseTestCase+OnFocusAddressValidationExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C1E60728893DB400FF34A8 /* VGSCheckoutSaveCardBaseTestCase+OnFocusAddressValidationExtensions.swift */; };
4350
44C4C9352666012D00195505 /* DemoAppConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C4C9342666012D00195505 /* DemoAppConfiguration.swift */; };
4451
44D520DD26773059005AB588 /* DemoAppResponseParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44D520DC26773059005AB588 /* DemoAppResponseParser.swift */; };
4552
44E10AD0269D7A5A001F0D44 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 44E10AD2269D7A5A001F0D44 /* Localizable.strings */; };
@@ -106,6 +113,13 @@
106113
4472AC2227FAAC2A005A0870 /* PaymentOrchestrationCustomBackendAPIClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PaymentOrchestrationCustomBackendAPIClient.swift; sourceTree = "<group>"; };
107114
4472AC2327FAAC2A005A0870 /* CheckoutAddCardVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckoutAddCardVC.swift; sourceTree = "<group>"; };
108115
44B601CD27F455B800F2CCFA /* VGSCheckoutOnlyPostalCodeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VGSCheckoutOnlyPostalCodeTests.swift; sourceTree = "<group>"; };
116+
44C1E5FA2888FC2C00FF34A8 /* VGSCheckoutAddressSectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VGSCheckoutAddressSectionTests.swift; sourceTree = "<group>"; };
117+
44C1E5FC288907F100FF34A8 /* VGSCheckoutUITestsAddressFields.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VGSCheckoutUITestsAddressFields.swift; sourceTree = "<group>"; };
118+
44C1E5FE288909A200FF34A8 /* VGSCheckoutUITestsAddressField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VGSCheckoutUITestsAddressField.swift; sourceTree = "<group>"; };
119+
44C1E60028890F7B00FF34A8 /* VGSCheckoutUITestsFeature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VGSCheckoutUITestsFeature.swift; sourceTree = "<group>"; };
120+
44C1E602288922A900FF34A8 /* VGSCheckoutBillingAddressFieldsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VGSCheckoutBillingAddressFieldsTests.swift; sourceTree = "<group>"; };
121+
44C1E604288933E300FF34A8 /* VGSCheckoutSaveCardBaseTestCase+AddressExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VGSCheckoutSaveCardBaseTestCase+AddressExtensions.swift"; sourceTree = "<group>"; };
122+
44C1E60728893DB400FF34A8 /* VGSCheckoutSaveCardBaseTestCase+OnFocusAddressValidationExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VGSCheckoutSaveCardBaseTestCase+OnFocusAddressValidationExtensions.swift"; sourceTree = "<group>"; };
109123
44C4C9342666012D00195505 /* DemoAppConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoAppConfiguration.swift; sourceTree = "<group>"; };
110124
44D520DC26773059005AB588 /* DemoAppResponseParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoAppResponseParser.swift; sourceTree = "<group>"; };
111125
44E10AD1269D7A5A001F0D44 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
@@ -323,6 +337,8 @@
323337
children = (
324338
441927D3265F63540080B01E /* UITestsMockedData.plist */,
325339
44282B7B2735248300223A66 /* UITestsConfigurationManager.swift */,
340+
44C1E5FE288909A200FF34A8 /* VGSCheckoutUITestsAddressField.swift */,
341+
44C1E60028890F7B00FF34A8 /* VGSCheckoutUITestsFeature.swift */,
326342
);
327343
path = MockedData;
328344
sourceTree = "<group>";
@@ -389,6 +405,7 @@
389405
isa = PBXGroup;
390406
children = (
391407
44282B742735210200223A66 /* VGSCheckoutTestFeature.swift */,
408+
44C1E5FC288907F100FF34A8 /* VGSCheckoutUITestsAddressFields.swift */,
392409
);
393410
path = CheckoutFeature;
394411
sourceTree = "<group>";
@@ -451,6 +468,7 @@
451468
isa = PBXGroup;
452469
children = (
453470
445C126626F9996700D6F3DD /* VGSCheckoutSaveCardBaseTestCase.swift */,
471+
44C1E60628893D9000FF34A8 /* SaveCard+Extensions */,
454472
);
455473
path = SaveCard;
456474
sourceTree = "<group>";
@@ -494,10 +512,21 @@
494512
isa = PBXGroup;
495513
children = (
496514
44B601CD27F455B800F2CCFA /* VGSCheckoutOnlyPostalCodeTests.swift */,
515+
44C1E5FA2888FC2C00FF34A8 /* VGSCheckoutAddressSectionTests.swift */,
516+
44C1E602288922A900FF34A8 /* VGSCheckoutBillingAddressFieldsTests.swift */,
497517
);
498518
path = BillingAddress;
499519
sourceTree = "<group>";
500520
};
521+
44C1E60628893D9000FF34A8 /* SaveCard+Extensions */ = {
522+
isa = PBXGroup;
523+
children = (
524+
44C1E604288933E300FF34A8 /* VGSCheckoutSaveCardBaseTestCase+AddressExtensions.swift */,
525+
44C1E60728893DB400FF34A8 /* VGSCheckoutSaveCardBaseTestCase+OnFocusAddressValidationExtensions.swift */,
526+
);
527+
path = "SaveCard+Extensions";
528+
sourceTree = "<group>";
529+
};
501530
44C4C9332666011A00195505 /* Configuration */ = {
502531
isa = PBXGroup;
503532
children = (
@@ -773,6 +802,7 @@
773802
buildActionMask = 2147483647;
774803
files = (
775804
441927CD265F62D10080B01E /* AppDelegate.swift in Sources */,
805+
44C1E5FF288909A200FF34A8 /* VGSCheckoutUITestsAddressField.swift in Sources */,
776806
441927DA265F65040080B01E /* ShoppingCartItemView.swift in Sources */,
777807
4403862026CBCA5C0056F2BA /* CheckoutDemoDialogHelper.swift in Sources */,
778808
441927E0265F67DE0080B01E /* ShoppingCartView.swift in Sources */,
@@ -788,6 +818,7 @@
788818
44282B7C2735248400223A66 /* UITestsConfigurationManager.swift in Sources */,
789819
44FC9F76265FC4F7001CDD79 /* DemoInsetContainerView.swift in Sources */,
790820
44FC9F79265FC6B9001CDD79 /* UIColor+Extensions.swift in Sources */,
821+
44C1E60128890F7B00FF34A8 /* VGSCheckoutUITestsFeature.swift in Sources */,
791822
441927EB265FA3E60080B01E /* UIFont+Extensions.swift in Sources */,
792823
441927E3265F6ACE0080B01E /* OrderItem.swift in Sources */,
793824
);
@@ -809,10 +840,15 @@
809840
445C126326F998C000D6F3DD /* VGSCheckoutCustomConfigFlow.swift in Sources */,
810841
445C126C26F99A2900D6F3DD /* VGSUITestElementType.swift in Sources */,
811842
445C126F26F99A6300D6F3DD /* XCTestCase+Extensions.swift in Sources */,
843+
44C1E5FD288907F100FF34A8 /* VGSCheckoutUITestsAddressFields.swift in Sources */,
812844
445C125E26F996DB00D6F3DD /* VGSCheckoutDemoAppBaseTestCase.swift in Sources */,
845+
44C1E60828893DB400FF34A8 /* VGSCheckoutSaveCardBaseTestCase+OnFocusAddressValidationExtensions.swift in Sources */,
813846
44125747280687F500C27A34 /* VGSCheckoutPayotAddCardConfigFlowTests.swift in Sources */,
814847
445C126726F9996700D6F3DD /* VGSCheckoutSaveCardBaseTestCase.swift in Sources */,
815848
445C127126F99A8F00D6F3DD /* XCUIElement+Extensions.swift in Sources */,
849+
44C1E603288922A900FF34A8 /* VGSCheckoutBillingAddressFieldsTests.swift in Sources */,
850+
44C1E5FB2888FC2C00FF34A8 /* VGSCheckoutAddressSectionTests.swift in Sources */,
851+
44C1E605288933E300FF34A8 /* VGSCheckoutSaveCardBaseTestCase+AddressExtensions.swift in Sources */,
816852
44282B752735210200223A66 /* VGSCheckoutTestFeature.swift in Sources */,
817853
44B601CE27F455B800F2CCFA /* VGSCheckoutOnlyPostalCodeTests.swift in Sources */,
818854
445C126A26F99A0700D6F3DD /* VGSUITestElement.swift in Sources */,

0 commit comments

Comments
 (0)