@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 CHANGED
@@ -1,4 +1,3 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
1
  <project version="4">
3
2
  <component name="ProjectRootManager">
4
3
  <output url="file://$PROJECT_DIR$/out" />
package/README.md CHANGED
@@ -7,7 +7,7 @@ To add the path of sdk in your project. Open your `package.json` file and inside
7
7
 
8
8
  ```json
9
9
  "dependencies": {
10
- "@jimrising/easymerchantsdk-react-native": "^2.0.0"
10
+ "@jimrising/easymerchantsdk-react-native": "^2.0.2"
11
11
  },
12
12
  ```
13
13
 
@@ -39,7 +39,7 @@ repositories {
39
39
  }
40
40
 
41
41
  dependencies {
42
- implementation 'com.app:paysdk:1.4.7'
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"
@@ -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
-
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'easymerchantsdk'
3
- s.version = '2.0.0'
3
+ s.version = '2.0.2'
4
4
  s.summary = 'A React Native SDK for Easy Merchant.'
5
5
  s.description = <<-DESC
6
6
  A React Native SDK to enable Easy Merchant functionality in mobile applications.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jimrising/easymerchantsdk-react-native",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {