@jimrising/easymerchantsdk-react-native 2.3.4 → 2.3.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.
Files changed (62) hide show
  1. package/README.md +1 -1
  2. package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
  3. package/android/build/.transforms/e9a664a11ce12edf79cd87b1e07aa243/transformed/classes/classes_dex/classes.dex +0 -0
  4. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
  5. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  6. package/android/build.gradle +1 -1
  7. package/ios/ApiManager/APIRequest.swift +1 -4
  8. package/ios/Bundle/EasyPayBundle.swift +1 -1
  9. package/ios/Classes/EasyMerchantSdk.m +2 -2
  10. package/ios/Classes/EasyMerchantSdk.swift +3 -3
  11. package/ios/CustomComponents/PlanSelector.swift +1 -1
  12. package/ios/Example/Base.lproj/Main.storyboard +183 -22
  13. package/ios/Example/ViewController.swift +208 -182
  14. package/ios/Helper/GrailPayHelper.swift +0 -1
  15. package/ios/Models/Request.swift +96 -71
  16. package/ios/Models/SDKResult.swift +32 -25
  17. package/ios/Pods/UserDefaults/UserStoreSingleton.swift +59 -60
  18. package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +360 -150
  19. package/ios/Pods/ViewControllers/BaseVC.swift +2 -1
  20. package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +401 -196
  21. package/ios/Pods/ViewControllers/Clean Runner_2025-07-23T14-58-05.txt +13 -0
  22. package/ios/Pods/ViewControllers/EmailVerificationVC.swift +0 -7
  23. package/ios/Pods/ViewControllers/GrailPayVC.swift +11 -3
  24. package/ios/Pods/ViewControllers/OTPVerificationVC.swift +252 -105
  25. package/ios/Pods/ViewControllers/PaymentDoneVC.swift +20 -5
  26. package/ios/Pods/ViewControllers/PaymentErrorVC.swift +2 -2
  27. package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +804 -347
  28. package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.swift +0 -1
  29. package/ios/Pods/ViewControllers/PaymentStatusWebViewVC.swift +1 -1
  30. package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +68 -66
  31. package/ios/Resources/Assets.xcassets/payment_done_icon.imageset/Contents.json +3 -0
  32. package/ios/easymerchantsdk.podspec +1 -1
  33. package/package.json +1 -1
  34. package/ios/CustomComponents/CheckboxButton.swift +0 -66
  35. package/ios/Models/AdditionalInfo.swift +0 -53
  36. package/ios/Models/BillingInfo.swift +0 -60
  37. package/ios/Pods/ViewControllers/CustomOverlay.swift +0 -199
  38. package/ios/Resources/Assets.xcassets/Card/Amex.imageset/206682_american_express_method_card_payment_icon.svg +0 -1
  39. package/ios/Resources/Assets.xcassets/Card/Amex.imageset/Contents.json +0 -12
  40. package/ios/Resources/Assets.xcassets/Card/Contents.json +0 -6
  41. package/ios/Resources/Assets.xcassets/Card/DinersClub.imageset/472318_card_club_diners_dinner_payment_icon.svg +0 -1
  42. package/ios/Resources/Assets.xcassets/Card/DinersClub.imageset/Contents.json +0 -12
  43. package/ios/Resources/Assets.xcassets/Card/Discover.imageset/206686_network_payment_discover_card_method_icon.svg +0 -1
  44. package/ios/Resources/Assets.xcassets/Card/Discover.imageset/Contents.json +0 -12
  45. package/ios/Resources/Assets.xcassets/Card/JCB.imageset/358102_card_jcb_payment_icon.svg +0 -1
  46. package/ios/Resources/Assets.xcassets/Card/JCB.imageset/Contents.json +0 -12
  47. package/ios/Resources/Assets.xcassets/Card/MasterCard.imageset/206680_master_method_card_payment_icon.svg +0 -1
  48. package/ios/Resources/Assets.xcassets/Card/MasterCard.imageset/Contents.json +0 -12
  49. package/ios/Resources/Assets.xcassets/Card/UnionPay.imageset/1468976_card_payment_unionpay_icon.svg +0 -1
  50. package/ios/Resources/Assets.xcassets/Card/UnionPay.imageset/Contents.json +0 -12
  51. package/ios/Resources/Assets.xcassets/Card/Visa.imageset/206684_visa_method_card_payment_icon.svg +0 -1
  52. package/ios/Resources/Assets.xcassets/Card/Visa.imageset/Contents.json +0 -12
  53. package/ios/Resources/Assets.xcassets/Card/maestro.imageset/Contents.json +0 -12
  54. package/ios/Resources/Assets.xcassets/Card/maestro.imageset/maestro.svg +0 -1
  55. package/ios/Resources/Assets.xcassets/Card/paypal.imageset/206675_paypal_method_payment_icon.svg +0 -1
  56. package/ios/Resources/Assets.xcassets/Card/paypal.imageset/Contents.json +0 -12
  57. package/ios/Resources/Assets.xcassets/Card/rupay.imageset/Contents.json +0 -12
  58. package/ios/Resources/Assets.xcassets/Card/rupay.imageset/rupay.svg +0 -1
  59. package/ios/Resources/Assets.xcassets/Card/unknown_card.imageset/4635000_card_credit_digital_money_icon.svg +0 -1
  60. package/ios/Resources/Assets.xcassets/Card/unknown_card.imageset/Contents.json +0 -12
  61. package/ios/Resources/Assets.xcassets/Card/worldpay.imageset/Contents.json +0 -12
  62. package/ios/Resources/Assets.xcassets/Card/worldpay.imageset/worldpay.svg +0 -1
