@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
|
@@ -811,6 +811,7 @@ class BillingInfoVC: BaseVC {
|
|
|
811
811
|
vc.grailPayAccountID = grailPayAccountID
|
|
812
812
|
vc.selectedGrailPayAccountType = selectedGrailPayAccountType
|
|
813
813
|
vc.selectedGrailPayAccountName = selectedGrailPayAccountName
|
|
814
|
+
vc.userEmail = userEmail
|
|
814
815
|
navigationController?.pushViewController(vc, animated: true)
|
|
815
816
|
}
|
|
816
817
|
else if !isAdditionalVisible && isSavedForFuture {
|
|
@@ -831,6 +832,7 @@ class BillingInfoVC: BaseVC {
|
|
|
831
832
|
vc.grailPayAccountID = grailPayAccountID
|
|
832
833
|
vc.selectedGrailPayAccountType = selectedGrailPayAccountType
|
|
833
834
|
vc.selectedGrailPayAccountName = selectedGrailPayAccountName
|
|
835
|
+
vc.userEmail = userEmail
|
|
834
836
|
navigationController?.pushViewController(vc, animated: true)
|
|
835
837
|
}
|
|
836
838
|
else {
|
|
@@ -860,24 +862,7 @@ class BillingInfoVC: BaseVC {
|
|
|
860
862
|
navigationController?.pushViewController(vc, animated: true)
|
|
861
863
|
}
|
|
862
864
|
else if !isAdditionalVisible && isSavedForFuture {
|
|
863
|
-
|
|
864
|
-
vc.billingInfoData = updatedBillingData
|
|
865
|
-
vc.fieldSection = updatedFieldSection
|
|
866
|
-
vc.billingInfo = updatedFieldSection.billing
|
|
867
|
-
vc.additionalInfo = updatedFieldSection.additional
|
|
868
|
-
vc.visibility = updatedFieldSection.visibility
|
|
869
|
-
vc.selectedPaymentMethod = selectedPaymentMethod
|
|
870
|
-
vc.isSavedForFuture = isSavedForFuture
|
|
871
|
-
vc.isFrom = isFrom
|
|
872
|
-
vc.isSavedNewAccount = isSavedNewAccount
|
|
873
|
-
vc.amount = Int(request.amount ?? 0)
|
|
874
|
-
vc.request = request
|
|
875
|
-
vc.chosenPlan = chosenPlan
|
|
876
|
-
vc.startDate = startDate
|
|
877
|
-
vc.grailPayAccountID = grailPayAccountID
|
|
878
|
-
vc.selectedGrailPayAccountType = selectedGrailPayAccountType
|
|
879
|
-
vc.selectedGrailPayAccountName = selectedGrailPayAccountName
|
|
880
|
-
navigationController?.pushViewController(vc, animated: true)
|
|
865
|
+
grailPayAccountChargeApi(customerId: UserStoreSingleton.shared.customerId)
|
|
881
866
|
}
|
|
882
867
|
else {
|
|
883
868
|
grailPayAccountChargeApi()
|
|
@@ -1008,19 +993,19 @@ class BillingInfoVC: BaseVC {
|
|
|
1008
993
|
// Conditionally pass raw FieldItem array
|
|
1009
994
|
paymentDoneVC.visibility = self.visibility
|
|
1010
995
|
|
|
1011
|
-
|
|
996
|
+
// if self.visibility?.billing == true {
|
|
1012
997
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1013
998
|
var billingDict: [String: Any] = [:]
|
|
1014
999
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1015
1000
|
paymentDoneVC.billingInfo = billingDict
|
|
1016
|
-
|
|
1001
|
+
// }
|
|
1017
1002
|
|
|
1018
|
-
|
|
1003
|
+
// if self.visibility?.additional == true {
|
|
1019
1004
|
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
1020
1005
|
var additionalDict: [String: Any] = [:]
|
|
1021
1006
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1022
1007
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1023
|
-
|
|
1008
|
+
// }
|
|
1024
1009
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1025
1010
|
}
|
|
1026
1011
|
}
|
|
@@ -1195,19 +1180,19 @@ class BillingInfoVC: BaseVC {
|
|
|
1195
1180
|
paymentDoneVC.visibility = self.visibility
|
|
1196
1181
|
paymentDoneVC.amount = self.amount
|
|
1197
1182
|
|
|
1198
|
-
|
|
1183
|
+
// if self.visibility?.billing == true {
|
|
1199
1184
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1200
1185
|
var billingDict: [String: Any] = [:]
|
|
1201
1186
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1202
1187
|
paymentDoneVC.billingInfo = billingDict
|
|
1203
|
-
|
|
1188
|
+
// }
|
|
1204
1189
|
|
|
1205
|
-
|
|
1190
|
+
// if self.visibility?.additional == true {
|
|
1206
1191
|
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
1207
1192
|
var additionalDict: [String: Any] = [:]
|
|
1208
1193
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1209
1194
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1210
|
-
|
|
1195
|
+
// }
|
|
1211
1196
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1212
1197
|
}
|
|
1213
1198
|
}
|
|
@@ -1372,19 +1357,19 @@ class BillingInfoVC: BaseVC {
|
|
|
1372
1357
|
paymentDoneVC.visibility = self.visibility
|
|
1373
1358
|
paymentDoneVC.amount = self.amount
|
|
1374
1359
|
|
|
1375
|
-
|
|
1360
|
+
// if self.visibility?.billing == true {
|
|
1376
1361
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1377
1362
|
var billingDict: [String: Any] = [:]
|
|
1378
1363
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1379
1364
|
paymentDoneVC.billingInfo = billingDict
|
|
1380
|
-
|
|
1365
|
+
// }
|
|
1381
1366
|
|
|
1382
|
-
|
|
1367
|
+
// if self.visibility?.additional == true {
|
|
1383
1368
|
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
1384
1369
|
var additionalDict: [String: Any] = [:]
|
|
1385
1370
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1386
1371
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1387
|
-
|
|
1372
|
+
// }
|
|
1388
1373
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1389
1374
|
}
|
|
1390
1375
|
}
|
|
@@ -1554,19 +1539,19 @@ class BillingInfoVC: BaseVC {
|
|
|
1554
1539
|
// Conditionally pass raw FieldItem array
|
|
1555
1540
|
paymentDoneVC.visibility = self.visibility
|
|
1556
1541
|
|
|
1557
|
-
|
|
1542
|
+
// if self.visibility?.billing == true {
|
|
1558
1543
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1559
1544
|
var billingDict: [String: Any] = [:]
|
|
1560
1545
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1561
1546
|
paymentDoneVC.billingInfo = billingDict
|
|
1562
|
-
|
|
1547
|
+
// }
|
|
1563
1548
|
|
|
1564
|
-
|
|
1549
|
+
// if self.visibility?.additional == true {
|
|
1565
1550
|
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
1566
1551
|
var additionalDict: [String: Any] = [:]
|
|
1567
1552
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1568
1553
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1569
|
-
|
|
1554
|
+
// }
|
|
1570
1555
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1571
1556
|
}
|
|
1572
1557
|
}
|
|
@@ -1732,19 +1717,19 @@ class BillingInfoVC: BaseVC {
|
|
|
1732
1717
|
// Conditionally pass raw FieldItem array
|
|
1733
1718
|
paymentDoneVC.visibility = self.visibility
|
|
1734
1719
|
|
|
1735
|
-
|
|
1720
|
+
// if self.visibility?.billing == true {
|
|
1736
1721
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1737
1722
|
var billingDict: [String: Any] = [:]
|
|
1738
1723
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1739
1724
|
paymentDoneVC.billingInfo = billingDict
|
|
1740
|
-
|
|
1725
|
+
// }
|
|
1741
1726
|
|
|
1742
|
-
|
|
1727
|
+
// if self.visibility?.additional == true {
|
|
1743
1728
|
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
1744
1729
|
var additionalDict: [String: Any] = [:]
|
|
1745
1730
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1746
1731
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1747
|
-
|
|
1732
|
+
// }
|
|
1748
1733
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1749
1734
|
}
|
|
1750
1735
|
}
|
|
@@ -1895,13 +1880,19 @@ class BillingInfoVC: BaseVC {
|
|
|
1895
1880
|
// Conditionally pass raw FieldItem array
|
|
1896
1881
|
paymentDoneVC.visibility = self.visibility
|
|
1897
1882
|
|
|
1898
|
-
if self.visibility?.billing == true {
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1883
|
+
// if self.visibility?.billing == true {
|
|
1884
|
+
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1885
|
+
var billingDict: [String: Any] = [:]
|
|
1886
|
+
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1887
|
+
paymentDoneVC.billingInfo = billingDict
|
|
1888
|
+
// }
|
|
1889
|
+
|
|
1890
|
+
// if self.visibility?.additional == true {
|
|
1891
|
+
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
1892
|
+
var additionalDict: [String: Any] = [:]
|
|
1893
|
+
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1894
|
+
paymentDoneVC.additionalInfo = additionalDict
|
|
1895
|
+
// }
|
|
1905
1896
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1906
1897
|
}
|
|
1907
1898
|
}
|
|
@@ -2056,12 +2047,19 @@ class BillingInfoVC: BaseVC {
|
|
|
2056
2047
|
// Conditionally pass raw FieldItem array
|
|
2057
2048
|
paymentDoneVC.visibility = self.visibility
|
|
2058
2049
|
|
|
2059
|
-
if self.visibility?.billing == true {
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
}
|
|
2050
|
+
// if self.visibility?.billing == true {
|
|
2051
|
+
paymentDoneVC.billingInfoData = self.billingInfo
|
|
2052
|
+
var billingDict: [String: Any] = [:]
|
|
2053
|
+
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
2054
|
+
paymentDoneVC.billingInfo = billingDict
|
|
2055
|
+
// }
|
|
2056
|
+
|
|
2057
|
+
// if self.visibility?.additional == true {
|
|
2058
|
+
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
2059
|
+
var additionalDict: [String: Any] = [:]
|
|
2060
|
+
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
2061
|
+
paymentDoneVC.additionalInfo = additionalDict
|
|
2062
|
+
// }
|
|
2065
2063
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
2066
2064
|
}
|
|
2067
2065
|
}
|
|
@@ -2225,12 +2223,19 @@ class BillingInfoVC: BaseVC {
|
|
|
2225
2223
|
// Conditionally pass raw FieldItem array
|
|
2226
2224
|
paymentDoneVC.visibility = self.visibility
|
|
2227
2225
|
|
|
2228
|
-
if self.visibility?.billing == true {
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
}
|
|
2226
|
+
// if self.visibility?.billing == true {
|
|
2227
|
+
paymentDoneVC.billingInfoData = self.billingInfo
|
|
2228
|
+
var billingDict: [String: Any] = [:]
|
|
2229
|
+
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
2230
|
+
paymentDoneVC.billingInfo = billingDict
|
|
2231
|
+
// }
|
|
2232
|
+
|
|
2233
|
+
// if self.visibility?.additional == true {
|
|
2234
|
+
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
2235
|
+
var additionalDict: [String: Any] = [:]
|
|
2236
|
+
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
2237
|
+
paymentDoneVC.additionalInfo = additionalDict
|
|
2238
|
+
// }
|
|
2234
2239
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
2235
2240
|
}
|
|
2236
2241
|
}
|
|
@@ -2387,12 +2392,237 @@ class BillingInfoVC: BaseVC {
|
|
|
2387
2392
|
// Conditionally pass raw FieldItem array
|
|
2388
2393
|
paymentDoneVC.visibility = self.visibility
|
|
2389
2394
|
|
|
2390
|
-
if self.visibility?.billing == true {
|
|
2395
|
+
// if self.visibility?.billing == true {
|
|
2396
|
+
paymentDoneVC.billingInfoData = self.billingInfo
|
|
2397
|
+
var billingDict: [String: Any] = [:]
|
|
2398
|
+
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
2399
|
+
paymentDoneVC.billingInfo = billingDict
|
|
2400
|
+
// }
|
|
2401
|
+
|
|
2402
|
+
// if self.visibility?.additional == true {
|
|
2403
|
+
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
2404
|
+
var additionalDict: [String: Any] = [:]
|
|
2405
|
+
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
2406
|
+
paymentDoneVC.additionalInfo = additionalDict
|
|
2407
|
+
// }
|
|
2408
|
+
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
} else {
|
|
2413
|
+
self.presentPaymentErrorVC(errorMessage: "Invalid JSON format")
|
|
2414
|
+
}
|
|
2415
|
+
} catch let jsonError {
|
|
2416
|
+
self.presentPaymentErrorVC(errorMessage: "Error parsing JSON: \(jsonError)")
|
|
2417
|
+
}
|
|
2418
|
+
} else {
|
|
2419
|
+
self.presentPaymentErrorVC(errorMessage: "No data received")
|
|
2420
|
+
}
|
|
2421
|
+
} else {
|
|
2422
|
+
if let data = serviceData,
|
|
2423
|
+
let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
|
|
2424
|
+
let message = responseObj["message"] as? String {
|
|
2425
|
+
self.presentPaymentErrorVC(errorMessage: message)
|
|
2426
|
+
} else {
|
|
2427
|
+
self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
task.resume()
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
//MARK: - GrailPay Account Charge Api if user saved account
|
|
2435
|
+
func grailPayAccountChargeApi(customerId: String?) {
|
|
2436
|
+
showLoadingIndicator()
|
|
2437
|
+
|
|
2438
|
+
let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.achCharge.path()
|
|
2439
|
+
|
|
2440
|
+
guard let serviceURL = URL(string: fullURL) else {
|
|
2441
|
+
print("Invalid URL")
|
|
2442
|
+
hideLoadingIndicator()
|
|
2443
|
+
return
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
var uRLRequest = URLRequest(url: serviceURL)
|
|
2447
|
+
uRLRequest.httpMethod = "POST"
|
|
2448
|
+
uRLRequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
2449
|
+
|
|
2450
|
+
let token = UserStoreSingleton.shared.clientToken
|
|
2451
|
+
print("Setting clientToken header: \(token ?? "None")")
|
|
2452
|
+
uRLRequest.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
|
|
2453
|
+
|
|
2454
|
+
if let apiKey = EnvironmentConfig.apiKey {
|
|
2455
|
+
uRLRequest.addValue(apiKey, forHTTPHeaderField: "X-Api-Key")
|
|
2456
|
+
}
|
|
2457
|
+
if let apiSecret = EnvironmentConfig.apiSecret {
|
|
2458
|
+
uRLRequest.addValue(apiSecret, forHTTPHeaderField: "X-Api-Secret")
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
let emailPrefix = userEmail?.components(separatedBy: "@").first ?? ""
|
|
2462
|
+
|
|
2463
|
+
var params: [String: Any] = [
|
|
2464
|
+
"account_id": self.grailPayAccountID ?? "",
|
|
2465
|
+
"account_type": self.selectedGrailPayAccountType ?? "",
|
|
2466
|
+
"name": self.selectedGrailPayAccountName ?? "",
|
|
2467
|
+
"save_account": 1,
|
|
2468
|
+
"is_default": 1,
|
|
2469
|
+
"customer_id": customerId ?? "",
|
|
2470
|
+
"email": userEmail ?? "",
|
|
2471
|
+
"create_customer": "1",
|
|
2472
|
+
]
|
|
2473
|
+
|
|
2474
|
+
if let customerId = customerId {
|
|
2475
|
+
params["customer"] = customerId
|
|
2476
|
+
} else {
|
|
2477
|
+
params["username"] = emailPrefix
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
// // Billing Info
|
|
2481
|
+
// if let visibility = visibility, visibility.billing == true,
|
|
2482
|
+
// let billing = billingInfo, !billing.isEmpty {
|
|
2483
|
+
// var billingDict: [String: Any] = [:]
|
|
2484
|
+
// billing.forEach { billingDict[$0.name] = $0.value }
|
|
2485
|
+
//
|
|
2486
|
+
// params["address"] = billingDict["address"] as? String ?? ""
|
|
2487
|
+
// params["country"] = billingDict["country"] as? String ?? ""
|
|
2488
|
+
// params["state"] = billingDict["state"] as? String ?? ""
|
|
2489
|
+
// params["city"] = billingDict["city"] as? String ?? ""
|
|
2490
|
+
// params["zip"] = billingDict["postal_code"] as? String ?? ""
|
|
2491
|
+
// }
|
|
2492
|
+
|
|
2493
|
+
// Always include Billing Info if available
|
|
2494
|
+
if let billing = billingInfo, !billing.isEmpty {
|
|
2495
|
+
var billingDict: [String: Any] = [:]
|
|
2496
|
+
billing.forEach { billingDict[$0.name] = $0.value }
|
|
2497
|
+
|
|
2498
|
+
params["address"] = billingDict["address"] as? String ?? ""
|
|
2499
|
+
params["country"] = billingDict["country"] as? String ?? ""
|
|
2500
|
+
params["state"] = billingDict["state"] as? String ?? ""
|
|
2501
|
+
params["city"] = billingDict["city"] as? String ?? ""
|
|
2502
|
+
params["zip"] = billingDict["postal_code"] as? String ?? ""
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
// // Additional Info or default description
|
|
2506
|
+
// var descriptionValue: String = "Hosted payment checkout" // default
|
|
2507
|
+
// if let visibility = visibility, visibility.additional == true,
|
|
2508
|
+
// let additional = additionalInfo, !additional.isEmpty {
|
|
2509
|
+
//
|
|
2510
|
+
// var additionalDict: [String: Any] = [:]
|
|
2511
|
+
// additional.forEach { additionalDict[$0.name] = $0.value }
|
|
2512
|
+
//
|
|
2513
|
+
// if let desc = additionalDict["description"] as? String, !desc.isEmpty {
|
|
2514
|
+
// descriptionValue = desc
|
|
2515
|
+
// }
|
|
2516
|
+
//
|
|
2517
|
+
// if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
|
|
2518
|
+
// params["phone_number"] = phone
|
|
2519
|
+
// }
|
|
2520
|
+
// }
|
|
2521
|
+
// params["description"] = descriptionValue
|
|
2522
|
+
|
|
2523
|
+
// Always include Additional Info if available
|
|
2524
|
+
var descriptionValue: String = "Hosted payment checkout"
|
|
2525
|
+
if let additional = additionalInfo, !additional.isEmpty {
|
|
2526
|
+
var additionalDict: [String: Any] = [:]
|
|
2527
|
+
additional.forEach { additionalDict[$0.name] = $0.value }
|
|
2528
|
+
|
|
2529
|
+
if let desc = additionalDict["description"] as? String, !desc.isEmpty {
|
|
2530
|
+
descriptionValue = desc
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
|
|
2534
|
+
params["phone_number"] = phone
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
params["description"] = descriptionValue
|
|
2538
|
+
|
|
2539
|
+
// Add these if recurring is enabled
|
|
2540
|
+
if let req = request, req.is_recurring == true {
|
|
2541
|
+
if let recurringType = req.recurringStartDateType, recurringType == .custom {
|
|
2542
|
+
// Only send start_date if type is .custom and field is not empty
|
|
2543
|
+
if let startDateText = startDate, !startDateText.isEmpty {
|
|
2544
|
+
let inputFormatter = DateFormatter()
|
|
2545
|
+
inputFormatter.dateFormat = "dd/MM/yyyy"
|
|
2546
|
+
|
|
2547
|
+
let outputFormatter = DateFormatter()
|
|
2548
|
+
outputFormatter.dateFormat = "MM/dd/yyyy"
|
|
2549
|
+
|
|
2550
|
+
if let date = inputFormatter.date(from: startDateText) {
|
|
2551
|
+
let apiFormattedDate = outputFormatter.string(from: date)
|
|
2552
|
+
params["start_date"] = apiFormattedDate
|
|
2553
|
+
} else {
|
|
2554
|
+
print("Invalid date format in startDateText")
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
params["interval"] = chosenPlan?.lowercased()
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
print(params)
|
|
2563
|
+
|
|
2564
|
+
do {
|
|
2565
|
+
let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
2566
|
+
uRLRequest.httpBody = jsonData
|
|
2567
|
+
if let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
2568
|
+
print("JSON Payload: \(jsonString)")
|
|
2569
|
+
}
|
|
2570
|
+
} catch let error {
|
|
2571
|
+
print("Error creating JSON data: \(error)")
|
|
2572
|
+
hideLoadingIndicator()
|
|
2573
|
+
return
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
let session = URLSession.shared
|
|
2577
|
+
let task = session.dataTask(with: uRLRequest) { (serviceData, serviceResponse, error) in
|
|
2578
|
+
|
|
2579
|
+
DispatchQueue.main.async {
|
|
2580
|
+
self.hideLoadingIndicator() // Stop loader when response is received
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
if let error = error {
|
|
2584
|
+
self.presentPaymentErrorVC(errorMessage: error.localizedDescription)
|
|
2585
|
+
return
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
guard let httpResponse = serviceResponse as? HTTPURLResponse else {
|
|
2589
|
+
self.presentPaymentErrorVC(errorMessage: "Invalid response")
|
|
2590
|
+
return
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
2594
|
+
if let data = serviceData {
|
|
2595
|
+
do {
|
|
2596
|
+
if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
2597
|
+
print("Response Data: \(responseObject)")
|
|
2598
|
+
|
|
2599
|
+
// Check if status is 0 and handle the error
|
|
2600
|
+
if let status = responseObject["status"] as? Int, status == 0 {
|
|
2601
|
+
let errorMessage = responseObject["message"] as? String ?? "Unknown error"
|
|
2602
|
+
self.presentPaymentErrorVC(errorMessage: errorMessage)
|
|
2603
|
+
} else {
|
|
2604
|
+
DispatchQueue.main.async {
|
|
2605
|
+
if let paymentDoneVC = self.storyboard?.instantiateViewController(withIdentifier: "PaymentDoneVC") as? PaymentDoneVC {
|
|
2606
|
+
paymentDoneVC.chargeData = responseObject
|
|
2607
|
+
paymentDoneVC.selectedPaymentMethod = self.selectedPaymentMethod
|
|
2608
|
+
paymentDoneVC.easyPayDelegate = self.easyPayDelegate
|
|
2609
|
+
// Pass billing and additional info
|
|
2610
|
+
// Conditionally pass raw FieldItem array
|
|
2611
|
+
paymentDoneVC.visibility = self.visibility
|
|
2612
|
+
|
|
2613
|
+
// if self.visibility?.billing == true {
|
|
2391
2614
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
2392
2615
|
var billingDict: [String: Any] = [:]
|
|
2393
2616
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
2394
2617
|
paymentDoneVC.billingInfo = billingDict
|
|
2395
|
-
|
|
2618
|
+
// }
|
|
2619
|
+
|
|
2620
|
+
// if self.visibility?.additional == true {
|
|
2621
|
+
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
2622
|
+
var additionalDict: [String: Any] = [:]
|
|
2623
|
+
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
2624
|
+
paymentDoneVC.additionalInfo = additionalDict
|
|
2625
|
+
// }
|
|
2396
2626
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
2397
2627
|
}
|
|
2398
2628
|
}
|