@jimrising/easymerchantsdk-react-native 2.5.1 → 2.5.3

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 (37) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/android/build.gradle +1 -1
  3. package/ios/ApiManager/APIHeaders.swift +0 -6
  4. package/ios/ApiManager/APIRequest.swift +3 -8
  5. package/ios/Classes/EasyMerchantSdk.m +2 -2
  6. package/ios/Classes/EasyMerchantSdk.swift +25 -13
  7. package/ios/Helper/GrailPayHelper.swift +1 -0
  8. package/ios/Models/Request.swift +3 -3
  9. package/ios/Pods/Storyboard/EasyPaySdk.storyboard +9089 -0
  10. package/ios/Pods/UserDefaults/UserStoreSingleton.swift +424 -0
  11. package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +2917 -0
  12. package/ios/Pods/ViewControllers/BaseVC.swift +142 -0
  13. package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +3686 -0
  14. package/ios/Pods/ViewControllers/BillingInfoVC/Cells/CityListTVC.swift +46 -0
  15. package/ios/Pods/ViewControllers/BillingInfoVC/Cells/CountryListTVC.swift +47 -0
  16. package/ios/Pods/ViewControllers/BillingInfoVC/Cells/StateListTVC.swift +46 -0
  17. package/ios/Pods/ViewControllers/Clean Runner_2025-07-23T14-58-05.txt +13 -0
  18. package/ios/Pods/ViewControllers/CountryListVC.swift +435 -0
  19. package/ios/Pods/ViewControllers/EmailVerificationVC.swift +286 -0
  20. package/ios/Pods/ViewControllers/GrailPayVC.swift +475 -0
  21. package/ios/Pods/ViewControllers/OTPVerificationVC.swift +2254 -0
  22. package/ios/Pods/ViewControllers/PaymentDoneVC.swift +284 -0
  23. package/ios/Pods/ViewControllers/PaymentErrorVC.swift +85 -0
  24. package/ios/Pods/ViewControllers/PaymentInformation/AccountTypeTVC.swift +41 -0
  25. package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +13010 -0
  26. package/ios/Pods/ViewControllers/PaymentInformation/PaymentInformationCVC.swift +35 -0
  27. package/ios/Pods/ViewControllers/PaymentInformation/RecurringTVC.swift +43 -0
  28. package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.swift +80 -0
  29. package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.xib +163 -0
  30. package/ios/Pods/ViewControllers/PaymentInformation/SavedCardsTVC/SavedCardsTVC.swift +81 -0
  31. package/ios/Pods/ViewControllers/PaymentInformation/SavedCardsTVC/SavedCardsTVC.xib +188 -0
  32. package/ios/Pods/ViewControllers/PaymentStatusWebViewVC.swift +127 -0
  33. package/ios/Pods/ViewControllers/TermAndConditionsVC.swift +63 -0
  34. package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +1220 -0
  35. package/ios/easymerchantsdk.podspec +1 -1
  36. package/package.json +1 -1
  37. package/ACH_CHARGE_ENDPOINT_TRACE.md +0 -69
