@jimrising/easymerchantsdk-react-native 2.2.9 → 2.3.1

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 (102) hide show
  1. package/.idea/caches/deviceStreaming.xml +11 -0
  2. package/README.md +310 -171
  3. package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$2.dex +0 -0
  4. package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$3.dex +0 -0
  5. package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
  6. package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  7. package/android/build/.transforms/3f3a228346492fb34e3f574e941b632f/transformed/bundleLibRuntimeToDirRelease/bundleLibRuntimeToDirRelease_dex/com/reactlibrary/RNEasymerchantsdkModule$2.dex +0 -0
  8. package/android/build/.transforms/3f3a228346492fb34e3f574e941b632f/transformed/bundleLibRuntimeToDirRelease/bundleLibRuntimeToDirRelease_dex/com/reactlibrary/RNEasymerchantsdkModule$3.dex +0 -0
  9. package/android/build/.transforms/3f3a228346492fb34e3f574e941b632f/transformed/bundleLibRuntimeToDirRelease/bundleLibRuntimeToDirRelease_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
  10. package/android/build/.transforms/3f3a228346492fb34e3f574e941b632f/transformed/bundleLibRuntimeToDirRelease/desugar_graph.bin +0 -0
  11. package/android/build/.transforms/58b147bdc43284da2468dab19bc4a64d/transformed/classes/classes_dex/classes.dex +0 -0
  12. package/android/build/.transforms/e9a664a11ce12edf79cd87b1e07aa243/transformed/classes/classes_dex/classes.dex +0 -0
  13. package/android/build/intermediates/aar_main_jar/release/syncReleaseLibJars/classes.jar +0 -0
  14. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  15. package/android/build/intermediates/compile_library_classes_jar/release/bundleLibCompileToJarRelease/classes.jar +0 -0
  16. package/android/build/intermediates/full_jar/release/createFullJarRelease/full.jar +0 -0
  17. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
  18. package/android/build/intermediates/incremental/lintVitalAnalyzeRelease/release-artifact-dependencies.xml +4 -4
  19. package/android/build/intermediates/incremental/lintVitalAnalyzeRelease/release-artifact-libraries.xml +4 -4
  20. package/android/build/intermediates/incremental/release/mergeReleaseResources/compile-file-map.properties +916 -916
  21. package/android/build/intermediates/incremental/release/mergeReleaseResources/merger.xml +3 -3
  22. package/android/build/intermediates/incremental/release/packageReleaseResources/compile-file-map.properties +1 -1
  23. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
  24. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$3.class +0 -0
  25. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
  26. package/android/build/intermediates/javac/release/compileReleaseJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
  27. package/android/build/intermediates/javac/release/compileReleaseJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$3.class +0 -0
  28. package/android/build/intermediates/javac/release/compileReleaseJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
  29. package/android/build/intermediates/lint-cache/lintVitalAnalyzeRelease/maven.google/com/android/tools/build/group-index.xml +22 -0
  30. package/android/build/intermediates/lint_model/release/generateReleaseLintModel/release-artifact-dependencies.xml +4 -4
  31. package/android/build/intermediates/lint_model/release/generateReleaseLintModel/release-artifact-libraries.xml +4 -4
  32. package/android/build/intermediates/lint_vital_lint_model/release/generateReleaseLintVitalModel/release-artifact-dependencies.xml +4 -4
  33. package/android/build/intermediates/lint_vital_lint_model/release/generateReleaseLintVitalModel/release-artifact-libraries.xml +4 -4
  34. package/android/build/intermediates/local_aar_for_lint/release/out.aar +0 -0
  35. package/android/build/intermediates/merged_res/release/mergeReleaseResources/layout/activity_payment_done_url.xml +2 -1
  36. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/multi-v2/values-night-v8.json +2 -2
  37. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/multi-v2/values.json +38 -38
  38. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/anim-v21.json +9 -9
  39. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/anim.json +24 -24
  40. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/animator-v21.json +1 -1
  41. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/animator.json +34 -34
  42. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/color-night-v8.json +3 -3
  43. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/color-v31.json +10 -10
  44. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/color.json +153 -153
  45. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable-anydpi-v21.json +6 -6
  46. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable-hdpi-v4.json +13 -13
  47. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable-ldpi-v4.json +6 -6
  48. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable-mdpi-v4.json +12 -12
  49. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable-v21.json +4 -4
  50. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable-v23.json +7 -7
  51. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable-v29.json +1 -1
  52. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable-xhdpi-v4.json +12 -12
  53. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable-xxhdpi-v4.json +7 -7
  54. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable-xxxhdpi-v4.json +7 -7
  55. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/drawable.json +395 -395
  56. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/font.json +9 -9
  57. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/interpolator-v21.json +10 -10
  58. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/interpolator.json +11 -11
  59. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/layout-land.json +3 -3
  60. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/layout-sw600dp-v13.json +2 -2
  61. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/layout-v21.json +4 -4
  62. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/layout-v26.json +1 -1
  63. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/layout.json +108 -108
  64. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-anydpi-v26.json +2 -2
  65. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-hdpi-v4.json +2 -2
  66. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-mdpi-v4.json +2 -2
  67. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-xhdpi-v4.json +2 -2
  68. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-xxhdpi-v4.json +2 -2
  69. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/mipmap-xxxhdpi-v4.json +2 -2
  70. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/raw.json +46 -46
  71. package/android/build/intermediates/merged_res_blame_folder/release/mergeReleaseResources/out/single/xml.json +3 -3
  72. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
  73. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule$3.class +0 -0
  74. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
  75. package/android/build/intermediates/runtime_library_classes_dir/release/bundleLibRuntimeToDirRelease/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
  76. package/android/build/intermediates/runtime_library_classes_dir/release/bundleLibRuntimeToDirRelease/com/reactlibrary/RNEasymerchantsdkModule$3.class +0 -0
  77. package/android/build/intermediates/runtime_library_classes_dir/release/bundleLibRuntimeToDirRelease/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
  78. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  79. package/android/build/intermediates/runtime_library_classes_jar/release/bundleLibRuntimeToJarRelease/classes.jar +0 -0
  80. package/android/build/intermediates/source_set_path_map/release/mapReleaseSourceSetPaths/file-map.txt +38 -38
  81. package/android/build/intermediates/verified_library_resources/release/verifyReleaseResources/compiled/layout_activity_payment_done_url.xml.flat +0 -0
  82. package/android/build/outputs/aar/jimrising_easymerchantsdk-react-native-release.aar +0 -0
  83. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  84. package/android/build/tmp/compileReleaseJavaWithJavac/previous-compilation-data.bin +0 -0
  85. package/android/build.gradle +1 -1
  86. package/android/src/main/java/com/reactlibrary/RNEasymerchantsdkModule.java +56 -1
  87. package/ios/Classes/EasyMerchantSdk.m +124 -141
  88. package/ios/Classes/EasyMerchantSdk.swift +270 -502
  89. package/ios/Classes/EasyPayViewController.swift +18 -15
  90. package/ios/CustomComponents/TextFieldStackView.swift +16 -46
  91. package/ios/EnvironmentConfig.swift +16 -0
  92. package/ios/Example/ViewController.swift +513 -76
  93. package/ios/Models/Request.swift +365 -171
  94. package/ios/Pods/UserDefaults/UserStoreSingleton.swift +116 -12
  95. package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +2 -32
  96. package/ios/Pods/ViewControllers/GrailPayVC.swift +258 -18
  97. package/ios/Pods/ViewControllers/OTPVerificationVC.swift +1 -66
  98. package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +571 -369
  99. package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +18 -9
  100. package/ios/easymerchantsdk.podspec +1 -1
  101. package/ios/easymerchantsdk.storyboard +108 -85
  102. package/package.json +1 -1
