From 17e862dc69bdb7f62d5b36eb5aa662877be88fc0 Mon Sep 17 00:00:00 2001 From: Elikem Savie Date: Fri, 19 Jul 2024 10:56:22 +0000 Subject: [PATCH] Make provisions for edge cases --- .../MangopayDemo/MangopayDemo/PrivacyInfo.xcprivacy | 10 ++++++++-- .../MangopayCheckoutForm/Views/MGPPaymentForm.swift | 13 +++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Examples/MangopayDemo/MangopayDemo/PrivacyInfo.xcprivacy b/Examples/MangopayDemo/MangopayDemo/PrivacyInfo.xcprivacy index 7b1b894..74ecee0 100644 --- a/Examples/MangopayDemo/MangopayDemo/PrivacyInfo.xcprivacy +++ b/Examples/MangopayDemo/MangopayDemo/PrivacyInfo.xcprivacy @@ -5,13 +5,19 @@ NSPrivacyAccessedAPITypes + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults NSPrivacyAccessedAPITypeReasons - 35F9.1 + CA92.1 + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons - + DDA9.1 diff --git a/MangopayCheckoutSDK/MangopayCheckoutForm/Views/MGPPaymentForm.swift b/MangopayCheckoutSDK/MangopayCheckoutForm/Views/MGPPaymentForm.swift index dd0f3cf..efe9b9a 100644 --- a/MangopayCheckoutSDK/MangopayCheckoutForm/Views/MGPPaymentForm.swift +++ b/MangopayCheckoutSDK/MangopayCheckoutForm/Views/MGPPaymentForm.swift @@ -307,7 +307,7 @@ public class MGPPaymentForm: UIView, FormValidatable { private func formatExpiryDate(_ text: String) -> String { var cleanedText = text.replacingOccurrences(of: "/", with: "") - + if cleanedText.isEmpty { return "" } @@ -321,7 +321,16 @@ public class MGPPaymentForm: UIView, FormValidatable { cleanedText = "0" + cleanedText } } - + + if cleanedText.count == 2 { + let firstDigit = cleanedText.first + let secondDigit = cleanedText[cleanedText.index(cleanedText.startIndex, offsetBy: 1)] + + if let digit = secondDigit.wholeNumberValue, digit > 2 && digit < 10 && firstDigit?.wholeNumberValue == 1 { + cleanedText.replaceSubrange(cleanedText.startIndex...cleanedText.startIndex, with: "0\(cleanedText.first!)") + } + } + if cleanedText.count > 2 { let index = cleanedText.index(cleanedText.startIndex, offsetBy: 2) cleanedText.insert("/", at: index)