@jimrising/easymerchantsdk-react-native 1.4.2 → 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.
- package/README.md +15 -4
- package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$1.dex +0 -0
- package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$2.dex +0 -0
- package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
- package/android/build/.transforms/e9a664a11ce12edf79cd87b1e07aa243/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$1.class.uniqueId2 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$2.class.uniqueId0 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule.class.uniqueId3 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactlibrary/RNEasymerchantsdkModule.java +0 -1
- package/ios/Classes/EasyMerchantSdk.m +4 -2
- package/ios/Classes/EasyMerchantSdk.swift +2 -0
- package/ios/Models/Request.swift +45 -54
- package/ios/Models/Result.swift +1 -0
- package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +310 -88
- package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +289 -59
- package/ios/Pods/ViewControllers/EmailVerificationVC.swift +41 -86
- package/ios/Pods/ViewControllers/OTPVerificationVC.swift +208 -129
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +1304 -158
- package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +24 -258
- package/ios/easymerchantsdk.podspec +1 -1
- package/ios/easymerchantsdk.storyboard +93 -12
- package/package.json +1 -1
|
@@ -201,10 +201,6 @@ class AdditionalInfoVC: BaseVC {
|
|
|
201
201
|
if let secondaryFontColor = UserStoreSingleton.shared.secondary_font_col,
|
|
202
202
|
let placeholderColor = UIColor(hex: secondaryFontColor) {
|
|
203
203
|
lblEasyMerchant.textColor = placeholderColor
|
|
204
|
-
// viewAdditionalInfo.layer.borderColor = placeholderColor.cgColor
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
// viewAdditionalInfo.layer.borderColor = UIColor.systemGray.cgColor
|
|
208
204
|
}
|
|
209
205
|
|
|
210
206
|
if let borderRadiusString = UserStoreSingleton.shared.border_radious,
|
|
@@ -212,17 +208,12 @@ class AdditionalInfoVC: BaseVC {
|
|
|
212
208
|
btnPayNow.layer.cornerRadius = CGFloat(borderRadius) // Set corner radius
|
|
213
209
|
btnPrevious.layer.cornerRadius = CGFloat(borderRadius)
|
|
214
210
|
btnPrevious.layer.borderWidth = 1
|
|
215
|
-
// viewAdditionalInfo.layer.cornerRadius = CGFloat(borderRadius)
|
|
216
|
-
// viewAdditionalInfo.layer.borderWidth = 1
|
|
217
211
|
} else {
|
|
218
212
|
btnPayNow.layer.cornerRadius = 8 // Default value
|
|
219
213
|
btnPrevious.layer.cornerRadius = 8
|
|
220
|
-
// viewAdditionalInfo.layer.borderWidth = 1
|
|
221
|
-
// viewAdditionalInfo.layer.cornerRadius = 8
|
|
222
214
|
}
|
|
223
215
|
btnPayNow.layer.masksToBounds = true // Ensure the corners are clipped properly
|
|
224
216
|
btnPrevious.layer.masksToBounds = true
|
|
225
|
-
// viewAdditionalInfo.layer.masksToBounds = true
|
|
226
217
|
|
|
227
218
|
if let primaryFontColor = UserStoreSingleton.shared.primary_font_col,
|
|
228
219
|
let uiColor = UIColor(hex: primaryFontColor) {
|
|
@@ -328,43 +319,51 @@ class AdditionalInfoVC: BaseVC {
|
|
|
328
319
|
|
|
329
320
|
// MARK: - Flow Based on Conditions
|
|
330
321
|
if isSavedForFuture {
|
|
331
|
-
if
|
|
332
|
-
//
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
emailVerificationVC
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
emailVerificationVC.
|
|
347
|
-
emailVerificationVC.
|
|
348
|
-
emailVerificationVC.
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
322
|
+
if selectedPaymentMethod == "NewGrailPayAccount" {
|
|
323
|
+
// Only call API, do NOT navigate
|
|
324
|
+
grailPayAccountChargeApi(customerId: UserStoreSingleton.shared.customerId)
|
|
325
|
+
} else {
|
|
326
|
+
// Navigate to EmailVerificationVC for all other payment methods
|
|
327
|
+
if let emailVerificationVC = self.storyboard?.instantiateViewController(withIdentifier: "EmailVerificationVC") as? EmailVerificationVC {
|
|
328
|
+
|
|
329
|
+
emailVerificationVC.billingInfoData = billingInfoData
|
|
330
|
+
emailVerificationVC.selectedPaymentMethod = selectedPaymentMethod
|
|
331
|
+
emailVerificationVC.easyPayDelegate = easyPayDelegate
|
|
332
|
+
emailVerificationVC.request = request
|
|
333
|
+
emailVerificationVC.chosenPlan = chosenPlan
|
|
334
|
+
emailVerificationVC.startDate = startDate
|
|
335
|
+
emailVerificationVC.userEmail = userEmail
|
|
336
|
+
emailVerificationVC.billingInfo = fieldSection?.billing
|
|
337
|
+
emailVerificationVC.additionalInfo = fieldSection?.additional
|
|
338
|
+
emailVerificationVC.visibility = fieldSection?.visibility
|
|
339
|
+
emailVerificationVC.amount = amount
|
|
340
|
+
|
|
341
|
+
// Payment method-specific data
|
|
342
|
+
switch selectedPaymentMethod {
|
|
343
|
+
case "Card":
|
|
344
|
+
emailVerificationVC.cardNumber = cardNumber
|
|
345
|
+
emailVerificationVC.expiryDate = expiryDate
|
|
346
|
+
emailVerificationVC.cvv = cvv
|
|
347
|
+
emailVerificationVC.nameOnCard = nameOnCard
|
|
348
|
+
|
|
349
|
+
case "Bank":
|
|
350
|
+
emailVerificationVC.accountName = accountName
|
|
351
|
+
emailVerificationVC.routingNumber = routingNumber
|
|
352
|
+
emailVerificationVC.accountType = accountType
|
|
353
|
+
emailVerificationVC.accountNumber = accountNumber
|
|
354
|
+
|
|
355
|
+
case "GrailPay":
|
|
356
|
+
emailVerificationVC.grailPayAccountID = grailPayAccountID
|
|
357
|
+
emailVerificationVC.selectedGrailPayAccountType = selectedGrailPayAccountType
|
|
358
|
+
emailVerificationVC.selectedGrailPayAccountName = selectedGrailPayAccountName
|
|
359
|
+
emailVerificationVC.isSavedForFuture = true
|
|
360
|
+
|
|
361
|
+
default:
|
|
362
|
+
break
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
navigationController?.pushViewController(emailVerificationVC, animated: true)
|
|
365
366
|
}
|
|
366
|
-
|
|
367
|
-
navigationController?.pushViewController(emailVerificationVC, animated: true)
|
|
368
367
|
}
|
|
369
368
|
}
|
|
370
369
|
else {
|
|
@@ -555,14 +554,14 @@ class AdditionalInfoVC: BaseVC {
|
|
|
555
554
|
// Conditionally pass raw FieldItem array
|
|
556
555
|
paymentDoneVC.visibility = self.visibility
|
|
557
556
|
|
|
558
|
-
|
|
557
|
+
// if self.visibility?.billing == true {
|
|
559
558
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
560
559
|
var billingDict: [String: Any] = [:]
|
|
561
560
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
562
561
|
paymentDoneVC.billingInfo = billingDict
|
|
563
|
-
|
|
562
|
+
// }
|
|
564
563
|
|
|
565
|
-
|
|
564
|
+
// if self.visibility?.additional == true {
|
|
566
565
|
// Update additionalInfo values before sending
|
|
567
566
|
if let index = self.additionalInfo?.firstIndex(where: { $0.name == "description" }) {
|
|
568
567
|
self.additionalInfo?[index].value = self.txtFieldDescription.text ?? ""
|
|
@@ -576,7 +575,7 @@ class AdditionalInfoVC: BaseVC {
|
|
|
576
575
|
var additionalDict: [String: Any] = [:]
|
|
577
576
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
578
577
|
paymentDoneVC.additionalInfo = additionalDict
|
|
579
|
-
|
|
578
|
+
// }
|
|
580
579
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
581
580
|
}
|
|
582
581
|
}
|
|
@@ -760,14 +759,14 @@ class AdditionalInfoVC: BaseVC {
|
|
|
760
759
|
// Conditionally pass raw FieldItem array
|
|
761
760
|
paymentDoneVC.visibility = self.visibility
|
|
762
761
|
|
|
763
|
-
|
|
762
|
+
// if self.visibility?.billing == true {
|
|
764
763
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
765
764
|
var billingDict: [String: Any] = [:]
|
|
766
765
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
767
766
|
paymentDoneVC.billingInfo = billingDict
|
|
768
|
-
|
|
767
|
+
// }
|
|
769
768
|
|
|
770
|
-
|
|
769
|
+
// if self.visibility?.additional == true {
|
|
771
770
|
// Update additionalInfo values before sending
|
|
772
771
|
if let index = self.additionalInfo?.firstIndex(where: { $0.name == "description" }) {
|
|
773
772
|
self.additionalInfo?[index].value = self.txtFieldDescription.text ?? ""
|
|
@@ -781,7 +780,7 @@ class AdditionalInfoVC: BaseVC {
|
|
|
781
780
|
var additionalDict: [String: Any] = [:]
|
|
782
781
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
783
782
|
paymentDoneVC.additionalInfo = additionalDict
|
|
784
|
-
|
|
783
|
+
// }
|
|
785
784
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
786
785
|
}
|
|
787
786
|
}
|
|
@@ -956,14 +955,14 @@ class AdditionalInfoVC: BaseVC {
|
|
|
956
955
|
// Conditionally pass raw FieldItem array
|
|
957
956
|
paymentDoneVC.visibility = self.visibility
|
|
958
957
|
|
|
959
|
-
|
|
958
|
+
// if self.visibility?.billing == true {
|
|
960
959
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
961
960
|
var billingDict: [String: Any] = [:]
|
|
962
961
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
963
962
|
paymentDoneVC.billingInfo = billingDict
|
|
964
|
-
|
|
963
|
+
// }
|
|
965
964
|
|
|
966
|
-
|
|
965
|
+
// if self.visibility?.additional == true {
|
|
967
966
|
// Update additionalInfo values before sending
|
|
968
967
|
if let index = self.additionalInfo?.firstIndex(where: { $0.name == "description" }) {
|
|
969
968
|
self.additionalInfo?[index].value = self.txtFieldDescription.text ?? ""
|
|
@@ -977,7 +976,7 @@ class AdditionalInfoVC: BaseVC {
|
|
|
977
976
|
var additionalDict: [String: Any] = [:]
|
|
978
977
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
979
978
|
paymentDoneVC.additionalInfo = additionalDict
|
|
980
|
-
|
|
979
|
+
// }
|
|
981
980
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
982
981
|
}
|
|
983
982
|
}
|
|
@@ -1138,14 +1137,14 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1138
1137
|
// Conditionally pass raw FieldItem array
|
|
1139
1138
|
paymentDoneVC.visibility = self.visibility
|
|
1140
1139
|
|
|
1141
|
-
|
|
1140
|
+
// if self.visibility?.billing == true {
|
|
1142
1141
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1143
1142
|
var billingDict: [String: Any] = [:]
|
|
1144
1143
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1145
1144
|
paymentDoneVC.billingInfo = billingDict
|
|
1146
|
-
|
|
1145
|
+
// }
|
|
1147
1146
|
|
|
1148
|
-
|
|
1147
|
+
// if self.visibility?.additional == true {
|
|
1149
1148
|
// Update additionalInfo values before sending
|
|
1150
1149
|
if let index = self.additionalInfo?.firstIndex(where: { $0.name == "description" }) {
|
|
1151
1150
|
self.additionalInfo?[index].value = self.txtFieldDescription.text ?? ""
|
|
@@ -1159,7 +1158,7 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1159
1158
|
var additionalDict: [String: Any] = [:]
|
|
1160
1159
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1161
1160
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1162
|
-
|
|
1161
|
+
// }
|
|
1163
1162
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1164
1163
|
}
|
|
1165
1164
|
}
|
|
@@ -1315,14 +1314,14 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1315
1314
|
// Conditionally pass raw FieldItem array
|
|
1316
1315
|
paymentDoneVC.visibility = self.visibility
|
|
1317
1316
|
|
|
1318
|
-
|
|
1317
|
+
// if self.visibility?.billing == true {
|
|
1319
1318
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1320
1319
|
var billingDict: [String: Any] = [:]
|
|
1321
1320
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1322
1321
|
paymentDoneVC.billingInfo = billingDict
|
|
1323
|
-
|
|
1322
|
+
// }
|
|
1324
1323
|
|
|
1325
|
-
|
|
1324
|
+
// if self.visibility?.additional == true {
|
|
1326
1325
|
// Update additionalInfo values before sending
|
|
1327
1326
|
if let index = self.additionalInfo?.firstIndex(where: { $0.name == "description" }) {
|
|
1328
1327
|
self.additionalInfo?[index].value = self.txtFieldDescription.text ?? ""
|
|
@@ -1336,7 +1335,7 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1336
1335
|
var additionalDict: [String: Any] = [:]
|
|
1337
1336
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1338
1337
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1339
|
-
|
|
1338
|
+
// }
|
|
1340
1339
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1341
1340
|
}
|
|
1342
1341
|
}
|
|
@@ -1511,14 +1510,14 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1511
1510
|
// Conditionally pass raw FieldItem array
|
|
1512
1511
|
paymentDoneVC.visibility = self.visibility
|
|
1513
1512
|
|
|
1514
|
-
|
|
1513
|
+
// if self.visibility?.billing == true {
|
|
1515
1514
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1516
1515
|
var billingDict: [String: Any] = [:]
|
|
1517
1516
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1518
1517
|
paymentDoneVC.billingInfo = billingDict
|
|
1519
|
-
|
|
1518
|
+
// }
|
|
1520
1519
|
|
|
1521
|
-
|
|
1520
|
+
// if self.visibility?.additional == true {
|
|
1522
1521
|
// Update additionalInfo values before sending
|
|
1523
1522
|
if let index = self.additionalInfo?.firstIndex(where: { $0.name == "description" }) {
|
|
1524
1523
|
self.additionalInfo?[index].value = self.txtFieldDescription.text ?? ""
|
|
@@ -1532,7 +1531,7 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1532
1531
|
var additionalDict: [String: Any] = [:]
|
|
1533
1532
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1534
1533
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1535
|
-
|
|
1534
|
+
// }
|
|
1536
1535
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1537
1536
|
}
|
|
1538
1537
|
}
|
|
@@ -1703,14 +1702,14 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1703
1702
|
paymentDoneVC.visibility = self.visibility
|
|
1704
1703
|
paymentDoneVC.amount = self.amount
|
|
1705
1704
|
|
|
1706
|
-
|
|
1705
|
+
// if self.visibility?.billing == true {
|
|
1707
1706
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1708
1707
|
var billingDict: [String: Any] = [:]
|
|
1709
1708
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1710
1709
|
paymentDoneVC.billingInfo = billingDict
|
|
1711
|
-
|
|
1710
|
+
// }
|
|
1712
1711
|
|
|
1713
|
-
|
|
1712
|
+
// if self.visibility?.additional == true {
|
|
1714
1713
|
// Update additionalInfo values before sending
|
|
1715
1714
|
if let index = self.additionalInfo?.firstIndex(where: { $0.name == "description" }) {
|
|
1716
1715
|
self.additionalInfo?[index].value = self.txtFieldDescription.text ?? ""
|
|
@@ -1724,7 +1723,7 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1724
1723
|
var additionalDict: [String: Any] = [:]
|
|
1725
1724
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1726
1725
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1727
|
-
|
|
1726
|
+
// }
|
|
1728
1727
|
|
|
1729
1728
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1730
1729
|
}
|
|
@@ -1900,14 +1899,14 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1900
1899
|
paymentDoneVC.visibility = self.visibility
|
|
1901
1900
|
paymentDoneVC.amount = self.amount
|
|
1902
1901
|
|
|
1903
|
-
|
|
1902
|
+
// if self.visibility?.billing == true {
|
|
1904
1903
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1905
1904
|
var billingDict: [String: Any] = [:]
|
|
1906
1905
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1907
1906
|
paymentDoneVC.billingInfo = billingDict
|
|
1908
|
-
|
|
1907
|
+
// }
|
|
1909
1908
|
|
|
1910
|
-
|
|
1909
|
+
// if self.visibility?.additional == true {
|
|
1911
1910
|
// Update additionalInfo values before sending
|
|
1912
1911
|
if let index = self.additionalInfo?.firstIndex(where: { $0.name == "description" }) {
|
|
1913
1912
|
self.additionalInfo?[index].value = self.txtFieldDescription.text ?? ""
|
|
@@ -1921,7 +1920,7 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1921
1920
|
var additionalDict: [String: Any] = [:]
|
|
1922
1921
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1923
1922
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1924
|
-
|
|
1923
|
+
// }
|
|
1925
1924
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1926
1925
|
}
|
|
1927
1926
|
}
|
|
@@ -1983,7 +1982,7 @@ class AdditionalInfoVC: BaseVC {
|
|
|
1983
1982
|
"account_type": self.selectedGrailPayAccountType ?? "",
|
|
1984
1983
|
"name": self.selectedGrailPayAccountName ?? "",
|
|
1985
1984
|
"description": "payment checkout",
|
|
1986
|
-
"email":
|
|
1985
|
+
"email": userEmail ?? ""
|
|
1987
1986
|
]
|
|
1988
1987
|
|
|
1989
1988
|
// Conditionally add billing info
|
|
@@ -2002,18 +2001,23 @@ class AdditionalInfoVC: BaseVC {
|
|
|
2002
2001
|
params["zip"] = billingInfoDict["postal_code"] as? String ?? ""
|
|
2003
2002
|
}
|
|
2004
2003
|
|
|
2005
|
-
//
|
|
2004
|
+
// Additional Info or default description
|
|
2005
|
+
var descriptionValue: String = "Hosted payment checkout" // default
|
|
2006
2006
|
if let visibility = visibility, visibility.additional == true,
|
|
2007
2007
|
let additional = additionalInfo, !additional.isEmpty {
|
|
2008
2008
|
|
|
2009
|
-
var
|
|
2010
|
-
|
|
2011
|
-
|
|
2009
|
+
var additionalDict: [String: Any] = [:]
|
|
2010
|
+
additional.forEach { additionalDict[$0.name] = $0.value }
|
|
2011
|
+
|
|
2012
|
+
if let desc = additionalDict["description"] as? String, !desc.isEmpty {
|
|
2013
|
+
descriptionValue = desc
|
|
2012
2014
|
}
|
|
2013
2015
|
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
+
if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
|
|
2017
|
+
params["phone_number"] = phone
|
|
2018
|
+
}
|
|
2016
2019
|
}
|
|
2020
|
+
params["description"] = descriptionValue
|
|
2017
2021
|
|
|
2018
2022
|
// Add these if recurring is enabled
|
|
2019
2023
|
if let req = request, req.is_recurring == true {
|
|
@@ -2089,14 +2093,14 @@ class AdditionalInfoVC: BaseVC {
|
|
|
2089
2093
|
// Conditionally pass raw FieldItem array
|
|
2090
2094
|
paymentDoneVC.visibility = self.visibility
|
|
2091
2095
|
|
|
2092
|
-
|
|
2096
|
+
// if self.visibility?.billing == true {
|
|
2093
2097
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
2094
2098
|
var billingDict: [String: Any] = [:]
|
|
2095
2099
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
2096
2100
|
paymentDoneVC.billingInfo = billingDict
|
|
2097
|
-
|
|
2101
|
+
// }
|
|
2098
2102
|
|
|
2099
|
-
|
|
2103
|
+
// if self.visibility?.additional == true {
|
|
2100
2104
|
// Update additionalInfo values before sending
|
|
2101
2105
|
if let index = self.additionalInfo?.firstIndex(where: { $0.name == "description" }) {
|
|
2102
2106
|
self.additionalInfo?[index].value = self.txtFieldDescription.text ?? ""
|
|
@@ -2110,7 +2114,225 @@ class AdditionalInfoVC: BaseVC {
|
|
|
2110
2114
|
var additionalDict: [String: Any] = [:]
|
|
2111
2115
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
2112
2116
|
paymentDoneVC.additionalInfo = additionalDict
|
|
2113
|
-
|
|
2117
|
+
// }
|
|
2118
|
+
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
} else {
|
|
2123
|
+
self.presentPaymentErrorVC(errorMessage: "Invalid JSON format")
|
|
2124
|
+
}
|
|
2125
|
+
} catch let jsonError {
|
|
2126
|
+
self.presentPaymentErrorVC(errorMessage: "Error parsing JSON: \(jsonError)")
|
|
2127
|
+
}
|
|
2128
|
+
} else {
|
|
2129
|
+
self.presentPaymentErrorVC(errorMessage: "No data received")
|
|
2130
|
+
}
|
|
2131
|
+
} else {
|
|
2132
|
+
if let data = serviceData,
|
|
2133
|
+
let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
|
|
2134
|
+
let message = responseObj["message"] as? String {
|
|
2135
|
+
self.presentPaymentErrorVC(errorMessage: message)
|
|
2136
|
+
} else {
|
|
2137
|
+
self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
task.resume()
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
//MARK: - GrailPay Account Charge Api if user saved account
|
|
2145
|
+
func grailPayAccountChargeApi(customerId: String?) {
|
|
2146
|
+
showLoadingIndicator()
|
|
2147
|
+
|
|
2148
|
+
let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.achCharge.path()
|
|
2149
|
+
|
|
2150
|
+
guard let serviceURL = URL(string: fullURL) else {
|
|
2151
|
+
print("Invalid URL")
|
|
2152
|
+
hideLoadingIndicator()
|
|
2153
|
+
return
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
var uRLRequest = URLRequest(url: serviceURL)
|
|
2157
|
+
uRLRequest.httpMethod = "POST"
|
|
2158
|
+
uRLRequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
2159
|
+
|
|
2160
|
+
let token = UserStoreSingleton.shared.clientToken
|
|
2161
|
+
print("Setting clientToken header: \(token ?? "None")")
|
|
2162
|
+
uRLRequest.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
|
|
2163
|
+
|
|
2164
|
+
if let apiKey = EnvironmentConfig.apiKey {
|
|
2165
|
+
uRLRequest.addValue(apiKey, forHTTPHeaderField: "X-Api-Key")
|
|
2166
|
+
}
|
|
2167
|
+
if let apiSecret = EnvironmentConfig.apiSecret {
|
|
2168
|
+
uRLRequest.addValue(apiSecret, forHTTPHeaderField: "X-Api-Secret")
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
let emailPrefix = userEmail?.components(separatedBy: "@").first ?? ""
|
|
2172
|
+
|
|
2173
|
+
var params: [String: Any] = [
|
|
2174
|
+
"account_id": self.grailPayAccountID ?? "",
|
|
2175
|
+
"account_type": self.selectedGrailPayAccountType ?? "",
|
|
2176
|
+
"name": self.selectedGrailPayAccountName ?? "",
|
|
2177
|
+
"save_account": 1,
|
|
2178
|
+
"is_default": 1,
|
|
2179
|
+
"customer_id": customerId ?? "",
|
|
2180
|
+
"email": userEmail ?? "",
|
|
2181
|
+
"create_customer": "1",
|
|
2182
|
+
]
|
|
2183
|
+
|
|
2184
|
+
if let customerId = customerId {
|
|
2185
|
+
params["customer"] = customerId
|
|
2186
|
+
} else {
|
|
2187
|
+
params["username"] = emailPrefix
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
// // Billing Info
|
|
2191
|
+
// if let visibility = visibility, visibility.billing == true,
|
|
2192
|
+
// let billing = billingInfo, !billing.isEmpty {
|
|
2193
|
+
// var billingDict: [String: Any] = [:]
|
|
2194
|
+
// billing.forEach { billingDict[$0.name] = $0.value }
|
|
2195
|
+
//
|
|
2196
|
+
// params["address"] = billingDict["address"] as? String ?? ""
|
|
2197
|
+
// params["country"] = billingDict["country"] as? String ?? ""
|
|
2198
|
+
// params["state"] = billingDict["state"] as? String ?? ""
|
|
2199
|
+
// params["city"] = billingDict["city"] as? String ?? ""
|
|
2200
|
+
// params["zip"] = billingDict["postal_code"] as? String ?? ""
|
|
2201
|
+
// }
|
|
2202
|
+
|
|
2203
|
+
// Always include Billing Info if available
|
|
2204
|
+
if let billing = billingInfo, !billing.isEmpty {
|
|
2205
|
+
var billingDict: [String: Any] = [:]
|
|
2206
|
+
billing.forEach { billingDict[$0.name] = $0.value }
|
|
2207
|
+
|
|
2208
|
+
params["address"] = billingDict["address"] as? String ?? ""
|
|
2209
|
+
params["country"] = billingDict["country"] as? String ?? ""
|
|
2210
|
+
params["state"] = billingDict["state"] as? String ?? ""
|
|
2211
|
+
params["city"] = billingDict["city"] as? String ?? ""
|
|
2212
|
+
params["zip"] = billingDict["postal_code"] as? String ?? ""
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
// // Additional Info or default description
|
|
2216
|
+
// var descriptionValue: String = "Hosted payment checkout" // default
|
|
2217
|
+
// if let visibility = visibility, visibility.additional == true,
|
|
2218
|
+
// let additional = additionalInfo, !additional.isEmpty {
|
|
2219
|
+
//
|
|
2220
|
+
// var additionalDict: [String: Any] = [:]
|
|
2221
|
+
// additional.forEach { additionalDict[$0.name] = $0.value }
|
|
2222
|
+
//
|
|
2223
|
+
// if let desc = additionalDict["description"] as? String, !desc.isEmpty {
|
|
2224
|
+
// descriptionValue = desc
|
|
2225
|
+
// }
|
|
2226
|
+
//
|
|
2227
|
+
// if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
|
|
2228
|
+
// params["phone_number"] = phone
|
|
2229
|
+
// }
|
|
2230
|
+
// }
|
|
2231
|
+
// params["description"] = descriptionValue
|
|
2232
|
+
|
|
2233
|
+
// Always include Additional Info if available
|
|
2234
|
+
var descriptionValue: String = "Hosted payment checkout"
|
|
2235
|
+
if let additional = additionalInfo, !additional.isEmpty {
|
|
2236
|
+
var additionalDict: [String: Any] = [:]
|
|
2237
|
+
additional.forEach { additionalDict[$0.name] = $0.value }
|
|
2238
|
+
|
|
2239
|
+
if let desc = additionalDict["description"] as? String, !desc.isEmpty {
|
|
2240
|
+
descriptionValue = desc
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
|
|
2244
|
+
params["phone_number"] = phone
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
params["description"] = descriptionValue
|
|
2248
|
+
|
|
2249
|
+
// Add these if recurring is enabled
|
|
2250
|
+
if let req = request, req.is_recurring == true {
|
|
2251
|
+
if let recurringType = req.recurringStartDateType, recurringType == .custom {
|
|
2252
|
+
// Only send start_date if type is .custom and field is not empty
|
|
2253
|
+
if let startDateText = startDate, !startDateText.isEmpty {
|
|
2254
|
+
let inputFormatter = DateFormatter()
|
|
2255
|
+
inputFormatter.dateFormat = "dd/MM/yyyy"
|
|
2256
|
+
|
|
2257
|
+
let outputFormatter = DateFormatter()
|
|
2258
|
+
outputFormatter.dateFormat = "MM/dd/yyyy"
|
|
2259
|
+
|
|
2260
|
+
if let date = inputFormatter.date(from: startDateText) {
|
|
2261
|
+
let apiFormattedDate = outputFormatter.string(from: date)
|
|
2262
|
+
params["start_date"] = apiFormattedDate
|
|
2263
|
+
} else {
|
|
2264
|
+
print("Invalid date format in startDateText")
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
params["interval"] = chosenPlan?.lowercased()
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
print(params)
|
|
2273
|
+
|
|
2274
|
+
do {
|
|
2275
|
+
let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
2276
|
+
uRLRequest.httpBody = jsonData
|
|
2277
|
+
if let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
2278
|
+
print("JSON Payload: \(jsonString)")
|
|
2279
|
+
}
|
|
2280
|
+
} catch let error {
|
|
2281
|
+
print("Error creating JSON data: \(error)")
|
|
2282
|
+
hideLoadingIndicator()
|
|
2283
|
+
return
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
let session = URLSession.shared
|
|
2287
|
+
let task = session.dataTask(with: uRLRequest) { (serviceData, serviceResponse, error) in
|
|
2288
|
+
|
|
2289
|
+
DispatchQueue.main.async {
|
|
2290
|
+
self.hideLoadingIndicator() // Stop loader when response is received
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
if let error = error {
|
|
2294
|
+
self.presentPaymentErrorVC(errorMessage: error.localizedDescription)
|
|
2295
|
+
return
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
guard let httpResponse = serviceResponse as? HTTPURLResponse else {
|
|
2299
|
+
self.presentPaymentErrorVC(errorMessage: "Invalid response")
|
|
2300
|
+
return
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
2304
|
+
if let data = serviceData {
|
|
2305
|
+
do {
|
|
2306
|
+
if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
2307
|
+
print("Response Data: \(responseObject)")
|
|
2308
|
+
|
|
2309
|
+
// Check if status is 0 and handle the error
|
|
2310
|
+
if let status = responseObject["status"] as? Int, status == 0 {
|
|
2311
|
+
let errorMessage = responseObject["message"] as? String ?? "Unknown error"
|
|
2312
|
+
self.presentPaymentErrorVC(errorMessage: errorMessage)
|
|
2313
|
+
} else {
|
|
2314
|
+
DispatchQueue.main.async {
|
|
2315
|
+
if let paymentDoneVC = self.storyboard?.instantiateViewController(withIdentifier: "PaymentDoneVC") as? PaymentDoneVC {
|
|
2316
|
+
paymentDoneVC.chargeData = responseObject
|
|
2317
|
+
paymentDoneVC.selectedPaymentMethod = self.selectedPaymentMethod
|
|
2318
|
+
paymentDoneVC.easyPayDelegate = self.easyPayDelegate
|
|
2319
|
+
// Pass billing and additional info
|
|
2320
|
+
// Conditionally pass raw FieldItem array
|
|
2321
|
+
paymentDoneVC.visibility = self.visibility
|
|
2322
|
+
|
|
2323
|
+
// if self.visibility?.billing == true {
|
|
2324
|
+
paymentDoneVC.billingInfoData = self.billingInfo
|
|
2325
|
+
var billingDict: [String: Any] = [:]
|
|
2326
|
+
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
2327
|
+
paymentDoneVC.billingInfo = billingDict
|
|
2328
|
+
// }
|
|
2329
|
+
|
|
2330
|
+
// if self.visibility?.additional == true {
|
|
2331
|
+
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
2332
|
+
var additionalDict: [String: Any] = [:]
|
|
2333
|
+
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
2334
|
+
paymentDoneVC.additionalInfo = additionalDict
|
|
2335
|
+
// }
|
|
2114
2336
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
2115
2337
|
}
|
|
2116
2338
|
}
|