@@ -1,3 +1,10 @@
1
+ ////
2
+ //// ViewController.swift
3
+ //// easymerchantsdkDemo
4
+ ////
5
+ //// Created by iftekhar on 13/07/24.
6
+ ////
7
+ //
1
8
  //import UIKit
2
9
  //import EasyPay
3
10
  //
@@ -6,99 +13,131 @@
6
13
  // @IBOutlet weak var lblResponseShow: UILabel!
7
14
  // @IBOutlet private var payButton: UIButton!
8
15
  //
16
+ // @IBOutlet weak var txtFieldClientToken: UITextField!
17
+ //
18
+ // private var referenceToken: String?
19
+ //
9
20
  // override func viewDidLoad() {
10
21
  // super.viewDidLoad()
11
22
  //
12
- // // Select environment
13
- // EasyPay.EnvironmentConfig.setEnvironment(.staging)
23
+ // NotificationCenter.default.addObserver(self, selector: #selector(handleEasyPayResult(_:)), name: NSNotification.Name("EasyPayResult"), object: nil)
14
24
  //
15
- // // Blink Card License Setup
16
- // let licenseErrorMessage = BlinkCardHelper.setupLicense()
17
- // if !licenseErrorMessage.isEmpty {
18
- // showLicenseErrorAlert(message: licenseErrorMessage)
19
- // }
25
+ // // Add tap gesture to dismiss keyboard
26
+ // let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
27
+ // tapGesture.cancelsTouchesInView = false
28
+ // view.addGestureRecognizer(tapGesture)
20
29
  // }
21
30
  //
22
- // private func showLicenseErrorAlert(message: String) {
23
- // let alert = UIAlertController(title: "License Error", message: message, preferredStyle: .alert)
24
- // alert.addAction(UIAlertAction(title: "OK", style: .default))
25
- // self.present(alert, animated: true, completion: nil)
31
+ // // Method to dismiss keyboard
32
+ // @objc private func dismissKeyboard() {
33
+ // view.endEditing(true)
26
34
  // }
27
35
  //
28
- // @IBAction private func payAction() {
29
- // let apiKey = "14fbf8a186091763e59c289c1"
30
- // let apiSecret = "f90863e7a853539f8ace8d6de"
36
+ // //MARK: - Open With Payment Intent Api inside SDK.
37
+ // @IBAction private func actionBtnEnvConfigWithApiKeys() {
38
+ // // Select environment
39
+ //// EasyPay.EnvironmentConfig.setEnvironment(.sandbox)
31
40
  //
