@jimrising/easymerchantsdk-react-native 1.4.3 → 1.4.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.
@@ -363,7 +363,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
363
363
  var isFrom = String()
364
364
 
365
365
  //Blink Card
366
- // var blinkCardRecognizer: MBCBlinkCardRecognizer!
366
+ // var blinkCardRecognizer: MBCBlinkCardRecognizer!
367
367
 
368
368
  // Variables for Card Scanning Data Back
369
369
  var cardNumber: String?
@@ -1931,8 +1931,62 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
1931
1931
  }
1932
1932
 
1933
1933
  // Redirect based on billing visibility
1934
- if fieldSection.visibility.billing {
1935
- // Instantiate BillingInfoVC and pass the selected card data and CVV text
1934
+ // if fieldSection.visibility.billing {
1935
+ // // Instantiate BillingInfoVC and pass the selected card data and CVV text
1936
+ // let billingInfoVC = UIStoryboard(name: "easymerchantsdk", bundle: .easyPayBundle).instantiateViewController(withIdentifier: "BillingInfoVC") as! BillingInfoVC
1937
+ //
1938
+ // billingInfoVC.isFrom = "SavedCards"
1939
+ // billingInfoVC.selectedCard = self.selectedCard // Passing the selected card data
1940
+ // billingInfoVC.cvvText = cvvText // Passing the CVV text
1941
+ // billingInfoVC.amount = Int(self.request.amount ?? 0)
1942
+ // billingInfoVC.selectedPaymentMethod = self.selectedPaymentMethod
1943
+ //
1944
+ // if let billingInfoData = self.request.billingInfoData {
1945
+ // billingInfoVC.billingInfoData = billingInfoData
1946
+ // }
1947
+ //
1948
+ // billingInfoVC.request = self.request
1949
+ // billingInfoVC.chosenPlan = self.txtFieldSelectPlanSingleSavedCard.text
1950
+ // billingInfoVC.startDate = self.txtFieldSelectDateSingleSavedCard.text
1951
+ //
1952
+ // billingInfoVC.billingInfo = fieldSection.billing
1953
+ // billingInfoVC.additionalInfo = fieldSection.additional
1954
+ // billingInfoVC.visibility = fieldSection.visibility
1955
+ //
1956
+ // // Navigate to BillingInfoVC
1957
+ // self.navigationController?.pushViewController(billingInfoVC, animated: true)
1958
+ // }
1959
+ // else {
1960
+ // let additionalInfoVC = UIStoryboard(name: "easymerchantsdk", bundle: .easyPayBundle).instantiateViewController(withIdentifier: "AdditionalInfoVC") as! AdditionalInfoVC
1961
+ // additionalInfoVC.isFrom = "SavedCards"
1962
+ // additionalInfoVC.selectedCard = self.selectedCard // Passing the selected card data
1963
+ // additionalInfoVC.cvvText = cvvText // Passing the CVV text
1964
+ // additionalInfoVC.amount = Int(self.request.amount ?? 0)
1965
+ // additionalInfoVC.selectedPaymentMethod = self.selectedPaymentMethod
1966
+ //
1967
+ // if let billingInfoData = self.request.billingInfoData {
1968
+ // additionalInfoVC.billingInfoData = billingInfoData
1969
+ // }
1970
+ //
1971
+ // additionalInfoVC.request = self.request
1972
+ // additionalInfoVC.chosenPlan = self.txtFieldSelectPlanSingleSavedCard.text
1973
+ // additionalInfoVC.startDate = self.txtFieldSelectDateSingleSavedCard.text
1974
+ //
1975
+ // additionalInfoVC.billingInfo = fieldSection.billing
1976
+ // additionalInfoVC.additionalInfo = fieldSection.additional
1977
+ // additionalInfoVC.visibility = fieldSection.visibility
1978
+ //
1979
+ // self.navigationController?.pushViewController(additionalInfoVC, animated: true)
1980
+ // }
1981
+
1982
+ let showBilling = fieldSection.visibility.billing
1983
+ let showAdditional = fieldSection.visibility.additional
1984
+
1985
+ if !showBilling && !showAdditional {
1986
+ self.paymentIntentFromShowCardApi()
1987
+ }
1988
+ else if showBilling {
1989
+ // Push to BillingInfoVC
1936
1990
  let billingInfoVC = UIStoryboard(name: "easymerchantsdk", bundle: .easyPayBundle).instantiateViewController(withIdentifier: "BillingInfoVC") as! BillingInfoVC
1937
1991
 
1938
1992
  billingInfoVC.isFrom = "SavedCards"
@@ -1957,6 +2011,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
1957
2011
  self.navigationController?.pushViewController(billingInfoVC, animated: true)
1958
2012
  }
1959
2013
  else {
2014
+ // Push to AdditionalInfoVC
1960
2015
  let additionalInfoVC = UIStoryboard(name: "easymerchantsdk", bundle: .easyPayBundle).instantiateViewController(withIdentifier: "AdditionalInfoVC") as! AdditionalInfoVC
1961
2016
  additionalInfoVC.isFrom = "SavedCards"
1962
2017
  additionalInfoVC.selectedCard = self.selectedCard // Passing the selected card data
@@ -1978,6 +2033,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
1978
2033
 
1979
2034
  self.navigationController?.pushViewController(additionalInfoVC, animated: true)
1980
2035
  }
2036
+
1981
2037
  }
