@jimrising/easymerchantsdk-react-native 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/ios/Pods/UserDefaults/UserStoreSingleton.swift +304 -0
- package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +2636 -0
- package/ios/Pods/ViewControllers/BaseVC.swift +141 -0
- package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +3347 -0
- package/ios/Pods/ViewControllers/BillingInfoVC/Cells/CityListTVC.swift +46 -0
- package/ios/Pods/ViewControllers/BillingInfoVC/Cells/CountryListTVC.swift +47 -0
- package/ios/Pods/ViewControllers/BillingInfoVC/Cells/StateListTVC.swift +46 -0
- package/ios/Pods/ViewControllers/CountryListVC.swift +435 -0
- package/ios/Pods/ViewControllers/CustomOverlay.swift +199 -0
- package/ios/Pods/ViewControllers/EmailVerificationVC.swift +307 -0
- package/ios/Pods/ViewControllers/GrailPayVC.swift +244 -0
- package/ios/Pods/ViewControllers/OTPVerificationVC.swift +2066 -0
- package/ios/Pods/ViewControllers/PaymentDoneVC.swift +272 -0
- package/ios/Pods/ViewControllers/PaymentErrorVC.swift +85 -0
- package/ios/Pods/ViewControllers/PaymentInformation/AccountTypeTVC.swift +41 -0
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +11025 -0
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInformationCVC.swift +35 -0
- package/ios/Pods/ViewControllers/PaymentInformation/RecurringTVC.swift +40 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.swift +81 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.xib +163 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedCardsTVC/SavedCardsTVC.swift +81 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedCardsTVC/SavedCardsTVC.xib +188 -0
- package/ios/Pods/ViewControllers/PaymentStatusWebViewVC.swift +167 -0
- package/ios/Pods/ViewControllers/TermAndConditionsVC.swift +63 -0
- package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +629 -0
- package/ios/easymerchantsdk.podspec +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
////
|
|
2
|
+
//// CustomOverlay.swift
|
|
3
|
+
//// EasyPay
|
|
4
|
+
////
|
|
5
|
+
//// Created by Mony's Mac on 21/03/25.
|
|
6
|
+
////
|
|
7
|
+
//
|
|
8
|
+
////import BlinkCard
|
|
9
|
+
//
|
|
10
|
+
//protocol CustomOverlayDelegate: AnyObject {
|
|
11
|
+
// func didFinishScanningCard(cardNumber: String, expiryDate: String, cvv: String, nameOnCard: String)
|
|
12
|
+
//}
|
|
13
|
+
//
|
|
14
|
+
//class CustomOverlay: MBCCustomOverlayViewController, MBCScanningRecognizerRunnerViewControllerDelegate,
|
|
15
|
+
// MBCFirstSideFinishedRecognizerRunnerViewControllerDelegate {
|
|
16
|
+
//
|
|
17
|
+
// @IBOutlet weak var tooltipLabel: UILabel!
|
|
18
|
+
// @IBOutlet weak var centerView: UIView!
|
|
19
|
+
// @IBOutlet weak var lblScanCardCount: UILabel!
|
|
20
|
+
// @IBOutlet weak var btnRotate: UIButton!
|
|
21
|
+
// @IBOutlet weak var imgProcessing: UIImageView!
|
|
22
|
+
//
|
|
23
|
+
// var currentScanStep = 1 // Start with 1 for the first scan step
|
|
24
|
+
//
|
|
25
|
+
// var blinkCardEditScreen: MBCBlinkCardEditViewController?
|
|
26
|
+
// var blinkcardNavigationViewController: MBCBlinkCardEditNavigationController?
|
|
27
|
+
// var blinkCardRecognizerResult: MBCBlinkCardRecognizerResult?
|
|
28
|
+
//
|
|
29
|
+
// static func initFromStoryboard() -> CustomOverlay {
|
|
30
|
+
// let viewController = UIStoryboard(name: "easymerchantsdk", bundle: .easyPayBundle).instantiateViewController(withIdentifier: "CustomOverlay")
|
|
31
|
+
//
|
|
32
|
+
// guard let customOverlay = viewController as? CustomOverlay else {
|
|
33
|
+
// fatalError("CustomOverlay should always be an instance of \(CustomOverlay.self) here because we instantiate it from the Storyboard")
|
|
34
|
+
// }
|
|
35
|
+
//
|
|
36
|
+
// return customOverlay
|
|
37
|
+
// }
|
|
38
|
+
//
|
|
39
|
+
// weak var delegate: CustomOverlayDelegate?
|
|
40
|
+
//
|
|
41
|
+
// override func viewDidLoad() {
|
|
42
|
+
// super.viewDidLoad()
|
|
43
|
+
//
|
|
44
|
+
// super.scanningRecognizerRunnerViewControllerDelegate = self
|
|
45
|
+
// super.metadataDelegates.firstSideFinishedRecognizerRunnerViewControllerDelegate = self
|
|
46
|
+
//
|
|
47
|
+
// lblScanCardCount.text = "Scan Card (1/2)"
|
|
48
|
+
//
|
|
49
|
+
// centerView.layer.borderColor = UIColor.white.cgColor
|
|
50
|
+
// centerView.layer.borderWidth = 2.0
|
|
51
|
+
// centerView.layer.cornerRadius = 8.0
|
|
52
|
+
//
|
|
53
|
+
// imgProcessing.image = UIImage(systemName: "exclamationmark.circle")
|
|
54
|
+
// tooltipLabel.text = "Place the front side of your card inside the frame"
|
|
55
|
+
// }
|
|
56
|
+
//
|
|
57
|
+
// func updateScanProgress() {
|
|
58
|
+
// if currentScanStep < 2 {
|
|
59
|
+
// currentScanStep += 1
|
|
60
|
+
// lblScanCardCount.text = "Scan Card (\(currentScanStep)/2)"
|
|
61
|
+
// }
|
|
62
|
+
// }
|
|
63
|
+
//
|
|
64
|
+
// func showBorderColorForOneSeconds() {
|
|
65
|
+
// centerView.layer.borderColor = UIColor.green.cgColor
|
|
66
|
+
// centerView.layer.borderWidth = 2.0
|
|
67
|
+
// centerView.layer.cornerRadius = 8.0
|
|
68
|
+
//
|
|
69
|
+
// DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
|
70
|
+
// self.centerView.layer.borderColor = UIColor.white.cgColor
|
|
71
|
+
// self.centerView.layer.borderWidth = 2.0
|
|
72
|
+
// }
|
|
73
|
+
// }
|
|
74
|
+
//
|
|
75
|
+
// func recognizerRunnerViewControllerDidFinishScanning(_ recognizerRunnerViewController: UIViewController & MBCRecognizerRunnerViewController, state: MBCRecognizerResultState) {
|
|
76
|
+
// if state == .valid {
|
|
77
|
+
// recognizerRunnerViewController.pauseScanning()
|
|
78
|
+
//
|
|
79
|
+
// DispatchQueue.main.async {
|
|
80
|
+
// self.showBorderColorForOneSeconds()
|
|
81
|
+
//
|
|
82
|
+
// // Show loader while processing final results
|
|
83
|
+
// self.imgProcessing.image = UIImage(named: "loaderImage")
|
|
84
|
+
// self.tooltipLabel.text = "Keep it in frame while we’re processing..."
|
|
85
|
+
// self.startRotationAnimation(on: self.imgProcessing)
|
|
86
|
+
//
|
|
87
|
+
// for recognizer in self.recognizerCollection.recognizerList where recognizer.baseResult?.resultState == .valid {
|
|
88
|
+
// if recognizer is MBCBlinkCardRecognizer {
|
|
89
|
+
// let blinkCardRecognizer = recognizer as? MBCBlinkCardRecognizer
|
|
90
|
+
// self.blinkCardRecognizerResult = blinkCardRecognizer?.result
|
|
91
|
+
// }
|
|
92
|
+
// }
|
|
93
|
+
//
|
|
94
|
+
// self.imgProcessing.image = UIImage(named: "check")
|
|
95
|
+
// self.tooltipLabel.text = "Done"
|
|
96
|
+
// self.stopRotationAnimation(on: self.imgProcessing)
|
|
97
|
+
//
|
|
98
|
+
// guard let blinkCardResult = self.blinkCardRecognizerResult else { return }
|
|
99
|
+
//
|
|
100
|
+
// // Extract card details
|
|
101
|
+
// let cardNumber = blinkCardResult.cardNumber
|
|
102
|
+
// let expiryDate = "\(blinkCardResult.expiryDate.month)/\(blinkCardResult.expiryDate.year)"
|
|
103
|
+
// let cvv = blinkCardResult.cvv
|
|
104
|
+
// let nameOnCard = blinkCardResult.owner
|
|
105
|
+
//
|
|
106
|
+
// // Pass data to delegate
|
|
107
|
+
// self.delegate?.didFinishScanningCard(cardNumber: cardNumber, expiryDate: expiryDate, cvv: cvv, nameOnCard: nameOnCard)
|
|
108
|
+
//
|
|
109
|
+
// // Dismiss the scanner
|
|
110
|
+
// recognizerRunnerViewController.dismiss(animated: true, completion: nil)
|
|
111
|
+
// }
|
|
112
|
+
// }
|
|
113
|
+
// }
|
|
114
|
+
//
|
|
115
|
+
// func recognizerRunnerViewControllerDidFinishRecognition(ofFirstSide recognizerRunnerViewController: UIViewController & MBCRecognizerRunnerViewController) {
|
|
116
|
+
// DispatchQueue.main.async {
|
|
117
|
+
// // Show loader image during scanning
|
|
118
|
+
// self.imgProcessing.image = UIImage(named: "loaderImage", in: .easyPayBundle, with: nil)
|
|
119
|
+
// self.tooltipLabel.text = "Keep it in frame while we’re processing..."
|
|
120
|
+
// self.startRotationAnimation(on: self.imgProcessing)
|
|
121
|
+
//
|
|
122
|
+
// self.updateScanProgress()
|
|
123
|
+
// self.showBorderColorForOneSeconds()
|
|
124
|
+
//
|
|
125
|
+
// // Update tooltip and show check image after completing the first side
|
|
126
|
+
// DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
|
127
|
+
// self.imgProcessing.image = UIImage(named: "check", in: .easyPayBundle, with: nil)
|
|
128
|
+
// self.tooltipLabel.text = "Done"
|
|
129
|
+
// self.stopRotationAnimation(on: self.imgProcessing)
|
|
130
|
+
//
|
|
131
|
+
// DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
|
132
|
+
// self.imgProcessing.image = UIImage(systemName: "exclamationmark.circle")
|
|
133
|
+
// self.tooltipLabel.text = "Place the back side of your card inside the frame"
|
|
134
|
+
// self.stopRotationAnimation(on: self.imgProcessing)
|
|
135
|
+
// }
|
|
136
|
+
// }
|
|
137
|
+
// }
|
|
138
|
+
// }
|
|
139
|
+
//
|
|
140
|
+
// func startRotationAnimation(on imageView: UIImageView) {
|
|
141
|
+
// let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation")
|
|
142
|
+
// rotationAnimation.fromValue = 0
|
|
143
|
+
// rotationAnimation.toValue = CGFloat.pi * 2
|
|
144
|
+
// rotationAnimation.duration = 1.0 // Duration of one full rotation
|
|
145
|
+
// rotationAnimation.repeatCount = Float.infinity // Repeat indefinitely
|
|
146
|
+
// imageView.layer.add(rotationAnimation, forKey: "rotationAnimation")
|
|
147
|
+
// }
|
|
148
|
+
//
|
|
149
|
+
// func stopRotationAnimation(on imageView: UIImageView) {
|
|
150
|
+
// imageView.layer.removeAnimation(forKey: "rotationAnimation")
|
|
151
|
+
// }
|
|
152
|
+
//
|
|
153
|
+
// @IBAction func didTapClose(_ sender: Any) {
|
|
154
|
+
// self.recognizerRunnerViewController?.overlayViewControllerWillCloseCamera(self)
|
|
155
|
+
// self.dismiss(animated: true, completion: nil)
|
|
156
|
+
// }
|
|
157
|
+
//
|
|
158
|
+
// func showEditScreen(blinkCardRecognizerResult: MBCBlinkCardRecognizerResult) {
|
|
159
|
+
// blinkCardEditScreen = MBCBlinkCardEditViewController(blinkCardRecognizerResult: blinkCardRecognizerResult, fieldConfiguration: MBCBlinkCardEditFieldConfiguration(), delegate: self)
|
|
160
|
+
// blinkcardNavigationViewController = MBCBlinkCardEditNavigationController(rootViewController: blinkCardEditScreen!)
|
|
161
|
+
// self.present(blinkcardNavigationViewController!, animated: true, completion: nil)
|
|
162
|
+
// }
|
|
163
|
+
//
|
|
164
|
+
// @IBAction func actionBtnRotate(_ sender: UIButton) {
|
|
165
|
+
// UIView.animate(withDuration: 0.5, animations: {
|
|
166
|
+
// // Rotate the centerView by 180 degrees
|
|
167
|
+
// self.centerView.transform = self.centerView.transform.rotated(by: .pi/2)
|
|
168
|
+
// })
|
|
169
|
+
// }
|
|
170
|
+
//
|
|
171
|
+
//}
|
|
172
|
+
//
|
|
173
|
+
//extension CustomOverlay: MBCBlinkCardEditViewControllerDelegate {
|
|
174
|
+
// func blinkCardEditViewControllerDidFinishEditing(_ blinkCardEditViewController: MBCBlinkCardEditViewController, editResult: MBCBlinkCardEditResult) {
|
|
175
|
+
// self.recognizerRunnerViewController?.pauseScanning()
|
|
176
|
+
//
|
|
177
|
+
// DispatchQueue.main.async {
|
|
178
|
+
// let alertController: UIAlertController = UIAlertController.init(title: "BlinkCard Edit Results", message: editResult.description, preferredStyle: .alert)
|
|
179
|
+
//
|
|
180
|
+
// let okAction: UIAlertAction = UIAlertAction.init(title: "OK", style: .default, handler: { (action) -> Void in
|
|
181
|
+
// self.blinkCardEditScreen?.dismiss(animated: true, completion: nil)
|
|
182
|
+
// self.dismiss(animated: true, completion: nil)
|
|
183
|
+
// })
|
|
184
|
+
// alertController.addAction(okAction)
|
|
185
|
+
// blinkCardEditViewController.present(alertController, animated: true, completion: nil)
|
|
186
|
+
// }
|
|
187
|
+
// }
|
|
188
|
+
//
|
|
189
|
+
// func blinkCardEditViewControllerDidTapClose(_ blinkCardEditViewController: MBCBlinkCardEditViewController) {
|
|
190
|
+
// DispatchQueue.main.async {
|
|
191
|
+
// blinkCardEditViewController.dismiss(animated: true, completion: nil)
|
|
192
|
+
// }
|
|
193
|
+
// }
|
|
194
|
+
//}
|
|
195
|
+
//
|
|
196
|
+
//
|
|
197
|
+
//
|
|
198
|
+
//
|
|
199
|
+
//
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
//
|
|
2
|
+
// EmailVerficationVC.swift
|
|
3
|
+
// EasyPay
|
|
4
|
+
//
|
|
5
|
+
// Created by Mony's Mac on 14/08/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import UIKit
|
|
9
|
+
|
|
10
|
+
class EmailVerificationVC: BaseVC {
|
|
11
|
+
|
|
12
|
+
@IBOutlet weak var lblUsedSavedInfo: UILabel!
|
|
13
|
+
@IBOutlet weak var subLblUsedSavedInfo: UILabel!
|
|
14
|
+
@IBOutlet weak var txtFieldEmail: UITextField!
|
|
15
|
+
@IBOutlet weak var btnGetOTP: UIButton!
|
|
16
|
+
|
|
17
|
+
var cardNumber: String?
|
|
18
|
+
var expiryDate: String?
|
|
19
|
+
var cvv: String?
|
|
20
|
+
var nameOnCard: String?
|
|
21
|
+
var userEmail: String?
|
|
22
|
+
var billingInfoData: Data?
|
|
23
|
+
|
|
24
|
+
var amount: Int?
|
|
25
|
+
|
|
26
|
+
var chosenPlan: String?
|
|
27
|
+
var startDate: String?
|
|
28
|
+
|
|
29
|
+
var selectedPaymentMethod: String?
|
|
30
|
+
|
|
31
|
+
//Banking Params
|
|
32
|
+
var accountName: String?
|
|
33
|
+
var routingNumber: String?
|
|
34
|
+
var accountType: String?
|
|
35
|
+
var accountNumber: String?
|
|
36
|
+
|
|
37
|
+
var easyPayDelegate: EasyPayViewControllerDelegate?
|
|
38
|
+
|
|
39
|
+
var isSavedForFuture: Bool = false
|
|
40
|
+
|
|
41
|
+
//GrailPay Params
|
|
42
|
+
var grailPayAccountID: String?
|
|
43
|
+
var selectedGrailPayAccountType: String?
|
|
44
|
+
var selectedGrailPayAccountName: String?
|
|
45
|
+
|
|
46
|
+
var request: Request!
|
|
47
|
+
|
|
48
|
+
var fieldSection: FieldSection?
|
|
49
|
+
var additionalInfo: [FieldItem]?
|
|
50
|
+
var billingInfo: [FieldItem]?
|
|
51
|
+
var visibility: FieldsVisibility?
|
|
52
|
+
|
|
53
|
+
var isSavedNewAccount: Bool?
|
|
54
|
+
var isFrom = String()
|
|
55
|
+
|
|
56
|
+
var isSavedNewCard: Bool = false
|
|
57
|
+
|
|
58
|
+
override func viewDidLoad() {
|
|
59
|
+
super.viewDidLoad()
|
|
60
|
+
|
|
61
|
+
uiFinishingTouch()
|
|
62
|
+
|
|
63
|
+
// Add tap gesture recognizer to dismiss the keyboard
|
|
64
|
+
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
|
|
65
|
+
view.addGestureRecognizer(tapGesture)
|
|
66
|
+
|
|
67
|
+
if let email = userEmail {
|
|
68
|
+
txtFieldEmail.text = email
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
decodeBillingInfo()
|
|
72
|
+
|
|
73
|
+
/// Email field editable or not editable handling
|
|
74
|
+
DispatchQueue.main.async {
|
|
75
|
+
let isEmailEditable = self.request.isEmail ?? true
|
|
76
|
+
self.txtFieldEmail.isUserInteractionEnabled = isEmailEditable
|
|
77
|
+
|
|
78
|
+
// Get custom primary font color or fallback to .label
|
|
79
|
+
let primaryFontColorHex = UserStoreSingleton.shared.primary_font_col ?? "#000000"
|
|
80
|
+
let primaryFontColor = UIColor(hex: primaryFontColorHex) ?? .label
|
|
81
|
+
|
|
82
|
+
if let text = self.txtFieldEmail.text {
|
|
83
|
+
let attributes: [NSAttributedString.Key: Any] = [
|
|
84
|
+
.foregroundColor: isEmailEditable ? primaryFontColor : UIColor.gray
|
|
85
|
+
]
|
|
86
|
+
self.txtFieldEmail.attributedText = NSAttributedString(string: text, attributes: attributes)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Optional: Hide cursor if not editable
|
|
90
|
+
self.txtFieldEmail.tintColor = isEmailEditable ? primaryFontColor : .clear
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// MARK: - Decode billingInfoData
|
|
95
|
+
private func decodeBillingInfo() {
|
|
96
|
+
guard let data = billingInfoData else {
|
|
97
|
+
print("No billingInfoData found")
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
do {
|
|
102
|
+
let decodedSection = try JSONDecoder().decode(FieldSection.self, from: data)
|
|
103
|
+
self.fieldSection = decodedSection
|
|
104
|
+
self.billingInfo = decodedSection.billing
|
|
105
|
+
self.additionalInfo = decodedSection.additional
|
|
106
|
+
self.visibility = decodedSection.visibility
|
|
107
|
+
|
|
108
|
+
print("Decoded billingInfo: \(billingInfo ?? [])")
|
|
109
|
+
} catch {
|
|
110
|
+
print("Failed to decode billing info data: \(error)")
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
func uiFinishingTouch() {
|
|
115
|
+
if let containerBGcolor = UserStoreSingleton.shared.container_bg_col,
|
|
116
|
+
let uiColor = UIColor(hex: containerBGcolor) {
|
|
117
|
+
self.view.backgroundColor = uiColor
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if let primaryFontColor = UserStoreSingleton.shared.primary_font_col,
|
|
121
|
+
let uiColor = UIColor(hex: primaryFontColor) {
|
|
122
|
+
lblUsedSavedInfo.textColor = uiColor
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if let primaryFontColor = UserStoreSingleton.shared.secondary_font_col,
|
|
126
|
+
let uiColor = UIColor(hex: primaryFontColor) {
|
|
127
|
+
subLblUsedSavedInfo.textColor = uiColor
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if let primaryFontColor = UserStoreSingleton.shared.primary_btn_bg_col,
|
|
131
|
+
let uiColor = UIColor(hex: primaryFontColor) {
|
|
132
|
+
btnGetOTP.backgroundColor = uiColor
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if let secondaryBtnBackgroundColor = UserStoreSingleton.shared.primary_btn_font_col,
|
|
136
|
+
let secondaryUIColor = UIColor(hex: secondaryBtnBackgroundColor) {
|
|
137
|
+
btnGetOTP.setTitleColor(secondaryUIColor, for: .normal)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if let borderRadiusString = UserStoreSingleton.shared.border_radious,
|
|
141
|
+
let borderRadius = Double(borderRadiusString) { // Convert String to Double
|
|
142
|
+
btnGetOTP.layer.cornerRadius = CGFloat(borderRadius) // Set corner radius
|
|
143
|
+
} else {
|
|
144
|
+
btnGetOTP.layer.cornerRadius = 8 // Default value
|
|
145
|
+
}
|
|
146
|
+
btnGetOTP.layer.masksToBounds = true // Ensure the corners are clipped properly
|
|
147
|
+
|
|
148
|
+
if let fontSizeString = UserStoreSingleton.shared.fontSize,
|
|
149
|
+
let fontSizeDouble = Double(fontSizeString) { // Convert String to Double
|
|
150
|
+
let fontSize = CGFloat(fontSizeDouble) // Convert Double to CGFloat
|
|
151
|
+
subLblUsedSavedInfo.font = UIFont.systemFont(ofSize: fontSize)
|
|
152
|
+
btnGetOTP.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Method to dismiss the keyboard
|
|
157
|
+
@objc func dismissKeyboard() {
|
|
158
|
+
view.endEditing(true)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// MARK: - Send OTP Email Verification Api
|
|
162
|
+
func emailVerificationApi() {
|
|
163
|
+
showLoadingIndicator()
|
|
164
|
+
|
|
165
|
+
let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.emailVerification.path()
|
|
166
|
+
|
|
167
|
+
guard let serviceURL = URL(string: fullURL) else {
|
|
168
|
+
print("Invalid URL")
|
|
169
|
+
hideLoadingIndicator()
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
var request = URLRequest(url: serviceURL)
|
|
174
|
+
request.httpMethod = "POST"
|
|
175
|
+
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
176
|
+
|
|
177
|
+
let token = UserStoreSingleton.shared.clientToken
|
|
178
|
+
print("Setting clientToken header: \(token ?? "None")")
|
|
179
|
+
request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
|
|
180
|
+
|
|
181
|
+
// Add API headers
|
|
182
|
+
if let apiKey = EnvironmentConfig.apiKey,
|
|
183
|
+
let apiSecret = EnvironmentConfig.apiSecret {
|
|
184
|
+
request.addValue(apiKey, forHTTPHeaderField: "x-api-key")
|
|
185
|
+
request.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
let params: [String: Any] = [
|
|
189
|
+
"card_search_value": txtFieldEmail.text ?? "",
|
|
190
|
+
"card_search_key": "email"
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
do {
|
|
194
|
+
let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
195
|
+
request.httpBody = jsonData
|
|
196
|
+
if let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
197
|
+
print("JSON Payload: \(jsonString)")
|
|
198
|
+
}
|
|
199
|
+
} catch let error {
|
|
200
|
+
print("Error creating JSON data: \(error)")
|
|
201
|
+
hideLoadingIndicator()
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let session = URLSession.shared
|
|
206
|
+
let task = session.dataTask(with: request) { (serviceData, serviceResponse, error) in
|
|
207
|
+
|
|
208
|
+
DispatchQueue.main.async {
|
|
209
|
+
self.hideLoadingIndicator()
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if let error = error {
|
|
213
|
+
print("Error: \(error.localizedDescription)")
|
|
214
|
+
return
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
guard let httpResponse = serviceResponse as? HTTPURLResponse else {
|
|
218
|
+
print("Invalid response")
|
|
219
|
+
return
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
223
|
+
if let data = serviceData {
|
|
224
|
+
do {
|
|
225
|
+
if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
226
|
+
print("Response Data: \(responseObject)")
|
|
227
|
+
|
|
228
|
+
DispatchQueue.main.async {
|
|
229
|
+
if let vc = self.storyboard?.instantiateViewController(withIdentifier: "OTPVerificationVC") as? OTPVerificationVC {
|
|
230
|
+
vc.selectedPaymentMethod = self.selectedPaymentMethod
|
|
231
|
+
vc.easyPayDelegate = self.easyPayDelegate
|
|
232
|
+
vc.email = self.txtFieldEmail.text
|
|
233
|
+
vc.chosenPlan = self.chosenPlan
|
|
234
|
+
vc.startDate = self.startDate
|
|
235
|
+
vc.request = self.request
|
|
236
|
+
vc.billingInfoData = self.billingInfoData
|
|
237
|
+
vc.userEmail = self.userEmail
|
|
238
|
+
vc.billingInfo = self.fieldSection?.billing
|
|
239
|
+
vc.additionalInfo = self.fieldSection?.additional
|
|
240
|
+
vc.visibility = self.fieldSection?.visibility
|
|
241
|
+
vc.isSavedForFuture = self.isSavedForFuture
|
|
242
|
+
|
|
243
|
+
switch self.selectedPaymentMethod {
|
|
244
|
+
case "Card":
|
|
245
|
+
vc.cardNumber = self.cardNumber
|
|
246
|
+
vc.expiryDate = self.expiryDate
|
|
247
|
+
vc.cvv = self.cvv
|
|
248
|
+
vc.nameOnCard = self.nameOnCard
|
|
249
|
+
|
|
250
|
+
case "Bank":
|
|
251
|
+
vc.accountName = self.accountName
|
|
252
|
+
vc.routingNumber = self.routingNumber
|
|
253
|
+
vc.accountType = self.accountType
|
|
254
|
+
vc.accountNumber = self.accountNumber
|
|
255
|
+
|
|
256
|
+
case "GrailPay":
|
|
257
|
+
vc.grailPayAccountID = self.grailPayAccountID
|
|
258
|
+
vc.selectedGrailPayAccountType = self.selectedGrailPayAccountType
|
|
259
|
+
vc.selectedGrailPayAccountName = self.selectedGrailPayAccountName
|
|
260
|
+
|
|
261
|
+
default:
|
|
262
|
+
break
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
self.navigationController?.pushViewController(vc, animated: true)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
print("Invalid JSON format")
|
|
270
|
+
}
|
|
271
|
+
} catch let jsonError {
|
|
272
|
+
print("Error parsing JSON: \(jsonError)")
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
print("No data received")
|
|
276
|
+
}
|
|
277
|
+
} else {
|
|
278
|
+
print("HTTP Status Code: \(httpResponse.statusCode)")
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
task.resume()
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
@IBAction func actionBtnCancel(_ sender: UIButton) {
|
|
285
|
+
for viewController in self.navigationController?.viewControllers ?? [] {
|
|
286
|
+
if viewController is PaymentInfoVC {
|
|
287
|
+
self.navigationController?.popToViewController(viewController, animated: true)
|
|
288
|
+
break
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@IBAction func actionBtnGetOTP(_ sender: UIButton) {
|
|
294
|
+
guard let email = txtFieldEmail.text, !email.isEmpty else {
|
|
295
|
+
// Show an alert if the email field is empty
|
|
296
|
+
showAlert(message: "Please enter an email address.")
|
|
297
|
+
return
|
|
298
|
+
}
|
|
299
|
+
// Validate email format before calling the API
|
|
300
|
+
if isValidEmail(email) {
|
|
301
|
+
emailVerificationApi()
|
|
302
|
+
} else {
|
|
303
|
+
showAlert(message: "Please enter a valid email address.")
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
}
|