32
- // EasyPay.EnvironmentConfig.configure(apiKey: apiKey, apiSecret: apiSecret)
41
+ // /// Staging Keys
42
+ //// let apiKey = "13bcb1f54b894ddbbd75a86d5"
43
+ //// let apiSecret = "94f7ebd5384f6985f23920c13"
44
+ //
45
+ // /// Sandboxing Keys
46
+ // let apiKey = "75e47d32521175e04b4b65234"
47
+ // let apiSecret = "556f980d99f15599adaad1b56"
33
48
  //
49
+ // EasyPay.EnvironmentConfig.configure(apiKey: apiKey, apiSecret: apiSecret)
34
50
  //
51
+ // ///Dark Theme
35
52
  // let themeConfiguration = ThemeConfiguration(
36
- // bodyBackgroundColor: "#1F2937", // dark gray-blue
37
- // containerBackgroundColor: "#374151", // darker container
38
- // primaryFontColor: "#F9FAFB", // near white
39
- // secondaryFontColor: "#D1D5DB", // light gray
40
- // primaryButtonBackgroundColor: "#4F46E5", // indigo (keep for contrast)
41
- // primaryButtonHoverColor: "#4338CA", // deeper indigo
42
- // primaryButtonFontColor: "#FFFFFF", // white text on button
43
- // secondaryButtonBackgroundColor: "#1E40AF", // dark blue
44
- // secondaryButtonHoverColor: "#1E3A8A", // deeper blue on hover
45
- // secondaryButtonFontColor: "#E0E7FF", // soft blue-white
53
+ // bodyBackgroundColor: "#121212",
54
+ // containerBackgroundColor: "#1E1E1E",
55
+ // primaryFontColor: "#FFFFFF",
56
+ // secondaryFontColor: "#B0B0B0",
57
+ // primaryButtonBackgroundColor: "#2563EB",
58
+ // primaryButtonHoverColor: "#1D4ED8",
59
+ // primaryButtonFontColor: "#FFFFFF",
60
+ // secondaryButtonBackgroundColor: "#374151",
61
+ // secondaryButtonHoverColor: "#4B5563",
62
+ // secondaryButtonFontColor: "#E5E7EB",
46
63
  // borderRadius: "8",
47
- // fontSize: "14"
48
- // )
49
- //
50
- // let additionalInfo = AdditionalInfo(
51
- // name: "Test User",
52
- // email: "test@gmail.com",
53
- // phone_number: "9465351125",
54
- // country_code: "91",
55
- // description: "Test"
64
+ // fontSize: "14",
65
+ // fontWeight: 500,
66
+ // fontFamily: "\"Inter\", sans-serif"
56
67
  // )
57
68
  //
58
- // let billingInfo = BillingInfo(
59
- // address: "Mohali, Punjab",
60
- // country: "India",
61
- // state: "Punjab",
62
- // city: "Anandpur Sahib",
63
- // postal_code: "140118",
64
- // additional_info: additionalInfo
69
+ // let fields = FieldSection(
70
+ // visibility: FieldsVisibility(billing: false, additional: false),
71
+ // billing: [
72
+ // FieldItem(name: .address, required: true, value: "Mohali, Punjab"),
73
+ // FieldItem(name: .country, required: true, value: "Canada"),
74
+ // FieldItem(name: .state, required: true, value: "Punjab"),
75
+ // FieldItem(name: .city, required: false, value: "Anandpur Sahib"),
76
+ // FieldItem(name: .postalCode, required: true, value: "140118")
77
+ // ],
78
+ // additional: [
79
+ // // FieldItem(name: .name, required: true, value: "Test User"),
80
+ // // FieldItem(name: .email, required: true, value: "test@gmail.com"),
81
+ // FieldItem(name: .phoneNumber, required: true, value: "9465351125"),
82
+ // FieldItem(name: .description, required: false, value: "Test")
83
+ // ]
65
84
  // )
66
85
  //
67
- // // Encode Billing Info to Data
68
- // guard let billingData = try? JSONEncoder().encode(billingInfo) else {
69
- // print("Failed to encode BillingInfo")
86
+ // guard let billingData = try? JSONEncoder().encode(fields) else {
87
+ // print("Failed to encode fields")
70
88
  // return
71
89
  // }
72
90
  //
73
- // let authenticatedACH = false
91
+ // let authenticatedACH = false /// For GrailPay
74
92
  //
75
93
  // let grailPayParams = GrailPayRequest(
76
- // accessToken: "251|uTijpDGfrS88UR2V1cZNMQ8S4hUJA0sVzsnsoUZF",
77
- // vendorId: "251",
94
+ // // accessToken: "251|uTijpDGfrS88UR2V1cZNMQ8S4hUJA0sVzsnsoUZF",
95
+ // // vendorId: "251",
96
+ // // isSandbox: true,
78
97
  // role: "business",
