@jimrising/easymerchantsdk-react-native 1.3.3 → 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 {
@@ -118,6 +118,13 @@ class EmailVerificationVC: BaseVC {
118
118
  print("Setting clientToken header: \(token ?? "None")")
119
119
  request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
120
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
+
121
128
  let params: [String: Any] = [
122
129
  "card_search_value": txtFieldEmail.text ?? "",
123
130
  "card_search_key": "email"
@@ -236,6 +236,13 @@ class OTPVerificationVC: BaseVC {
236
236
  print("Setting clientToken header: \(token ?? "None")")
237
237
  request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
238
238
 
239
+ // Add API headers
240
+ if let apiKey = EnvironmentConfig.apiKey,
241
+ let apiSecret = EnvironmentConfig.apiSecret {
242
+ request.addValue(apiKey, forHTTPHeaderField: "x-api-key")
243
+ request.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
244
+ }
245
+
239
246
  let params: [String: Any] = [
240
247
  "card_search_value": email ?? "",
241
248
  "card_search_key": "email",
@@ -362,6 +369,13 @@ class OTPVerificationVC: BaseVC {
362
369
  print("Setting clientToken header: \(token ?? "None")")
363
370
  request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
364
371
 
372
+ // Add API headers
373
+ if let apiKey = EnvironmentConfig.apiKey,
374
+ let apiSecret = EnvironmentConfig.apiSecret {
375
+ request.addValue(apiKey, forHTTPHeaderField: "x-api-key")
376
+ request.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
377
+ }
378
+
365
379
  let params: [String: Any] = [
366
380
  "card_search_value": email ?? "",
367
381
  "card_search_key": "email"
@@ -438,6 +452,13 @@ class OTPVerificationVC: BaseVC {
438
452
  print("Setting clientToken header: \(token ?? "None")")
439
453
  request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
440
454
 
455
+ // Add API headers
456
+ if let apiKey = EnvironmentConfig.apiKey,
457
+ let apiSecret = EnvironmentConfig.apiSecret {
458
+ request.addValue(apiKey, forHTTPHeaderField: "x-api-key")
459
+ request.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
460
+ }
461
+
441
462
  guard let billingInfoData = billingInfoData else {
442
463
  print("Billing info data is nil")
443
464
  return
@@ -547,7 +568,13 @@ class OTPVerificationVC: BaseVC {
547
568
  self.presentPaymentErrorVC(errorMessage: "No data received")
548
569
  }
549
570
  } else {
550
- self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
571
+ if let data = serviceData,
572
+ let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
573
+ let message = responseObj["message"] as? String {
574
+ self.presentPaymentErrorVC(errorMessage: message)
575
+ } else {
576
+ self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
577
+ }
551
578
  }
552
579
  }
553
580
  task.resume()
@@ -573,6 +600,13 @@ class OTPVerificationVC: BaseVC {
573
600
  print("Setting clientToken header: \(token ?? "None")")
574
601
  request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
575
602
 
603
+ // Add API headers
604
+ if let apiKey = EnvironmentConfig.apiKey,
605
+ let apiSecret = EnvironmentConfig.apiSecret {
606
+ request.addValue(apiKey, forHTTPHeaderField: "x-api-key")
607
+ request.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
608
+ }
609
+
576
610
  let emailPrefix = email?.components(separatedBy: "@").first ?? ""
577
611
 
578
612
  var params: [String: Any] = [
@@ -658,7 +692,13 @@ class OTPVerificationVC: BaseVC {
658
692
  self.presentPaymentErrorVC(errorMessage: "No data received")
659
693
  }
660
694
  } else {
661
- self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
695
+ if let data = serviceData,
696
+ let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
697
+ let message = responseObj["message"] as? String {
698
+ self.presentPaymentErrorVC(errorMessage: message)
699
+ } else {
700
+ self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
701
+ }
662
702
  }
663
703
  }
664
704
  task.resume()
@@ -694,6 +734,13 @@ class OTPVerificationVC: BaseVC {
694
734
  print("Setting clientToken header: \(token ?? "None")")
695
735
  request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
696
736
 
737
+ // Add API headers
738
+ if let apiKey = EnvironmentConfig.apiKey,
739
+ let apiSecret = EnvironmentConfig.apiSecret {
740
+ request.addValue(apiKey, forHTTPHeaderField: "x-api-key")
741
+ request.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
742
+ }
743
+
697
744
  guard let billingInfoData = billingInfoData else {
698
745
  print("Billing info data is nil")
699
746
  return
@@ -802,7 +849,13 @@ class OTPVerificationVC: BaseVC {
802
849
  self.presentPaymentErrorVC(errorMessage: "No data received")
803
850
  }
804
851
  } else {
805
- self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
852
+ if let data = serviceData,
853
+ let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
854
+ let message = responseObj["message"] as? String {
855
+ self.presentPaymentErrorVC(errorMessage: message)
856
+ } else {
857
+ self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
858
+ }
806
859
  }
807
860
  }
808
861
  task.resume()
@@ -828,6 +881,13 @@ class OTPVerificationVC: BaseVC {
828
881
  print("Setting clientToken header: \(token ?? "None")")
829
882
  request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
830
883
 
884
+ // Add API headers
885
+ if let apiKey = EnvironmentConfig.apiKey,
886
+ let apiSecret = EnvironmentConfig.apiSecret {
887
+ request.addValue(apiKey, forHTTPHeaderField: "x-api-key")
888
+ request.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
889
+ }
890
+
831
891
  let emailPrefix = email?.components(separatedBy: "@").first ?? ""
832
892
 
833
893
  var params: [String: Any] = [
@@ -912,7 +972,13 @@ class OTPVerificationVC: BaseVC {
912
972
  self.presentPaymentErrorVC(errorMessage: "No data received")
913
973
  }
914
974
  } else {
915
- self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
975
+ if let data = serviceData,
976
+ let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
977
+ let message = responseObj["message"] as? String {
978
+ self.presentPaymentErrorVC(errorMessage: message)
979
+ } else {
980
+ self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
981
+ }
916
982
  }
917
983
  }
918
984
  task.resume()
@@ -1016,7 +1082,13 @@ class OTPVerificationVC: BaseVC {
1016
1082
  self.presentPaymentErrorVC(errorMessage: "No data received")
1017
1083
  }
1018
1084
  } else {
1019
- self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
1085
+ if let data = serviceData,
1086
+ let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
1087
+ let message = responseObj["message"] as? String {
1088
+ self.presentPaymentErrorVC(errorMessage: message)
1089
+ } else {
1090
+ self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
1091
+ }
1020
1092
  }
1021
1093
  }
1022
1094
  task.resume()
@@ -18,7 +18,10 @@ class PaymentDoneVC: UIViewController {
18
18
  @IBOutlet weak var lblHeadingDate: UILabel!
19
19
  @IBOutlet weak var lblHeadingTransactionID: UILabel!
20
20
  @IBOutlet weak var lbHeadingPaymentMethod: UILabel!
21
- @IBOutlet weak var lblHeadingTotal: UILabel!
21
+ @IBOutlet weak var lblHeadingTotal: UILabel!
22
+
23
+ @IBOutlet weak var viewSubscriptionId: UIStackView!
24
+ @IBOutlet weak var lblSubscriptionId: UILabel!
22
25
 
23
26
  var chargeData: [String: Any]?
24
27
  var selectedPaymentMethod: String?