@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.
Files changed (28) hide show
  1. package/README.md +1 -1
  2. package/ios/Pods/UserDefaults/UserStoreSingleton.swift +304 -0
  3. package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +2636 -0
  4. package/ios/Pods/ViewControllers/BaseVC.swift +141 -0
  5. package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +3347 -0
  6. package/ios/Pods/ViewControllers/BillingInfoVC/Cells/CityListTVC.swift +46 -0
  7. package/ios/Pods/ViewControllers/BillingInfoVC/Cells/CountryListTVC.swift +47 -0
  8. package/ios/Pods/ViewControllers/BillingInfoVC/Cells/StateListTVC.swift +46 -0
  9. package/ios/Pods/ViewControllers/CountryListVC.swift +435 -0
  10. package/ios/Pods/ViewControllers/CustomOverlay.swift +199 -0
  11. package/ios/Pods/ViewControllers/EmailVerificationVC.swift +307 -0
  12. package/ios/Pods/ViewControllers/GrailPayVC.swift +244 -0
  13. package/ios/Pods/ViewControllers/OTPVerificationVC.swift +2066 -0
  14. package/ios/Pods/ViewControllers/PaymentDoneVC.swift +272 -0
  15. package/ios/Pods/ViewControllers/PaymentErrorVC.swift +85 -0
  16. package/ios/Pods/ViewControllers/PaymentInformation/AccountTypeTVC.swift +41 -0
  17. package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +11025 -0
  18. package/ios/Pods/ViewControllers/PaymentInformation/PaymentInformationCVC.swift +35 -0
  19. package/ios/Pods/ViewControllers/PaymentInformation/RecurringTVC.swift +40 -0
  20. package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.swift +81 -0
  21. package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.xib +163 -0
  22. package/ios/Pods/ViewControllers/PaymentInformation/SavedCardsTVC/SavedCardsTVC.swift +81 -0
  23. package/ios/Pods/ViewControllers/PaymentInformation/SavedCardsTVC/SavedCardsTVC.xib +188 -0
  24. package/ios/Pods/ViewControllers/PaymentStatusWebViewVC.swift +167 -0
  25. package/ios/Pods/ViewControllers/TermAndConditionsVC.swift +63 -0
  26. package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +629 -0
  27. package/ios/easymerchantsdk.podspec +1 -1
  28. package/package.json +1 -1