79
98
  // timeout: 10,
80
- // isSandbox: true,
81
99
  // brandingName: "Lyfecycle Payments",
82
100
  // finderSubtitle: "Search for your bank",
83
101
  // searchPlaceholder: "Enter bank name"
84
- // )
102
+ // ) /// if authenticatedACH is true
103
+ //
104
+ // let metadata: [String: Any] = [
105
+ // "name": "King",
106
+ // "age": 32,
107
+ // "city": "Manhattan"
108
+ // ]
85
109
  //
86
110
  // let request = EasyPay.Request(
87
- // amount: 99,
88
- // billingInfoData: billingData,
111
+ // amount: 13.528,
112
+ // currency: "usd",
113
+ // fields: billingData, /// billingData or nil
89
114
  // paymentMethods: [.Card, .Bank],
90
- // themeConfiguration: themeConfiguration,
91
- // tokenOnly: false,
92
- // saveCard: false,
93
- // saveAccount: false,
115
+ // appearanceSettings: themeConfiguration,
116
+ // tokenOnly: true, /// true || false
117
+ // saveCard: true, /// true || false
118
+ // saveAccount: true, /// true || false
94
119
  // submitButtonText: "Submit",
95
- // authenticatedACH: authenticatedACH,
96
- // grailPayParams: authenticatedACH ? grailPayParams : nil,
97
- // is_recurring: true,
98
- // recurringIntervals: [.weekly, .monthly],
99
- // recurringStartDateType: .custom,
100
- // recurringStartDate: "05/30/2025", /// Format MM/dd/yyyy, must be today or future date
101
- // enable3DS: true
120
+ // authenticatedACH: authenticatedACH, /// if authenticatedACH is true
121
+ // grailPayParams: authenticatedACH ? grailPayParams : nil, /// if authenticatedACH is true || false
122
+ //
123
+ // //MARK: Recurring params.
124
+ // is_recurring: true, /// true || false
125
+ // numOfCycle: 2, /// required if is_recurring: true
126
+ // recurringIntervals: [.daily, .weekly], /// required if is_recurring: true
127
+ // recurringStartDateType: .fixed, /// custom or fixed /// required if is_recurring: true
128
+ // recurringStartDate: "30/09/2025", /// Format dd/MM/yyyy, must be today or future date /// required if is_recurring: true
129
+ //
130
+ // secureAuthentication: false, /// For 3DSecure
131
+ // showReceipt: true, /// true || false
132
+ // showTotal: true, /// true || false
133
+ // showSubmitButton: true, /// true || false
134
+ // isEmail: true, /// true || false for make email fields editable or not editable
135
+ // email: "pabloemilioescobargaviria285@gmail.com",
136
+ // name: "Mony",
137
+ // metadata: metadata,
138
+ // environment: .sandbox, // Pass environment
139
+ // apiKey: apiKey, // Pass API key
140
+ // apiSecret: apiSecret // Pass API secret
102
141
  // )
103
142
  //
104
143
  // if request.tokenOnly == true {
@@ -106,40 +145,416 @@
106
145
  // if let clientToken = notification.object as? String {
107
146
  // self.lblResponseShow.isHidden = false
108
147
  // self.lblResponseShow.text = "Client Token: \(clientToken)"
148
+ //
149
+ // self.txtFieldClientToken.text = clientToken
109
150
  // }
110
151
  // }
111
- // } else {
152
+ // } else if request.initializationErrorMessage == nil {
112
153
  // let controller = EasyPayViewController(request: request, delegate: self)
113
154
  // self.present(controller, animated: true)
114
155
  // }
115
156
  // }