@@ -347,56 +347,58 @@ public final class Request: NSObject {
347
347
  return
348
348
  }
349
349
 
350
- // Handle recurring setup differently for API keys vs clientToken flow
351
- if let token = clientToken, !token.isEmpty {
352
- // --- Client Token Flow ---
353
- if let savedIsRecurring = UserStoreSingleton.shared.isRecurring,
354
- savedIsRecurring == "1" {
355
-
356
- self.is_recurring = true
357
- print("Recurring enabled (clientToken flow) → is_recurring = \(self.is_recurring ?? false)")
358
-
359
- if let cycles = UserStoreSingleton.shared.allowCycles,
360
- let num = Int(cycles) {
361
- self.numOfCycle = num
362
- }
363
-
364
- if let intervals = UserStoreSingleton.shared.interval {
365
- let parts = intervals.split(separator: ",").map { String($0).trimmingCharacters(in: .whitespaces) }
366
- self.recurringIntervals = parts.compactMap { RecurringIntervals(rawValue: $0) }
367
- }
368
-
369
- if let startType = UserStoreSingleton.shared.startDateType {
370
- self.recurringStartDateType = RecurringStartDateType(rawValue: startType)
371
- }
350
+ // Handle recurring setup differently for API keys vs clientToken flow
351
+ if let token = clientToken, !token.isEmpty {
352
+ // --- Client Token Flow ---
353
+ if let savedIsRecurring = UserStoreSingleton.shared.isRecurring,
354
+ savedIsRecurring == "1" {
355
+
356
+ self.is_recurring = true
357
+ print("Recurring enabled (clientToken flow) → is_recurring = \(self.is_recurring ?? false)")
358
+
359
+ if let cycles = UserStoreSingleton.shared.allowCycles,
360
+ let num = Int(cycles) {
361
+ self.numOfCycle = num
362
+ }
363
+
364
+ if let intervals = UserStoreSingleton.shared.interval {
365
+ let parts = intervals.split(separator: ",").map { String($0).trimmingCharacters(in: .whitespaces) }
366
+ self.recurringIntervals = parts.compactMap { RecurringIntervals(rawValue: $0) }
367
+ }
368
+
369
+ if let startType = UserStoreSingleton.shared.startDateType {
370
+ self.recurringStartDateType = RecurringStartDateType(rawValue: startType)
371
+ }
372
+
373
+ if let startDate = UserStoreSingleton.shared.startDate {
374
+ self.recurringStartDate = startDate
375
+ }
376
+ } else {
377
+ self.is_recurring = false
378
+ }
379
+ } else {
380
+ // --- API Keys Flow ---
381
+ // Keep whatever was passed from outside (don’t override)
382
+ print("Recurring setup (API keys flow) → is_recurring = \(self.is_recurring ?? false)")
383
+ }
372
384
 
373
- if let startDate = UserStoreSingleton.shared.startDate {
374
- self.recurringStartDate = startDate
375
- }
376
- } else {
377
- self.is_recurring = false
378
- }
379
- } else {
380
- // --- API Keys Flow ---
381
- // Keep whatever was passed from outside (don’t override)
382
- print("Recurring setup (API keys flow) → is_recurring = \(self.is_recurring ?? false)")
385
+ if is_recurring == true {
386
+ // Validate recurring start date not in past
387
+ if let startDateString = recurringStartDate,
388
+ let startDate = DateFormatter.recurringDateFormatter.date(from: startDateString) {
389
+ let today = Calendar.current.startOfDay(for: Date())
390
+ let startDay = Calendar.current.startOfDay(for: startDate)
391
+ if startDay < today {
392
+ self.initializationErrorMessage = "The recurring start date cannot be in the past. Please select today or a future date."
393
+ Request.notifyValidationError(self.initializationErrorMessage!)
394
+ return
383
395
  }
384
-
385
- // Validate recurring start date not in past
386
- if let startDateString = recurringStartDate,
387
- let startDate = DateFormatter.recurringDateFormatter.date(from: startDateString) {
388
- let today = Calendar.current.startOfDay(for: Date())
389
- let startDay = Calendar.current.startOfDay(for: startDate)
390
- if startDay < today {
391
- self.initializationErrorMessage = "The recurring start date cannot be in the past. Please select today or a future date."
396
+ } else if recurringStartDate != nil {
397
+ // Provided but invalid format
398
+ self.initializationErrorMessage = "Recurring date format should be dd/MM/yyyy"
392
399
  Request.notifyValidationError(self.initializationErrorMessage!)
393
400
  return
394
401
  }
395
- } else if recurringStartDate != nil {
396
- // Provided but invalid format
397
- self.initializationErrorMessage = "Recurring date format should be dd/MM/yyyy"
398
- Request.notifyValidationError(self.initializationErrorMessage!)
399
- return
400
402
  }
401
403
 
402
404
  // Validate metadata limits
@@ -482,31 +484,31 @@ public final class Request: NSObject {
482
484
  }
483
485
  }
484
486
  }
485
- else {
486
- if clientToken == nil {
487
- // Proceed with normal payment flow for API key/secret case
488
- self.paymentIntentApi { success in
489
- if success {
490
- print("Payment Intent API call succeeded")
491
- UserStoreSingleton.shared.price = String(self.amount ?? 0)
492
- print("Saved amount: \(UserStoreSingleton.shared.price ?? "No amount")")
493
- } else {
494
- print("Payment Intent API call failed")
495
- }
496
- }
497
- } else {
498
- // For clientToken case, directly call hostedCheckoutsApi
499
- UserStoreSingleton.shared.clientToken = clientToken
500
- self.hostedCheckoutsApi { success in
501
- if success {
502
- print("Hosted Checkout API call succeeded")
503
- UserStoreSingleton.shared.price = String(self.amount ?? 0)
504
- } else {
505
- print("Hosted Checkout API call failed")
506
- }
507
- }
508
- }
509
- }
487
+ // else {
488
+ // if clientToken == nil {
489
+ // // Proceed with normal payment flow for API key/secret case
490
+ // self.paymentIntentApi { success in
491
+ // if success {
492
+ // print("Payment Intent API call succeeded")
493
+ // UserStoreSingleton.shared.price = String(self.amount ?? 0)
494
+ // print("Saved amount: \(UserStoreSingleton.shared.price ?? "No amount")")
495
+ // } else {
496
+ // print("Payment Intent API call failed")
497
+ // }
498
+ // }
499
+ // } else {
500
+ // // For clientToken case, directly call hostedCheckoutsApi
501
+ // UserStoreSingleton.shared.clientToken = clientToken
502
+ // self.hostedCheckoutsApi { success in
503
+ // if success {
504
+ // print("Hosted Checkout API call succeeded")
505
+ // UserStoreSingleton.shared.price = String(self.amount ?? 0)
506
+ // } else {
507
+ // print("Hosted Checkout API call failed")
508
+ // }
509
+ // }
510
+ // }
511
+ // }
510
512
 
511
513
  if referenceID == true {
512
514
  fetchReferenceData { response in
@@ -798,11 +800,22 @@ public final class Request: NSObject {
798
800
  "status": false,
799
801
  "message": message
800
802
  ]
801
- let result = SDKResult(type: .error, chargeData: chargeData, billingInfo: nil, additionalInfo: nil)
803
+ let result = SDKResult(type: .error, data: chargeData as NSDictionary)
802
804
  NotificationCenter.default.post(name: NSNotification.Name("EasyPayResult"), object: result)
803
805
  }
804
806
  }
805
807
 
808
+ // MARK: - Clear cached values on token change
809
+ private func clearCachedValues() {
810
+ UserStoreSingleton.shared.amount = nil
811
+ UserStoreSingleton.shared.price = nil
812
+ UserStoreSingleton.shared.isRecurring = nil
813
+ UserStoreSingleton.shared.allowCycles = nil
814
+ UserStoreSingleton.shared.interval = nil
815
+ UserStoreSingleton.shared.startDateType = nil
816
+ UserStoreSingleton.shared.startDate = nil
817
+ }
818
+
806
819
  // MARK: - Hosted Checkout API
807
820
  func hostedCheckoutsApi(completion: @escaping (Bool) -> Void) {
808
821
  // Build the URL using EnvironmentConfig
@@ -857,6 +870,18 @@ public final class Request: NSObject {
857
870
  let dataObject = responseObject["data"] as? [String: Any] {
858
871
  print("Hosted Checkout API Response: \(dataObject)")
859
872
 
873
+ if let paymentAmount = dataObject["payment_intent_amount"] as? Double {
874
+ // ✅ Update Request + Singleton with fresh value
875
+ self.amount = paymentAmount
876
+ UserStoreSingleton.shared.amount = String(paymentAmount)
877
+ UserStoreSingleton.shared.price = String(paymentAmount)
878
+ }
879
+
880
+ if let recurring = dataObject["is_recurring"] as? Bool {
881
+ self.is_recurring = recurring
882
+ UserStoreSingleton.shared.isRecurring = recurring ? "1" : "0"
883
+ }
884
+
860
885
  // Persist the exact token used for the request (header value),
861
886
  // not self.clientToken which may be nil on first-run flows.
862
887
  UserStoreSingleton.shared.clientToken = token
@@ -6,46 +6,53 @@
6
6
  //
7
7
 
8
8
  import UIKit
9
-
9
+
10
10
  @objc
11
11
  public enum ResultType: Int {
12
12
  case cancelled
13
13
  case success
14
14
  case error
15
15
  }
16
-
16
+
17
17
  @objc
18
18
  public final class SDKResult: NSObject {
19
19
 
20
20
  @objc public let type: ResultType
21
- @objc public let error: NSError?
22
- @objc public let chargeData: [String: Any]?
21
+ @objc public let data: NSDictionary?
23
22
 
24
- @objc public let billingInfo: [String: Any]?
25
- @objc public let additionalInfo: [String: Any]?
23
+ // Computed properties for backward compatibility
24
+ @objc public var chargeData: [String: Any]? {
25
+ guard let data = data as? [String: Any] else { return nil }
26
+
27
+ // Extract everything except billingInfo and additionalInfo as chargeData
28
+ var chargeData: [String: Any] = [:]
29
+ for (key, value) in data {
30
+ if key != "billingInfo" && key != "additionalInfo" {
31
+ chargeData[key] = value
32
+ }
33
+ }
34
+ return chargeData.isEmpty ? nil : chargeData
35
+ }
26
36
 
27
- // Initializer for error type result
28
- internal init(error: NSError) {
29
- self.type = .error
30
- self.error = error
31
- self.chargeData = nil
32
- self.billingInfo = nil
33
- self.additionalInfo = nil
34
- super.init()
37
+ @objc public var billingInfo: [String: Any]? {
38
+ return data?["billingInfo"] as? [String: Any]
39
+ }
40
+
41
+ @objc public var additionalInfo: [String: Any]? {
42
+ return data?["additionalInfo"] as? [String: Any]
43
+ }
44
+
45
+ @objc public var error: NSError? {
46
+ // For backward compatibility, create NSError from data if type is error
47
+ guard type == .error, let data = data as? [String: Any] else { return nil }
48
+ let message = data["message"] as? String ?? "Unknown error"
49
+ return NSError(domain: "SDKResult", code: 0, userInfo: [NSLocalizedDescriptionKey: message])
35
50
  }
36
51
 
37
- // Initializer for success/cancelled result types
38
- internal init(type: ResultType,
39
- chargeData: [String: Any]? = nil,
40
- billingInfo: [String: Any]? = nil,
41
- additionalInfo: [String: Any]? = nil) {
52
+ // Initializer for all result types
53
+ internal init(type: ResultType, data: NSDictionary? = nil) {
42
54
  self.type = type
43
- self.error = nil
44
- self.chargeData = chargeData
45
- self.billingInfo = billingInfo
46
- self.additionalInfo = additionalInfo
55
+ self.data = data
47
56
  super.init()
48
57
  }
49
58
  }
50
-
51
-
@@ -320,8 +320,7 @@ class UserStoreSingleton: NSObject {
320
320
  "payment_methods",
321
321
  "bank_widget_key",
322
322
  "vendor_id",
323
-
324
- // "amount",
323
+ // "amount"
325
324
  // "allowCycles",
326
325
  // "interval",
327
326
  // "isRecurring",
@@ -348,61 +347,61 @@ class UserStoreSingleton: NSObject {
348
347
 
349
348
  }
350
349
 
351
- var amount : String? {
352
- get {
353
- return (UserDefaults().object(forKey: "amount") as? String)
354
- } set {
355
- UserDefaults.standard.setValue(newValue, forKey: "amount")
356
- }
357
- }
358
-
359
- //Recurring params
360
- var allowCycles : String? {
361
- get {
362
- return (UserDefaults().object(forKey: "allowCycles") as? String)
363
- } set {
364
- UserDefaults.standard.setValue(newValue, forKey: "allowCycles")
365
- }
366
- }
367
-
368
- var interval : String? {
369
- get {
370
- return (UserDefaults().object(forKey: "interval") as? String)
371
- } set {
372
- UserDefaults.standard.setValue(newValue, forKey: "interval")
373
- }
374
- }
375
-
376
- var isRecurring : String? {
377
- get {
378
- return (UserDefaults().object(forKey: "isRecurring") as? String)
379
- } set {
380
- UserDefaults.standard.setValue(newValue, forKey: "isRecurring")
381
- }
382
- }
383
-
384
- var startDate : String? {
385
- get {
386
- return (UserDefaults().object(forKey: "startDate") as? String)
387
- } set {
388
- UserDefaults.standard.setValue(newValue, forKey: "startDate")
389
- }
390
- }
391
-
392
- var startDateType : String? {
393
- get {
394
- return (UserDefaults().object(forKey: "startDateType") as? String)
395
- } set {
396
- UserDefaults.standard.setValue(newValue, forKey: "startDateType")
397
- }
398
- }
399
-
400
- var paymentIntentId : String? {
401
- get {
402
- return (UserDefaults().object(forKey: "paymentIntentId") as? String)
403
- } set {
404
- UserDefaults.standard.setValue(newValue, forKey: "paymentIntentId")
405
- }
406
- }
407
-
408
-
350
+ //var amount : String? {
351
+ // get {
352
+ // return (UserDefaults().object(forKey: "amount") as? String)
353
+ // } set {
354
+ // UserDefaults.standard.setValue(newValue, forKey: "amount")
355
+ // }
356
+ //}
357
+ //
358
+ ////Recurring params
359
+ //var allowCycles : String? {
360
+ // get {
361
+ // return (UserDefaults().object(forKey: "allowCycles") as? String)
362
+ // } set {
363
+ // UserDefaults.standard.setValue(newValue, forKey: "allowCycles")
364
+ // }
365
+ //}
366
+ //
367
+ //var interval : String? {
368
+ // get {
369
+ // return (UserDefaults().object(forKey: "interval") as? String)
370
+ // } set {
371
+ // UserDefaults.standard.setValue(newValue, forKey: "interval")
372
+ // }
373
+ //}
374
+ //
375
+ //var isRecurring : String? {
376
+ // get {
377
+ // return (UserDefaults().object(forKey: "isRecurring") as? String)
378
+ // } set {
379
+ // UserDefaults.standard.setValue(newValue, forKey: "isRecurring")
380
+ // }
381
+ //}
382
+ //
383
+ //var startDate : String? {
384
+ // get {
385
+ // return (UserDefaults().object(forKey: "startDate") as? String)
386
+ // } set {
387
+ // UserDefaults.standard.setValue(newValue, forKey: "startDate")
388
+ // }
389
+ //}
390
+ //
391
+ //var startDateType : String? {
392
+ // get {
393
+ // return (UserDefaults().object(forKey: "startDateType") as? String)
394
+ // } set {
395
+ // UserDefaults.standard.setValue(newValue, forKey: "startDateType")
396
+ // }
397
+ //}
398
+ //
399
+ //var paymentIntentId : String? {
400
+ // get {
401
+ // return (UserDefaults().object(forKey: "paymentIntentId") as? String)
402
+ // } set {
403
+ // UserDefaults.standard.setValue(newValue, forKey: "paymentIntentId")
404
+ // }
405
+ //}
406
+ //
407
+ //