@jimrising/easymerchantsdk-react-native 1.2.0 → 1.2.2
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/.idea/caches/deviceStreaming.xml +209 -0
- package/.idea/workspace.xml +193 -0
- package/README.md +1 -1
- package/ios/Classes/EasyMerchantSdk.m +4 -4
- package/ios/Pods/UserDefaults/UserStoreSingleton.swift +233 -0
- package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +1137 -0
- package/ios/Pods/ViewControllers/BaseVC.swift +126 -0
- package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +803 -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 +404 -0
- package/ios/Pods/ViewControllers/EmailVerificationVC.swift +239 -0
- package/ios/Pods/ViewControllers/OTPVerificationVC.swift +1134 -0
- package/ios/Pods/ViewControllers/PaymentDoneVC.swift +159 -0
- package/ios/Pods/ViewControllers/PaymentErrorVC.swift +90 -0
- package/ios/Pods/ViewControllers/PaymentInformation/AccountTypeTVC.swift +41 -0
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +5160 -0
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInformationCVC.swift +35 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.swift +77 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.xib +163 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedCardsTVC/SavedCardsTVC.swift +76 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedCardsTVC/SavedCardsTVC.xib +184 -0
- package/ios/Pods/ViewControllers/TermAndConditionsVC.swift +63 -0
- package/ios/easymerchantsdk.podspec +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,239 @@
|
|
|
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 billingInfoData: [String: Any]?
|
|
22
|
+
|
|
23
|
+
var selectedPaymentMethod: String?
|
|
24
|
+
|
|
25
|
+
//Banking Params
|
|
26
|
+
var accountName: String?
|
|
27
|
+
var routingNumber: String?
|
|
28
|
+
var accountType: String?
|
|
29
|
+
var accountNumber: String?
|
|
30
|
+
|
|
31
|
+
var easyPayDelegate: EasyPayViewControllerDelegate?
|
|
32
|
+
|
|
33
|
+
var isSavedForFuture: Bool = false
|
|
34
|
+
|
|
35
|
+
override func viewDidLoad() {
|
|
36
|
+
super.viewDidLoad()
|
|
37
|
+
|
|
38
|
+
uiFinishingTouch()
|
|
39
|
+
|
|
40
|
+
// Add tap gesture recognizer to dismiss the keyboard
|
|
41
|
+
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
|
|
42
|
+
view.addGestureRecognizer(tapGesture)
|
|
43
|
+
|
|
44
|
+
print(isSavedForFuture)
|
|
45
|
+
print(cardNumber ?? "")
|
|
46
|
+
print(expiryDate ?? "")
|
|
47
|
+
print(cvv ?? "")
|
|
48
|
+
print(nameOnCard ?? "")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func uiFinishingTouch() {
|
|
52
|
+
if let containerBGcolor = UserStoreSingleton.shared.container_bg_col,
|
|
53
|
+
let uiColor = UIColor(hex: containerBGcolor) {
|
|
54
|
+
self.view.backgroundColor = uiColor
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if let primaryFontColor = UserStoreSingleton.shared.primary_font_col,
|
|
58
|
+
let uiColor = UIColor(hex: primaryFontColor) {
|
|
59
|
+
lblUsedSavedInfo.textColor = uiColor
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if let primaryFontColor = UserStoreSingleton.shared.secondary_font_col,
|
|
63
|
+
let uiColor = UIColor(hex: primaryFontColor) {
|
|
64
|
+
subLblUsedSavedInfo.textColor = uiColor
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if let primaryFontColor = UserStoreSingleton.shared.primary_btn_bg_col,
|
|
68
|
+
let uiColor = UIColor(hex: primaryFontColor) {
|
|
69
|
+
btnGetOTP.backgroundColor = uiColor
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if let secondaryBtnBackgroundColor = UserStoreSingleton.shared.primary_btn_font_col,
|
|
73
|
+
let secondaryUIColor = UIColor(hex: secondaryBtnBackgroundColor) {
|
|
74
|
+
btnGetOTP.setTitleColor(secondaryUIColor, for: .normal)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if let borderRadiusString = UserStoreSingleton.shared.border_radious,
|
|
78
|
+
let borderRadius = Double(borderRadiusString) { // Convert String to Double
|
|
79
|
+
btnGetOTP.layer.cornerRadius = CGFloat(borderRadius) // Set corner radius
|
|
80
|
+
} else {
|
|
81
|
+
btnGetOTP.layer.cornerRadius = 8 // Default value
|
|
82
|
+
}
|
|
83
|
+
btnGetOTP.layer.masksToBounds = true // Ensure the corners are clipped properly
|
|
84
|
+
|
|
85
|
+
if let fontSizeString = UserStoreSingleton.shared.fontSize,
|
|
86
|
+
let fontSizeDouble = Double(fontSizeString) { // Convert String to Double
|
|
87
|
+
let fontSize = CGFloat(fontSizeDouble) // Convert Double to CGFloat
|
|
88
|
+
subLblUsedSavedInfo.font = UIFont.systemFont(ofSize: fontSize)
|
|
89
|
+
btnGetOTP.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Method to dismiss the keyboard
|
|
94
|
+
@objc func dismissKeyboard() {
|
|
95
|
+
view.endEditing(true)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// MARK: - Send OTP Email Verification Api
|
|
99
|
+
func emailVerificationApi() {
|
|
100
|
+
showLoadingIndicator()
|
|
101
|
+
// var components = URLComponents()
|
|
102
|
+
// components.scheme = "https"
|
|
103
|
+
// components.host = "stage-api.stage-easymerchant.io"
|
|
104
|
+
// components.path = "/api/v1/customer/send_otp"
|
|
105
|
+
//
|
|
106
|
+
// guard let serviceURL = components.url else {
|
|
107
|
+
// print("Invalid URL")
|
|
108
|
+
// hideLoadingIndicator()
|
|
109
|
+
// return
|
|
110
|
+
// }
|
|
111
|
+
|
|
112
|
+
// Construct the full URL using baseURL from EnvironmentConfig and path from the endpoint
|
|
113
|
+
let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.emailVerification.path()
|
|
114
|
+
|
|
115
|
+
guard let serviceURL = URL(string: fullURL) else {
|
|
116
|
+
print("Invalid URL")
|
|
117
|
+
hideLoadingIndicator()
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var request = URLRequest(url: serviceURL)
|
|
122
|
+
request.httpMethod = "POST"
|
|
123
|
+
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
124
|
+
|
|
125
|
+
let token = UserStoreSingleton.shared.clientToken
|
|
126
|
+
print("Setting clientToken header: \(token ?? "None")")
|
|
127
|
+
request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
|
|
128
|
+
|
|
129
|
+
let params: [String: Any] = [
|
|
130
|
+
"card_search_value": txtFieldEmail.text ?? "",
|
|
131
|
+
"card_search_key": "email"
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
do {
|
|
135
|
+
let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
136
|
+
request.httpBody = jsonData
|
|
137
|
+
if let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
138
|
+
print("JSON Payload: \(jsonString)")
|
|
139
|
+
}
|
|
140
|
+
} catch let error {
|
|
141
|
+
print("Error creating JSON data: \(error)")
|
|
142
|
+
hideLoadingIndicator()
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
let session = URLSession.shared
|
|
147
|
+
let task = session.dataTask(with: request) { (serviceData, serviceResponse, error) in
|
|
148
|
+
|
|
149
|
+
DispatchQueue.main.async {
|
|
150
|
+
self.hideLoadingIndicator() // Stop loader when response is received
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if let error = error {
|
|
154
|
+
print("Error: \(error.localizedDescription)")
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
guard let httpResponse = serviceResponse as? HTTPURLResponse else {
|
|
159
|
+
print("Invalid response")
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
164
|
+
if let data = serviceData {
|
|
165
|
+
do {
|
|
166
|
+
if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
167
|
+
print("Response Data: \(responseObject)")
|
|
168
|
+
|
|
169
|
+
// Navigate to PaymentDoneVC and pass the response data
|
|
170
|
+
DispatchQueue.main.async {
|
|
171
|
+
if self.selectedPaymentMethod == "Card" {
|
|
172
|
+
if let vc = self.storyboard?.instantiateViewController(withIdentifier: "OTPVerificationVC") as? OTPVerificationVC {
|
|
173
|
+
// Pass any necessary data to OTP VerfificationVC
|
|
174
|
+
vc.cardNumber = self.cardNumber
|
|
175
|
+
vc.expiryDate = self.expiryDate
|
|
176
|
+
vc.cvv = self.cvv
|
|
177
|
+
vc.nameOnCard = self.nameOnCard
|
|
178
|
+
vc.billingInfoData = self.billingInfoData
|
|
179
|
+
vc.selectedPaymentMethod = self.selectedPaymentMethod
|
|
180
|
+
vc.easyPayDelegate = self.easyPayDelegate
|
|
181
|
+
vc.email = self.txtFieldEmail.text
|
|
182
|
+
vc.isSavedForFuture = self.isSavedForFuture
|
|
183
|
+
self.navigationController?.pushViewController(vc, animated: true)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else if self.selectedPaymentMethod == "Bank" {
|
|
187
|
+
if let vc = self.storyboard?.instantiateViewController(withIdentifier: "OTPVerificationVC") as? OTPVerificationVC {
|
|
188
|
+
vc.accountName = self.accountName
|
|
189
|
+
vc.routingNumber = self.routingNumber
|
|
190
|
+
vc.accountType = self.accountType
|
|
191
|
+
vc.accountNumber = self.accountNumber
|
|
192
|
+
vc.billingInfoData = self.billingInfoData
|
|
193
|
+
vc.selectedPaymentMethod = self.selectedPaymentMethod
|
|
194
|
+
vc.easyPayDelegate = self.easyPayDelegate
|
|
195
|
+
vc.email = self.txtFieldEmail.text
|
|
196
|
+
self.navigationController?.pushViewController(vc, animated: true)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
print("Invalid JSON format")
|
|
202
|
+
}
|
|
203
|
+
} catch let jsonError {
|
|
204
|
+
print("Error parsing JSON: \(jsonError)")
|
|
205
|
+
}
|
|
206
|
+
} else {
|
|
207
|
+
print("No data received")
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
print("HTTP Status Code: \(httpResponse.statusCode)")
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
task.resume()
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@IBAction func actionBtnCancel(_ sender: UIButton) {
|
|
217
|
+
for viewController in self.navigationController?.viewControllers ?? [] {
|
|
218
|
+
if viewController is PaymentInfoVC {
|
|
219
|
+
self.navigationController?.popToViewController(viewController, animated: true)
|
|
220
|
+
break
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@IBAction func actionBtnGetOTP(_ sender: UIButton) {
|
|
226
|
+
guard let email = txtFieldEmail.text, !email.isEmpty else {
|
|
227
|
+
// Show an alert if the email field is empty
|
|
228
|
+
showAlert(message: "Please enter an email address.")
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
// Validate email format before calling the API
|
|
232
|
+
if isValidEmail(email) {
|
|
233
|
+
emailVerificationApi()
|
|
234
|
+
} else {
|
|
235
|
+
showAlert(message: "Please enter a valid email address.")
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
}
|