157
+ //
158
+ // //MARK: - Open With Direct Client Token and Payment Intent. Payment Intent Api Outside SDK
159
+ // @IBAction func actionBtnEnvConfigWithClientToken(_ sender: UIButton) {
160
+ // ///Dark Theme
161
+ // let themeConfiguration = ThemeConfiguration(
162
+ // bodyBackgroundColor: "#121212",
163
+ // containerBackgroundColor: "#1E1E1E",
164
+ // primaryFontColor: "#FFFFFF",
165
+ // secondaryFontColor: "#B0B0B0",
166
+ // primaryButtonBackgroundColor: "#2563EB",
167
+ // primaryButtonHoverColor: "#1D4ED8",
168
+ // primaryButtonFontColor: "#FFFFFF",
169
+ // secondaryButtonBackgroundColor: "#374151",
170
+ // secondaryButtonHoverColor: "#4B5563",
171
+ // secondaryButtonFontColor: "#E5E7EB",
172
+ // borderRadius: "8",
173
+ // fontSize: "14",
174
+ // fontWeight: 500,
175
+ // fontFamily: "\"Inter\", sans-serif"
176
+ // )
177
+ //
178
+ // let fields = FieldSection(
179
+ // visibility: FieldsVisibility(billing: false, additional: false),
180
+ // billing: [
181
+ // FieldItem(name: .address, required: true, value: "Mohali, Punjab"),
182
+ // FieldItem(name: .country, required: true, value: "Canada"),
183
+ // FieldItem(name: .state, required: true, value: "Punjab"),
184
+ // FieldItem(name: .city, required: false, value: "Anandpur Sahib"),
185
+ // FieldItem(name: .postalCode, required: true, value: "140118")
186
+ // ],
187
+ // additional: [
188
+ // FieldItem(name: .phoneNumber, required: true, value: "9465351125"),
189
+ // FieldItem(name: .description, required: false, value: "Test")
190
+ // ]
191
+ // )
192
+ //
193
+ // guard let billingData = try? JSONEncoder().encode(fields) else {
194
+ // print("Failed to encode fields")
195
+ // return
196
+ // }
197
+ //
198
+ // let authenticatedACH = false /// For GrailPay
199
+ //
200
+ // let grailPayParams = GrailPayRequest(
201
+ // role: "business",
202
+ // timeout: 10,
203
+ // brandingName: "Lyfecycle Payments",
204
+ // finderSubtitle: "Search for your bank",
205
+ // searchPlaceholder: "Enter bank name"
206
+ // ) /// if authenticatedACH is true
207
+ //
208
+ // let metadata: [String: Any] = [
209
+ // "name": "King",
210
+ // "age": 32,
211
+ // "city": "Manhattan"
212
+ // ]
213
+ //
214
+ // let request = EasyPay.Request(
215
+ // currency: "usd",
216
+ // fields: billingData, /// billingData or nil
217
+ // paymentMethods: [.Card, .Bank],
218
+ // appearanceSettings: themeConfiguration,
219
+ // saveCard: true, /// true || false
220
+ // saveAccount: true, /// true || false
221
+ // submitButtonText: "Submit",
222
+ // authenticatedACH: authenticatedACH, /// if authenticatedACH is true
223
+ // grailPayParams: authenticatedACH ? grailPayParams : nil, /// if authenticatedACH is true || false
224
+ //
225
+ // secureAuthentication: true, /// For 3DSecure
226
+ // showReceipt: true, /// true || false
227
+ // showTotal: true, /// true || false
228
+ // showSubmitButton: true, /// true || false
229
+ // isEmail: true, /// true || false for make email fields editable or not editable
230
+ // email: "pabloemilioescobargaviria285@gmail.com",
231
+ // name: "Mony",
232
+ // clientToken: txtFieldClientToken.text,
233
+ // metadata: metadata,
234
+ // environment: .sandbox
235
+ // )
236
+ //
237
+ // if request.initializationErrorMessage == nil {
238
+ // let controller = EasyPayViewController(request: request, delegate: self)
239
+ // self.present(controller, animated: true)
240
+ // }
241
+ // }
242
+ //
243
+ // // MARK: - Open With Direct Client Token and Payment Intent. Payment Intent Api Outside SDK
244
+ //// @IBAction func actionBtnEnvConfigWithClientToken(_ sender: UIButton) {
245
+ //// /// Dark Theme
246
+ //// let themeConfiguration = ThemeConfiguration(
247
+ //// bodyBackgroundColor: "#121212",
248
+ //// containerBackgroundColor: "#1E1E1E",
249
+ //// primaryFontColor: "#FFFFFF",
250
+ //// secondaryFontColor: "#B0B0B0",
251
+ //// primaryButtonBackgroundColor: "#2563EB",
252
+ //// primaryButtonHoverColor: "#1D4ED8",
253
+ //// primaryButtonFontColor: "#FFFFFF",
254
+ //// secondaryButtonBackgroundColor: "#374151",
255
+ //// secondaryButtonHoverColor: "#4B5563",
256
+ //// secondaryButtonFontColor: "#E5E7EB",
257
+ //// borderRadius: "8",
258
+ //// fontSize: "14",
259
+ //// fontWeight: 500,
260
+ //// fontFamily: "\"Inter\", sans-serif"
261
+ //// )
262
+ ////
263
+ //// let fields = FieldSection(
264
+ //// visibility: FieldsVisibility(billing: false, additional: false),
265
+ //// billing: [
266
+ //// FieldItem(name: .address, required: true, value: "Mohali, Punjab"),
267
+ //// FieldItem(name: .country, required: true, value: "Canada"),
268
+ //// FieldItem(name: .state, required: true, value: "Punjab"),
269
+ //// FieldItem(name: .city, required: false, value: "Anandpur Sahib"),
270
+ //// FieldItem(name: .postalCode, required: true, value: "140118")
271
+ //// ],
272
+ //// additional: [
273
+ //// FieldItem(name: .phoneNumber, required: true, value: "9465351125"),
274
+ //// FieldItem(name: .description, required: false, value: "Test")
275
+ //// ]
276
+ //// )
277
+ ////
278
+ //// guard let billingData = try? JSONEncoder().encode(fields) else {
279
+ //// print("Failed to encode fields")
280
+ //// return
281
+ //// }
282
+ ////
283
+ //// let authenticatedACH = true /// Changed to true to include grailPayParams
284
+ //// let amount = 13.53 /// Explicit amount to match provided JSON
285
+ ////
286
+ //// let grailPayParams = GrailPayRequest(
287
+ //// role: "business",
288
+ //// timeout: 10,
289
+ //// brandingName: "Lyfecycle Payments",
290
+ //// finderSubtitle: "Search for your bank",
291
+ //// searchPlaceholder: "Enter bank name"
292
+ //// )
293
+ ////
294
+ //// let metadata: [String: Any] = [
295
+ //// "name": "King",
296
+ //// "age": 32,
297
+ //// "city": "Manhattan"
298
+ //// ]
299
+ ////
300
+ //// let environment: EnvironmentConfig.Environment = .sandbox
301
+ ////
302
+ //// let request = EasyPay.Request(
303
+ //// amount: amount,
304
+ //// currency: "usd",
305
+ //// fields: billingData,
306
+ //// paymentMethods: [.Card, .Bank],
307
+ //// appearanceSettings: themeConfiguration,
308
+ //// saveCard: true,
309
+ //// saveAccount: true,
310
+ //// submitButtonText: "Submit",
311
+ //// authenticatedACH: authenticatedACH,
312
+ //// grailPayParams: grailPayParams, // Always pass grailPayParams
313
+ //// secureAuthentication: true,
314
+ //// showReceipt: false,
315
+ //// showTotal: false,
316
+ //// showSubmitButton: true,
317
+ //// isEmail: true,
318
+ //// email: "pabloemilioescobargaviria285@gmail.com",
319
+ //// name: "Mony",
320
+ //// clientToken: txtFieldClientToken.text,
321
+ //// metadata: metadata,
322
+ //// environment: environment
323
+ //// )
324
+ ////
325
+ //// // Helper function to convert Environment to string
326
+ //// func environmentToString(_ environment: EnvironmentConfig.Environment?) -> String? {
327
+ //// guard let environment = environment else { return nil }
328
+ //// switch environment {
329
+ //// case .staging:
330
+ //// return "staging"
331
+ //// case .sandbox:
332
+ //// return "sandbox"
333
+ //// case .production:
334
+ //// return "production"
335
+ //// }
336
+ //// }
337
+ ////
338
+ //// // Convert request parameters to JSON, excluding null values
339
+ //// do {
340
+ //// var requestDict: [String: Any] = [:]
341
+ ////
342
+ //// // Add non-nil values only
343
+ //// if let amount = request.amount {
344
+ //// requestDict["amount"] = String(format: "%.2f", amount) // Format to two decimal places
345
+ //// }
346
+ //// if let currency = request.currency {
347
+ //// requestDict["currency"] = currency
348
+ //// }
349
+ //// if let fieldsData = request.fields, let fieldsJSON = try? JSONSerialization.jsonObject(with: fieldsData) {
350
+ //// requestDict["fields"] = fieldsJSON
351
+ //// }
352
+ //// requestDict["paymentMethods"] = request.selectedPaymentMethods.map { $0.rawValue }
353
+ //// if let theme = request.appearanceSettings {
354
+ //// var appearanceDict: [String: Any] = [:]
355
+ //// if let bodyBackgroundColor = theme.bodyBackgroundColor {
356
+ //// appearanceDict["bodyBackgroundColor"] = bodyBackgroundColor
357
+ //// }
358
+ //// if let containerBackgroundColor = theme.containerBackgroundColor {
359
+ //// appearanceDict["containerBackgroundColor"] = containerBackgroundColor
360
+ //// }
361
+ //// if let primaryFontColor = theme.primaryFontColor {
362
+ //// appearanceDict["primaryFontColor"] = primaryFontColor
363
+ //// }
364
+ //// if let secondaryFontColor = theme.secondaryFontColor {
365
+ //// appearanceDict["secondaryFontColor"] = secondaryFontColor
366
+ //// }
367
+ //// if let primaryButtonBackgroundColor = theme.primaryButtonBackgroundColor {
368
+ //// appearanceDict["primaryButtonBackgroundColor"] = primaryButtonBackgroundColor
369
+ //// }
370
+ //// if let primaryButtonHoverColor = theme.primaryButtonHoverColor {
371
+ //// appearanceDict["primaryButtonHoverColor"] = primaryButtonHoverColor
372
+ //// }
373
+ //// if let primaryButtonFontColor = theme.primaryButtonFontColor {
374
+ //// appearanceDict["primaryButtonFontColor"] = primaryButtonFontColor
375
+ //// }
376
+ //// if let secondaryButtonBackgroundColor = theme.secondaryButtonBackgroundColor {
377
+ //// appearanceDict["secondaryButtonBackgroundColor"] = secondaryButtonBackgroundColor
378
+ //// }
379
+ //// if let secondaryButtonHoverColor = theme.secondaryButtonHoverColor {
380
+ //// appearanceDict["secondaryButtonHoverColor"] = secondaryButtonHoverColor
381
+ //// }
382
+ //// if let secondaryButtonFontColor = theme.secondaryButtonFontColor {
383
+ //// appearanceDict["secondaryButtonFontColor"] = secondaryButtonFontColor
384
+ //// }
385
+ //// if let borderRadius = theme.borderRadius {
386
+ //// appearanceDict["borderRadius"] = borderRadius
387
+ //// }
388
+ //// if let fontSize = theme.fontSize {
389
+ //// appearanceDict["fontSize"] = fontSize
390
+ //// }
391
+ //// if let fontWeight = theme.fontWeight {
392
+ //// appearanceDict["fontWeight"] = fontWeight
393
+ //// }
394
+ //// if let fontFamily = theme.fontFamily {
395
+ //// appearanceDict["fontFamily"] = fontFamily
396
+ //// }
397
+ //// if !appearanceDict.isEmpty {
398
+ //// requestDict["appearanceSettings"] = appearanceDict
399
+ //// }
400
+ //// }
401
+ //// requestDict["saveCard"] = request.saveCard ?? false
402
+ //// requestDict["saveAccount"] = request.saveAccount ?? false
403
+ //// if let submitButtonText = request.submitButtonText {
404
+ //// requestDict["submitButtonText"] = submitButtonText
405
+ //// }
406
+ //// requestDict["authenticatedACH"] = request.authenticatedACH ?? false
407
+ //// if let grailPay = request.grailPayParams {
408
+ //// requestDict["grailPayParams"] = [
409
+ //// "role": grailPay.role,
410
+ //// "timeout": grailPay.timeout,
411
+ //// "brandingName": grailPay.brandingName,
412
+ //// "finderSubtitle": grailPay.finderSubtitle,
413
+ //// "searchPlaceholder": grailPay.searchPlaceholder
414
+ //// ]
415
+ //// }
416
+ //// requestDict["secureAuthentication"] = request.secureAuthentication ?? false
417
+ //// requestDict["showReceipt"] = request.showReceipt ?? false
418
+ //// requestDict["showTotal"] = request.showTotal ?? false
419
+ //// requestDict["showSubmitButton"] = request.showSubmitButton ?? false
420
+ //// requestDict["isEmail"] = request.isEmail ?? false
421
+ //// if let email = request.email {
422
+ //// requestDict["email"] = email
423
+ //// }
424
+ //// if let name = request.name {
425
+ //// requestDict["name"] = name
426
+ //// }
427
+ //// if let clientToken = request.clientToken {
428
+ //// requestDict["clientToken"] = clientToken
429
+ //// }
430
+ //// if let metadata = request.metadata {
431
+ //// requestDict["metadata"] = metadata
432
+ //// }
433
+ //// if let envString = environmentToString(environment) {
434
+ //// requestDict["environment"] = envString
435
+ //// }
436
+ ////
437
+ //// let jsonData = try JSONSerialization.data(withJSONObject: requestDict, options: [.prettyPrinted])
438
+ //// if let jsonString = String(data: jsonData, encoding: .utf8) {
439
+ //// print("Request Configuration JSON:\n\(jsonString)")
440
+ //// }
441
+ //// } catch {
442
+ //// print("Failed to serialize request to JSON: \(error)")
443
+ //// }
444
+ ////
445
+ //// if request.initializationErrorMessage == nil {
446
+ //// let controller = EasyPayViewController(request: request, delegate: self)
447
+ //// self.present(controller, animated: true)
448
+ //// }
449
+ //// }
450
+ //
451
+ // @objc private func handleEasyPayResult(_ notification: Notification) {
452
+ // guard let result = notification.object as? SDKResult else { return }
453
+ // switch result.type {
454
+ // case .error:
455
+ // if let chargeData = result.chargeData,
456
+ // let data = try? JSONSerialization.data(withJSONObject: chargeData, options: .prettyPrinted),
457
+ // let json = String(data: data, encoding: .utf8) {
458
+ // self.lblResponseShow.isHidden = false
459
+ // self.lblResponseShow.text = json
460
+ // } else if let error = result.error {
461
+ // self.lblResponseShow.isHidden = false
462
+ // self.lblResponseShow.text = "{\n \"status\": false,\n \"message\": \"\(error.localizedDescription)\"\n}"
463
+ // }
464
+ // default:
465
+ // break
466
+ // }
467
+ // }
468
+ //
469
+ // @IBAction func actionBtnPaymentRefference(_ sender: UIButton) {
470
+ // guard let token = referenceToken else {
471
+ // lblResponseShow.isHidden = false
472
+ // lblResponseShow.text = "Reference token not available yet."
473
+ // return
474
+ // }
475
+ //
476
+ // let request = EasyPay.Request(
477
+ // referenceID: true,
478
+ // referenceToken: token
479
+ // )
480
+ //
481
+ // if request.referenceID == true {
482
+ // NotificationCenter.default.addObserver(forName: NSNotification.Name("ReferenceIDResponse"), object: nil, queue: .main) { notification in
483
+ // if let data = notification.object as? [String: Any] {
484
+ // self.lblResponseShow.isHidden = false
485
+ // self.lblResponseShow.text = "Reference Response:\n\(data)"
486
+ // }
487
+ // }
488
+ // }
489
+ // }
490
+ //
491
+ // private func showAlert(message: String) {
492
+ // let alert = UIAlertController(title: "Validation Error", message: message, preferredStyle: .alert)
493
+ // alert.addAction(UIAlertAction(title: "OK", style: .default))
494
+ // self.present(alert, animated: true)
495
+ // }
496
+ //
116
497
  //}