1982
2038
  }
1983
2039
  catch {
@@ -2193,7 +2249,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
2193
2249
 
2194
2250
  let showBilling = fieldSection.visibility.billing
2195
2251
  let showAdditional = fieldSection.visibility.additional
2196
-
2252
+
2197
2253
  if !showBilling && !showAdditional {
2198
2254
  self.threeDSecurePaymentNewCardApi(customerId: UserStoreSingleton.shared.customerId ?? "")
2199
2255
  }
@@ -2751,7 +2807,8 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
2751
2807
 
2752
2808
  if !showBilling && !showAdditional {
2753
2809
  // Navigate directly to EmailVerificationVC
2754
- let vc = easymerchantsdk.instantiateViewController(withIdentifier: "EmailVerificationVC") as! EmailVerificationVC
2810
+ // let vc = easymerchantsdk.instantiateViewController(withIdentifier: "EmailVerificationVC") as! EmailVerificationVC
2811
+ let vc = easymerchantsdk.instantiateViewController(withIdentifier: "OTPVerificationVC") as! OTPVerificationVC
2755
2812
  vc.easyPayDelegate = self.easyPayDelegate
2756
2813
  vc.grailPayAccountID = self.grailPayAccountID
2757
2814
  vc.selectedGrailPayAccountType = self.selectedGrailPayAccountType
@@ -2766,6 +2823,8 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
2766
2823
  vc.billingInfo = fieldSection.billing
2767
2824
  vc.additionalInfo = fieldSection.additional
2768
2825
  vc.visibility = fieldSection.visibility
2826
+ vc.amount = self.amount
2827
+ vc.email = self.txtFieldEmailGrailPayView.text
2769
2828
  self.navigationController?.pushViewController(vc, animated: true)
2770
2829
  }
2771
2830
  else if showBilling {
@@ -2819,7 +2878,8 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
2819
2878
  else {
2820
2879
  //If billing info is nil
2821
2880
  // Navigate to EmailVerificationVC directly
2822
- let vc = easymerchantsdk.instantiateViewController(withIdentifier: "EmailVerificationVC") as! EmailVerificationVC
2881
+ // let vc = easymerchantsdk.instantiateViewController(withIdentifier: "EmailVerificationVC") as! EmailVerificationVC
2882
+ let vc = easymerchantsdk.instantiateViewController(withIdentifier: "OTPVerificationVC") as! OTPVerificationVC
2823
2883
  vc.easyPayDelegate = self.easyPayDelegate
2824
2884
  vc.grailPayAccountID = self.grailPayAccountID
2825
2885
  vc.selectedGrailPayAccountType = self.selectedGrailPayAccountType
@@ -2829,7 +2889,8 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
2829
2889
  vc.request = self.request
2830
2890
  vc.isSavedForFuture = self.isSavedForFuture
2831
2891
  vc.selectedPaymentMethod = "GrailPay"
2832
- vc.userEmail = self.txtFieldEmailGrailPayView.text
2892
+ vc.email = self.txtFieldEmailGrailPayView.text
2893
+ vc.amount = self.amount
2833
2894
  self.navigationController?.pushViewController(vc, animated: true)
2834
2895
  }
2835
2896
  } else {
@@ -4113,7 +4174,11 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
4113
4174
  let showAdditional = fieldSection.visibility.additional
4114
4175
 
4115
4176
  if !showBilling && !showAdditional {
4116
- self.threeDSecurePaymentApi()
4177
+ if self.isSavedForFuture {
4178
+ self.navigateCardDataToEmailVerificationVC()
4179
+ } else {
4180
+ self.threeDSecurePaymentApi()
4181
+ }
4117
4182
  }
4118
4183
  else if showBilling {
4119
4184
  // Push to BillingInfoVC
@@ -4444,7 +4509,8 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
4444
4509
 
4445
4510
  // Function to navigate to EmailVerificationVC
4446
4511
  func navigateCardDataToEmailVerificationVC() {
4447
- if let emailVerificationVC = storyboard?.instantiateViewController(withIdentifier: "EmailVerificationVC") as? EmailVerificationVC {
4512
+ // if let emailVerificationVC = storyboard?.instantiateViewController(withIdentifier: "EmailVerificationVC") as? EmailVerificationVC {
4513
+ if let emailVerificationVC = storyboard?.instantiateViewController(withIdentifier: "OTPVerificationVC") as? OTPVerificationVC {
4448
4514
  if let billingInfoData = request.billingInfoData {
4449
4515
  do {
4450
4516
  let fieldSection = try JSONDecoder().decode(FieldSection.self, from: billingInfoData)
@@ -4463,6 +4529,9 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
4463
4529
  emailVerificationVC.request = self.request
4464
4530
  emailVerificationVC.chosenPlan = self.txtFieldChosePlanCard.text
4465
4531
  emailVerificationVC.startDate = self.txtFieldStartDateCard.text
4532
+ emailVerificationVC.userEmail = self.txtFieldEmailCardView.text
4533
+ emailVerificationVC.email = self.txtFieldEmailCardView.text
4534
+ emailVerificationVC.amount = self.amount
4466
4535
  }
4467
4536
  catch {
4468
4537
  print("Failed to decode billingInfoData: \(error.localizedDescription)")
@@ -4472,7 +4541,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
4472
4541
  self.navigationController?.pushViewController(emailVerificationVC, animated: true)
4473
4542
  }
4474
4543
  }
4475
-
4544
+
4476
4545
  func navigateBankDataToEmailVerificationVC() {
4477
4546
  if let emailVerificationVC = storyboard?.instantiateViewController(withIdentifier: "EmailVerificationVC") as? EmailVerificationVC {
4478
4547
  if let billingInfoData = request.billingInfoData {
@@ -4493,6 +4562,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
4493
4562
  emailVerificationVC.chosenPlan = self.txtFieldSelectPlanViewBankFields.text
4494
4563
  emailVerificationVC.startDate = self.txtFieldSelectDateViewBankFields.text
4495
4564
  emailVerificationVC.request = self.request
4565
+ emailVerificationVC.userEmail = self.txtFieldEmailAccountView.text
4496
4566
  }
4497
4567
  catch {
4498
4568
  print("Failed to decode billingInfoData: \(error.localizedDescription)")
@@ -5915,6 +5985,210 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
5915
5985
  task.resume()
5916
5986
  }
5917
5987
 
5988
+ //MARK: - Credit Card Charge Api from Saved cards if Billing info exist but not go to billing and additonal page
5989
+ func paymentIntentFromShowCardApi() {
5990
+ showLoadingIndicator()
5991
+
5992
+ let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.charges.path()
5993
+
5994
+ guard let serviceURL = URL(string: fullURL) else {
5995
+ print("Invalid URL")
5996
+ hideLoadingIndicator()
5997
+ return
5998
+ }
5999
+
6000
+ var uRLRequest = URLRequest(url: serviceURL)
6001
+ uRLRequest.httpMethod = "POST"
6002
+ uRLRequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
6003
+
6004
+ let token = UserStoreSingleton.shared.clientToken
6005
+ print("Setting clientToken header: \(token ?? "None")")
6006
+ uRLRequest.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
6007
+
6008
+ var params: [String: Any] = [
6009
+ "currency": "usd",
6010
+ "payment_method": "card",
6011
+ "save_card": 0,
6012
+ "customer" : selectedCard?.customerId ?? "",
6013
+ "customer_id" : selectedCard?.customerId ?? "",
6014
+ "card_id" : selectedCard?.cardId ?? "",
6015
+ "cvc" : txtFieldCVVSingleSavedCard.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "",
6016
+ ]
6017
+
6018
+ if let billingInfoData = request.billingInfoData {
6019
+ do {
6020
+ let fieldSection = try JSONDecoder().decode(FieldSection.self, from: billingInfoData)
6021
+
6022
+ // Billing Info
6023
+ let billing = fieldSection.billing
6024
+ if !billing.isEmpty {
6025
+ var billingDict: [String: Any] = [:]
6026
+ billing.forEach { billingDict[$0.name] = $0.value }
6027
+
6028
+ if let address = billingDict["address"] as? String, !address.isEmpty {
6029
+ params["address"] = address
6030
+ }
6031
+ if let country = billingDict["country"] as? String, !country.isEmpty {
6032
+ params["country"] = country
6033
+ }
6034
+ if let state = billingDict["state"] as? String, !state.isEmpty {
6035
+ params["state"] = state
6036
+ }
6037
+ if let city = billingDict["city"] as? String, !city.isEmpty {
6038
+ params["city"] = city
6039
+ }
6040
+ if let postalCode = billingDict["postal_code"] as? String, !postalCode.isEmpty {
6041
+ params["zip"] = postalCode
6042
+ }
6043
+ }
6044
+
6045
+ // Additional Info
6046
+ let additional = fieldSection.additional
6047
+ if !additional.isEmpty {
6048
+ var additionalDict: [String: Any] = [:]
6049
+ additional.forEach { additionalDict[$0.name] = $0.value }
6050
+
6051
+ if let desc = additionalDict["description"] as? String, !desc.isEmpty {
6052
+ params["description"] = desc
6053
+ } else {
6054
+ params["description"] = "Hosted payment checkout"
6055
+ }
6056
+
6057
+ if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
6058
+ params["phone_number"] = phone
6059
+ }
6060
+ if let email = additionalDict["email"] as? String, !email.isEmpty {
6061
+ params["email"] = email
6062
+ }
6063
+ if let name = additionalDict["name"] as? String, !name.isEmpty {
6064
+ params["name"] = name
6065
+ }
6066
+ } else {
6067
+ // If no description in additional info, set default
6068
+ params["description"] = "Hosted payment checkout"
6069
+ }
6070
+
6071
+ } catch {
6072
+ print("Failed to decode FieldSection: \(error)")
6073
+ params["description"] = "Hosted payment checkout"
6074
+ }
6075
+ } else {
6076
+ // Fallback if billingInfoData is missing
6077
+ params["description"] = "Hosted payment checkout"
6078
+ }
6079
+
6080
+ // Add these if recurring is enabled
6081
+ if let req = request, req.is_recurring == true {
6082
+ if let recurringType = req.recurringStartDateType, recurringType == .custom {
6083
+ // Only send start_date if type is .custom and field is not empty
6084
+ if let startDateText = txtFieldSelectDateSingleSavedCard?.text, !startDateText.isEmpty {
6085
+ let inputFormatter = DateFormatter()
6086
+ inputFormatter.dateFormat = "dd/MM/yyyy"
6087
+
6088
+ let outputFormatter = DateFormatter()
6089
+ outputFormatter.dateFormat = "MM/dd/yyyy"
6090
+
6091
+ if let date = inputFormatter.date(from: startDateText) {
6092
+ let apiFormattedDate = outputFormatter.string(from: date)
6093
+ params["start_date"] = apiFormattedDate
6094
+ } else {
6095
+ print("Invalid date format in startDateText")
6096
+ }
6097
+ }
6098
+ }
6099
+
6100
+ params["interval"] = txtFieldSelectPlanSingleSavedCard.text.lowercased()
6101
+ }
6102
+
6103
+ do {
6104
+ let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
6105
+ uRLRequest.httpBody = jsonData
6106
+ if let jsonString = String(data: jsonData, encoding: .utf8) {
6107
+ print("JSON Payload: \(jsonString)")
6108
+ }
6109
+ } catch let error {
6110
+ print("Error creating JSON data: \(error)")
6111
+ hideLoadingIndicator()
6112
+ return
6113
+ }
6114
+
6115
+ let session = URLSession.shared
6116
+ let task = session.dataTask(with: uRLRequest) { (serviceData, serviceResponse, error) in
6117
+
6118
+ DispatchQueue.main.async {
6119
+ self.hideLoadingIndicator() // Stop loader when response is received
6120
+ }
6121
+
6122
+ if let error = error {
6123
+ print("Error: \(error.localizedDescription)")
6124
+ return
6125
+ }
6126
+
6127
+ guard let httpResponse = serviceResponse as? HTTPURLResponse else {
6128
+ print("Invalid response")
6129
+ return
6130
+ }
6131
+
6132
+ if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
6133
+ if let data = serviceData {
6134
+ do {
6135
+ if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
6136
+ print("Response Data: \(responseObject)")
6137
+
6138
+ // Check if status is 0 and handle the error
6139
+ if let status = responseObject["status"] as? Int, status == 0 {
6140
+ let errorMessage = responseObject["message"] as? String ?? "Unknown error"
6141
+ self.presentPaymentErrorVC(errorMessage: errorMessage)
6142
+ } else {
6143
+ DispatchQueue.main.async {
6144
+ if let paymentDoneVC = self.storyboard?.instantiateViewController(withIdentifier: "PaymentDoneVC") as? PaymentDoneVC {
6145
+ paymentDoneVC.chargeData = responseObject
6146
+ paymentDoneVC.selectedPaymentMethod = self.selectedPaymentMethod
6147
+ paymentDoneVC.easyPayDelegate = self.easyPayDelegate
6148
+ // Pass billing info and additional info if available
6149
+ if let billingInfoData = self.request.billingInfoData,
6150
+ let fieldSection = try? JSONDecoder().decode(FieldSection.self, from: billingInfoData) {
6151
+
6152
+ // Filter billing info: only include non-empty values
6153
+ let filteredBilling = fieldSection.billing.filter { !($0.value.trimmingCharacters(in: .whitespaces).isEmpty) }
6154
+ paymentDoneVC.billingInfoData = filteredBilling
6155
+ var billingDict: [String: Any] = [:]
6156
+ filteredBilling.forEach { billingDict[$0.name] = $0.value }
6157
+ paymentDoneVC.billingInfo = billingDict
6158
+
6159
+ // Filter additional info: only include non-empty values
6160
+ let filteredAdditional = fieldSection.additional.filter { !($0.value.trimmingCharacters(in: .whitespaces).isEmpty) }
6161
+ paymentDoneVC.additionalInfoData = filteredAdditional
6162
+ var additionalDict: [String: Any] = [:]
6163
+ filteredAdditional.forEach { additionalDict[$0.name] = $0.value }
6164
+ paymentDoneVC.additionalInfo = additionalDict
6165
+ }
6166
+ self.navigationController?.pushViewController(paymentDoneVC, animated: true)
6167
+ }
6168
+ }
6169
+ }
6170
+ } else {
6171
+ self.presentPaymentErrorVC(errorMessage: "Invalid JSON format")
6172
+ }
6173
+ } catch let jsonError {
6174
+ self.presentPaymentErrorVC(errorMessage: "Error parsing JSON: \(jsonError)")
6175
+ }
6176
+ } else {
6177
+ self.presentPaymentErrorVC(errorMessage: "No data received")
6178
+ }
6179
+ } else {
6180
+ if let data = serviceData,
6181
+ let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
6182
+ let message = responseObj["message"] as? String {
6183
+ self.presentPaymentErrorVC(errorMessage: message)
6184
+ } else {
6185
+ self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
6186
+ }
6187
+ }
6188
+ }
6189
+ task.resume()
6190
+ }
6191
+
5918
6192
  //MARK: - Credit Card Charge Api from Add new cards If Billing info is nil and Logged in.
5919
6193
  func paymentIntentFromAddNewCardApi(customerId: String?) {
5920
6194
  // Get the text fields from the selected cell and trim whitespace
@@ -7691,44 +7965,22 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
7691
7965
  paymentDoneVC.chargeData = responseObject
7692
7966
  paymentDoneVC.easyPayDelegate = self.easyPayDelegate
7693
7967
  paymentDoneVC.amount = self.amount
7694
- // // Pass billingInfo and additionalInfo
7695
- // if let billingData = self.request.billingInfoData,
7696
- // let billingInfoDict = try? JSONSerialization.jsonObject(with: billingData, options: []) as? [String: Any] {
7697
- //
7698
- // // Extract main billing fields
7699
- // let cleanBillingInfo: [String: Any] = [
7700
- // "postal_code": billingInfoDict["postal_code"] ?? "",
7701
- // "country": billingInfoDict["country"] ?? "",
7702
- // "city": billingInfoDict["city"] ?? "",
7703
- // "address": billingInfoDict["address"] ?? "",
7704
- // "state": billingInfoDict["state"] ?? ""
7705
- // ]
7706
- // paymentDoneVC.billingInfo = cleanBillingInfo
7707
- //
7708
- // // Extract additional_info
7709
- // if let additional = billingInfoDict["additional_info"] as? [String: Any] {
7710
- // let cleanAdditionalInfo: [String: Any] = [
7711
- // "email": additional["email"] ?? "",
7712
- // "phone_number": additional["phone_number"] ?? "",
7713
- // "name": additional["name"] ?? "",
7714
- // "country_code": additional["country_code"] ?? ""
7715
- // ]
7716
- // paymentDoneVC.additionalInfo = cleanAdditionalInfo
7717
- // }
7718
- // }
7719
-
7720
7968
  // Pass billing info and additional info if available
7721
7969
  if let billingInfoData = self.request.billingInfoData,
7722
7970
  let fieldSection = try? JSONDecoder().decode(FieldSection.self, from: billingInfoData) {
7723
7971
 
7724
- paymentDoneVC.billingInfoData = fieldSection.billing
7972
+ // Filter billing info: only include non-empty values
7973
+ let filteredBilling = fieldSection.billing.filter { !($0.value.trimmingCharacters(in: .whitespaces).isEmpty) }
7974
+ paymentDoneVC.billingInfoData = filteredBilling
7725
7975
  var billingDict: [String: Any] = [:]
7726
- fieldSection.billing.forEach { billingDict[$0.name] = $0.value }
7976
+ filteredBilling.forEach { billingDict[$0.name] = $0.value }
7727
7977
  paymentDoneVC.billingInfo = billingDict
7728
-
7729
- paymentDoneVC.additionalInfoData = fieldSection.additional
7978
+
7979
+ // Filter additional info: only include non-empty values
7980
+ let filteredAdditional = fieldSection.additional.filter { !($0.value.trimmingCharacters(in: .whitespaces).isEmpty) }
7981
+ paymentDoneVC.additionalInfoData = filteredAdditional
7730
7982
  var additionalDict: [String: Any] = [:]
7731
- fieldSection.additional.forEach { additionalDict[$0.name] = $0.value }
7983
+ filteredAdditional.forEach { additionalDict[$0.name] = $0.value }
7732
7984
  paymentDoneVC.additionalInfo = additionalDict
7733
7985
  }
7734
7986
  self.navigationController?.pushViewController(paymentDoneVC, animated: true)
@@ -8007,14 +8259,18 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
8007
8259
  if let billingInfoData = self.request.billingInfoData,
8008
8260
  let fieldSection = try? JSONDecoder().decode(FieldSection.self, from: billingInfoData) {
8009
8261
 
8010
- paymentDoneVC.billingInfoData = fieldSection.billing
8262
+ // Filter billing info: only include non-empty values
8263
+ let filteredBilling = fieldSection.billing.filter { !($0.value.trimmingCharacters(in: .whitespaces).isEmpty) }
8264
+ paymentDoneVC.billingInfoData = filteredBilling
8011
8265
  var billingDict: [String: Any] = [:]
8012
- fieldSection.billing.forEach { billingDict[$0.name] = $0.value }
8266
+ filteredBilling.forEach { billingDict[$0.name] = $0.value }
8013
8267
  paymentDoneVC.billingInfo = billingDict
8014
-
8015
- paymentDoneVC.additionalInfoData = fieldSection.additional
8268
+
8269
+ // Filter additional info: only include non-empty values
8270
+ let filteredAdditional = fieldSection.additional.filter { !($0.value.trimmingCharacters(in: .whitespaces).isEmpty) }
8271
+ paymentDoneVC.additionalInfoData = filteredAdditional
8016
8272
  var additionalDict: [String: Any] = [:]
8017
- fieldSection.additional.forEach { additionalDict[$0.name] = $0.value }
8273
+ filteredAdditional.forEach { additionalDict[$0.name] = $0.value }
8018
8274
  paymentDoneVC.additionalInfo = additionalDict
8019
8275
  }
8020
8276
  self.navigationController?.pushViewController(paymentDoneVC, animated: true)
@@ -248,21 +248,35 @@ class ThreeDSecurePaymentDoneVC: BaseVC {
248
248
  }
249
249
  }
250
250
 
251
-
252
251
  @IBAction func actionBtnDone(_ sender: UIButton) {
253
- // Combine 3DS status into additionalInfo
252
+ var resultBillingInfo: [String: Any]? = nil
253
+ var resultAdditionalInfo: [String: Any]? = nil
254
+
255
+ // Only assign billingInfo if it contains at least one non-empty key-value pair
256
+ if let billing = billingInfo, !billing.isEmpty {
257
+ resultBillingInfo = billing
258
+ }
259
+
260
+ // Combine 3DS status into additionalInfo if needed
254
261
  var combinedAdditionalInfo = additionalInfo ?? [:]
255
262
  if let threeDS = threeDSecureStatusResponse {
256
263
  combinedAdditionalInfo["threeDSecureStatus"] = threeDS
257
264
  }
258
-
259
- let result = Result(type: .success,
260
- chargeData: chargeData,
261
- billingInfo: billingInfo,
262
- additionalInfo: combinedAdditionalInfo)
263
-
265
+
266
+ // Only assign additionalInfo if it contains at least one non-empty key-value pair
267
+ if !combinedAdditionalInfo.isEmpty {
268
+ resultAdditionalInfo = combinedAdditionalInfo
269
+ }
270
+
271
+ let result = Result(
272
+ type: .success,
273
+ chargeData: chargeData,
274
+ billingInfo: resultBillingInfo,
275
+ additionalInfo: resultAdditionalInfo
276
+ )
277
+
264
278
  easyPayDelegate?.easyPayController(self.navigationController as! EasyPayViewController, didFinishWith: result)
265
-
279
+
266
280
  if let easyPayVC = self.navigationController as? EasyPayViewController {
267
281
  easyPayVC.dismiss(animated: true, completion: {
268
282
  if let delegate = easyPayVC.easyPayDelegate {
@@ -272,7 +286,7 @@ class ThreeDSecurePaymentDoneVC: BaseVC {
272
286
  })
273
287
  }
274
288
  }
275
-
289
+
276
290
  func uiFinishingTouchElements() {
277
291
  // Set background color for the main view
278
292
  if let containerBGcolor = UserStoreSingleton.shared.container_bg_col,
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'easymerchantsdk'
3
- s.version = '1.4.3'
3
+ s.version = '1.4.4'
4
4
  s.summary = 'A React Native SDK for Easy Merchant.'
5
5
  s.description = <<-DESC
6
6
  A React Native SDK to enable Easy Merchant functionality in mobile applications.