@jimrising/easymerchantsdk-react-native 1.8.4 → 1.8.5
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 +1007 -350
- package/android/build/.transforms/15b6a8a60a6b32d0dcaf609723cf365b/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/8508f1428f740032c45a43f48b1bbe1e/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/.transforms/ffabb40f9809b32eb9546ce76fc51764/transformed/bundleLibRuntimeToDirRelease/desugar_graph.bin +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/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 +126 -21
- package/android/build/intermediates/incremental/release/mergeReleaseResources/merger.xml +3 -3
- 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/androidx/core/group-index.xml +4 -4
- package/android/build/intermediates/lint-cache/lintVitalAnalyzeRelease/maven.google/androidx/lifecycle/group-index.xml +2 -2
- package/android/build/intermediates/lint-cache/lintVitalAnalyzeRelease/maven.google/com/android/tools/build/group-index.xml +14 -14
- package/android/build/intermediates/lint-cache/lintVitalAnalyzeRelease/sdk_index/snapshot.gz +0 -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/layout/activity_card_addition_ifo.xml +4 -5
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/multi-v2/values-night-v8.json +2 -2
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/multi-v2/values.json +38 -38
- package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable.json +62 -62
- 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 +20 -20
- 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/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 +2 -2
- package/android/build/intermediates/verified_library_resources/release/verifyReleaseResources/compiled/layout_activity_card_addition_ifo.xml.flat +0 -0
- package/android/build/outputs/aar/jimrising_easymerchantsdk-react-native-release.aar +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$1$1.class.uniqueId1 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$1.class.uniqueId0 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$2.class.uniqueId3 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule.class.uniqueId2 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/compileReleaseJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$1$1.class.uniqueId1 +0 -0
- package/android/build/tmp/compileReleaseJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$1.class.uniqueId3 +0 -0
- package/android/build/tmp/compileReleaseJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$2.class.uniqueId0 +0 -0
- package/android/build/tmp/compileReleaseJavaWithJavac/compileTransaction/stash-dir/{RNEasymerchantsdkModule.class.uniqueId1 → RNEasymerchantsdkModule.class.uniqueId2} +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 +77 -38
- package/ios/Classes/EasyPayViewController.swift +3 -2
- package/ios/Models/Request.swift +215 -218
- package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +2 -1
- package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +7 -6
- package/ios/Pods/ViewControllers/OTPVerificationVC.swift +2 -1
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +21 -10
- package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +4 -3
- package/ios/easymerchantsdk.podspec +1 -1
- package/package.json +1 -1
- package/android/build/tmp/compileReleaseJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$1.class.uniqueId2 +0 -0
- /package/android/build/tmp/compileReleaseJavaWithJavac/compileTransaction/stash-dir/{RNEasymerchantsdkPackage.class.uniqueId3 → RNEasymerchantsdkPackage.class.uniqueId4} +0 -0
package/ios/Models/Request.swift
CHANGED
|
@@ -284,13 +284,6 @@ public final class Request: NSObject {
|
|
|
284
284
|
|
|
285
285
|
super.init()
|
|
286
286
|
|
|
287
|
-
// /// ✅ Clear old user data first
|
|
288
|
-
// DispatchQueue.main.async {
|
|
289
|
-
// if let topVC = UIApplication.topViewController() as? PaymentInfoVC {
|
|
290
|
-
// topVC.logOut()
|
|
291
|
-
// }
|
|
292
|
-
// }
|
|
293
|
-
|
|
294
287
|
// If tokenOnly is true, fetch only the clientToken and do not open the SDK
|
|
295
288
|
if tokenOnly {
|
|
296
289
|
self.paymentIntentApi { success in
|
|
@@ -322,239 +315,241 @@ public final class Request: NSObject {
|
|
|
322
315
|
}
|
|
323
316
|
|
|
324
317
|
//MARK: - Payment Intent Api
|
|
325
|
-
// func paymentIntentApi(completion: @escaping (Bool) -> Void) {
|
|
326
|
-
// guard let serviceURL = URL(string: EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.paymentIntent.path()) else {
|
|
327
|
-
// showErrorAndDismiss(message: "Invalid payment URL.")
|
|
328
|
-
// completion(false)
|
|
329
|
-
// return
|
|
330
|
-
// }
|
|
331
|
-
//
|
|
332
|
-
// var request = URLRequest(url: serviceURL)
|
|
333
|
-
// request.httpMethod = "POST"
|
|
334
|
-
// request.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
335
|
-
// request.addValue(EnvironmentConfig.apiKey ?? "", forHTTPHeaderField: "X-Api-Key")
|
|
336
|
-
// request.addValue(EnvironmentConfig.apiSecret ?? "", forHTTPHeaderField: "X-Api-Secret")
|
|
337
|
-
//
|
|
338
|
-
// // Recurring date validation
|
|
339
|
-
// if let startDateString = recurringStartDate,
|
|
340
|
-
// let startDate = DateFormatter.recurringDateFormatter.date(from: startDateString) {
|
|
341
|
-
// let today = Calendar.current.startOfDay(for: Date())
|
|
342
|
-
// let startDay = Calendar.current.startOfDay(for: startDate)
|
|
343
|
-
//
|
|
344
|
-
// if startDay < today {
|
|
345
|
-
// showErrorAndDismiss(message: "The recurring start date cannot be in the past. Please select today or a future date.")
|
|
346
|
-
// completion(false)
|
|
347
|
-
// return
|
|
348
|
-
// }
|
|
349
|
-
// }
|
|
350
|
-
//
|
|
351
|
-
// let params: [String: Any] = [
|
|
352
|
-
// "amount": amount ?? 0,
|
|
353
|
-
// // "allowed_cycles": String(recurringIntervals?.count ?? 0),
|
|
354
|
-
// "allowed_cycles": numOfCycle ?? 0,
|
|
355
|
-
// "intervals": recurringIntervals?.map { $0.rawValue } ?? [],
|
|
356
|
-
// "is_recurring": self.is_recurring ?? false,
|
|
357
|
-
// "recurring_start_date": recurringStartDate ?? "",
|
|
358
|
-
// "recurring_start_date_type": recurringStartDateType?.rawValue ?? ""
|
|
359
|
-
// ]
|
|
360
|
-
//
|
|
361
|
-
// do {
|
|
362
|
-
// request.httpBody = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
363
|
-
// } catch {
|
|
364
|
-
// showErrorAndDismiss(message: "Failed to encode payment data.")
|
|
365
|
-
// completion(false)
|
|
366
|
-
// return
|
|
367
|
-
// }
|
|
368
|
-
//
|
|
369
|
-
// let task = URLSession.shared.dataTask(with: request) { data, response, error in
|
|
370
|
-
// guard let httpResponse = response as? HTTPURLResponse, error == nil else {
|
|
371
|
-
// self.showErrorAndDismiss(message: error?.localizedDescription ?? "An unknown error occurred.")
|
|
372
|
-
// completion(false)
|
|
373
|
-
// return
|
|
374
|
-
// }
|
|
375
|
-
//
|
|
376
|
-
// if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
377
|
-
// if let data = data {
|
|
378
|
-
// do {
|
|
379
|
-
// if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
380
|
-
// if let clientToken = responseObject["client_token"] as? String {
|
|
381
|
-
// UserStoreSingleton.shared.clientToken = clientToken
|
|
382
|
-
// print(clientToken)
|
|
383
|
-
// }
|
|
384
|
-
// if let paymentIntent = responseObject["payment_intent"] as? String {
|
|
385
|
-
// UserStoreSingleton.shared.paymentIntent = paymentIntent
|
|
386
|
-
// }
|
|
387
|
-
// self.hostedCheckoutsApi { success in
|
|
388
|
-
// completion(success)
|
|
389
|
-
// }
|
|
390
|
-
// return
|
|
391
|
-
// } else {
|
|
392
|
-
// self.showErrorAndDismiss(message: "Invalid response format.")
|
|
393
|
-
// }
|
|
394
|
-
// } catch {
|
|
395
|
-
// self.showErrorAndDismiss(message: "Failed to parse response.")
|
|
396
|
-
// }
|
|
397
|
-
// } else {
|
|
398
|
-
// self.showErrorAndDismiss(message: "No response data received.")
|
|
399
|
-
// }
|
|
400
|
-
// } else {
|
|
401
|
-
// var message = "Payment request failed with status code: \(httpResponse.statusCode)"
|
|
402
|
-
// if let data = data,
|
|
403
|
-
// let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
|
|
404
|
-
// let msg = responseObj["message"] as? String {
|
|
405
|
-
// message = msg
|
|
406
|
-
// }
|
|
407
|
-
// self.showErrorAndDismiss(message: message)
|
|
408
|
-
// }
|
|
409
|
-
// completion(false)
|
|
410
|
-
// }
|
|
411
|
-
//
|
|
412
|
-
// task.resume()
|
|
413
|
-
// }
|
|
414
|
-
|
|
415
|
-
// MARK: - Payment Intent Api
|
|
416
318
|
func paymentIntentApi(completion: @escaping (Bool) -> Void) {
|
|
417
|
-
// ✅ Show Loader
|
|
418
|
-
DispatchQueue.main.async {
|
|
419
|
-
UIApplication.topViewController()?.ep_showLoadingIndicator()
|
|
420
|
-
}
|
|
421
|
-
|
|
422
319
|
guard let serviceURL = URL(string: EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.paymentIntent.path()) else {
|
|
423
|
-
|
|
424
|
-
UIApplication.topViewController()?.ep_hideLoadingIndicator()
|
|
425
|
-
self.showErrorAndDismiss(message: "Invalid payment URL.")
|
|
426
|
-
}
|
|
320
|
+
showErrorAndDismiss(message: "Invalid payment URL.")
|
|
427
321
|
completion(false)
|
|
428
322
|
return
|
|
429
323
|
}
|
|
430
|
-
|
|
324
|
+
|
|
431
325
|
var request = URLRequest(url: serviceURL)
|
|
432
326
|
request.httpMethod = "POST"
|
|
433
327
|
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
434
328
|
request.addValue(EnvironmentConfig.apiKey ?? "", forHTTPHeaderField: "X-Api-Key")
|
|
435
329
|
request.addValue(EnvironmentConfig.apiSecret ?? "", forHTTPHeaderField: "X-Api-Secret")
|
|
436
|
-
|
|
437
|
-
//
|
|
330
|
+
|
|
331
|
+
// Recurring date validation
|
|
438
332
|
if let startDateString = recurringStartDate,
|
|
439
333
|
let startDate = DateFormatter.recurringDateFormatter.date(from: startDateString) {
|
|
440
334
|
let today = Calendar.current.startOfDay(for: Date())
|
|
441
335
|
let startDay = Calendar.current.startOfDay(for: startDate)
|
|
442
|
-
|
|
336
|
+
|
|
443
337
|
if startDay < today {
|
|
444
|
-
|
|
445
|
-
UIApplication.topViewController()?.ep_hideLoadingIndicator()
|
|
446
|
-
self.showErrorAndDismiss(message: "The recurring start date cannot be in the past. Please select today or a future date.")
|
|
447
|
-
}
|
|
338
|
+
showErrorAndDismiss(message: "The recurring start date cannot be in the past. Please select today or a future date.")
|
|
448
339
|
completion(false)
|
|
449
340
|
return
|
|
450
341
|
}
|
|
451
342
|
}
|
|
452
|
-
|
|
343
|
+
|
|
453
344
|
let params: [String: Any] = [
|
|
454
345
|
"amount": amount ?? 0,
|
|
346
|
+
// "allowed_cycles": String(recurringIntervals?.count ?? 0),
|
|
455
347
|
"allowed_cycles": numOfCycle ?? 0,
|
|
456
348
|
"intervals": recurringIntervals?.map { $0.rawValue } ?? [],
|
|
457
349
|
"is_recurring": self.is_recurring ?? false,
|
|
458
350
|
"recurring_start_date": recurringStartDate ?? "",
|
|
459
351
|
"recurring_start_date_type": recurringStartDateType?.rawValue ?? ""
|
|
460
352
|
]
|
|
461
|
-
|
|
353
|
+
|
|
354
|
+
print(params)
|
|
355
|
+
|
|
462
356
|
do {
|
|
463
357
|
request.httpBody = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
464
358
|
} catch {
|
|
465
|
-
|
|
466
|
-
UIApplication.topViewController()?.ep_hideLoadingIndicator()
|
|
467
|
-
self.showErrorAndDismiss(message: "Failed to encode payment data.")
|
|
468
|
-
}
|
|
359
|
+
showErrorAndDismiss(message: "Failed to encode payment data.")
|
|
469
360
|
completion(false)
|
|
470
361
|
return
|
|
471
362
|
}
|
|
472
|
-
|
|
473
|
-
URLSession.shared.dataTask(with: request) { data, response, error in
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
UIApplication.topViewController()?.ep_hideLoadingIndicator()
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
if let error = error {
|
|
481
|
-
DispatchQueue.main.async {
|
|
482
|
-
self.showErrorAndDismiss(message: error.localizedDescription)
|
|
483
|
-
}
|
|
484
|
-
completion(false)
|
|
485
|
-
return
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
guard let httpResponse = response as? HTTPURLResponse else {
|
|
489
|
-
DispatchQueue.main.async {
|
|
490
|
-
self.showErrorAndDismiss(message: "Invalid response.")
|
|
491
|
-
}
|
|
363
|
+
|
|
364
|
+
let task = URLSession.shared.dataTask(with: request) { data, response, error in
|
|
365
|
+
guard let httpResponse = response as? HTTPURLResponse, error == nil else {
|
|
366
|
+
self.showErrorAndDismiss(message: error?.localizedDescription ?? "An unknown error occurred.")
|
|
492
367
|
completion(false)
|
|
493
368
|
return
|
|
494
369
|
}
|
|
495
|
-
|
|
370
|
+
|
|
496
371
|
if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
372
|
+
if let data = data {
|
|
373
|
+
do {
|
|
374
|
+
if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
375
|
+
if let clientToken = responseObject["client_token"] as? String {
|
|
376
|
+
UserStoreSingleton.shared.clientToken = clientToken
|
|
377
|
+
print(clientToken)
|
|
378
|
+
}
|
|
379
|
+
if let paymentIntent = responseObject["payment_intent"] as? String {
|
|
380
|
+
UserStoreSingleton.shared.paymentIntent = paymentIntent
|
|
381
|
+
}
|
|
382
|
+
self.hostedCheckoutsApi { success in
|
|
383
|
+
completion(success)
|
|
384
|
+
}
|
|
385
|
+
return
|
|
386
|
+
} else {
|
|
508
387
|
self.showErrorAndDismiss(message: "Invalid response format.")
|
|
509
388
|
}
|
|
510
|
-
|
|
511
|
-
return
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// ✅ Save values into UserStoreSingleton
|
|
515
|
-
if let clientToken = responseObject["client_token"] as? String {
|
|
516
|
-
UserStoreSingleton.shared.clientToken = clientToken
|
|
517
|
-
print("✅ Saved Client Token: \(clientToken)")
|
|
518
|
-
}
|
|
519
|
-
if let paymentIntent = responseObject["payment_intent"] as? String {
|
|
520
|
-
UserStoreSingleton.shared.paymentIntent = paymentIntent
|
|
521
|
-
print("✅ Saved Payment Intent: \(paymentIntent)")
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// ✅ Proceed to next step only after saving
|
|
525
|
-
self.hostedCheckoutsApi { success in
|
|
526
|
-
DispatchQueue.main.async {
|
|
527
|
-
UIApplication.topViewController()?.ep_hideLoadingIndicator()
|
|
528
|
-
}
|
|
529
|
-
completion(success)
|
|
530
|
-
}
|
|
531
|
-
return
|
|
532
|
-
|
|
533
|
-
} catch {
|
|
534
|
-
DispatchQueue.main.async {
|
|
389
|
+
} catch {
|
|
535
390
|
self.showErrorAndDismiss(message: "Failed to parse response.")
|
|
536
391
|
}
|
|
537
|
-
|
|
538
|
-
|
|
392
|
+
} else {
|
|
393
|
+
self.showErrorAndDismiss(message: "No response data received.")
|
|
539
394
|
}
|
|
540
|
-
|
|
541
395
|
} else {
|
|
542
396
|
var message = "Payment request failed with status code: \(httpResponse.statusCode)"
|
|
543
397
|
if let data = data,
|
|
544
|
-
let responseObj = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
|
|
398
|
+
let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
|
|
545
399
|
let msg = responseObj["message"] as? String {
|
|
546
400
|
message = msg
|
|
547
401
|
}
|
|
548
|
-
|
|
549
|
-
self.showErrorAndDismiss(message: message)
|
|
550
|
-
}
|
|
402
|
+
self.showErrorAndDismiss(message: message)
|
|
551
403
|
}
|
|
552
|
-
|
|
553
404
|
completion(false)
|
|
554
|
-
|
|
555
|
-
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
task.resume()
|
|
556
408
|
}
|
|
557
409
|
|
|
410
|
+
// MARK: - Payment Intent Api
|
|
411
|
+
// func paymentIntentApi(completion: @escaping (Bool) -> Void) {
|
|
412
|
+
// // ✅ Show Loader
|
|
413
|
+
// DispatchQueue.main.async {
|
|
414
|
+
// UIApplication.topViewController()?.ep_showLoadingIndicator()
|
|
415
|
+
// }
|
|
416
|
+
//
|
|
417
|
+
// guard let serviceURL = URL(string: EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.paymentIntent.path()) else {
|
|
418
|
+
// DispatchQueue.main.async {
|
|
419
|
+
// UIApplication.topViewController()?.ep_hideLoadingIndicator()
|
|
420
|
+
// self.showErrorAndDismiss(message: "Invalid payment URL.")
|
|
421
|
+
// }
|
|
422
|
+
// completion(false)
|
|
423
|
+
// return
|
|
424
|
+
// }
|
|
425
|
+
//
|
|
426
|
+
// var request = URLRequest(url: serviceURL)
|
|
427
|
+
// request.httpMethod = "POST"
|
|
428
|
+
// request.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
429
|
+
// request.addValue(EnvironmentConfig.apiKey ?? "", forHTTPHeaderField: "X-Api-Key")
|
|
430
|
+
// request.addValue(EnvironmentConfig.apiSecret ?? "", forHTTPHeaderField: "X-Api-Secret")
|
|
431
|
+
//
|
|
432
|
+
// // Validate recurring start date
|
|
433
|
+
// if let startDateString = recurringStartDate,
|
|
434
|
+
// let startDate = DateFormatter.recurringDateFormatter.date(from: startDateString) {
|
|
435
|
+
// let today = Calendar.current.startOfDay(for: Date())
|
|
436
|
+
// let startDay = Calendar.current.startOfDay(for: startDate)
|
|
437
|
+
//
|
|
438
|
+
// if startDay < today {
|
|
439
|
+
// DispatchQueue.main.async {
|
|
440
|
+
// UIApplication.topViewController()?.ep_hideLoadingIndicator()
|
|
441
|
+
// self.showErrorAndDismiss(message: "The recurring start date cannot be in the past. Please select today or a future date.")
|
|
442
|
+
// }
|
|
443
|
+
// completion(false)
|
|
444
|
+
// return
|
|
445
|
+
// }
|
|
446
|
+
// }
|
|
447
|
+
//
|
|
448
|
+
// let params: [String: Any] = [
|
|
449
|
+
// "amount": amount ?? 0,
|
|
450
|
+
// "allowed_cycles": numOfCycle ?? 0,
|
|
451
|
+
// "intervals": recurringIntervals?.map { $0.rawValue } ?? [],
|
|
452
|
+
// "is_recurring": self.is_recurring ?? false,
|
|
453
|
+
// "recurring_start_date": recurringStartDate ?? "",
|
|
454
|
+
// "recurring_start_date_type": recurringStartDateType?.rawValue ?? ""
|
|
455
|
+
// ]
|
|
456
|
+
//
|
|
457
|
+
// do {
|
|
458
|
+
// request.httpBody = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
459
|
+
// } catch {
|
|
460
|
+
// DispatchQueue.main.async {
|
|
461
|
+
// UIApplication.topViewController()?.ep_hideLoadingIndicator()
|
|
462
|
+
// self.showErrorAndDismiss(message: "Failed to encode payment data.")
|
|
463
|
+
// }
|
|
464
|
+
// completion(false)
|
|
465
|
+
// return
|
|
466
|
+
// }
|
|
467
|
+
//
|
|
468
|
+
// URLSession.shared.dataTask(with: request) { data, response, error in
|
|
469
|
+
// defer {
|
|
470
|
+
// DispatchQueue.main.async {
|
|
471
|
+
// UIApplication.topViewController()?.ep_hideLoadingIndicator()
|
|
472
|
+
// }
|
|
473
|
+
// }
|
|
474
|
+
//
|
|
475
|
+
// if let error = error {
|
|
476
|
+
// DispatchQueue.main.async {
|
|
477
|
+
// self.showErrorAndDismiss(message: error.localizedDescription)
|
|
478
|
+
// }
|
|
479
|
+
// completion(false)
|
|
480
|
+
// return
|
|
481
|
+
// }
|
|
482
|
+
//
|
|
483
|
+
// guard let httpResponse = response as? HTTPURLResponse else {
|
|
484
|
+
// DispatchQueue.main.async {
|
|
485
|
+
// self.showErrorAndDismiss(message: "Invalid response.")
|
|
486
|
+
// }
|
|
487
|
+
// completion(false)
|
|
488
|
+
// return
|
|
489
|
+
// }
|
|
490
|
+
//
|
|
491
|
+
// if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
492
|
+
// guard let data = data else {
|
|
493
|
+
// DispatchQueue.main.async {
|
|
494
|
+
// self.showErrorAndDismiss(message: "No response data received.")
|
|
495
|
+
// }
|
|
496
|
+
// completion(false)
|
|
497
|
+
// return
|
|
498
|
+
// }
|
|
499
|
+
//
|
|
500
|
+
// do {
|
|
501
|
+
// guard let responseObject = try JSONSerialization.jsonObject(with: data) as? [String: Any] else {
|
|
502
|
+
// DispatchQueue.main.async {
|
|
503
|
+
// self.showErrorAndDismiss(message: "Invalid response format.")
|
|
504
|
+
// }
|
|
505
|
+
// completion(false)
|
|
506
|
+
// return
|
|
507
|
+
// }
|
|
508
|
+
//
|
|
509
|
+
// // ✅ Save values into UserStoreSingleton
|
|
510
|
+
// if let clientToken = responseObject["client_token"] as? String {
|
|
511
|
+
// UserStoreSingleton.shared.clientToken = clientToken
|
|
512
|
+
// print("✅ Saved Client Token: \(clientToken)")
|
|
513
|
+
// }
|
|
514
|
+
// if let paymentIntent = responseObject["payment_intent"] as? String {
|
|
515
|
+
// UserStoreSingleton.shared.paymentIntent = paymentIntent
|
|
516
|
+
// print("✅ Saved Payment Intent: \(paymentIntent)")
|
|
517
|
+
// }
|
|
518
|
+
//
|
|
519
|
+
// // ✅ Proceed to next step only after saving
|
|
520
|
+
// self.hostedCheckoutsApi { success in
|
|
521
|
+
// DispatchQueue.main.async {
|
|
522
|
+
// UIApplication.topViewController()?.ep_hideLoadingIndicator()
|
|
523
|
+
// }
|
|
524
|
+
// completion(success)
|
|
525
|
+
// }
|
|
526
|
+
// return
|
|
527
|
+
//
|
|
528
|
+
// } catch {
|
|
529
|
+
// DispatchQueue.main.async {
|
|
530
|
+
// self.showErrorAndDismiss(message: "Failed to parse response.")
|
|
531
|
+
// }
|
|
532
|
+
// completion(false)
|
|
533
|
+
// return
|
|
534
|
+
// }
|
|
535
|
+
//
|
|
536
|
+
// } else {
|
|
537
|
+
// var message = "Payment request failed with status code: \(httpResponse.statusCode)"
|
|
538
|
+
// if let data = data,
|
|
539
|
+
// let responseObj = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
|
|
540
|
+
// let msg = responseObj["message"] as? String {
|
|
541
|
+
// message = msg
|
|
542
|
+
// }
|
|
543
|
+
// DispatchQueue.main.async {
|
|
544
|
+
// self.showErrorAndDismiss(message: message)
|
|
545
|
+
// }
|
|
546
|
+
// }
|
|
547
|
+
//
|
|
548
|
+
// completion(false)
|
|
549
|
+
//
|
|
550
|
+
// }.resume()
|
|
551
|
+
// }
|
|
552
|
+
|
|
558
553
|
private func showErrorAndDismiss(message: String) {
|
|
559
554
|
DispatchQueue.main.async {
|
|
560
555
|
if let topVC = UIApplication.topViewController() {
|
|
@@ -594,6 +589,8 @@ public final class Request: NSObject {
|
|
|
594
589
|
"amount": amount ?? 0,
|
|
595
590
|
]
|
|
596
591
|
|
|
592
|
+
print(params)
|
|
593
|
+
|
|
597
594
|
do {
|
|
598
595
|
request.httpBody = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
599
596
|
} catch {
|
|
@@ -815,34 +812,34 @@ extension UIApplication {
|
|
|
815
812
|
}
|
|
816
813
|
|
|
817
814
|
|
|
818
|
-
extension UIViewController {
|
|
819
|
-
|
|
820
|
-
func ep_showLoadingIndicator() {
|
|
821
|
-
let tag = 99999 // A unique tag so we can identify and remove the loader later
|
|
822
|
-
if self.view.viewWithTag(tag) == nil {
|
|
823
|
-
let loader = UIActivityIndicatorView(style: .large)
|
|
824
|
-
loader.center = self.view.center
|
|
825
|
-
loader.tag = tag
|
|
826
|
-
loader.startAnimating()
|
|
827
|
-
loader.color = .gray
|
|
828
|
-
loader.hidesWhenStopped = true
|
|
829
|
-
loader.translatesAutoresizingMaskIntoConstraints = false
|
|
830
|
-
self.view.addSubview(loader)
|
|
831
|
-
|
|
832
|
-
// Optional: center constraints
|
|
833
|
-
NSLayoutConstraint.activate([
|
|
834
|
-
loader.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
|
|
835
|
-
loader.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
|
|
836
|
-
])
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
func ep_hideLoadingIndicator() {
|
|
841
|
-
let tag = 99999
|
|
842
|
-
if let loader = self.view.viewWithTag(tag) as? UIActivityIndicatorView {
|
|
843
|
-
loader.stopAnimating()
|
|
844
|
-
loader.removeFromSuperview()
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}
|
|
815
|
+
//extension UIViewController {
|
|
816
|
+
//
|
|
817
|
+
// func ep_showLoadingIndicator() {
|
|
818
|
+
// let tag = 99999 // A unique tag so we can identify and remove the loader later
|
|
819
|
+
// if self.view.viewWithTag(tag) == nil {
|
|
820
|
+
// let loader = UIActivityIndicatorView(style: .large)
|
|
821
|
+
// loader.center = self.view.center
|
|
822
|
+
// loader.tag = tag
|
|
823
|
+
// loader.startAnimating()
|
|
824
|
+
// loader.color = .gray
|
|
825
|
+
// loader.hidesWhenStopped = true
|
|
826
|
+
// loader.translatesAutoresizingMaskIntoConstraints = false
|
|
827
|
+
// self.view.addSubview(loader)
|
|
828
|
+
//
|
|
829
|
+
// // Optional: center constraints
|
|
830
|
+
// NSLayoutConstraint.activate([
|
|
831
|
+
// loader.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
|
|
832
|
+
// loader.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
|
|
833
|
+
// ])
|
|
834
|
+
// }
|
|
835
|
+
// }
|
|
836
|
+
//
|
|
837
|
+
// func ep_hideLoadingIndicator() {
|
|
838
|
+
// let tag = 99999
|
|
839
|
+
// if let loader = self.view.viewWithTag(tag) as? UIActivityIndicatorView {
|
|
840
|
+
// loader.stopAnimating()
|
|
841
|
+
// loader.removeFromSuperview()
|
|
842
|
+
// }
|
|
843
|
+
// }
|
|
844
|
+
//}
|
|
848
845
|
|
|
@@ -75,7 +75,8 @@ class BillingInfoVC: BaseVC {
|
|
|
75
75
|
|
|
76
76
|
var request: Request!
|
|
77
77
|
var selectedCard: CardModel?
|
|
78
|
-
var amount: Int?
|
|
78
|
+
// var amount: Int?
|
|
79
|
+
var amount: Double?
|
|
79
80
|
var cvvText: String?
|
|
80
81
|
|
|
81
82
|
var isFrom = String()
|
|
@@ -666,7 +667,7 @@ class BillingInfoVC: BaseVC {
|
|
|
666
667
|
vc.visibility = updatedFieldSection.visibility
|
|
667
668
|
vc.selectedPaymentMethod = selectedPaymentMethod
|
|
668
669
|
vc.isSavedForFuture = isSavedForFuture
|
|
669
|
-
vc.amount =
|
|
670
|
+
vc.amount = Double(self.request.amount ?? 0)
|
|
670
671
|
vc.request = request
|
|
671
672
|
vc.chosenPlan = chosenPlan
|
|
672
673
|
vc.startDate = startDate
|
|
@@ -745,7 +746,7 @@ class BillingInfoVC: BaseVC {
|
|
|
745
746
|
vc.accountID = accountID
|
|
746
747
|
vc.isFrom = isFrom
|
|
747
748
|
vc.isSavedNewAccount = isSavedNewAccount
|
|
748
|
-
vc.amount =
|
|
749
|
+
vc.amount = Double(self.request.amount ?? 0)
|
|
749
750
|
vc.request = request
|
|
750
751
|
vc.chosenPlan = chosenPlan
|
|
751
752
|
vc.startDate = startDate
|
|
@@ -807,7 +808,7 @@ class BillingInfoVC: BaseVC {
|
|
|
807
808
|
vc.isSavedForFuture = isSavedForFuture
|
|
808
809
|
vc.isFrom = isFrom
|
|
809
810
|
vc.isSavedNewAccount = isSavedNewAccount
|
|
810
|
-
vc.amount =
|
|
811
|
+
vc.amount = Double(self.request.amount ?? 0)
|
|
811
812
|
vc.request = request
|
|
812
813
|
vc.chosenPlan = chosenPlan
|
|
813
814
|
vc.startDate = startDate
|
|
@@ -829,7 +830,7 @@ class BillingInfoVC: BaseVC {
|
|
|
829
830
|
vc.isSavedForFuture = isSavedForFuture
|
|
830
831
|
vc.isFrom = isFrom
|
|
831
832
|
vc.isSavedNewAccount = isSavedNewAccount
|
|
832
|
-
vc.amount =
|
|
833
|
+
vc.amount = Double(self.request.amount ?? 0)
|
|
833
834
|
vc.request = request
|
|
834
835
|
vc.chosenPlan = chosenPlan
|
|
835
836
|
vc.startDate = startDate
|
|
@@ -861,7 +862,7 @@ class BillingInfoVC: BaseVC {
|
|
|
861
862
|
vc.isSavedForFuture = isSavedForFuture
|
|
862
863
|
vc.isFrom = isFrom
|
|
863
864
|
vc.isSavedNewAccount = isSavedNewAccount
|
|
864
|
-
vc.amount =
|
|
865
|
+
vc.amount = Double(self.request.amount ?? 0)
|
|
865
866
|
vc.request = request
|
|
866
867
|
vc.chosenPlan = chosenPlan
|
|
867
868
|
vc.startDate = startDate
|