117
498
  //
118
499
  //extension ViewController: EasyPayViewControllerDelegate {
119
500
  //
120
- // func easyPayController(_ controller: EasyPayViewController, didFinishWith result: EasyPay.Result) {
501
+ // func easyPayController(_ controller: EasyPayViewController, didFinishWith result: EasyPay.SDKResult) {
121
502
  // switch result.type {
122
503
  // case .cancelled:
123
- // print("Cancelled")
124
504
  // lblResponseShow.isHidden = false
125
- // if let message = result.chargeData?["message"] as? String {
126
- // print("Message from chargeData: \(message)")
127
- // lblResponseShow.text = message
505
+ //
506
+ // if let chargeData = result.chargeData {
507
+ // let status = (chargeData["status"] as? Bool) ?? false
508
+ // let message = (chargeData["message"] as? String) ?? "No message"
509
+ //
510
+ // // Combine into one string for the label
511
+ // lblResponseShow.text = "Status: \(status), Message: \(message)"
512
+ //
513
+ // print("Cancel Data:", chargeData) // Debug print
128
514
  // }
515
+ //
129
516
  // case .success:
517
+ // lblResponseShow.isHidden = false
518
+ // var fullResponse: [String: Any] = [:]
519
+ //
130
520
  // if let chargeData = result.chargeData {
