react-amwal-pay 0.1.13 → 0.1.14
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/ios/ReactAmwalPay.m
CHANGED
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
@interface RCT_EXTERN_MODULE(ReactAmwalPay, RCTEventEmitter)
|
|
5
5
|
|
|
6
|
-
RCT_EXTERN_METHOD(initiate:(NSDictionary *)config
|
|
7
|
-
resolver:(RCTPromiseResolveBlock)resolve
|
|
8
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
6
|
+
RCT_EXTERN_METHOD(initiate:(NSDictionary *)config)
|
|
9
7
|
|
|
10
|
-
RCT_EXTERN_METHOD(
|
|
8
|
+
RCT_EXTERN_METHOD(addListener:(NSString *)eventName)
|
|
11
9
|
|
|
12
|
-
RCT_EXTERN_METHOD(
|
|
10
|
+
RCT_EXTERN_METHOD(removeListeners:(double)count)
|
|
13
11
|
|
|
14
12
|
@end
|
package/ios/ReactAmwalPay.swift
CHANGED
|
@@ -1,11 +1,118 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import amwalsdk
|
|
3
3
|
import React
|
|
4
|
+
import UIKit
|
|
5
|
+
|
|
6
|
+
// MARK: - Fix UIViewController presentation for share sheets
|
|
7
|
+
public extension UIViewController {
|
|
8
|
+
static let swizzlePresentOnce: Void = {
|
|
9
|
+
let originalSelector = #selector(UIViewController.present(_:animated:completion:))
|
|
10
|
+
let swizzledSelector = #selector(UIViewController.swizzled_present(_:animated:completion:))
|
|
11
|
+
|
|
12
|
+
guard let originalMethod = class_getInstanceMethod(UIViewController.self, originalSelector),
|
|
13
|
+
let swizzledMethod = class_getInstanceMethod(UIViewController.self, swizzledSelector) else {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
method_exchangeImplementations(originalMethod, swizzledMethod)
|
|
18
|
+
}()
|
|
19
|
+
|
|
20
|
+
@objc dynamic func swizzled_present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) {
|
|
21
|
+
// Check if this view controller's view is in the window hierarchy
|
|
22
|
+
if self.view.window == nil {
|
|
23
|
+
print("⚠️ Attempting to present on VC not in hierarchy, finding correct presenter...")
|
|
24
|
+
// Find the correct view controller to present from
|
|
25
|
+
if let topVC = UIViewController.getTopMostViewController() {
|
|
26
|
+
topVC.swizzled_present(viewControllerToPresent, animated: flag, completion: completion)
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Check if we're already presenting something
|
|
32
|
+
if self.presentedViewController != nil {
|
|
33
|
+
print("⚠️ Already presenting, dismissing first...")
|
|
34
|
+
self.dismiss(animated: false) { [weak self] in
|
|
35
|
+
self?.swizzled_present(viewControllerToPresent, animated: flag, completion: completion)
|
|
36
|
+
}
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Call original implementation
|
|
41
|
+
self.swizzled_present(viewControllerToPresent, animated: flag, completion: completion)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static func getTopMostViewController() -> UIViewController? {
|
|
45
|
+
var topController: UIViewController?
|
|
46
|
+
|
|
47
|
+
if #available(iOS 13.0, *) {
|
|
48
|
+
let keyWindow = UIApplication.shared.connectedScenes
|
|
49
|
+
.compactMap { $0 as? UIWindowScene }
|
|
50
|
+
.flatMap { $0.windows }
|
|
51
|
+
.first { $0.isKeyWindow }
|
|
52
|
+
topController = keyWindow?.rootViewController
|
|
53
|
+
} else {
|
|
54
|
+
topController = UIApplication.shared.keyWindow?.rootViewController
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
while let presented = topController?.presentedViewController {
|
|
58
|
+
topController = presented
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return topController
|
|
62
|
+
}
|
|
63
|
+
}
|
|
4
64
|
|
|
5
65
|
@objc(ReactAmwalPay)
|
|
6
|
-
class ReactAmwalPay: RCTEventEmitter {
|
|
66
|
+
open class ReactAmwalPay: RCTEventEmitter {
|
|
7
67
|
private var hasListeners = false
|
|
8
68
|
|
|
69
|
+
// Initialize swizzling when the class is first loaded
|
|
70
|
+
private static let initializeSwizzling: Void = {
|
|
71
|
+
_ = UIViewController.swizzlePresentOnce
|
|
72
|
+
}()
|
|
73
|
+
|
|
74
|
+
// Initialize swizzling when the module is loaded
|
|
75
|
+
public override init() {
|
|
76
|
+
super.init()
|
|
77
|
+
_ = ReactAmwalPay.initializeSwizzling
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
open override func supportedEvents() -> [String]! {
|
|
81
|
+
return ["onResponse", "onCustomerId"]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
open override func startObserving() {
|
|
85
|
+
print("🔴 startObserving called - setting hasListeners = true")
|
|
86
|
+
hasListeners = true
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
open override func stopObserving() {
|
|
90
|
+
print("🔴 stopObserving called - setting hasListeners = false")
|
|
91
|
+
hasListeners = false
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private func emitOnResponse(_ params: [String: Any]) {
|
|
95
|
+
print("🔴 emitOnResponse called with params: \(params)")
|
|
96
|
+
print("🔴 hasListeners: \(hasListeners)")
|
|
97
|
+
if hasListeners {
|
|
98
|
+
print("🔴 Sending onResponse event to JS")
|
|
99
|
+
sendEvent(withName: "onResponse", body: params)
|
|
100
|
+
} else {
|
|
101
|
+
print("🔴 NOT sending - no listeners!")
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private func emitOnCustomerId(_ customerId: String?) {
|
|
106
|
+
print("🔴 emitOnCustomerId called with: \(customerId ?? "nil")")
|
|
107
|
+
print("🔴 hasListeners: \(hasListeners)")
|
|
108
|
+
if hasListeners {
|
|
109
|
+
print("🔴 Sending onCustomerId event to JS")
|
|
110
|
+
sendEvent(withName: "onCustomerId", body: customerId)
|
|
111
|
+
} else {
|
|
112
|
+
print("🔴 NOT sending - no listeners!")
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
9
116
|
private func mapEnvironment(environment: String) -> Config.Environment {
|
|
10
117
|
switch environment {
|
|
11
118
|
case "PROD": return .PROD
|
|
@@ -39,8 +146,6 @@ class ReactAmwalPay: RCTEventEmitter {
|
|
|
39
146
|
}
|
|
40
147
|
}
|
|
41
148
|
|
|
42
|
-
private var onResponseCallback: RCTResponseSenderBlock?
|
|
43
|
-
private var onCustomerIdCallback: RCTResponseSenderBlock?
|
|
44
149
|
private func prepareConfig(config: [String: Any]) -> Config {
|
|
45
150
|
// Handle additionValues
|
|
46
151
|
var additionValues: [String: String] = Config.generateDefaultAdditionValues()
|
|
@@ -50,7 +155,7 @@ class ReactAmwalPay: RCTEventEmitter {
|
|
|
50
155
|
additionValues[key] = value
|
|
51
156
|
}
|
|
52
157
|
}
|
|
53
|
-
|
|
158
|
+
|
|
54
159
|
return Config(
|
|
55
160
|
environment: mapEnvironment(environment: config["environment"] as? String ?? "PROD"),
|
|
56
161
|
sessionToken: config["sessionToken"] as? String ?? "",
|
|
@@ -68,56 +173,91 @@ class ReactAmwalPay: RCTEventEmitter {
|
|
|
68
173
|
}
|
|
69
174
|
|
|
70
175
|
@objc
|
|
71
|
-
func initiate(_ config: [String: Any]
|
|
72
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
73
|
-
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
176
|
+
open func initiate(_ config: [String: Any]) {
|
|
74
177
|
DispatchQueue.main.async {
|
|
75
178
|
do {
|
|
76
179
|
let sdkConfig = self.prepareConfig(config: config)
|
|
77
180
|
let sdk = AmwalSDK()
|
|
78
|
-
|
|
181
|
+
|
|
79
182
|
guard let rootVC = UIApplication.shared.keyWindow?.rootViewController else {
|
|
80
|
-
|
|
183
|
+
let errorData: [String: Any] = [
|
|
184
|
+
"data": [
|
|
185
|
+
"status": "ERROR",
|
|
186
|
+
"message": "No root view controller found"
|
|
187
|
+
]
|
|
188
|
+
]
|
|
189
|
+
self.emitOnResponse(errorData)
|
|
81
190
|
return
|
|
82
191
|
}
|
|
83
|
-
|
|
192
|
+
|
|
84
193
|
let sdkVC = try sdk.createViewController(
|
|
85
194
|
config: sdkConfig,
|
|
86
195
|
onResponse: { [weak self] response in
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
196
|
+
print("🟠 SDK onResponse callback fired!")
|
|
197
|
+
print("🟠 Response type: \(type(of: response))")
|
|
198
|
+
print("🟠 Response value: \(response ?? "nil")")
|
|
199
|
+
|
|
200
|
+
// The SDK returns a JSON string, we need to parse it
|
|
201
|
+
if let responseString = response as? String,
|
|
202
|
+
let data = responseString.data(using: .utf8),
|
|
203
|
+
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
|
|
204
|
+
print("🟠 Successfully parsed JSON string to dictionary")
|
|
205
|
+
self?.emitOnResponse(json)
|
|
206
|
+
} else if let responseDict = response as? [String: Any] {
|
|
207
|
+
print("🟠 Response is already a dictionary")
|
|
208
|
+
self?.emitOnResponse(responseDict)
|
|
209
|
+
} else {
|
|
210
|
+
print("🟠 Could not parse response, sending as-is")
|
|
211
|
+
let errorData: [String: Any] = [
|
|
212
|
+
"status": "error",
|
|
213
|
+
"message": "Invalid response format",
|
|
214
|
+
"rawResponse": String(describing: response)
|
|
215
|
+
]
|
|
216
|
+
self?.emitOnResponse(errorData)
|
|
217
|
+
}
|
|
218
|
+
},
|
|
93
219
|
onCustomerId: { [weak self] customerId in
|
|
94
|
-
|
|
95
|
-
|
|
220
|
+
print("🟠 SDK onCustomerId callback fired with: \(customerId ?? "nil")")
|
|
221
|
+
self?.emitOnCustomerId(customerId)
|
|
222
|
+
}
|
|
96
223
|
)
|
|
97
|
-
|
|
224
|
+
|
|
225
|
+
print("🟠 SDK ViewController created successfully")
|
|
226
|
+
print("🟠 About to present SDK ViewController...")
|
|
227
|
+
|
|
98
228
|
// Present modally (critical missing piece)
|
|
99
229
|
rootVC.present(sdkVC, animated: true)
|
|
100
|
-
|
|
101
|
-
resolve(true)
|
|
102
230
|
} catch {
|
|
103
231
|
print("Presentation failed: \(error.localizedDescription)")
|
|
104
|
-
|
|
232
|
+
let errorData: [String: Any] = [
|
|
233
|
+
"data": [
|
|
234
|
+
"status": "ERROR",
|
|
235
|
+
"message": error.localizedDescription
|
|
236
|
+
]
|
|
237
|
+
]
|
|
238
|
+
self.emitOnResponse(errorData)
|
|
105
239
|
}
|
|
106
240
|
}
|
|
107
241
|
}
|
|
108
242
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
override
|
|
243
|
+
@objc
|
|
244
|
+
open override func addListener(_ eventName: String) {
|
|
245
|
+
super.addListener(eventName)
|
|
246
|
+
print("🔴 addListener called for: \(eventName)")
|
|
247
|
+
if !hasListeners {
|
|
248
|
+
hasListeners = true
|
|
249
|
+
print("🔴 Set hasListeners = true")
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@objc
|
|
254
|
+
open override func removeListeners(_ count: Double) {
|
|
255
|
+
super.removeListeners(count)
|
|
256
|
+
print("🔴 removeListeners called with count: \(count)")
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@objc
|
|
260
|
+
public override static func requiresMainQueueSetup() -> Bool {
|
|
121
261
|
return true
|
|
122
262
|
}
|
|
123
263
|
}
|
|
@@ -61,14 +61,28 @@ class AmwalPaySDK {
|
|
|
61
61
|
setupEventListeners(config) {
|
|
62
62
|
// Remove any existing listeners
|
|
63
63
|
this.removeEventListeners();
|
|
64
|
+
console.log('🟢 Setting up event listeners...');
|
|
65
|
+
console.log('🟢 onResponse callback exists?', typeof config.onResponse === 'function');
|
|
66
|
+
console.log('🟢 onCustomerId callback exists?', typeof config.onCustomerId === 'function');
|
|
64
67
|
this.onResponseSubscription = onResponse(response => {
|
|
68
|
+
console.log('🟢 SDK onResponse listener triggered with:', response);
|
|
65
69
|
console.log('Received AmwalPayResponse:', response);
|
|
66
|
-
config.onResponse
|
|
70
|
+
if (config.onResponse) {
|
|
71
|
+
config.onResponse(response);
|
|
72
|
+
} else {
|
|
73
|
+
console.error('❌ config.onResponse is not a function!');
|
|
74
|
+
}
|
|
67
75
|
});
|
|
68
76
|
this.onCustomerIdSubscription = onCustomerId(customerId => {
|
|
77
|
+
console.log('🟢 SDK onCustomerId listener triggered with:', customerId);
|
|
69
78
|
console.log('Received customerId:', customerId);
|
|
70
|
-
config.onCustomerId
|
|
79
|
+
if (config.onCustomerId) {
|
|
80
|
+
config.onCustomerId(customerId);
|
|
81
|
+
} else {
|
|
82
|
+
console.error('❌ config.onCustomerId is not a function!');
|
|
83
|
+
}
|
|
71
84
|
});
|
|
85
|
+
console.log('🟢 Event listeners set up complete');
|
|
72
86
|
}
|
|
73
87
|
|
|
74
88
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initiate","onCustomerId","onResponse","NetworkClient","AmwalPaySDK","onResponseSubscription","onCustomerIdSubscription","constructor","getInstance","instance","startPayment","config","setupEventListeners","networkClient","console","log","environment","sessionToken","fetchSessionToken","merchantId","customerId","secureHash","completeConfig","JSON","stringify","error","dispose","removeEventListeners","response","remove"],"sourceRoot":"../../src","sources":["AmwalPaySDK.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,UAAU,QAA6B,YAAS;AACjF,OAAOC,aAAa,MAAM,4BAAyB;AAInD,MAAMC,WAAW,CAAC;EAGRC,sBAAsB,GAA6B,IAAI;EAEvDC,wBAAwB,GAA6B,IAAI;EAEzDC,WAAWA,CAAA,EAAG;IACpB;EAAA;EAIF,OAAOC,WAAWA,CAAA,EAAgB;IAChC,IAAI,CAACJ,WAAW,CAACK,QAAQ,EAAE;MACzBL,WAAW,CAACK,QAAQ,GAAG,IAAIL,WAAW,CAAC,CAAC;IAC1C;IACA,OAAOA,WAAW,CAACK,QAAQ;EAC7B;;EAEA;AACF;AACA;AACA;EACE,MAAMC,YAAYA,CAACC,MAA4C,EAAiB;IAC9E,IAAI;MACF;MACA,IAAI,CAACC,mBAAmB,CAACD,MAAM,CAAC;;MAEhC;MACA,MAAME,aAAa,GAAGV,aAAa,CAACK,WAAW,CAAC,CAAC;;MAEjD;MACAM,OAAO,CAACC,GAAG,CAAC,yCAAyC,EAAEJ,MAAM,CAACK,WAAW,CAAC;MAC1E,MAAMC,YAAY,GAAG,MAAMJ,aAAa,CAACK,iBAAiB,CACxDP,MAAM,CAACK,WAAW,EAClBL,MAAM,CAACQ,UAAU,EACjBR,MAAM,CAACS,UAAU,EACjBT,MAAM,CAACU,UACT,CAAC;MAEDP,OAAO,CAACC,GAAG,CAAC,uBAAuB,EAAEE,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;MAEzE,IAAI,CAACA,YAAY,EAAE;QACjB;QACA;MACF;;MAEA;MACA,MAAMK,cAA8B,GAAG;QACrC,GAAGX,MAAM;QACTM;MACF,CAAC;;MAED;MACAH,OAAO,CAACC,GAAG,CAAC,wCAAwC,EAAEQ,IAAI,CAACC,SAAS,CAACF,cAAc,CAAC,CAAC;MACrFtB,QAAQ,CAACsB,cAAc,CAAC;IAC1B,CAAC,CAAC,OAAOG,KAAK,EAAE;MACdX,OAAO,CAACW,KAAK,CAAC,yBAAyB,EAAEA,KAAK,CAAC;IACjD;EACF;EAEAC,OAAOA,CAAA,EAAS;IACd;IACA,IAAI,CAACC,oBAAoB,CAAC,CAAC;EAC7B;;EAEA;AACF;AACA;AACA;EACUf,mBAAmBA,CAACD,MAA4C,EAAQ;IAC9E;IACA,IAAI,CAACgB,oBAAoB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"names":["initiate","onCustomerId","onResponse","NetworkClient","AmwalPaySDK","onResponseSubscription","onCustomerIdSubscription","constructor","getInstance","instance","startPayment","config","setupEventListeners","networkClient","console","log","environment","sessionToken","fetchSessionToken","merchantId","customerId","secureHash","completeConfig","JSON","stringify","error","dispose","removeEventListeners","response","remove"],"sourceRoot":"../../src","sources":["AmwalPaySDK.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmwalPaySDK.d.ts","sourceRoot":"","sources":["../../../src/AmwalPaySDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAKlF,cAAM,WAAW;IACf,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IAErC,OAAO,CAAC,sBAAsB,CAAkC;IAEhE,OAAO,CAAC,wBAAwB,CAAkC;IAElE,OAAO;IAKP,MAAM,CAAC,WAAW,IAAI,WAAW;IAOjC;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC/E,OAAO,IAAI,IAAI;IAKf;;;OAGG;IACH,OAAO,CAAC,mBAAmB;
|
|
1
|
+
{"version":3,"file":"AmwalPaySDK.d.ts","sourceRoot":"","sources":["../../../src/AmwalPaySDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAKlF,cAAM,WAAW;IACf,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IAErC,OAAO,CAAC,sBAAsB,CAAkC;IAEhE,OAAO,CAAC,wBAAwB,CAAkC;IAElE,OAAO;IAKP,MAAM,CAAC,WAAW,IAAI,WAAW;IAOjC;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC/E,OAAO,IAAI,IAAI;IAKf;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IA+B3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAM7B;AAED,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
package/src/AmwalPaySDK.ts
CHANGED
|
@@ -77,15 +77,31 @@ class AmwalPaySDK {
|
|
|
77
77
|
// Remove any existing listeners
|
|
78
78
|
this.removeEventListeners();
|
|
79
79
|
|
|
80
|
+
console.log('🟢 Setting up event listeners...');
|
|
81
|
+
console.log('🟢 onResponse callback exists?', typeof config.onResponse === 'function');
|
|
82
|
+
console.log('🟢 onCustomerId callback exists?', typeof config.onCustomerId === 'function');
|
|
83
|
+
|
|
80
84
|
this.onResponseSubscription = onResponse((response) => {
|
|
85
|
+
console.log('🟢 SDK onResponse listener triggered with:', response);
|
|
81
86
|
console.log('Received AmwalPayResponse:', response);
|
|
82
|
-
config.onResponse
|
|
87
|
+
if (config.onResponse) {
|
|
88
|
+
config.onResponse(response);
|
|
89
|
+
} else {
|
|
90
|
+
console.error('❌ config.onResponse is not a function!');
|
|
91
|
+
}
|
|
83
92
|
});
|
|
84
93
|
|
|
85
94
|
this.onCustomerIdSubscription = onCustomerId((customerId) => {
|
|
95
|
+
console.log('🟢 SDK onCustomerId listener triggered with:', customerId);
|
|
86
96
|
console.log('Received customerId:', customerId);
|
|
87
|
-
config.onCustomerId
|
|
97
|
+
if (config.onCustomerId) {
|
|
98
|
+
config.onCustomerId(customerId);
|
|
99
|
+
} else {
|
|
100
|
+
console.error('❌ config.onCustomerId is not a function!');
|
|
101
|
+
}
|
|
88
102
|
});
|
|
103
|
+
|
|
104
|
+
console.log('🟢 Event listeners set up complete');
|
|
89
105
|
}
|
|
90
106
|
|
|
91
107
|
/**
|