@@ -0,0 +1,272 @@
1
+ //
2
+ // PaymentDoneVC.swift
3
+ // EasyPay
4
+ //
5
+ // Created by Mony's Mac on 13/08/24.
6
+ //
7
+
8
+ import UIKit
9
+
10
+ class PaymentDoneVC: UIViewController {
11
+
12
+ @IBOutlet weak var viewMain: UIView!
13
+ @IBOutlet weak var lblDate: UILabel!
14
+ @IBOutlet weak var lblTransactionId: UILabel!
15
+ @IBOutlet weak var lblPaymentSource: UILabel!
16
+ @IBOutlet weak var lblTotal: UILabel!
17
+ @IBOutlet weak var btnDone: UIButton!
18
+
19
+ @IBOutlet weak var lblHeadingDate: UILabel!
20
+ @IBOutlet weak var lblHeadingTransactionID: UILabel!
21
+ @IBOutlet weak var lbHeadingPaymentMethod: UILabel!
22
+ @IBOutlet weak var lblHeadingTotal: UILabel!
23
+
24
+ @IBOutlet weak var viewSubscriptionId: UIStackView!
25
+ @IBOutlet weak var lblHeadingSubscriptionId: UILabel!
26
+ @IBOutlet weak var lblSubscriptionId: UILabel!
27
+ @IBOutlet weak var lblBillingInfo: UILabel!
28
+
29
+ var chargeData: [String: Any]?
30
+ var selectedPaymentMethod: String?
31
+ var easyPayDelegate: EasyPayViewControllerDelegate?
32
+
33
+ //Crypto
34
+ var amount: String?
35
+ var dateCreated: String?
36
+ var transactionId: String?
37
+ var isFrom = String()
38
+
39
+ // Add these two properties:
40
+ var billingInfo: [String: Any]?
41
+ var additionalInfo: [String: Any]?
42
+
43
+ var additionalInfoData: [FieldItem]?
44
+ var billingInfoData: [FieldItem]?
45
+ var visibility: FieldsVisibility?
46
+
47
+ var bankPaymentParams: [String: Any]?
48
+
49
+ var request: Request!
50
+
51
+ override func viewDidLoad() {
52
+ super.viewDidLoad()
53
+
54
+ uiFinishingTouchElements()
55
+
56
+ if isFrom == "Crypto" {
57
+ // Display the crypto data if available
58
+ lblTotal.text = "$\(amount ?? "0.00")"
59
+ lblTransactionId.text = transactionId ?? "Transaction ID not available"
60
+
61
+ // Validate and format the date
62
+ if let dateCreated = dateCreated, isValidDate(dateCreated) {
63
+ lblDate.text = dateCreated
64
+ } else {
65
+ lblDate.text = "Date not available"
66
+ }
67
+
68
+ }
69
+ else {
70
+ // Default behavior for non-crypto payment methods
71
+ if let chargeData = chargeData {
72
+ print("Charge Data: \(chargeData)")
73
+
74
+ if let chargeId = chargeData["charge_id"] as? String {
75
+ lblTransactionId.text = chargeId
76
+ } else {
77
+ lblTransactionId.text = "Charge ID not available"
78
+ }
79
+
80
+ // Handle subscription_id visibility
81
+ if let subscriptionId = chargeData["subscription_id"] as? String, !subscriptionId.isEmpty {
82
+ viewSubscriptionId.isHidden = false
83
+ lblSubscriptionId.text = subscriptionId
84
+ } else {
85
+ viewSubscriptionId.isHidden = true
86
+ }
87
+ }
88
+
89
+ lblPaymentSource.text = selectedPaymentMethod
90
+ let rawAmount = Double(request?.amount ?? 0)
91
+ let amountText = String(format: "$%.2f", rawAmount)
92
+ lblTotal.text = "\(amountText)"
93
+ showDateAndTime()
94
+ }
95
+
96
+ // showBillingInfo()
97
+
98
+ // if let paymentParams = bankPaymentParams {
99
+ // print("Payment Params JSON:")
100
+ // if let jsonData = try? JSONSerialization.data(withJSONObject: paymentParams, options: .prettyPrinted),
101
+ // let jsonString = String(data: jsonData, encoding: .utf8) {
102
+ // print(jsonString)
103
+ // }
104
+ // }
105
+ }
106
+
107
+ override func viewWillAppear(_ animated: Bool) {
108
+ uiFinishingTouchElements()
109
+ }
110
+
111
+ func uiFinishingTouchElements() {
112
+ // Set background color for the main view
113
+ if let containerBGcolor = UserStoreSingleton.shared.container_bg_col,
114
+ let uiColor = UIColor(hex: containerBGcolor) {
115
+ self.view.backgroundColor = uiColor
116
+ self.viewMain.backgroundColor = uiColor
117
+ }
118
+
119
+ if let primaryBtnBackGroundColor = UserStoreSingleton.shared.primary_btn_bg_col,
120
+ let uiColor = UIColor(hex: primaryBtnBackGroundColor) {
121
+ btnDone.backgroundColor = uiColor
122
+ }
123
+
124
+ if let primaryBtnFontColor = UserStoreSingleton.shared.primary_btn_font_col,
125
+ let secondaryUIColor = UIColor(hex: primaryBtnFontColor) {
126
+ btnDone.setTitleColor(secondaryUIColor, for: .normal)
127
+ }
128
+
129
+ if let borderRadiusString = UserStoreSingleton.shared.border_radious,
130
+ let borderRadius = Double(borderRadiusString) { // Convert String to Double
131
+ btnDone.layer.cornerRadius = CGFloat(borderRadius) // Set corner radius
132
+ } else {
133
+ btnDone.layer.cornerRadius = 8 // Default value
134
+ }
135
+ btnDone.layer.masksToBounds = true // Ensure the corners are clipped properly
136
+
137
+ if let primaryFontColor = UserStoreSingleton.shared.primary_font_col,
138
+ let uiColor = UIColor(hex: primaryFontColor) {
139
+ lblHeadingDate.textColor = uiColor
140
+ lblHeadingTransactionID.textColor = uiColor
141
+ lbHeadingPaymentMethod.textColor = uiColor
142
+ lblHeadingTotal.textColor = uiColor
143
+ lblDate.textColor = uiColor
144
+ lblTransactionId.textColor = uiColor
145
+ lblPaymentSource.textColor = uiColor
146
+ lblTotal.textColor = uiColor
147
+ lblHeadingSubscriptionId.textColor = uiColor
148
+ lblSubscriptionId.textColor = uiColor
149
+ lblBillingInfo.textColor = uiColor
150
+ }
151
+
152
+ if let fontSizeString = UserStoreSingleton.shared.fontSize,
153
+ let fontSizeDouble = Double(fontSizeString) { // Convert String to Double
154
+ let fontSize = CGFloat(fontSizeDouble) // Convert Double to CGFloat
155
+ lblDate.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
156
+ lblTransactionId.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
157
+ lblPaymentSource.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
158
+ lblTotal.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
159
+ lblHeadingDate.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
160
+ lblHeadingTransactionID.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
161
+ lbHeadingPaymentMethod.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
162
+ lblHeadingTotal.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
163
+ btnDone.titleLabel?.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
164
+ lblHeadingSubscriptionId.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
165
+ lblSubscriptionId.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
166
+ lblBillingInfo.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
167
+ }
168
+
169
+ }
170
+
171
+ // func showBillingInfo() {
172
+ // var displayText = ""
173
+ //
174
+ // if let visibility = visibility {
175
+ // if visibility.billing, let billing = billingInfo {
176
+ // displayText += "Billing Info:-\n"
177
+ // for (key, value) in billing {
178
+ // displayText += "\(key.capitalized): \(value)\n"
179
+ // }
180
+ // }
181
+ //
182
+ // if visibility.additional, let additional = additionalInfo {
183
+ // if !displayText.isEmpty {
184
+ // displayText += "\n"
185
+ // }
186
+ // displayText += "Additional Info:-\n"
187
+ // for (key, value) in additional {
188
+ // displayText += "\(key.capitalized): \(value)\n"
189
+ // }
190
+ // }
191
+ // }
192
+ //
193
+ // if displayText.isEmpty {
194
+ // lblBillingInfo.isHidden = true
195
+ // } else {
196
+ // lblBillingInfo.text = displayText.trimmingCharacters(in: .whitespacesAndNewlines)
197
+ // lblBillingInfo.isHidden = false
198
+ // }
199
+ // }
200
+
201
+ // Helper method to check if the date string is valid
202
+ func isValidDate(_ dateString: String) -> Bool {
203
+ let dateFormatter = DateFormatter()
204
+ dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
205
+ return dateFormatter.date(from: dateString) != nil
206
+ }
207
+
208
+ func showDateAndTime() {
209
+ // Get the current date and time
210
+ let currentDate = Date()
211
+ // Format the date and time as "dd/MM/yyyy, HH:mm:ss"
212
+ let dateFormatter = DateFormatter()
213
+ dateFormatter.dateFormat = "dd/MM/yyyy, HH:mm:ss"
214
+ let formattedDate = dateFormatter.string(from: currentDate)
215
+ // Set the formatted date and time to the lblDate
216
+ lblDate.text = formattedDate
217
+ }
218
+
219
+ // @IBAction func actionBtnDone(_ sender: UIButton) {
220
+ // let result = SDKResult(type: .success,
221
+ // chargeData: chargeData,
222
+ // billingInfo: billingInfo,
223
+ // additionalInfo: additionalInfo)
224
+ //
225
+ // easyPayDelegate?.easyPayController(self.navigationController as! EasyPayViewController, didFinishWith: result)
226
+ //
227
+ // if let easyPayVC = self.navigationController as? EasyPayViewController {
228
+ // easyPayVC.dismiss(animated: true, completion: {
229
+ // if let delegate = easyPayVC.easyPayDelegate {
230
+ // UserStoreSingleton.shared.isLoggedIn = false
231
+ // delegate.easyPayController(easyPayVC, didFinishWith: result)
232
+ // }
233
+ // })
234
+ // }
235
+ // }
236
+
237
+ @IBAction func actionBtnDone(_ sender: UIButton) {
238
+ var finalChargeData = chargeData ?? [:]
239
+
240
+ // Add selected fields from bankPaymentParams
241
+ if let paymentParams = bankPaymentParams {
242
+ if let accountType = paymentParams["account_type"] {
243
+ finalChargeData["account_type"] = accountType
244
+ }
245
+ if let name = paymentParams["name"] {
246
+ finalChargeData["name"] = name
247
+ }
248
+ if let email = paymentParams["email"] {
249
+ finalChargeData["email"] = email
250
+ }
251
+ }
252
+
253
+ // Create SDK result with updated charge data
254
+ let result = SDKResult(type: .success,
255
+ chargeData: finalChargeData,
256
+ billingInfo: billingInfo,
257
+ additionalInfo: additionalInfo)
258
+
259
+ // Notify delegate and dismiss
260
+ easyPayDelegate?.easyPayController(self.navigationController as! EasyPayViewController, didFinishWith: result)
261
+
262
+ if let easyPayVC = self.navigationController as? EasyPayViewController {
263
+ easyPayVC.dismiss(animated: true, completion: {
264
+ if let delegate = easyPayVC.easyPayDelegate {
265
+ UserStoreSingleton.shared.isLoggedIn = false
266
+ delegate.easyPayController(easyPayVC, didFinishWith: result)
267
+ }
268
+ })
269
+ }
270
+ }
271
+
272
+ }
@@ -0,0 +1,85 @@
1
+ ////
2
+ //// PaymentErrorVC.swift
3
+ //// EasyPay
4
+ ////
5
+ //// Created by Mony's Mac on 20/08/24.
6
+
7
+ import UIKit
8
+
9
+ class PaymentErrorVC: UIViewController {
10
+
11
+ @IBOutlet weak var btnDone: UIButton!
12
+ @IBOutlet weak var lblError: UILabel!
13
+
14
+ var errorMessage: String?
15
+ var errorStatus: Bool? // <-- NEW
16
+ var easyPayDelegate: EasyPayViewControllerDelegate?
17
+
18
+ override func viewDidLoad() {
19
+ super.viewDidLoad()
20
+ uiFinishingTouchElements()
21
+ lblError.text = errorMessage
22
+ }
23
+
24
+ override func viewWillAppear(_ animated: Bool) {
25
+ super.viewWillAppear(animated)
26
+ uiFinishingTouchElements()
27
+ }
28
+
29
+ func uiFinishingTouchElements() {
30
+ if let containerBGcolor = UserStoreSingleton.shared.container_bg_col,
31
+ let uiColor = UIColor(hex: containerBGcolor) {
32
+ self.view.backgroundColor = uiColor
33
+ }
34
+
35
+ if let primaryBtnBackGroundColor = UserStoreSingleton.shared.primary_btn_bg_col,
36
+ let uiColor = UIColor(hex: primaryBtnBackGroundColor) {
37
+ btnDone.backgroundColor = uiColor
38
+ }
39
+
40
+ if let primaryBtnFontColor = UserStoreSingleton.shared.primary_btn_font_col,
41
+ let secondaryUIColor = UIColor(hex: primaryBtnFontColor) {
42
+ btnDone.setTitleColor(secondaryUIColor, for: .normal)
43
+ }
44
+
45
+ if let borderRadiusString = UserStoreSingleton.shared.border_radious,
46
+ let borderRadius = Double(borderRadiusString) {
47
+ btnDone.layer.cornerRadius = CGFloat(borderRadius)
48
+ } else {
49
+ btnDone.layer.cornerRadius = 8
50
+ }
51
+ btnDone.layer.masksToBounds = true
52
+
53
+ if let primaryFontColor = UserStoreSingleton.shared.primary_font_col,
54
+ let uiColor = UIColor(hex: primaryFontColor) {
55
+ lblError.textColor = uiColor
56
+ }
57
+
58
+ if let fontSizeString = UserStoreSingleton.shared.fontSize,
59
+ let fontSizeDouble = Double(fontSizeString) {
60
+ let fontSize = CGFloat(fontSizeDouble)
61
+ lblError.font = UIFont.systemFont(ofSize: fontSize)
62
+ btnDone.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
63
+ }
64
+ }
65
+
66
+ @IBAction func actionBtnDone(_ sender: UIButton) {
67
+ let errorData: [String: Any] = [
68
+ "status": errorStatus ?? false,
69
+ "message": errorMessage ?? "Unknown error"
70
+ ]
71
+
72
+ let result = SDKResult(type: .error, chargeData: errorData)
73
+ easyPayDelegate?.easyPayController(self.navigationController as! EasyPayViewController, didFinishWith: result)
74
+
75
+ if let easyPayVC = self.navigationController as? EasyPayViewController {
76
+ easyPayVC.dismiss(animated: true) {
77
+ if let delegate = easyPayVC.easyPayDelegate {
78
+ UserStoreSingleton.shared.isLoggedIn = false
79
+ let errorResult = SDKResult(type: .error, chargeData: errorData)
80
+ delegate.easyPayController(easyPayVC, didFinishWith: errorResult)
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,41 @@
1
+ //
2
+ // AccountTypeTVC.swift
3
+ // EasyPay
4
+ //
5
+ // Created by Mony's Mac on 14/08/24.
6
+ //
7
+
8
+ import UIKit
9
+
10
+ class AccountTypeTVC: UITableViewCell {
11
+
12
+ @IBOutlet weak var lblAccountType: UILabel!
13
+ @IBOutlet weak var viewCell: UIView!
14
+
15
+ override func awakeFromNib() {
16
+ super.awakeFromNib()
17
+
18
+ if let primaryFontColor = UserStoreSingleton.shared.primary_font_col,
19
+ let uiColor = UIColor(hex: primaryFontColor) {
20
+ lblAccountType.textColor = uiColor
21
+ }
22
+
23
+ if let fontSizeString = UserStoreSingleton.shared.fontSize,
24
+ let fontSizeDouble = Double(fontSizeString) { // Convert String to Double
25
+ let fontSize = CGFloat(fontSizeDouble) // Convert Double to CGFloat
26
+ lblAccountType.font = UIFont.systemFont(ofSize: fontSize)
27
+ }
28
+
29
+ }
30
+
31
+ override func layoutSubviews() {
32
+ super.layoutSubviews()
33
+
34
+ if let containerBGcolor = UserStoreSingleton.shared.container_bg_col,
35
+ let uiColor = UIColor(hex: containerBGcolor) {
36
+ self.contentView.backgroundColor = uiColor
37
+ viewCell?.backgroundColor = uiColor // Prevents crash if viewCell is nil
38
+ }
39
+ }
40
+
41
+ }