@jimrising/easymerchantsdk-react-native 2.5.2 → 2.5.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.
@@ -79,6 +79,8 @@ class OTPVerificationVC: BaseVC {
79
79
 
80
80
  var isSavedNewAccount: Bool?
81
81
  var isFrom = String()
82
+ /// After OTP success for manual ACH: "direct" = charge here, "billing" = push BillingInfoVC, "additional" = push AdditionalInfoVC
83
+ var afterOTPFlow: String?
82
84
 
83
85
  override func viewDidLoad() {
84
86
  super.viewDidLoad()
@@ -429,22 +431,37 @@ class OTPVerificationVC: BaseVC {
429
431
  }
430
432
  }
431
433
  else if self.selectedPaymentMethod == "Bank" {
432
-
433
- if let dataSection = responseObject["data"] as? [String: Any],
434
- let innerData = dataSection["data"] as? [String: Any],
435
- let customerId = innerData["customer_id"] as? String {
436
- if self.billingInfoData == nil {
437
- self.accountChargeWithSavedAccountApi(customerId: customerId)
434
+ let flow = self.afterOTPFlow ?? "direct"
435
+ let customerId = (responseObject["data"] as? [String: Any]).flatMap { $0["data"] as? [String: Any] }.flatMap { $0["customer_id"] as? String }
436
+ if flow == "billing" {
437
+ if let id = customerId {
438
+ UserStoreSingleton.shared.customerId = id
438
439
  }
439
- else {
440
- self.accountChargeApi(customerId: customerId)
440
+ DispatchQueue.main.async {
441
+ self.pushBillingInfoVCAfterOTP()
441
442
  }
442
- } else {
443
- if self.billingInfoData == nil {
444
- self.accountChargeWithSavedAccountApi(customerId: nil)
443
+ } else if flow == "additional" {
444
+ if let id = customerId {
445
+ UserStoreSingleton.shared.customerId = id
445
446
  }
446
- else {
447
- self.accountChargeApi(customerId: nil)
447
+ DispatchQueue.main.async {
448
+ self.pushAdditionalInfoVCAfterOTP()
449
+ }
450
+ } else {
451
+ if let customerId = customerId {
452
+ if self.billingInfoData == nil {
453
+ self.accountChargeWithSavedAccountApi(customerId: customerId)
454
+ }
455
+ else {
456
+ self.accountChargeApi(customerId: customerId)
457
+ }
458
+ } else {
459
+ if self.billingInfoData == nil {
460
+ self.accountChargeWithSavedAccountApi(customerId: nil)
461
+ }
462
+ else {
463
+ self.accountChargeApi(customerId: nil)
464
+ }
448
465
  }
449
466
  }
450
467
  }
@@ -939,6 +956,50 @@ class OTPVerificationVC: BaseVC {
939
956
  }
940
957
  }
941
958
 
959
+ /// Push BillingInfoVC after OTP success for manual ACH (save account) when billing is visible.
960
+ private func pushBillingInfoVCAfterOTP() {
961
+ guard let vc = storyboard?.instantiateViewController(withIdentifier: "BillingInfoVC") as? BillingInfoVC else { return }
962
+ vc.accountName = accountName
963
+ vc.routingNumber = routingNumber
964
+ vc.accountType = accountType
965
+ vc.accountNumber = accountNumber
966
+ vc.billingInfoData = billingInfoData
967
+ vc.selectedPaymentMethod = "Bank"
968
+ vc.isFrom = "AddNewAccountWithSave"
969
+ vc.isSavedNewAccount = true
970
+ vc.chosenPlan = chosenPlan
971
+ vc.startDate = startDate
972
+ vc.request = request
973
+ vc.amount = amount ?? 0
974
+ vc.billingInfo = billingInfo
975
+ vc.additionalInfo = additionalInfo
976
+ vc.visibility = visibility
977
+ vc.easyPayDelegate = easyPayDelegate
978
+ navigationController?.pushViewController(vc, animated: true)
979
+ }
980
+
981
+ /// Push AdditionalInfoVC after OTP success for manual ACH (save account) when additional is visible.
982
+ private func pushAdditionalInfoVCAfterOTP() {
983
+ guard let vc = storyboard?.instantiateViewController(withIdentifier: "AdditionalInfoVC") as? AdditionalInfoVC else { return }
984
+ vc.accountName = accountName
985
+ vc.routingNumber = routingNumber
986
+ vc.accountType = accountType
987
+ vc.accountNumber = accountNumber
988
+ vc.billingInfoData = billingInfoData
989
+ vc.selectedPaymentMethod = "Bank"
990
+ vc.isFrom = "AddNewAccountWithSave"
991
+ vc.isSavedNewAccount = true
992
+ vc.chosenPlan = chosenPlan
993
+ vc.startDate = startDate
994
+ vc.request = request
995
+ vc.amount = amount ?? 0
996
+ vc.billingInfo = billingInfo
997
+ vc.additionalInfo = additionalInfo
998
+ vc.visibility = visibility
999
+ vc.easyPayDelegate = easyPayDelegate
1000
+ navigationController?.pushViewController(vc, animated: true)
1001
+ }
1002
+
942
1003
  //MARK: - Account Charge Api
943
1004
  func accountChargeApi(customerId: String?) {
944
1005
  showLoadingIndicator()