@jimrising/easymerchantsdk-react-native 1.3.2 → 1.3.4

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.
@@ -7,7 +7,7 @@
7
7
 
8
8
  import UIKit
9
9
 
10
- // @available(iOS 16.0, *)
10
+ @available(iOS 16.0, *)
11
11
 
12
12
  protocol BillingInfoVCDelegate: AnyObject {
13
13
  func didPassTextBack(_ text: String)
@@ -323,150 +323,6 @@ class BillingInfoVC: BaseVC {
323
323
  task.resume()
324
324
  }
325
325
 
326
- ///** Normal Case
327
- // //MARK: Get State List
328
- // func getStateListApi(for country: String) {
329
- // let urlString = "https://countriesnow.space/api/v0.1/countries/states"
330
- // guard let serviceURL = URL(string: urlString) else {
331
- // print("Invalid URL")
332
- // hideLoadingIndicator()
333
- // return
334
- // }
335
- //
336
- // var request = URLRequest(url: serviceURL)
337
- // request.httpMethod = "POST"
338
- // request.addValue("application/json", forHTTPHeaderField: "Content-Type")
339
- //
340
- // let params: [String: Any] = [
341
- // "country": country
342
- // ]
343
- //
344
- // do {
345
- // let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
346
- // request.httpBody = jsonData
347
- // } catch {
348
- // print("Error creating JSON data: \(error)")
349
- // return
350
- // }
351
- //
352
- // let session = URLSession.shared
353
- // let task = session.dataTask(with: request) { (serviceData, serviceResponse, error) in
354
- // if let error = error {
355
- // print("Error: \(error.localizedDescription)")
356
- // return
357
- // }
358
- //
359
- // guard let httpResponse = serviceResponse as? HTTPURLResponse, httpResponse.statusCode == 200 else {
360
- // print("Invalid response or status code")
361
- // return
362
- // }
363
- //
364
- // if let data = serviceData {
365
- // do {
366
- // if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
367
- // let dataObject = responseObject["data"] as? [String: Any],
368
- // let statesArray = dataObject["states"] as? [[String: Any]] {
369
- //
370
- // DispatchQueue.main.async {
371
- // self.stateList = statesArray
372
- // self.tblViewStateList.reloadData()
373
- //
374
- // // Pick a random state and set it in txtFieldState
375
- // if let randomState = statesArray.randomElement(),
376
- // let stateName = randomState["name"] as? String {
377
- // self.txtFieldState.text = stateName
378
- //
379
- // // Fetch cities for the randomly selected state and country
380
- // if let country = self.txtFieldCountry.text {
381
- // self.getCityListListApi(for: country, state: stateName)
382
- // }
383
- // } else {
384
- // self.txtFieldState.text = "" // No state available
385
- // }
386
- // }
387
- // } else {
388
- // print("Error: Invalid JSON structure")
389
- // }
390
- // } catch {
391
- // print("Error parsing JSON: \(error)")
392
- // }
393
- // } else {
394
- // print("No data received")
395
- // }
396
- // }
397
- // task.resume()
398
- // }
399
- //
400
-
401
- ///** Normal Case
402
- // //MARK: Get City List
403
- // func getCityListListApi(for country: String, state: String) {
404
- // let urlString = "https://countriesnow.space/api/v0.1/countries/state/cities"
405
- // guard let serviceURL = URL(string: urlString) else {
406
- // print("Invalid URL")
407
- // hideLoadingIndicator()
408
- // return
409
- // }
410
- //
411
- // var request = URLRequest(url: serviceURL)
412
- // request.httpMethod = "POST"
413
- // request.addValue("application/json", forHTTPHeaderField: "Content-Type")
414
- //
415
- // let params: [String: Any] = [
416
- // "country": country,
417
- // "state": state
418
- // ]
419
- //
420
- // do {
421
- // let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
422
- // request.httpBody = jsonData
423
- // } catch {
424
- // print("Error creating JSON data: \(error)")
425
- // return
426
- // }
427
- //
428
- // let session = URLSession.shared
429
- // let task = session.dataTask(with: request) { (serviceData, serviceResponse, error) in
430
- // if let error = error {
431
- // print("Error: \(error.localizedDescription)")
432
- // return
433
- // }
434
- //
435
- // guard let httpResponse = serviceResponse as? HTTPURLResponse, httpResponse.statusCode == 200 else {
436
- // print("Invalid response or status code")
437
- // return
438
- // }
439
- //
440
- // if let data = serviceData {
441
- // do {
442
- // if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
443
- // let citiesArray = responseObject["data"] as? [String] { // Directly accessing city list array
444
- //
445
- // DispatchQueue.main.async {
446
- // self.cityList = citiesArray.map { ["city_name": $0] } // Converting to expected format
447
- // self.tblViewCityList.reloadData()
448
- //
449
- // // Pick a random city and set it in txtFieldCity
450
- // if let randomCity = citiesArray.randomElement() {
451
- // self.txtFieldCity.text = randomCity
452
- // } else {
453
- // self.txtFieldCity.text = "" // No city available
454
- // }
455
- // }
456
- // } else {
457
- // print("Error: Invalid JSON structure")
458
- // }
459
- // } catch {
460
- // print("Error parsing JSON: \(error)")
461
- // }
462
- // } else {
463
- // print("No data received")
464
- // }
465
- // }
466
- // task.resume()
467
- // }
468
-
469
-
470
326
  ///**In case of state and city name not found
471
327
  func getStateListApi(for country: String) {
472
328
  let urlString = "https://countriesnow.space/api/v0.1/countries/states"
@@ -645,51 +501,68 @@ class BillingInfoVC: BaseVC {
645
501
  }
646
502
 
647
503
  @IBAction func actionBtnNext(_ sender: UIButton) {
648
- let vc = easymerchantsdk.instantiateViewController(withIdentifier: "AdditionalInfoVC") as! AdditionalInfoVC
649
- // Set properties on AdditionalInfoVC
650
- vc.cardNumber = cardNumber
651
- vc.expiryDate = expiryDate
652
- vc.cvv = cvv
653
- vc.nameOnCard = nameOnCard
654
- updateBillingInfoData()
655
- vc.billingInfoData = billingInfoData
656
- // Pass the selected payment method
657
- vc.selectedPaymentMethod = selectedPaymentMethod
658
- vc.isSavedForFuture = isSavedForFuture
659
-
660
- //Banking Case
661
- vc.accountName = accountName
662
- vc.routingNumber = routingNumber
663
- vc.accountType = accountType
664
- vc.accountNumber = accountNumber
665
-
666
- vc.customerID = customerID
667
- vc.accountID = accountID
668
- vc.isFrom = isFrom
669
-
670
- vc.isSavedNewAccount = isSavedNewAccount
671
- vc.amount = amount
672
-
673
- if isFrom == "SavedCards" {
674
- vc.isFrom = "SavedCards"
675
- vc.selectedCard = selectedCard // Passing the selected card data
676
- vc.cvvText = cvvText // Passing the CVV text
677
- vc.amount = amount
504
+ if self.txtFieldAddress.text?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == true {
505
+ self.showAlert(title: "Missing Information", message: "Please enter your address.")
678
506
  }
679
-
680
- if isFrom == "AddNewCard" {
681
- vc.isFrom = "AddNewCard"
507
+ else if self.txtFieldCountry.text?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == true {
508
+ self.showAlert(title: "Missing Information", message: "Please select your country.")
509
+ }
510
+ else if self.txtFieldState.text?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == true {
511
+ self.showAlert(title: "Missing Information", message: "Please select your state.")
512
+ }
513
+ else if self.txtFieldCity.text?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == true {
514
+ self.showAlert(title: "Missing Information", message: "Please select your city.")
515
+ }
516
+ else if self.txtFieldPostalCode.text?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == true {
517
+ self.showAlert(title: "Missing Information", message: "Please enter your postal code.")
518
+ }
519
+ else {
520
+ let vc = easymerchantsdk.instantiateViewController(withIdentifier: "AdditionalInfoVC") as! AdditionalInfoVC
521
+ // Set properties on AdditionalInfoVC
522
+ vc.cardNumber = cardNumber
523
+ vc.expiryDate = expiryDate
524
+ vc.cvv = cvv
525
+ vc.nameOnCard = nameOnCard
526
+ updateBillingInfoData()
527
+ vc.billingInfoData = billingInfoData
528
+ // Pass the selected payment method
529
+ vc.selectedPaymentMethod = selectedPaymentMethod
530
+ vc.isSavedForFuture = isSavedForFuture
531
+
532
+ //Banking Case
533
+ vc.accountName = accountName
534
+ vc.routingNumber = routingNumber
535
+ vc.accountType = accountType
536
+ vc.accountNumber = accountNumber
537
+
538
+ vc.customerID = customerID
539
+ vc.accountID = accountID
540
+ vc.isFrom = isFrom
541
+
542
+ vc.isSavedNewAccount = isSavedNewAccount
682
543
  vc.amount = amount
683
- vc.isSavedNewCard = isSavedNewCard
544
+
545
+ if isFrom == "SavedCards" {
546
+ vc.isFrom = "SavedCards"
547
+ vc.selectedCard = selectedCard // Passing the selected card data
548
+ vc.cvvText = cvvText // Passing the CVV text
549
+ vc.amount = amount
550
+ }
551
+
552
+ if isFrom == "AddNewCard" {
553
+ vc.isFrom = "AddNewCard"
554
+ vc.amount = amount
555
+ vc.isSavedNewCard = isSavedNewCard
556
+ }
557
+
558
+ self.navigationController?.pushViewController(vc, animated: true)
684
559
  }
685
-
686
- self.navigationController?.pushViewController(vc, animated: true)
687
560
  }
688
561
 
689
562
  }
690
563
 
691
564
  //MARK: - Table View
692
- // @available(iOS 16.0, *)
565
+ @available(iOS 16.0, *)
693
566
  extension BillingInfoVC: UITableViewDelegate, UITableViewDataSource {
694
567
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
695
568
  if tableView == tblViewCountryList {
@@ -766,7 +639,7 @@ extension BillingInfoVC: UITableViewDelegate, UITableViewDataSource {
766
639
 
767
640
  }
768
641
 
769
- // @available(iOS 16.0, *)
642
+ @available(iOS 16.0, *)
770
643
  extension BillingInfoVC: UITextFieldDelegate {
771
644
  func textFieldShouldReturn(_ textField: UITextField) -> Bool {
772
645
  textField.resignFirstResponder() // Dismiss the keyboard
@@ -16,6 +16,7 @@ class CountryListVC: UIViewController {
16
16
  @IBOutlet var viewClass: UIView!
17
17
  @IBOutlet weak var searchBarCountry: UISearchBar!
18
18
  @IBOutlet weak var tblViewCountry: UITableView!
19
+ @IBOutlet weak var viewSearch: UIView!
19
20
 
20
21
  var list: [Country] = [Country]()
21
22
  var searchList: [Country] = [Country]()
@@ -25,6 +26,13 @@ class CountryListVC: UIViewController {
25
26
  override func viewDidLoad() {
26
27
  super.viewDidLoad()
27
28
 
29
+ // Remove top and bottom lines (background/shadow)
30
+ if let searchBar = self.searchBarCountry {
31
+ searchBar.backgroundImage = UIImage() // Removes background line
32
+ searchBar.layer.borderWidth = 0
33
+ searchBar.layer.borderColor = UIColor.clear.cgColor
34
+ }
35
+
28
36
  if let containerBGcolor = UserStoreSingleton.shared.container_bg_col,
29
37
  let uiColor = UIColor(hex: containerBGcolor) {
30
38
  self.view.backgroundColor = uiColor
@@ -83,6 +91,10 @@ class CountryListVC: UIViewController {
83
91
  self.tblViewCountry.reloadData()
84
92
  }
85
93
 
94
+ @IBAction func actionBtnClose(_ sender: UIButton) {
95
+ self.navigationController?.popViewController(animated: true)
96
+ }
97
+
86
98
  }
87
99
 
88
100
  extension String {
@@ -32,6 +32,11 @@ class EmailVerificationVC: BaseVC {
32
32
 
33
33
  var isSavedForFuture: Bool = false
34
34
 
35
+ //GrailPay Params
36
+ var grailPayAccountID: String?
37
+ var selectedGrailPayAccountType: String?
38
+ var selectedGrailPayAccountName: String?
39
+
35
40
  override func viewDidLoad() {
36
41
  super.viewDidLoad()
37
42
 
@@ -41,11 +46,9 @@ class EmailVerificationVC: BaseVC {
41
46
  let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
42
47
  view.addGestureRecognizer(tapGesture)
43
48
 
44
- print(isSavedForFuture)
45
- print(cardNumber ?? "")
46
- print(expiryDate ?? "")
47
- print(cvv ?? "")
48
- print(nameOnCard ?? "")
49
+ print(grailPayAccountID ?? "")
50
+ print(selectedGrailPayAccountType ?? "")
51
+ print(selectedGrailPayAccountName ?? "")
49
52
  }
50
53
 
51
54
  func uiFinishingTouch() {
@@ -98,18 +101,7 @@ class EmailVerificationVC: BaseVC {
98
101
  // MARK: - Send OTP Email Verification Api
99
102
  func emailVerificationApi() {
100
103
  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
104
+
113
105
  let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.emailVerification.path()
114
106
 
115
107
  guard let serviceURL = URL(string: fullURL) else {
@@ -126,6 +118,13 @@ class EmailVerificationVC: BaseVC {
126
118
  print("Setting clientToken header: \(token ?? "None")")
127
119
  request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
128
120
 
121
+ // Add API headers
122
+ if let apiKey = EnvironmentConfig.apiKey,
123
+ let apiSecret = EnvironmentConfig.apiSecret {
124
+ request.addValue(apiKey, forHTTPHeaderField: "x-api-key")
125
+ request.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
126
+ }
127
+
129
128
  let params: [String: Any] = [
130
129
  "card_search_value": txtFieldEmail.text ?? "",
131
130
  "card_search_key": "email"
@@ -196,6 +195,17 @@ class EmailVerificationVC: BaseVC {
196
195
  self.navigationController?.pushViewController(vc, animated: true)
197
196
  }
198
197
  }
198
+ else if self.selectedPaymentMethod == "GrailPay" {
199
+ if let vc = self.storyboard?.instantiateViewController(withIdentifier: "OTPVerificationVC") as? OTPVerificationVC {
200
+ vc.selectedPaymentMethod = "GrailPay"
201
+ vc.easyPayDelegate = self.easyPayDelegate
202
+ vc.grailPayAccountID = self.grailPayAccountID
203
+ vc.selectedGrailPayAccountType = self.selectedGrailPayAccountType
204
+ vc.selectedGrailPayAccountName = self.selectedGrailPayAccountName
205
+ vc.email = self.txtFieldEmail.text
206
+ self.navigationController?.pushViewController(vc, animated: true)
207
+ }
208
+ }
199
209
  }
200
210
  } else {
201
211
  print("Invalid JSON format")