@@ -0,0 +1,475 @@
1
+ ////
2
+ //// GrailPayVC.swift
3
+ //// EasyPay
4
+ ////
5
+ //// Created by Mony's Mac on 02/05/25.
6
+ ////
7
+
8
+ //import UIKit
9
+ //import WebKit
10
+ //
11
+ //public class GrailPayVC: UIViewController {
12
+ //
13
+ // private var webView: WKWebView!
14
+ // private var loadingIndicator: UIActivityIndicatorView!
15
+ // private var request: GrailPayRequest
16
+ // public var onCompletion: ((EasyPay.SDKResult) -> Void)?
17
+ // private var didHandleBankConnection = false
18
+ // private var allLinkedAccounts: [[String: Any]] = []
19
+ //
20
+ // public init(request: GrailPayRequest) {
21
+ // self.request = request
22
+ // super.init(nibName: nil, bundle: nil)
23
+ // }
24
+ //
25
+ // required init?(coder: NSCoder) {
26
+ // fatalError("init(coder:) has not been implemented")
27
+ // }
28
+ //
29
+ // override public func viewDidLoad() {
30
+ // super.viewDidLoad()
31
+ // setupUI()
32
+ // loadGrailPaySDK()
33
+ // }
34
+ //
35
+ // private func setupUI() {
36
+ // view.backgroundColor = .white
37
+ //
38
+ // let config = WKWebViewConfiguration()
39
+ // if #available(iOS 14.0, *) {
40
+ // let webpagePreferences = WKWebpagePreferences()
41
+ // webpagePreferences.allowsContentJavaScript = true
42
+ // config.defaultWebpagePreferences = webpagePreferences
43
+ // } else {
44
+ // let preferences = WKPreferences()
45
+ // preferences.javaScriptEnabled = true
46
+ // config.preferences = preferences
47
+ // }
48
+ //
49
+ // config.websiteDataStore = WKWebsiteDataStore.default()
50
+ // config.userContentController.add(self, name: "grailpayHandler")
51
+ // config.allowsInlineMediaPlayback = true
52
+ // config.mediaTypesRequiringUserActionForPlayback = []
53
+ //
54
+ // webView = WKWebView(frame: view.bounds, configuration: config)
55
+ // webView.navigationDelegate = self
56
+ // webView.uiDelegate = self
57
+ // webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
58
+ // view.addSubview(webView)
59
+ //
60
+ // loadingIndicator = UIActivityIndicatorView(style: .large)
61
+ // loadingIndicator.center = view.center
62
+ // loadingIndicator.hidesWhenStopped = true
63
+ // view.addSubview(loadingIndicator)
64
+ // }
65
+ //
66
+ // private func loadGrailPaySDK() {
67
+ // loadingIndicator.startAnimating()
68
+ //
69
+ //// let sdkURL = request.isSandbox
70
+ //// ? "https://bank-link-widget-sandbox.grailpay.com/sdk.js"
71
+ //// : "https://bank-link-widget.grailpay.com/sdk.js"
72
+ //
73
+ // let sdkURL = EnvironmentConfig.grailPaySDKURL
74
+ //
75
+ // let html = """
76
+ // <!DOCTYPE html>
77
+ // <html>
78
+ // <head>
79
+ // <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\">
80
+ // <script>
81
+ // window.sdkInitialized = false;
82
+ //
83
+ // function initializeSDK() {
84
+ // if (window.sdkInitialized) return;
85
+ //
86
+ // if (typeof window.grailpay === 'undefined') {
87
+ // window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'error', data: 'SDK not loaded' });
88
+ // return;
89
+ // }
90
+ //
91
+ // window.grailpay.init({
92
+ // token: '\(UserStoreSingleton.shared.bankWidgetKey ?? "")',
93
+ // vendorId: '\(UserStoreSingleton.shared.vendorID ?? "")',
94
+ // role: '\(request.role)',
95
+ // timeout: \(request.timeout),
96
+ // theme: {
97
+ // branding_name: '\(request.brandingName)',
98
+ // screens: {
99
+ // finder: {
100
+ // subtitle: '\(request.finderSubtitle)',
101
+ // searchPlaceholder: '\(request.searchPlaceholder)'
102
+ // }
103
+ // }
104
+ // },
105
+ // onError: function(error) {
106
+ // console.log("JS onError:", error);
107
+ // window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'error', data: error });
108
+ // },
109
+ // onBankConnected: function(data) {
110
+ // console.log("✅ Bank connected:", data);
111
+ // window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'bankConnected', data: data });
112
+ // },
113
+ // onLinkedDefaultAccount: function(data) {
114
+ // console.log("✅ Default Account selected:", data);
115
+ // window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'defaultAccountSelected', data: data });
116
+ // },
117
+ // onLinkExit: function(data) {
118
+ // console.log("⚠️ User exited:", data);
119
+ // window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'linkExit', data: data });
120
+ // }
121
+ // }).then(function() {
122
+ // window.sdkInitialized = true;
123
+ // window.grailpay.open();
124
+ // }).catch(function(error) {
125
+ // console.log("❌ SDK init failed:", error);
126
+ // window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'error', data: error });
127
+ // });
128
+ // }
129
+ //
130
+ // function loadSDK() {
131
+ // const script = document.createElement('script');
132
+ // script.src = '\(sdkURL)';
133
+ // script.onload = function() {
134
+ // setTimeout(initializeSDK, 1000);
135
+ // };
136
+ // script.onerror = function(error) {
137
+ // console.log("❌ Failed to load SDK script");
138
+ // window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'error', data: 'Failed to load SDK script' });
139
+ // };
140
+ // document.head.appendChild(script);
141
+ // }
142
+ //
143
+ // document.addEventListener('DOMContentLoaded', loadSDK);
144
+ // </script>
145
+ // </head>
146
+ // <body style=\"margin:0;padding:0;\"></body>
147
+ // </html>
148
+ // """
149
+ //
150
+ //// let baseURL = URL(string: request.isSandbox
151
+ //// ? "https://bank-link-widget-sandbox.grailpay.com"
152
+ //// : "https://bank-link-widget.grailpay.com")
153
+ //
154
+ // let baseURL = URL(string: EnvironmentConfig.grailPayBaseURL)
155
+ //
156
+ // webView.loadHTMLString(html, baseURL: baseURL)
157
+ // }
158
+ //
159
+ // private func handleError(_ error: Error) {
160
+ // DispatchQueue.main.async {
161
+ // self.loadingIndicator.stopAnimating()
162
+ // self.onCompletion?(EasyPay.SDKResult(error: error as NSError))
163
+ // self.dismiss(animated: true)
164
+ // }
165
+ // }
166
+ //}
167
+ //
168
+ //// MARK: - WKNavigationDelegate
169
+ //extension GrailPayVC: WKNavigationDelegate {
170
+ // public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
171
+ // loadingIndicator.stopAnimating()
172
+ // }
173
+ //
174
+ // public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
175
+ // handleError(error)
176
+ // }
177
+ //}
178
+ //
179
+ //// MARK: - WKScriptMessageHandler
180
+ //extension GrailPayVC: WKScriptMessageHandler {
181
+ // public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
182
+ //
183
+ // guard let body = message.body as? [String: Any],
184
+ // let type = body["type"] as? String else {
185
+ // return
186
+ // }
187
+ //
188
+ // switch type {
189
+ // case "bankConnected":
190
+ // if let data = body["data"] as? [[String: Any]] {
191
+ // self.allLinkedAccounts = data
192
+ // }
193
+ //
194
+ // case "defaultAccountSelected":
195
+ // guard let selectedAccount = body["data"] as? [String: Any] else {
196
+ // return
197
+ // }
198
+ //
199
+ //
200
+ // if !didHandleBankConnection {
201
+ // didHandleBankConnection = true
202
+ // DispatchQueue.main.async {
203
+ // self.onCompletion?(EasyPay.SDKResult(type: .success, chargeData: ["data": [selectedAccount]]))
204
+ // self.dismiss(animated: true)
205
+ // }
206
+ // }
207
+ //
208
+ // case "linkExit":
209
+ // if didHandleBankConnection {
210
+ // return
211
+ // }
212
+ // DispatchQueue.main.async {
213
+ // self.onCompletion?(EasyPay.SDKResult(type: .cancelled))
214
+ // self.dismiss(animated: true)
215
+ // }
216
+ //
217
+ // case "error":
218
+ // let errorMessage = body["data"] as? String ?? "Unknown error"
219
+ // let error = NSError(domain: "GrailPayError", code: 0, userInfo: [NSLocalizedDescriptionKey: errorMessage])
220
+ // handleError(error)
221
+ //
222
+ // default:
223
+ // }
224
+ // }
225
+ //}
226
+ //
227
+ //// MARK: - WKUIDelegate
228
+ //extension GrailPayVC: WKUIDelegate {
229
+ // public func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration,
230
+ // for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
231
+ // if navigationAction.targetFrame == nil {
232
+ // webView.load(navigationAction.request)
233
+ // }
234
+ // return nil
235
+ // }
236
+ //}
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ import UIKit
248
+ import WebKit
249
+
250
+ public class GrailPayVC: UIViewController {
251
+
252
+ private var webView: WKWebView!
253
+ private var loadingIndicator: UIActivityIndicatorView!
254
+ private var request: GrailPayRequest
255
+ public var onCompletion: ((SDKResult) -> Void)?
256
+ private var didHandleBankConnection = false
257
+ private var allLinkedAccounts: [[String: Any]] = []
258
+
259
+ public init(request: GrailPayRequest) {
260
+ self.request = request
261
+ super.init(nibName: nil, bundle: nil)
262
+ }
263
+
264
+ required init?(coder: NSCoder) {
265
+ fatalError("init(coder:) has not been implemented")
266
+ }
267
+
268
+ override public func viewDidLoad() {
269
+ super.viewDidLoad()
270
+ setupUI()
271
+ loadGrailPaySDK()
272
+ }
273
+
274
+ private func setupUI() {
275
+ view.backgroundColor = .white
276
+
277
+ let config = WKWebViewConfiguration()
278
+ if #available(iOS 14.0, *) {
279
+ let webpagePreferences = WKWebpagePreferences()
280
+ webpagePreferences.allowsContentJavaScript = true
281
+ config.defaultWebpagePreferences = webpagePreferences
282
+ } else {
283
+ let preferences = WKPreferences()
284
+ preferences.javaScriptEnabled = true
285
+ config.preferences = preferences
286
+ }
287
+
288
+ config.websiteDataStore = WKWebsiteDataStore.default()
289
+ config.userContentController.add(self, name: "grailpayHandler")
290
+ config.allowsInlineMediaPlayback = true
291
+ config.mediaTypesRequiringUserActionForPlayback = []
292
+
293
+ webView = WKWebView(frame: view.bounds, configuration: config)
294
+ webView.navigationDelegate = self
295
+ webView.uiDelegate = self
296
+ webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
297
+ view.addSubview(webView)
298
+
299
+ loadingIndicator = UIActivityIndicatorView(style: .large)
300
+ loadingIndicator.center = view.center
301
+ loadingIndicator.hidesWhenStopped = true
302
+ view.addSubview(loadingIndicator)
303
+ }
304
+
305
+ private func loadGrailPaySDK() {
306
+ loadingIndicator.startAnimating()
307
+
308
+ let sdkURL = EnvironmentConfig.grailPaySDKURL
309
+ let baseURL = URL(string: EnvironmentConfig.grailPayBaseURL)
310
+
311
+ let html = """
312
+ <!DOCTYPE html>
313
+ <html>
314
+ <head>
315
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
316
+ <script>
317
+ window.sdkInitialized = false;
318
+
319
+ function initializeSDK() {
320
+ if (window.sdkInitialized) return;
321
+
322
+ if (typeof window.grailpay === 'undefined') {
323
+ window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'error', data: 'SDK not loaded' });
324
+ return;
325
+ }
326
+
327
+ window.grailpay.init({
328
+ token: '\(UserStoreSingleton.shared.bankWidgetKey ?? "")',
329
+ vendorId: '\(UserStoreSingleton.shared.vendorID ?? "")',
330
+ role: '\(request.role)',
331
+ timeout: \(request.timeout),
332
+ theme: {
333
+ branding_name: '\(request.brandingName)',
334
+ screens: {
335
+ finder: {
336
+ subtitle: '\(request.finderSubtitle)',
337
+ searchPlaceholder: '\(request.searchPlaceholder)'
338
+ }
339
+ }
340
+ },
341
+ onError: function(error) {
342
+ console.log("JS onError:", error);
343
+ window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'error', data: error });
344
+ },
345
+ onBankConnected: function(data) {
346
+ console.log("✅ Bank connected:", data);
347
+ window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'bankConnected', data: data });
348
+ },
349
+ onLinkedDefaultAccount: function(data) {
350
+ console.log("✅ Default Account selected:", data);
351
+ window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'defaultAccountSelected', data: data });
352
+ },
353
+ onLinkExit: function(data) {
354
+ console.log("⚠️ User exited:", data);
355
+ window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'linkExit', data: data });
356
+ }
357
+ }).then(function() {
358
+ window.sdkInitialized = true;
359
+ window.grailpay.open();
360
+ }).catch(function(error) {
361
+ console.log("❌ SDK init failed:", error);
362
+ window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'error', data: error });
363
+ });
364
+ }
365
+
366
+ function loadSDK() {
367
+ const script = document.createElement('script');
368
+ script.src = '\(sdkURL)';
369
+ script.onload = function() {
370
+ setTimeout(initializeSDK, 1000);
371
+ };
372
+ script.onerror = function(error) {
373
+ console.log("❌ Failed to load SDK script");
374
+ window.webkit.messageHandlers.grailpayHandler.postMessage({ type: 'error', data: 'Failed to load SDK script' });
375
+ };
376
+ document.head.appendChild(script);
377
+ }
378
+
379
+ document.addEventListener('DOMContentLoaded', loadSDK);
380
+ </script>
381
+ </head>
382
+ <body style="margin:0;padding:0;"></body>
383
+ </html>
384
+ """
385
+
386
+ webView.loadHTMLString(html, baseURL: baseURL)
387
+ }
388
+
389
+ private func handleError(_ error: Error) {
390
+ DispatchQueue.main.async {
391
+ self.loadingIndicator.stopAnimating()
392
+ let errorData: [String: Any] = [
393
+ "status": false,
394
+ "message": error.localizedDescription
395
+ ]
396
+ self.onCompletion?(SDKResult(type: .error, data: errorData as NSDictionary))
397
+ self.dismiss(animated: true)
398
+ }
399
+ }
400
+ }
401
+
402
+ // MARK: - WKNavigationDelegate
403
+ extension GrailPayVC: WKNavigationDelegate {
404
+ public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
405
+ loadingIndicator.stopAnimating()
406
+ }
407
+
408
+ public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
409
+ handleError(error)
410
+ }
411
+ }
412
+
413
+ // MARK: - WKScriptMessageHandler
414
+ extension GrailPayVC: WKScriptMessageHandler {
415
+ public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
416
+
417
+ guard let body = message.body as? [String: Any],
418
+ let type = body["type"] as? String else {
419
+ return
420
+ }
421
+
422
+ switch type {
423
+ case "bankConnected":
424
+ if let data = body["data"] as? [[String: Any]] {
425
+ self.allLinkedAccounts = data
426
+ }
427
+
428
+ case "defaultAccountSelected":
429
+ guard let selectedAccount = body["data"] as? [String: Any] else {
430
+ return
431
+ }
432
+
433
+
434
+ if !didHandleBankConnection {
435
+ didHandleBankConnection = true
436
+ DispatchQueue.main.async {
437
+ self.onCompletion?(SDKResult(type: .success, data: ["data": [selectedAccount]] as NSDictionary))
438
+ self.dismiss(animated: true)
439
+ }
440
+ }
441
+
442
+ case "linkExit":
443
+ if didHandleBankConnection {
444
+ return
445
+ }
446
+ DispatchQueue.main.async {
447
+ let cancelData: [String: Any] = [
448
+ "status": false,
449
+ "message": "User cancelled the payment"
450
+ ]
451
+ self.onCompletion?(SDKResult(type: .cancelled, data: cancelData as NSDictionary))
452
+ self.dismiss(animated: true)
453
+ }
454
+
455
+ case "error":
456
+ let errorMessage = body["data"] as? String ?? "Unknown error"
457
+ let error = NSError(domain: "GrailPayError", code: 0, userInfo: [NSLocalizedDescriptionKey: errorMessage])
458
+ handleError(error)
459
+
460
+ default:
461
+ break
462
+ }
463
+ }
464
+ }
465
+
466
+ // MARK: - WKUIDelegate
467
+ extension GrailPayVC: WKUIDelegate {
468
+ public func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration,
469
+ for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
470
+ if navigationAction.targetFrame == nil {
471
+ webView.load(navigationAction.request)
472
+ }
473
+ return nil
474
+ }
475
+ }