@jimrising/easymerchantsdk-react-native 2.0.0 → 2.0.2
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/.idea/misc.xml +0 -1
- package/README.md +1 -1
- package/android/build.gradle +1 -1
- package/ios/Models/Request.swift +49 -38
- package/ios/easymerchantsdk.podspec +1 -1
- package/package.json +1 -1
package/.idea/misc.xml
CHANGED
package/README.md
CHANGED
package/android/build.gradle
CHANGED
|
@@ -39,7 +39,7 @@ repositories {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
dependencies {
|
|
42
|
-
implementation 'com.app:paysdk:1.4.
|
|
42
|
+
implementation 'com.app:paysdk:1.4.8'
|
|
43
43
|
implementation 'com.hbb20:ccp:2.7.3'
|
|
44
44
|
implementation 'com.github.bumptech.glide:glide:4.16.0'
|
|
45
45
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1"
|
package/ios/Models/Request.swift
CHANGED
|
@@ -284,6 +284,54 @@ public final class Request: NSObject {
|
|
|
284
284
|
|
|
285
285
|
super.init()
|
|
286
286
|
|
|
287
|
+
// ✅ Validate recurring intervals
|
|
288
|
+
if is_recurring == true {
|
|
289
|
+
let intervals = recurringIntervals ?? []
|
|
290
|
+
|
|
291
|
+
if intervals.count < 2 {
|
|
292
|
+
DispatchQueue.main.async {
|
|
293
|
+
if let topVC = UIApplication.topViewController() {
|
|
294
|
+
let alert = UIAlertController(
|
|
295
|
+
title: "Recurring Interval Required",
|
|
296
|
+
message: "Please add minimum two intervals for recurring.",
|
|
297
|
+
preferredStyle: .alert
|
|
298
|
+
)
|
|
299
|
+
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
|
|
300
|
+
if let easyPayVC = UIApplication.findEasyPayViewController(from: topVC) {
|
|
301
|
+
easyPayVC.dismiss(animated: true)
|
|
302
|
+
} else {
|
|
303
|
+
topVC.dismiss(animated: true)
|
|
304
|
+
}
|
|
305
|
+
}))
|
|
306
|
+
topVC.present(alert, animated: true)
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
let uniqueIntervals = Set(intervals)
|
|
313
|
+
if uniqueIntervals.count < intervals.count {
|
|
314
|
+
DispatchQueue.main.async {
|
|
315
|
+
if let topVC = UIApplication.topViewController() {
|
|
316
|
+
let alert = UIAlertController(
|
|
317
|
+
title: "Duplicate Intervals",
|
|
318
|
+
message: "Duplicate interval values",
|
|
319
|
+
preferredStyle: .alert
|
|
320
|
+
)
|
|
321
|
+
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
|
|
322
|
+
if let easyPayVC = UIApplication.findEasyPayViewController(from: topVC) {
|
|
323
|
+
easyPayVC.dismiss(animated: true)
|
|
324
|
+
} else {
|
|
325
|
+
topVC.dismiss(animated: true)
|
|
326
|
+
}
|
|
327
|
+
}))
|
|
328
|
+
topVC.present(alert, animated: true)
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
287
335
|
// If tokenOnly is true, fetch only the clientToken and do not open the SDK
|
|
288
336
|
if tokenOnly {
|
|
289
337
|
self.paymentIntentApi { success in
|
|
@@ -342,9 +390,7 @@ public final class Request: NSObject {
|
|
|
342
390
|
}
|
|
343
391
|
|
|
344
392
|
let params: [String: Any] = [
|
|
345
|
-
// "amount": amount ?? 0,
|
|
346
393
|
"amount": ((amount ?? 0) * 100).rounded() / 100,
|
|
347
|
-
// "allowed_cycles": String(recurringIntervals?.count ?? 0),
|
|
348
394
|
"allowed_cycles": numOfCycle ?? 0,
|
|
349
395
|
"intervals": recurringIntervals?.map { $0.rawValue } ?? [],
|
|
350
396
|
"is_recurring": self.is_recurring ?? false,
|
|
@@ -375,7 +421,7 @@ public final class Request: NSObject {
|
|
|
375
421
|
if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
376
422
|
if let clientToken = responseObject["client_token"] as? String {
|
|
377
423
|
UserStoreSingleton.shared.clientToken = clientToken
|
|
378
|
-
print(clientToken)
|
|
424
|
+
// print(clientToken)
|
|
379
425
|
}
|
|
380
426
|
if let paymentIntent = responseObject["payment_intent"] as? String {
|
|
381
427
|
UserStoreSingleton.shared.paymentIntent = paymentIntent
|
|
@@ -404,7 +450,6 @@ public final class Request: NSObject {
|
|
|
404
450
|
}
|
|
405
451
|
completion(false)
|
|
406
452
|
}
|
|
407
|
-
|
|
408
453
|
task.resume()
|
|
409
454
|
}
|
|
410
455
|
|
|
@@ -444,7 +489,6 @@ public final class Request: NSObject {
|
|
|
444
489
|
request.addValue(UserStoreSingleton.shared.clientToken ?? "", forHTTPHeaderField: "clientToken")
|
|
445
490
|
|
|
446
491
|
let params: [String: Any] = [
|
|
447
|
-
// "amount": amount ?? 0,
|
|
448
492
|
"amount": ((amount ?? 0) * 100).rounded() / 100,
|
|
449
493
|
]
|
|
450
494
|
|
|
@@ -623,7 +667,6 @@ public final class Request: NSObject {
|
|
|
623
667
|
completion(nil)
|
|
624
668
|
}
|
|
625
669
|
}
|
|
626
|
-
|
|
627
670
|
task.resume()
|
|
628
671
|
}
|
|
629
672
|
|
|
@@ -670,35 +713,3 @@ extension UIApplication {
|
|
|
670
713
|
}
|
|
671
714
|
}
|
|
672
715
|
|
|
673
|
-
|
|
674
|
-
//extension UIViewController {
|
|
675
|
-
//
|
|
676
|
-
// func ep_showLoadingIndicator() {
|
|
677
|
-
// let tag = 99999 // A unique tag so we can identify and remove the loader later
|
|
678
|
-
// if self.view.viewWithTag(tag) == nil {
|
|
679
|
-
// let loader = UIActivityIndicatorView(style: .large)
|
|
680
|
-
// loader.center = self.view.center
|
|
681
|
-
// loader.tag = tag
|
|
682
|
-
// loader.startAnimating()
|
|
683
|
-
// loader.color = .gray
|
|
684
|
-
// loader.hidesWhenStopped = true
|
|
685
|
-
// loader.translatesAutoresizingMaskIntoConstraints = false
|
|
686
|
-
// self.view.addSubview(loader)
|
|
687
|
-
//
|
|
688
|
-
// // Optional: center constraints
|
|
689
|
-
// NSLayoutConstraint.activate([
|
|
690
|
-
// loader.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
|
|
691
|
-
// loader.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
|
|
692
|
-
// ])
|
|
693
|
-
// }
|
|
694
|
-
// }
|
|
695
|
-
//
|
|
696
|
-
// func ep_hideLoadingIndicator() {
|
|
697
|
-
// let tag = 99999
|
|
698
|
-
// if let loader = self.view.viewWithTag(tag) as? UIActivityIndicatorView {
|
|
699
|
-
// loader.stopAnimating()
|
|
700
|
-
// loader.removeFromSuperview()
|
|
701
|
-
// }
|
|
702
|
-
// }
|
|
703
|
-
//}
|
|
704
|
-
|