react-amwal-pay 0.1.16 → 0.1.17

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.
@@ -258,7 +258,8 @@ open class ReactAmwalPay: RCTEventEmitter {
258
258
  transactionType: mapTransactionType(transactionType: config["transactionType"] as? String ?? "CARD_WALLET"),
259
259
  transactionId: config["transactionId"] as? String ?? Config.generateTransactionId(),
260
260
  additionValues: additionValues,
261
- merchantReference: config["merchantReference"] as? String
261
+ merchantReference: config["merchantReference"] as? String,
262
+ secureHash: config["secureHash"] as? String
262
263
  )
263
264
  }
264
265
 
@@ -284,29 +285,31 @@ open class ReactAmwalPay: RCTEventEmitter {
284
285
  config: sdkConfig,
285
286
  onResponse: { [weak self] response in
286
287
  print("🟠 SDK onResponse callback fired!")
287
- print("🟠 Response type: \(type(of: response))")
288
288
  print("🟠 Response value: \(response ?? "nil")")
289
289
 
290
- // Dismiss SDK window when payment completes
290
+ // Always dismiss SDK window when this callback fires
291
291
  DispatchQueue.main.async {
292
292
  self?.dismissSDKWindow()
293
293
  }
294
294
 
295
+ // nil response means SDK was dismissed without completing a payment
296
+ // (e.g., error during initialization). Don't emit to React Native.
297
+ guard let response = response else {
298
+ print("🟠 nil response - SDK dismissed without payment, not emitting to JS")
299
+ return
300
+ }
301
+
295
302
  // The SDK returns a JSON string, we need to parse it
296
- if let responseString = response as? String,
297
- let data = responseString.data(using: .utf8),
303
+ if let data = response.data(using: .utf8),
298
304
  let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
299
305
  print("🟠 Successfully parsed JSON string to dictionary")
300
306
  self?.emitOnResponse(json)
301
- } else if let responseDict = response as? [String: Any] {
302
- print("🟠 Response is already a dictionary")
303
- self?.emitOnResponse(responseDict)
304
307
  } else {
305
- print("🟠 Could not parse response, sending as-is")
308
+ print("🟠 Could not parse response as JSON, sending error")
306
309
  let errorData: [String: Any] = [
307
310
  "status": "error",
308
311
  "message": "Invalid response format",
309
- "rawResponse": String(describing: response)
312
+ "rawResponse": response
310
313
  ]
311
314
  self?.emitOnResponse(errorData)
312
315
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-amwal-pay",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "amwal pay",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",