@jimrising/easymerchantsdk-react-native 2.0.4 → 2.0.7
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 +1016 -391
- package/android/.gradle/8.10/checksums/checksums.lock +0 -0
- package/android/.gradle/8.10/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.10/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.10/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.10/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.10/gc.properties +0 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/nb-cache/trust/0B5D6BE682AD6AEE9815EC13516BF075752CAE5AD5BECDCC00315C37622C2FD3 +1 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build/.transforms/15b6a8a60a6b32d0dcaf609723cf365b/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/664c2535aec304a21f4de38c6fe405c3/results.bin +1 -0
- package/android/build/.transforms/664c2535aec304a21f4de38c6fe405c3/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/8508f1428f740032c45a43f48b1bbe1e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$1$1.dex +0 -0
- package/android/build/.transforms/8508f1428f740032c45a43f48b1bbe1e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$1.dex +0 -0
- package/android/build/.transforms/8508f1428f740032c45a43f48b1bbe1e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$2.dex +0 -0
- package/android/build/.transforms/8508f1428f740032c45a43f48b1bbe1e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
- package/android/build/.transforms/8b9a31b6d3889f12f1bd8cedf6c6f513/results.bin +1 -0
- package/android/build/.transforms/8b9a31b6d3889f12f1bd8cedf6c6f513/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/BuildConfig.dex +0 -0
- package/android/build/.transforms/8b9a31b6d3889f12f1bd8cedf6c6f513/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$1$1.dex +0 -0
- package/android/build/.transforms/8b9a31b6d3889f12f1bd8cedf6c6f513/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$1.dex +0 -0
- package/android/build/.transforms/8b9a31b6d3889f12f1bd8cedf6c6f513/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$2.dex +0 -0
- package/android/build/.transforms/8b9a31b6d3889f12f1bd8cedf6c6f513/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
- package/android/build/.transforms/8b9a31b6d3889f12f1bd8cedf6c6f513/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkPackage.dex +0 -0
- package/android/build/.transforms/8b9a31b6d3889f12f1bd8cedf6c6f513/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/.transforms/eef2d06269ef2e204b4f065513034fca/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/ffabb40f9809b32eb9546ce76fc51764/transformed/bundleLibRuntimeToDirRelease/bundleLibRuntimeToDirRelease_dex/com/reactlibrary/RNEasymerchantsdkModule$1$1.dex +0 -0
- package/android/build/.transforms/ffabb40f9809b32eb9546ce76fc51764/transformed/bundleLibRuntimeToDirRelease/bundleLibRuntimeToDirRelease_dex/com/reactlibrary/RNEasymerchantsdkModule$1.dex +0 -0
- package/android/build/.transforms/ffabb40f9809b32eb9546ce76fc51764/transformed/bundleLibRuntimeToDirRelease/bundleLibRuntimeToDirRelease_dex/com/reactlibrary/RNEasymerchantsdkModule$2.dex +0 -0
- package/android/build/.transforms/ffabb40f9809b32eb9546ce76fc51764/transformed/bundleLibRuntimeToDirRelease/bundleLibRuntimeToDirRelease_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
- package/android/build/intermediates/aar_main_jar/release/syncReleaseLibJars/classes.jar +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/compile_library_classes_jar/release/bundleLibCompileToJarRelease/classes.jar +0 -0
- package/android/build/intermediates/full_jar/release/createFullJarRelease/full.jar +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
- package/android/build/intermediates/incremental/lintVitalAnalyzeRelease/release-artifact-dependencies.xml +4 -4
- package/android/build/intermediates/incremental/lintVitalAnalyzeRelease/release-artifact-libraries.xml +4 -4
- package/android/build/intermediates/incremental/release/mergeReleaseResources/compile-file-map.properties +426 -425
- package/android/build/intermediates/incremental/release/mergeReleaseResources/merged.dir/values/values.xml +1 -1
- package/android/build/intermediates/incremental/release/mergeReleaseResources/merger.xml +3 -3
- package/android/build/intermediates/incremental/release/packageReleaseResources/compile-file-map.properties +1 -1
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$1$1.class +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/javac/release/compileReleaseJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$1$1.class +0 -0
- package/android/build/intermediates/javac/release/compileReleaseJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$1.class +0 -0
- package/android/build/intermediates/javac/release/compileReleaseJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
- package/android/build/intermediates/javac/release/compileReleaseJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
- package/android/build/intermediates/lint-cache/lintVitalAnalyzeRelease/maven.google/com/android/tools/build/group-index.xml +15 -15
- package/android/build/intermediates/lint-cache/lintVitalAnalyzeRelease/maven.google/master-index.xml +1 -0
- package/android/build/intermediates/lint_model/release/generateReleaseLintModel/release-artifact-dependencies.xml +4 -4
- package/android/build/intermediates/lint_model/release/generateReleaseLintModel/release-artifact-libraries.xml +4 -4
- package/android/build/intermediates/lint_vital_lint_model/release/generateReleaseLintVitalModel/release-artifact-dependencies.xml +4 -4
- package/android/build/intermediates/lint_vital_lint_model/release/generateReleaseLintVitalModel/release-artifact-libraries.xml +4 -4
- package/android/build/intermediates/local_aar_for_lint/release/out.aar +0 -0
- package/android/build/intermediates/merged_res/release/mergeReleaseResources/drawable/close_icon_main.xml +16 -0
- package/android/build/intermediates/merged_res/release/mergeReleaseResources/layout/activity_payment_done_url.xml +2 -3
- package/android/build/intermediates/merged_res/release/mergeReleaseResources/layout/activity_select_payment_method.xml +24 -6
- package/android/build/intermediates/merged_res/release/mergeReleaseResources/values/values.xml +1 -1
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/multi-v2/values-night-v8.json +19 -19
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/multi-v2/values.json +102 -102
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/anim-v21.json +1 -1
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/anim.json +1 -1
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/animator.json +8 -8
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable.json +319 -315
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/font.json +9 -9
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/layout.json +27 -27
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-anydpi-v26.json +2 -2
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-hdpi-v4.json +2 -2
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-mdpi-v4.json +2 -2
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-xhdpi-v4.json +2 -2
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-xxhdpi-v4.json +2 -2
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-xxxhdpi-v4.json +2 -2
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/raw.json +46 -46
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/xml.json +2 -2
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule$1$1.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_dir/release/bundleLibRuntimeToDirRelease/com/reactlibrary/RNEasymerchantsdkModule$1$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/release/bundleLibRuntimeToDirRelease/com/reactlibrary/RNEasymerchantsdkModule$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/release/bundleLibRuntimeToDirRelease/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/release/bundleLibRuntimeToDirRelease/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/release/bundleLibRuntimeToJarRelease/classes.jar +0 -0
- package/android/build/intermediates/source_set_path_map/release/mapReleaseSourceSetPaths/file-map.txt +17 -17
- package/android/build/intermediates/verified_library_resources/release/verifyReleaseResources/compiled/drawable_close_icon_main.xml.flat +0 -0
- package/android/build/intermediates/verified_library_resources/release/verifyReleaseResources/compiled/layout_activity_payment_done_url.xml.flat +0 -0
- package/android/build/intermediates/verified_library_resources/release/verifyReleaseResources/compiled/layout_activity_select_payment_method.xml.flat +0 -0
- package/android/build/intermediates/verified_library_resources/release/verifyReleaseResources/compiled/values_values.arsc.flat +0 -0
- package/android/build/outputs/aar/jimrising_easymerchantsdk-react-native-release.aar +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/compileReleaseJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactlibrary/RNEasymerchantsdkModule.java +9 -0
- package/ios/Classes/EasyMerchantSdk.m +2 -0
- package/ios/Classes/EasyMerchantSdk.swift +3 -1
- package/ios/Models/Request.swift +50 -3
- package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +74 -6
- package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +92 -20
- package/ios/Pods/ViewControllers/OTPVerificationVC.swift +28 -2
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +73 -564
- package/ios/easymerchantsdk.podspec +1 -1
- package/package.json +1 -1
|
@@ -610,6 +610,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
|
|
613
|
+
print(request.metadata ?? "")
|
|
613
614
|
}
|
|
614
615
|
|
|
615
616
|
//MARK: - View Wiil Appear
|
|
@@ -1810,17 +1811,6 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
1810
1811
|
txtFieldSelectDateNewCardView.textField.becomeFirstResponder()
|
|
1811
1812
|
}
|
|
1812
1813
|
|
|
1813
|
-
// @IBAction func actionBtnSelectPlanViewBankFields(_ sender: UIButton) {
|
|
1814
|
-
// guard let plans = request?.recurringIntervals, !plans.isEmpty else {
|
|
1815
|
-
// print("No recurring intervals available.")
|
|
1816
|
-
// return
|
|
1817
|
-
// }
|
|
1818
|
-
//
|
|
1819
|
-
// PlanSelector.presentPlanOptions(from: self, sourceView: sender, allowedPlans: plans) { selectedPlan in
|
|
1820
|
-
// self.txtFieldSelectPlanViewBankFields.text = selectedPlan
|
|
1821
|
-
// }
|
|
1822
|
-
// }
|
|
1823
|
-
|
|
1824
1814
|
@IBAction func actionBtnSelectPlanViewBankFields(_ sender: UIButton) {
|
|
1825
1815
|
guard var plans = request?.recurringIntervals, !plans.isEmpty else {
|
|
1826
1816
|
print("No recurring intervals available.")
|
|
@@ -2054,7 +2044,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
2054
2044
|
billingInfoVC.isFrom = "SavedCards"
|
|
2055
2045
|
billingInfoVC.selectedCard = self.selectedCard // Passing the selected card data
|
|
2056
2046
|
billingInfoVC.cvvText = cvvText // Passing the CVV text
|
|
2057
|
-
//
|
|
2047
|
+
// billingInfoVC.amount = Int(self.request.amount ?? 0)
|
|
2058
2048
|
billingInfoVC.amount = Double(self.request.amount ?? 0)
|
|
2059
2049
|
billingInfoVC.selectedPaymentMethod = self.selectedPaymentMethod
|
|
2060
2050
|
|
|
@@ -2783,7 +2773,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
2783
2773
|
|
|
2784
2774
|
if !showBilling && !showAdditional {
|
|
2785
2775
|
// Navigate directly to EmailVerificationVC
|
|
2786
|
-
//
|
|
2776
|
+
// let vc = easymerchantsdk.instantiateViewController(withIdentifier: "EmailVerificationVC") as! EmailVerificationVC
|
|
2787
2777
|
let vc = easymerchantsdk.instantiateViewController(withIdentifier: "OTPVerificationVC") as! OTPVerificationVC
|
|
2788
2778
|
vc.easyPayDelegate = self.easyPayDelegate
|
|
2789
2779
|
vc.grailPayAccountID = self.grailPayAccountID
|
|
@@ -2853,7 +2843,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
2853
2843
|
else {
|
|
2854
2844
|
//If billing info is nil
|
|
2855
2845
|
// Navigate to EmailVerificationVC directly
|
|
2856
|
-
//
|
|
2846
|
+
// let vc = easymerchantsdk.instantiateViewController(withIdentifier: "EmailVerificationVC") as! EmailVerificationVC
|
|
2857
2847
|
let vc = easymerchantsdk.instantiateViewController(withIdentifier: "OTPVerificationVC") as! OTPVerificationVC
|
|
2858
2848
|
vc.easyPayDelegate = self.easyPayDelegate
|
|
2859
2849
|
vc.grailPayAccountID = self.grailPayAccountID
|
|
@@ -4392,7 +4382,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
4392
4382
|
|
|
4393
4383
|
// Function to navigate to EmailVerificationVC
|
|
4394
4384
|
func navigateCardDataToEmailVerificationVC() {
|
|
4395
|
-
//
|
|
4385
|
+
// if let emailVerificationVC = storyboard?.instantiateViewController(withIdentifier: "EmailVerificationVC") as? EmailVerificationVC {
|
|
4396
4386
|
if let emailVerificationVC = storyboard?.instantiateViewController(withIdentifier: "OTPVerificationVC") as? OTPVerificationVC {
|
|
4397
4387
|
if let billingInfoData = request.billingInfoData {
|
|
4398
4388
|
do {
|
|
@@ -4426,7 +4416,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
4426
4416
|
}
|
|
4427
4417
|
|
|
4428
4418
|
func navigateBankDataToEmailVerificationVC() {
|
|
4429
|
-
//
|
|
4419
|
+
// if let emailVerificationVC = storyboard?.instantiateViewController(withIdentifier: "EmailVerificationVC") as? EmailVerificationVC {
|
|
4430
4420
|
if let emailVerificationVC = storyboard?.instantiateViewController(withIdentifier: "OTPVerificationVC") as? OTPVerificationVC {
|
|
4431
4421
|
if let billingInfoData = request.billingInfoData {
|
|
4432
4422
|
do {
|
|
@@ -4467,9 +4457,9 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
4467
4457
|
|
|
4468
4458
|
func logOut() {
|
|
4469
4459
|
DispatchQueue.main.async {
|
|
4470
|
-
print("isLoggedIn before clear: \(UserStoreSingleton.shared.isLoggedIn ?? false)")
|
|
4460
|
+
// print("isLoggedIn before clear: \(UserStoreSingleton.shared.isLoggedIn ?? false)")
|
|
4471
4461
|
UserStoreSingleton.shared.clearUserData()
|
|
4472
|
-
print("isLoggedIn after clear: \(UserStoreSingleton.shared.isLoggedIn ?? false)")
|
|
4462
|
+
// print("isLoggedIn after clear: \(UserStoreSingleton.shared.isLoggedIn ?? false)")
|
|
4473
4463
|
|
|
4474
4464
|
UserStoreSingleton.shared.isLoggedIn = false
|
|
4475
4465
|
self.settingsView.isHidden = true
|
|
@@ -5396,12 +5386,6 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
5396
5386
|
let task = session.dataTask(with: uRLRequest) { [weak self] (data, response, error) in
|
|
5397
5387
|
guard let self = self else { return }
|
|
5398
5388
|
|
|
5399
|
-
// defer {
|
|
5400
|
-
// DispatchQueue.main.async {
|
|
5401
|
-
// self.hideLoadingIndicator()
|
|
5402
|
-
// }
|
|
5403
|
-
// }
|
|
5404
|
-
|
|
5405
5389
|
if let error = error {
|
|
5406
5390
|
print("❌ Error in getShowCardsApi: \(error.localizedDescription)")
|
|
5407
5391
|
if let httpResponse = response as? HTTPURLResponse {
|
|
@@ -5520,172 +5504,6 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
5520
5504
|
task.resume()
|
|
5521
5505
|
}
|
|
5522
5506
|
|
|
5523
|
-
// MARK: - Credit Card Charge Api If Billing info is nil and Without Login.
|
|
5524
|
-
// func paymentIntentApi() {
|
|
5525
|
-
// showLoadingIndicator()
|
|
5526
|
-
//
|
|
5527
|
-
// ///Old Using URL Endpoints
|
|
5528
|
-
// // let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.creditCharges.path()
|
|
5529
|
-
//
|
|
5530
|
-
// let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.charges.path()
|
|
5531
|
-
//
|
|
5532
|
-
// guard let serviceURL = URL(string: fullURL) else {
|
|
5533
|
-
// print("Invalid URL")
|
|
5534
|
-
// hideLoadingIndicator()
|
|
5535
|
-
// return
|
|
5536
|
-
// }
|
|
5537
|
-
//
|
|
5538
|
-
// var uRLRequest = URLRequest(url: serviceURL)
|
|
5539
|
-
// uRLRequest.httpMethod = "POST"
|
|
5540
|
-
// uRLRequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
5541
|
-
//
|
|
5542
|
-
// let token = UserStoreSingleton.shared.clientToken
|
|
5543
|
-
// print("Setting clientToken header: \(token ?? "None")")
|
|
5544
|
-
// uRLRequest.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
|
|
5545
|
-
//
|
|
5546
|
-
// // Add API headers
|
|
5547
|
-
// if let apiKey = EnvironmentConfig.apiKey,
|
|
5548
|
-
// let apiSecret = EnvironmentConfig.apiSecret {
|
|
5549
|
-
// uRLRequest.addValue(apiKey, forHTTPHeaderField: "x-api-key")
|
|
5550
|
-
// uRLRequest.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
|
|
5551
|
-
// }
|
|
5552
|
-
//
|
|
5553
|
-
// var params: [String: Any] = [
|
|
5554
|
-
// "name": cardNameTextField.text,
|
|
5555
|
-
//// "email": UserStoreSingleton.shared.merchantEmail ?? "",
|
|
5556
|
-
// "email": txtFieldEmailCardView.text,
|
|
5557
|
-
// "card_number": cardNumberTextField.text.replacingOccurrences(of: " ", with: ""),
|
|
5558
|
-
// "cardholder_name": cardNameTextField.text,
|
|
5559
|
-
// "exp_month": cardExpiryTextField.text.components(separatedBy: "/").first ?? "",
|
|
5560
|
-
// "exp_year": cardExpiryTextField.text.components(separatedBy: "/").last ?? "",
|
|
5561
|
-
// "cvc": cardCvvTextField.text,
|
|
5562
|
-
// "description": "payment checkout",
|
|
5563
|
-
// "currency": "usd"
|
|
5564
|
-
// // "payment_method": "card"
|
|
5565
|
-
// ]
|
|
5566
|
-
//
|
|
5567
|
-
// // Add these if recurring is enabled
|
|
5568
|
-
// if let req = request, req.is_recurring == true {
|
|
5569
|
-
// if let recurringType = req.recurringStartDateType, recurringType == .custom {
|
|
5570
|
-
// // Only send start_date if type is .custom and field is not empty
|
|
5571
|
-
// if let startDateText = txtFieldStartDateCard?.text, !startDateText.isEmpty {
|
|
5572
|
-
// let inputFormatter = DateFormatter()
|
|
5573
|
-
// inputFormatter.dateFormat = "dd/MM/yyyy"
|
|
5574
|
-
//
|
|
5575
|
-
// let outputFormatter = DateFormatter()
|
|
5576
|
-
// outputFormatter.dateFormat = "MM/dd/yyyy"
|
|
5577
|
-
//
|
|
5578
|
-
// if let date = inputFormatter.date(from: startDateText) {
|
|
5579
|
-
// let apiFormattedDate = outputFormatter.string(from: date)
|
|
5580
|
-
// params["start_date"] = apiFormattedDate
|
|
5581
|
-
// } else {
|
|
5582
|
-
// print("Invalid date format in startDateText")
|
|
5583
|
-
// }
|
|
5584
|
-
// }
|
|
5585
|
-
// }
|
|
5586
|
-
//
|
|
5587
|
-
// params["interval"] = txtFieldChosePlanCard.text.lowercased()
|
|
5588
|
-
// }
|
|
5589
|
-
//
|
|
5590
|
-
// print(params)
|
|
5591
|
-
//
|
|
5592
|
-
// do {
|
|
5593
|
-
// let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
5594
|
-
// uRLRequest.httpBody = jsonData
|
|
5595
|
-
// if let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
5596
|
-
// print("JSON Payload: \(jsonString)")
|
|
5597
|
-
// }
|
|
5598
|
-
// } catch let error {
|
|
5599
|
-
// print("Error creating JSON data: \(error)")
|
|
5600
|
-
// hideLoadingIndicator()
|
|
5601
|
-
// return
|
|
5602
|
-
// }
|
|
5603
|
-
//
|
|
5604
|
-
// let session = URLSession.shared
|
|
5605
|
-
// let task = session.dataTask(with: uRLRequest) { (serviceData, serviceResponse, error) in
|
|
5606
|
-
//
|
|
5607
|
-
// DispatchQueue.main.async {
|
|
5608
|
-
// self.hideLoadingIndicator() // Stop loader when response is received
|
|
5609
|
-
// }
|
|
5610
|
-
//
|
|
5611
|
-
// if let error = error {
|
|
5612
|
-
// print("Error: \(error.localizedDescription)")
|
|
5613
|
-
// return
|
|
5614
|
-
// }
|
|
5615
|
-
//
|
|
5616
|
-
// guard let httpResponse = serviceResponse as? HTTPURLResponse else {
|
|
5617
|
-
// print("Invalid response")
|
|
5618
|
-
// return
|
|
5619
|
-
// }
|
|
5620
|
-
//
|
|
5621
|
-
// if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
5622
|
-
// if let data = serviceData {
|
|
5623
|
-
// do {
|
|
5624
|
-
// if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
5625
|
-
// print("Response Data: \(responseObject)")
|
|
5626
|
-
//
|
|
5627
|
-
// // Check if status is 0 and handle the error
|
|
5628
|
-
// if let status = responseObject["status"] as? Int, status == 0 {
|
|
5629
|
-
// let errorMessage = responseObject["message"] as? String ?? "Unknown error"
|
|
5630
|
-
// self.presentPaymentErrorVC(errorMessage: errorMessage)
|
|
5631
|
-
// } else {
|
|
5632
|
-
// DispatchQueue.main.async {
|
|
5633
|
-
// if let paymentDoneVC = self.storyboard?.instantiateViewController(withIdentifier: "PaymentDoneVC") as? PaymentDoneVC {
|
|
5634
|
-
// paymentDoneVC.chargeData = responseObject
|
|
5635
|
-
// paymentDoneVC.selectedPaymentMethod = self.selectedPaymentMethod
|
|
5636
|
-
// paymentDoneVC.easyPayDelegate = self.easyPayDelegate
|
|
5637
|
-
//
|
|
5638
|
-
// // Pass billingInfo and additionalInfo
|
|
5639
|
-
// if let billingData = self.request.billingInfoData,
|
|
5640
|
-
// let billingInfoDict = try? JSONSerialization.jsonObject(with: billingData, options: []) as? [String: Any] {
|
|
5641
|
-
//
|
|
5642
|
-
// // Extract main billing fields
|
|
5643
|
-
// let cleanBillingInfo: [String: Any] = [
|
|
5644
|
-
// "postal_code": billingInfoDict["postal_code"] ?? "",
|
|
5645
|
-
// "country": billingInfoDict["country"] ?? "",
|
|
5646
|
-
// "city": billingInfoDict["city"] ?? "",
|
|
5647
|
-
// "address": billingInfoDict["address"] ?? "",
|
|
5648
|
-
// "state": billingInfoDict["state"] ?? ""
|
|
5649
|
-
// ]
|
|
5650
|
-
// paymentDoneVC.billingInfo = cleanBillingInfo
|
|
5651
|
-
//
|
|
5652
|
-
// // Extract additional_info
|
|
5653
|
-
// if let additional = billingInfoDict["additional_info"] as? [String: Any] {
|
|
5654
|
-
// let cleanAdditionalInfo: [String: Any] = [
|
|
5655
|
-
// "email": additional["email"] ?? "",
|
|
5656
|
-
// "phone_number": additional["phone_number"] ?? "",
|
|
5657
|
-
// "name": additional["name"] ?? "",
|
|
5658
|
-
// "country_code": additional["country_code"] ?? ""
|
|
5659
|
-
// ]
|
|
5660
|
-
// paymentDoneVC.additionalInfo = cleanAdditionalInfo
|
|
5661
|
-
// }
|
|
5662
|
-
// }
|
|
5663
|
-
// self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
5664
|
-
// }
|
|
5665
|
-
// }
|
|
5666
|
-
// }
|
|
5667
|
-
// } else {
|
|
5668
|
-
// self.presentPaymentErrorVC(errorMessage: "Invalid JSON format")
|
|
5669
|
-
// }
|
|
5670
|
-
// } catch let jsonError {
|
|
5671
|
-
// self.presentPaymentErrorVC(errorMessage: "Error parsing JSON: \(jsonError)")
|
|
5672
|
-
// }
|
|
5673
|
-
// } else {
|
|
5674
|
-
// self.presentPaymentErrorVC(errorMessage: "No data received")
|
|
5675
|
-
// }
|
|
5676
|
-
// } else {
|
|
5677
|
-
// if let data = serviceData,
|
|
5678
|
-
// let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
|
|
5679
|
-
// let message = responseObj["message"] as? String {
|
|
5680
|
-
// self.presentPaymentErrorVC(errorMessage: message)
|
|
5681
|
-
// } else {
|
|
5682
|
-
// self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
|
|
5683
|
-
// }
|
|
5684
|
-
// }
|
|
5685
|
-
// }
|
|
5686
|
-
// task.resume()
|
|
5687
|
-
// }
|
|
5688
|
-
|
|
5689
5507
|
// MARK: - Credit Card Charge Api If Billing info is nil and Without Login.
|
|
5690
5508
|
func paymentIntentApi() {
|
|
5691
5509
|
showLoadingIndicator()
|
|
@@ -5723,6 +5541,18 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
5723
5541
|
}
|
|
5724
5542
|
}
|
|
5725
5543
|
|
|
5544
|
+
// // ✅ Include metadata only if it has at least 1 key-value pair
|
|
5545
|
+
// if let metadata = request?.metadata, !metadata.isEmpty {
|
|
5546
|
+
// requestBody["metadata"] = metadata
|
|
5547
|
+
// }
|
|
5548
|
+
|
|
5549
|
+
// ✅ Flatten metadata into requestBody
|
|
5550
|
+
if let metadata = request?.metadata, !metadata.isEmpty {
|
|
5551
|
+
for (key, value) in metadata {
|
|
5552
|
+
requestBody[key] = value
|
|
5553
|
+
}
|
|
5554
|
+
}
|
|
5555
|
+
|
|
5726
5556
|
print("Request Body: \(requestBody)")
|
|
5727
5557
|
|
|
5728
5558
|
let request = APIRequest(
|
|
@@ -5789,214 +5619,6 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
5789
5619
|
}
|
|
5790
5620
|
}
|
|
5791
5621
|
|
|
5792
|
-
// MARK: - Credit Card Charge Api if billing info is available but visibility of billing and additinal is false
|
|
5793
|
-
// func paymentIntentCardApi() {
|
|
5794
|
-
// showLoadingIndicator()
|
|
5795
|
-
//
|
|
5796
|
-
// let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.charges.path()
|
|
5797
|
-
//
|
|
5798
|
-
// guard let serviceURL = URL(string: fullURL) else {
|
|
5799
|
-
// print("Invalid URL")
|
|
5800
|
-
// hideLoadingIndicator()
|
|
5801
|
-
// return
|
|
5802
|
-
// }
|
|
5803
|
-
//
|
|
5804
|
-
// var urlRequest = URLRequest(url: serviceURL)
|
|
5805
|
-
// urlRequest.httpMethod = "POST"
|
|
5806
|
-
// urlRequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
5807
|
-
//
|
|
5808
|
-
// let token = UserStoreSingleton.shared.clientToken
|
|
5809
|
-
// print("Setting clientToken header: \(token ?? "None")")
|
|
5810
|
-
// urlRequest.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
|
|
5811
|
-
//
|
|
5812
|
-
// var params: [String: Any] = [
|
|
5813
|
-
// "name": cardNameTextField.text,
|
|
5814
|
-
// "email": txtFieldEmailCardView.text,
|
|
5815
|
-
// "card_number": cardNumberTextField.text.replacingOccurrences(of: " ", with: ""),
|
|
5816
|
-
// "cardholder_name": cardNameTextField.text,
|
|
5817
|
-
// "exp_month": cardExpiryTextField.text.components(separatedBy: "/").first ?? "",
|
|
5818
|
-
// "exp_year": cardExpiryTextField.text.components(separatedBy: "/").last ?? "",
|
|
5819
|
-
// "cvc": cardCvvTextField.text,
|
|
5820
|
-
// "currency": "usd"
|
|
5821
|
-
// ]
|
|
5822
|
-
//
|
|
5823
|
-
// if let billingInfoData = request.billingInfoData {
|
|
5824
|
-
// do {
|
|
5825
|
-
// let fieldSection = try JSONDecoder().decode(FieldSection.self, from: billingInfoData)
|
|
5826
|
-
//
|
|
5827
|
-
// // Billing Info
|
|
5828
|
-
// let billing = fieldSection.billing
|
|
5829
|
-
// if !billing.isEmpty {
|
|
5830
|
-
// var billingDict: [String: Any] = [:]
|
|
5831
|
-
// billing.forEach { billingDict[$0.name] = $0.value }
|
|
5832
|
-
//
|
|
5833
|
-
// if let address = billingDict["address"] as? String, !address.isEmpty {
|
|
5834
|
-
// params["address"] = address
|
|
5835
|
-
// }
|
|
5836
|
-
// if let country = billingDict["country"] as? String, !country.isEmpty {
|
|
5837
|
-
// params["country"] = country
|
|
5838
|
-
// }
|
|
5839
|
-
// if let state = billingDict["state"] as? String, !state.isEmpty {
|
|
5840
|
-
// params["state"] = state
|
|
5841
|
-
// }
|
|
5842
|
-
// if let city = billingDict["city"] as? String, !city.isEmpty {
|
|
5843
|
-
// params["city"] = city
|
|
5844
|
-
// }
|
|
5845
|
-
// if let postalCode = billingDict["postal_code"] as? String, !postalCode.isEmpty {
|
|
5846
|
-
// params["zip"] = postalCode
|
|
5847
|
-
// }
|
|
5848
|
-
// }
|
|
5849
|
-
//
|
|
5850
|
-
// // Additional Info
|
|
5851
|
-
// let additional = fieldSection.additional
|
|
5852
|
-
// if !additional.isEmpty {
|
|
5853
|
-
// var additionalDict: [String: Any] = [:]
|
|
5854
|
-
// additional.forEach { additionalDict[$0.name] = $0.value }
|
|
5855
|
-
//
|
|
5856
|
-
// if let desc = additionalDict["description"] as? String, !desc.isEmpty {
|
|
5857
|
-
// params["description"] = desc
|
|
5858
|
-
// } else {
|
|
5859
|
-
// params["description"] = "Hosted payment checkout"
|
|
5860
|
-
// }
|
|
5861
|
-
//
|
|
5862
|
-
// if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
|
|
5863
|
-
// params["phone_number"] = phone
|
|
5864
|
-
// }
|
|
5865
|
-
// if let email = additionalDict["email"] as? String, !email.isEmpty {
|
|
5866
|
-
// params["email"] = email
|
|
5867
|
-
// }
|
|
5868
|
-
// if let name = additionalDict["name"] as? String, !name.isEmpty {
|
|
5869
|
-
// params["name"] = name
|
|
5870
|
-
// }
|
|
5871
|
-
// }
|
|
5872
|
-
// else {
|
|
5873
|
-
// // If no description in additional info, set default
|
|
5874
|
-
// params["description"] = "Hosted payment checkout"
|
|
5875
|
-
// }
|
|
5876
|
-
// } catch {
|
|
5877
|
-
// print("Failed to decode FieldSection: \(error)")
|
|
5878
|
-
// params["description"] = "Hosted payment checkout"
|
|
5879
|
-
// }
|
|
5880
|
-
// } else {
|
|
5881
|
-
// // Fallback if billingInfoData is missing
|
|
5882
|
-
// params["description"] = "Hosted payment checkout"
|
|
5883
|
-
// }
|
|
5884
|
-
//
|
|
5885
|
-
// // Add these if recurring is enabled
|
|
5886
|
-
// if let req = request, req.is_recurring == true {
|
|
5887
|
-
// if let recurringType = req.recurringStartDateType, recurringType == .custom {
|
|
5888
|
-
// // Only send start_date if type is .custom and field is not empty
|
|
5889
|
-
// if let startDateText = txtFieldStartDateCard?.text, !startDateText.isEmpty {
|
|
5890
|
-
// let inputFormatter = DateFormatter()
|
|
5891
|
-
// inputFormatter.dateFormat = "dd/MM/yyyy"
|
|
5892
|
-
//
|
|
5893
|
-
// let outputFormatter = DateFormatter()
|
|
5894
|
-
// outputFormatter.dateFormat = "MM/dd/yyyy"
|
|
5895
|
-
//
|
|
5896
|
-
// if let date = inputFormatter.date(from: startDateText) {
|
|
5897
|
-
// let apiFormattedDate = outputFormatter.string(from: date)
|
|
5898
|
-
// params["start_date"] = apiFormattedDate
|
|
5899
|
-
// } else {
|
|
5900
|
-
// print("Invalid date format in startDateText")
|
|
5901
|
-
// }
|
|
5902
|
-
// }
|
|
5903
|
-
// }
|
|
5904
|
-
//
|
|
5905
|
-
// params["interval"] = txtFieldChosePlanCard.text.lowercased()
|
|
5906
|
-
// }
|
|
5907
|
-
//
|
|
5908
|
-
// print(params)
|
|
5909
|
-
//
|
|
5910
|
-
// do {
|
|
5911
|
-
// let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
5912
|
-
// urlRequest.httpBody = jsonData
|
|
5913
|
-
// if let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
5914
|
-
// print("JSON Payload: \(jsonString)")
|
|
5915
|
-
// }
|
|
5916
|
-
// } catch let error {
|
|
5917
|
-
// print("Error creating JSON data: \(error)")
|
|
5918
|
-
// hideLoadingIndicator()
|
|
5919
|
-
// return
|
|
5920
|
-
// }
|
|
5921
|
-
//
|
|
5922
|
-
// let session = URLSession.shared
|
|
5923
|
-
// let task = session.dataTask(with: urlRequest) { (serviceData, serviceResponse, error) in
|
|
5924
|
-
//
|
|
5925
|
-
// DispatchQueue.main.async {
|
|
5926
|
-
// self.hideLoadingIndicator()
|
|
5927
|
-
// }
|
|
5928
|
-
//
|
|
5929
|
-
// if let error = error {
|
|
5930
|
-
// print("Error: \(error.localizedDescription)")
|
|
5931
|
-
// self.presentPaymentErrorVC(errorMessage: error.localizedDescription)
|
|
5932
|
-
// return
|
|
5933
|
-
// }
|
|
5934
|
-
//
|
|
5935
|
-
// guard let httpResponse = serviceResponse as? HTTPURLResponse else {
|
|
5936
|
-
// print("Invalid response")
|
|
5937
|
-
// self.presentPaymentErrorVC(errorMessage: "Invalid response from server.")
|
|
5938
|
-
// return
|
|
5939
|
-
// }
|
|
5940
|
-
//
|
|
5941
|
-
// if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
5942
|
-
// if let data = serviceData {
|
|
5943
|
-
// do {
|
|
5944
|
-
// if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
5945
|
-
// print("Response Data: \(responseObject)")
|
|
5946
|
-
//
|
|
5947
|
-
// if let status = responseObject["status"] as? Int, status == 0 {
|
|
5948
|
-
// let errorMessage = responseObject["message"] as? String ?? "Unknown error occurred."
|
|
5949
|
-
// self.presentPaymentErrorVC(errorMessage: errorMessage)
|
|
5950
|
-
// } else {
|
|
5951
|
-
// DispatchQueue.main.async {
|
|
5952
|
-
// if let paymentDoneVC = self.storyboard?.instantiateViewController(withIdentifier: "PaymentDoneVC") as? PaymentDoneVC {
|
|
5953
|
-
// paymentDoneVC.chargeData = responseObject
|
|
5954
|
-
// paymentDoneVC.selectedPaymentMethod = self.selectedPaymentMethod
|
|
5955
|
-
// paymentDoneVC.easyPayDelegate = self.easyPayDelegate
|
|
5956
|
-
// // Pass billing info and additional info if available
|
|
5957
|
-
// if let billingInfoData = self.request.billingInfoData,
|
|
5958
|
-
// let fieldSection = try? JSONDecoder().decode(FieldSection.self, from: billingInfoData) {
|
|
5959
|
-
//
|
|
5960
|
-
// // Filter billing info: only include non-empty values
|
|
5961
|
-
// let filteredBilling = fieldSection.billing.filter { !($0.value.trimmingCharacters(in: .whitespaces).isEmpty) }
|
|
5962
|
-
// paymentDoneVC.billingInfoData = filteredBilling
|
|
5963
|
-
// var billingDict: [String: Any] = [:]
|
|
5964
|
-
// filteredBilling.forEach { billingDict[$0.name] = $0.value }
|
|
5965
|
-
// paymentDoneVC.billingInfo = billingDict
|
|
5966
|
-
//
|
|
5967
|
-
// // Filter additional info: only include non-empty values
|
|
5968
|
-
// let filteredAdditional = fieldSection.additional.filter { !($0.value.trimmingCharacters(in: .whitespaces).isEmpty) }
|
|
5969
|
-
// paymentDoneVC.additionalInfoData = filteredAdditional
|
|
5970
|
-
// var additionalDict: [String: Any] = [:]
|
|
5971
|
-
// filteredAdditional.forEach { additionalDict[$0.name] = $0.value }
|
|
5972
|
-
// paymentDoneVC.additionalInfo = additionalDict
|
|
5973
|
-
// }
|
|
5974
|
-
// self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
5975
|
-
// }
|
|
5976
|
-
// }
|
|
5977
|
-
// }
|
|
5978
|
-
// } else {
|
|
5979
|
-
// self.presentPaymentErrorVC(errorMessage: "Invalid JSON format")
|
|
5980
|
-
// }
|
|
5981
|
-
// } catch let jsonError {
|
|
5982
|
-
// self.presentPaymentErrorVC(errorMessage: "Error parsing response: \(jsonError.localizedDescription)")
|
|
5983
|
-
// }
|
|
5984
|
-
// } else {
|
|
5985
|
-
// self.presentPaymentErrorVC(errorMessage: "No data received from server.")
|
|
5986
|
-
// }
|
|
5987
|
-
// } else {
|
|
5988
|
-
// if let data = serviceData,
|
|
5989
|
-
// let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
|
|
5990
|
-
// let message = responseObj["message"] as? String {
|
|
5991
|
-
// self.presentPaymentErrorVC(errorMessage: message)
|
|
5992
|
-
// } else {
|
|
5993
|
-
// self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
|
|
5994
|
-
// }
|
|
5995
|
-
// }
|
|
5996
|
-
// }
|
|
5997
|
-
// task.resume()
|
|
5998
|
-
// }
|
|
5999
|
-
|
|
6000
5622
|
// MARK: - Credit Card Charge Api if billing info is available but visibility of billing and additinal is false
|
|
6001
5623
|
func paymentIntentCardApi() {
|
|
6002
5624
|
showLoadingIndicator()
|
|
@@ -6097,6 +5719,18 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
6097
5719
|
params["interval"] = txtFieldChosePlanCard.text.lowercased()
|
|
6098
5720
|
}
|
|
6099
5721
|
|
|
5722
|
+
// // ✅ Include metadata only if it has at least 1 key-value pair
|
|
5723
|
+
// if let metadata = request?.metadata, !metadata.isEmpty {
|
|
5724
|
+
// requestBody["metadata"] = metadata
|
|
5725
|
+
// }
|
|
5726
|
+
|
|
5727
|
+
// ✅ Flatten metadata into requestBody
|
|
5728
|
+
if let metadata = request?.metadata, !metadata.isEmpty {
|
|
5729
|
+
for (key, value) in metadata {
|
|
5730
|
+
params[key] = value
|
|
5731
|
+
}
|
|
5732
|
+
}
|
|
5733
|
+
|
|
6100
5734
|
print(params)
|
|
6101
5735
|
|
|
6102
5736
|
let request = APIRequest(
|
|
@@ -6157,168 +5791,6 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
6157
5791
|
}
|
|
6158
5792
|
}
|
|
6159
5793
|
|
|
6160
|
-
// MARK: - Credit Card Charge API (Saved Cards, No Billing Info, Logged In)
|
|
6161
|
-
// func paymentIntentFromShowSavedCardApi() {
|
|
6162
|
-
// showLoadingIndicator()
|
|
6163
|
-
//
|
|
6164
|
-
// ///Old Using URL Endpoints
|
|
6165
|
-
// // let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.creditCharges.path()
|
|
6166
|
-
//
|
|
6167
|
-
// let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.charges.path()
|
|
6168
|
-
//
|
|
6169
|
-
// guard let serviceURL = URL(string: fullURL) else {
|
|
6170
|
-
// print("Invalid URL")
|
|
6171
|
-
// hideLoadingIndicator()
|
|
6172
|
-
// return
|
|
6173
|
-
// }
|
|
6174
|
-
//
|
|
6175
|
-
// var uRLRequest = URLRequest(url: serviceURL)
|
|
6176
|
-
// uRLRequest.httpMethod = "POST"
|
|
6177
|
-
// uRLRequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
6178
|
-
//
|
|
6179
|
-
// // Add client token
|
|
6180
|
-
// let token = UserStoreSingleton.shared.clientToken
|
|
6181
|
-
// print("Setting clientToken header: \(token ?? "None")")
|
|
6182
|
-
// uRLRequest.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
|
|
6183
|
-
//
|
|
6184
|
-
// // Add API headers
|
|
6185
|
-
// if let apiKey = EnvironmentConfig.apiKey,
|
|
6186
|
-
// let apiSecret = EnvironmentConfig.apiSecret {
|
|
6187
|
-
// uRLRequest.addValue(apiKey, forHTTPHeaderField: "x-api-key")
|
|
6188
|
-
// uRLRequest.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
|
|
6189
|
-
// }
|
|
6190
|
-
//
|
|
6191
|
-
// var params: [String: Any] = [
|
|
6192
|
-
// "description": "payment checkout",
|
|
6193
|
-
// "currency": "usd",
|
|
6194
|
-
// "card_id": selectedCard?.cardId ?? "",
|
|
6195
|
-
// "cvc": txtFieldCVVSingleSavedCard.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "",
|
|
6196
|
-
// "customer_id": selectedCard?.customerId ?? "",
|
|
6197
|
-
// "name": UserStoreSingleton.shared.merchantName ?? "",
|
|
6198
|
-
// "email": UserStoreSingleton.shared.verificationEmail ?? ""
|
|
6199
|
-
// ]
|
|
6200
|
-
//
|
|
6201
|
-
// // Add these if recurring is enabled
|
|
6202
|
-
// if let req = request, req.is_recurring == true {
|
|
6203
|
-
// if let recurringType = req.recurringStartDateType, recurringType == .custom {
|
|
6204
|
-
// // Only send start_date if type is .custom and field is not empty
|
|
6205
|
-
// if let startDateText = txtFieldSelectDateSingleSavedCard?.text, !startDateText.isEmpty {
|
|
6206
|
-
// let inputFormatter = DateFormatter()
|
|
6207
|
-
// inputFormatter.dateFormat = "dd/MM/yyyy"
|
|
6208
|
-
//
|
|
6209
|
-
// let outputFormatter = DateFormatter()
|
|
6210
|
-
// outputFormatter.dateFormat = "MM/dd/yyyy"
|
|
6211
|
-
//
|
|
6212
|
-
// if let date = inputFormatter.date(from: startDateText) {
|
|
6213
|
-
// let apiFormattedDate = outputFormatter.string(from: date)
|
|
6214
|
-
// params["start_date"] = apiFormattedDate
|
|
6215
|
-
// } else {
|
|
6216
|
-
// print("Invalid date format in startDateText")
|
|
6217
|
-
// }
|
|
6218
|
-
// }
|
|
6219
|
-
// }
|
|
6220
|
-
//
|
|
6221
|
-
// params["interval"] = txtFieldSelectPlanSingleSavedCard.text.lowercased()
|
|
6222
|
-
// }
|
|
6223
|
-
//
|
|
6224
|
-
// print("Request Params: \(params)")
|
|
6225
|
-
//
|
|
6226
|
-
// do {
|
|
6227
|
-
// let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
6228
|
-
// uRLRequest.httpBody = jsonData
|
|
6229
|
-
//
|
|
6230
|
-
// if let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
6231
|
-
// print("JSON Payload: \(jsonString)")
|
|
6232
|
-
// }
|
|
6233
|
-
// } catch {
|
|
6234
|
-
// print("Error creating JSON data: \(error)")
|
|
6235
|
-
// hideLoadingIndicator()
|
|
6236
|
-
// return
|
|
6237
|
-
// }
|
|
6238
|
-
//
|
|
6239
|
-
// // API Call
|
|
6240
|
-
// let task = URLSession.shared.dataTask(with: uRLRequest) { (data, response, error) in
|
|
6241
|
-
// DispatchQueue.main.async {
|
|
6242
|
-
// self.hideLoadingIndicator()
|
|
6243
|
-
// }
|
|
6244
|
-
//
|
|
6245
|
-
// if let error = error {
|
|
6246
|
-
// print("Error: \(error.localizedDescription)")
|
|
6247
|
-
// return
|
|
6248
|
-
// }
|
|
6249
|
-
//
|
|
6250
|
-
// guard let httpResponse = response as? HTTPURLResponse else {
|
|
6251
|
-
// print("Invalid response")
|
|
6252
|
-
// return
|
|
6253
|
-
// }
|
|
6254
|
-
//
|
|
6255
|
-
// if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
6256
|
-
// if let data = data {
|
|
6257
|
-
// do {
|
|
6258
|
-
// if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
6259
|
-
// print("Response Data: \(responseObject)")
|
|
6260
|
-
//
|
|
6261
|
-
// if let status = responseObject["status"] as? Int, status == 0 {
|
|
6262
|
-
// let errorMessage = responseObject["message"] as? String ?? "Unknown error"
|
|
6263
|
-
// self.presentPaymentErrorVC(errorMessage: errorMessage)
|
|
6264
|
-
// } else {
|
|
6265
|
-
// DispatchQueue.main.async {
|
|
6266
|
-
// if let paymentDoneVC = self.storyboard?.instantiateViewController(withIdentifier: "PaymentDoneVC") as? PaymentDoneVC {
|
|
6267
|
-
// paymentDoneVC.chargeData = responseObject
|
|
6268
|
-
// paymentDoneVC.selectedPaymentMethod = self.selectedPaymentMethod
|
|
6269
|
-
// paymentDoneVC.easyPayDelegate = self.easyPayDelegate
|
|
6270
|
-
//
|
|
6271
|
-
// // Pass billingInfo and additionalInfo
|
|
6272
|
-
// if let billingData = self.request.billingInfoData,
|
|
6273
|
-
// let billingInfoDict = try? JSONSerialization.jsonObject(with: billingData, options: []) as? [String: Any] {
|
|
6274
|
-
//
|
|
6275
|
-
// // Extract main billing fields
|
|
6276
|
-
// let cleanBillingInfo: [String: Any] = [
|
|
6277
|
-
// "postal_code": billingInfoDict["postal_code"] ?? "",
|
|
6278
|
-
// "country": billingInfoDict["country"] ?? "",
|
|
6279
|
-
// "city": billingInfoDict["city"] ?? "",
|
|
6280
|
-
// "address": billingInfoDict["address"] ?? "",
|
|
6281
|
-
// "state": billingInfoDict["state"] ?? ""
|
|
6282
|
-
// ]
|
|
6283
|
-
// paymentDoneVC.billingInfo = cleanBillingInfo
|
|
6284
|
-
//
|
|
6285
|
-
// // Extract additional_info
|
|
6286
|
-
// if let additional = billingInfoDict["additional_info"] as? [String: Any] {
|
|
6287
|
-
// let cleanAdditionalInfo: [String: Any] = [
|
|
6288
|
-
// "email": additional["email"] ?? "",
|
|
6289
|
-
// "phone_number": additional["phone_number"] ?? "",
|
|
6290
|
-
// "name": additional["name"] ?? "",
|
|
6291
|
-
// "country_code": additional["country_code"] ?? ""
|
|
6292
|
-
// ]
|
|
6293
|
-
// paymentDoneVC.additionalInfo = cleanAdditionalInfo
|
|
6294
|
-
// }
|
|
6295
|
-
// }
|
|
6296
|
-
// self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
6297
|
-
// }
|
|
6298
|
-
// }
|
|
6299
|
-
// }
|
|
6300
|
-
// } else {
|
|
6301
|
-
// self.presentPaymentErrorVC(errorMessage: "Invalid JSON format")
|
|
6302
|
-
// }
|
|
6303
|
-
// } catch {
|
|
6304
|
-
// self.presentPaymentErrorVC(errorMessage: "Error parsing JSON: \(error)")
|
|
6305
|
-
// }
|
|
6306
|
-
// } else {
|
|
6307
|
-
// self.presentPaymentErrorVC(errorMessage: "No data received")
|
|
6308
|
-
// }
|
|
6309
|
-
// } else {
|
|
6310
|
-
// if let data = data,
|
|
6311
|
-
// let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
|
|
6312
|
-
// let message = responseObj["message"] as? String {
|
|
6313
|
-
// self.presentPaymentErrorVC(errorMessage: message)
|
|
6314
|
-
// } else {
|
|
6315
|
-
// self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
|
|
6316
|
-
// }
|
|
6317
|
-
// }
|
|
6318
|
-
// }
|
|
6319
|
-
// task.resume()
|
|
6320
|
-
// }
|
|
6321
|
-
|
|
6322
5794
|
// MARK: - Credit Card Charge API (Saved Cards, No Billing Info, Logged In)
|
|
6323
5795
|
func paymentIntentFromShowSavedCardApi() {
|
|
6324
5796
|
showLoadingIndicator()
|
|
@@ -6356,6 +5828,18 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
6356
5828
|
params["interval"] = txtFieldSelectPlanSingleSavedCard.text.lowercased()
|
|
6357
5829
|
}
|
|
6358
5830
|
|
|
5831
|
+
// // ✅ Include metadata only if it has at least 1 key-value pair
|
|
5832
|
+
// if let metadata = request?.metadata, !metadata.isEmpty {
|
|
5833
|
+
// requestBody["metadata"] = metadata
|
|
5834
|
+
// }
|
|
5835
|
+
|
|
5836
|
+
// ✅ Flatten metadata into requestBody
|
|
5837
|
+
if let metadata = request?.metadata, !metadata.isEmpty {
|
|
5838
|
+
for (key, value) in metadata {
|
|
5839
|
+
params[key] = value
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
|
|
6359
5843
|
print("Request Params: \(params)")
|
|
6360
5844
|
|
|
6361
5845
|
let request = APIRequest(
|
|
@@ -6539,6 +6023,18 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
6539
6023
|
params["interval"] = txtFieldSelectPlanSingleSavedCard.text.lowercased()
|
|
6540
6024
|
}
|
|
6541
6025
|
|
|
6026
|
+
// // ✅ Include metadata only if it has at least 1 key-value pair
|
|
6027
|
+
// if let metadata = request?.metadata, !metadata.isEmpty {
|
|
6028
|
+
// requestBody["metadata"] = metadata
|
|
6029
|
+
// }
|
|
6030
|
+
|
|
6031
|
+
// ✅ Flatten metadata into requestBody
|
|
6032
|
+
if let metadata = request?.metadata, !metadata.isEmpty {
|
|
6033
|
+
for (key, value) in metadata {
|
|
6034
|
+
params[key] = value
|
|
6035
|
+
}
|
|
6036
|
+
}
|
|
6037
|
+
|
|
6542
6038
|
print(params)
|
|
6543
6039
|
|
|
6544
6040
|
do {
|
|
@@ -7015,6 +6511,18 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
7015
6511
|
params["email"] = UserStoreSingleton.shared.verificationEmail
|
|
7016
6512
|
}
|
|
7017
6513
|
|
|
6514
|
+
// // ✅ Include metadata only if it has at least 1 key-value pair
|
|
6515
|
+
// if let metadata = request?.metadata, !metadata.isEmpty {
|
|
6516
|
+
// requestBody["metadata"] = metadata
|
|
6517
|
+
// }
|
|
6518
|
+
|
|
6519
|
+
// ✅ Flatten metadata into requestBody
|
|
6520
|
+
if let metadata = request?.metadata, !metadata.isEmpty {
|
|
6521
|
+
for (key, value) in metadata {
|
|
6522
|
+
params[key] = value
|
|
6523
|
+
}
|
|
6524
|
+
}
|
|
6525
|
+
|
|
7018
6526
|
print(params)
|
|
7019
6527
|
|
|
7020
6528
|
do {
|
|
@@ -7735,7 +7243,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
7735
7243
|
}
|
|
7736
7244
|
|
|
7737
7245
|
var params: [String: Any] = [
|
|
7738
|
-
"name": txtFieldAccountName.text ?? "",
|
|
7246
|
+
"name": !(request.name?.isEmpty ?? true) ? request.name! : (txtFieldAccountName.text ?? ""),
|
|
7739
7247
|
"email": txtFieldEmailAccountView.text,
|
|
7740
7248
|
"description": "TestDescription",
|
|
7741
7249
|
"currency": "usd",
|
|
@@ -8334,7 +7842,8 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
8334
7842
|
let accountNumber = txtFieldAccountNumberNewAccountView.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
|
8335
7843
|
|
|
8336
7844
|
var params: [String: Any] = [
|
|
8337
|
-
|
|
7845
|
+
// "name": accountName,
|
|
7846
|
+
"name": !(request.name?.isEmpty ?? true) ? request.name! : (accountName),
|
|
8338
7847
|
"email": UserStoreSingleton.shared.verificationEmail ?? "",
|
|
8339
7848
|
"description": "Test Description",
|
|
8340
7849
|
"currency": "usd",
|
|
@@ -8503,7 +8012,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
8503
8012
|
let accountNumber = txtFieldAccountNumberNewAccountView.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
|
8504
8013
|
|
|
8505
8014
|
var params: [String: Any] = [
|
|
8506
|
-
"name": accountName,
|
|
8015
|
+
"name": !(request.name?.isEmpty ?? true) ? request.name! : (accountName),
|
|
8507
8016
|
"email": UserStoreSingleton.shared.verificationEmail ?? "",
|
|
8508
8017
|
"description": "Test Description",
|
|
8509
8018
|
"currency": "usd",
|
|
@@ -8730,7 +8239,7 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
8730
8239
|
let emailPrefix = UserStoreSingleton.shared.verificationEmail?.components(separatedBy: "@").first ?? ""
|
|
8731
8240
|
|
|
8732
8241
|
var params: [String: Any] = [
|
|
8733
|
-
"name": accountName,
|
|
8242
|
+
"name": !(request.name?.isEmpty ?? true) ? request.name! : (accountName),
|
|
8734
8243
|
"email": UserStoreSingleton.shared.verificationEmail ?? "",
|
|
8735
8244
|
"description": "Test Description",
|
|
8736
8245
|
"currency": "usd",
|