131
- // if let clientToken = chargeData["clientToken"] as? String {
132
- // // If tokenOnly was true, display the token
133
- // lblResponseShow.isHidden = false
134
- // lblResponseShow.text = "Client Token: \(clientToken)"
135
- // } else {
136
- // handleSuccess(with: chargeData)
521
+ // fullResponse["chargeData"] = chargeData
522
+ // }
523
+ //
524
+ // if let billing = result.billingInfo {
525
+ // fullResponse["billingInfo"] = billing
526
+ // }
527
+ //
528
+ // if let additional = result.additionalInfo {
529
+ // fullResponse["additionalInfo"] = additional
530
+ //
531
+ // // Extract and save ref_token
532
+ // if let threeDSecureStatus = additional["threeDSecureStatus"] as? [String: Any],
533
+ // let data = threeDSecureStatus["data"] as? [String: Any],
534
+ // let token = data["ref_token"] as? String {
535
+ // self.referenceToken = token
137
536
  // }
138
537
  // }
538
+ //
539
+ // do {
540
+ // let jsonData = try JSONSerialization.data(withJSONObject: fullResponse, options: .prettyPrinted)
541
+ // if let jsonString = String(data: jsonData, encoding: .utf8) {
542
+ // print(jsonString)
543
+ // lblResponseShow.text = jsonString
544
+ // }
545
+ // } catch {
546
+ // lblResponseShow.text = "Failed to format response: \(error.localizedDescription)"
547
+ // }
548
+ //
139
549
  // case .error:
140
- // if let chargeData = result.chargeData, let errorMessage = chargeData["errorMessage"] as? String {
550
+ // if let chargeData = result.chargeData {
551
+ // let status = (chargeData["status"] as? Bool) ?? false
552
+ // let message = (chargeData["message"] as? String) ?? "Unknown error"
553
+ //
141
554
  // lblResponseShow.isHidden = false
142
- // lblResponseShow.text = "Error: \(errorMessage)"
555
+ // lblResponseShow.text = "Status: \(status), Message: \(message)"
556
+ //
557
+ // print("Error Data:", chargeData) // Debugging
143
558
  // } else {
144
559
  // lblResponseShow.isHidden = false
145
560
  // lblResponseShow.text = "An unknown error occurred."
@@ -154,3 +569,25 @@
154
569
  //
155
570
  //}
156
571
  //
572
+ //
573
+ //
574
+ //
575
+ //
576
+ //
577
+ //// /// Light Theme
578
+ //// let themeConfiguration = ThemeConfiguration(
579
+ //// bodyBackgroundColor: "#E5E7EB", // Light grey background
580
+ //// containerBackgroundColor: "#F9FAFB", // Light gray container
581
+ //// primaryFontColor: "#111827", // Dark gray/black text
582
+ //// secondaryFontColor: "#6B7280", // Medium gray text
583
+ //// primaryButtonBackgroundColor: "#2563EB", // Blue
584
+ //// primaryButtonHoverColor: "#1D4ED8", // Darker blue on hover
585
+ //// primaryButtonFontColor: "#FFFFFF", // White text on blue button
586
+ //// secondaryButtonBackgroundColor: "#E5E7EB", // Light gray button
587
+ //// secondaryButtonHoverColor: "#D1D5DB", // Slightly darker gray on hover
588
+ //// secondaryButtonFontColor: "#111827", // Dark text on light button
589
+ //// borderRadius: "8",
590
+ //// fontSize: "14",
591
+ //// fontWeight: 500,
592
+ //// fontFamily: "\"Inter\", sans-serif"
593
+ //// )