react-amwal-pay 0.1.14 → 0.1.15

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/README.md CHANGED
@@ -170,7 +170,10 @@ const config: AmwalPayConfig = {
170
170
  merchantReference: 'optional-merchant-reference', // optional: merchant reference for transaction tracking
171
171
  additionValues: { // optional: custom key-value pairs for SDK configuration
172
172
  merchantIdentifier: 'merchant.applepay.amwalpay', // for Apple Pay configuration
173
- customKey: 'customValue' // add more as needed
173
+ useBottomSheetDesign: 'true', // use bottom sheet design (v2)
174
+ primaryColor: '#FF5733', // custom primary color
175
+ secondaryColor: '#33FF57', // custom secondary color
176
+ ignoreReceipt: 'false' // show receipt after transaction
174
177
  },
175
178
  onCustomerId(customerId) {
176
179
  console.log('Customer ID:', customerId);
@@ -236,7 +239,32 @@ The SDK supports `additionValues` parameter for passing custom key-value pairs t
236
239
  The SDK automatically provides default values:
237
240
  - `merchantIdentifier`: "merchant.applepay.amwalpay" (used for Apple Pay configuration)
238
241
 
239
- ### Usage
242
+ ### Available Configuration Options
243
+
244
+ You can customize the SDK behavior using the following `additionValues` keys:
245
+
246
+ #### UI Customization
247
+ - **`useBottomSheetDesign`**: `'true'` | `'false'` (default: `'false'`)
248
+ - Controls the payment screen design
249
+ - `'true'`: Uses the newer bottom sheet design (v2)
250
+ - `'false'`: Uses the original full-screen design
251
+
252
+ - **`primaryColor`**: Hex color string (e.g., `'#FF5733'`)
253
+ - Sets the primary theme color for the SDK UI
254
+
255
+ - **`secondaryColor`**: Hex color string (e.g., `'#33FF57'`)
256
+ - Sets the secondary theme color for the SDK UI
257
+
258
+ #### Payment Flow
259
+ - **`ignoreReceipt`**: `'true'` | `'false'` (default: `'false'`)
260
+ - Controls whether to show the receipt screen after transaction
261
+ - `'true'`: Skips the receipt display
262
+ - `'false'`: Shows the receipt screen
263
+
264
+ - **`merchantIdentifier`**: String (default: `'merchant.applepay.amwalpay'`)
265
+ - Apple Pay merchant identifier for iOS
266
+
267
+ ### Usage Examples
240
268
 
241
269
  ```js
242
270
  // Using default additionValues (automatically applied)
@@ -245,18 +273,31 @@ const config = {
245
273
  // additionValues will automatically include merchantIdentifier
246
274
  };
247
275
 
248
- // Using custom additionValues
276
+ // Using custom additionValues with UI customization
249
277
  const customConfig = {
250
278
  // ... other configuration
251
279
  additionValues: {
252
- merchantIdentifier: 'merchant.custom.identifier',
253
- customKey: 'customValue'
280
+ useBottomSheetDesign: 'true',
281
+ primaryColor: '#FF5733',
282
+ secondaryColor: '#33FF57',
283
+ ignoreReceipt: 'false',
284
+ merchantIdentifier: 'merchant.custom.identifier'
285
+ }
286
+ };
287
+
288
+ // Minimal configuration with bottom sheet design
289
+ const minimalConfig = {
290
+ // ... other configuration
291
+ additionValues: {
292
+ useBottomSheetDesign: 'true'
254
293
  }
255
294
  };
256
295
  ```
257
296
 
258
297
  Custom `additionValues` will be merged with defaults, with custom values taking precedence.
259
298
 
299
+ **Note:** All boolean values should be passed as strings (`'true'` or `'false'`).
300
+
260
301
  ## Configuration
261
302
 
262
303
  The `AmwalPayConfig` interface includes the following properties:
@@ -3,6 +3,70 @@ import amwalsdk
3
3
  import React
4
4
  import UIKit
5
5
 
6
+ // MARK: - Container view controller that keeps SDK alive during 3DS presentation
7
+ /// This container wraps the SDK view controller as a child
8
+ /// When 3DS opens its WebView, it can present on top without dismissing the SDK
9
+ class ShareableContainerViewController: UIViewController {
10
+ private let sdkViewController: UIViewController
11
+
12
+ init(sdkViewController: UIViewController) {
13
+ self.sdkViewController = sdkViewController
14
+ super.init(nibName: nil, bundle: nil)
15
+ }
16
+
17
+ required init?(coder: NSCoder) {
18
+ fatalError("init(coder:) has not been implemented")
19
+ }
20
+
21
+ override func viewDidLoad() {
22
+ super.viewDidLoad()
23
+
24
+ // Add SDK view controller as child - this keeps it alive during 3DS presentation
25
+ addChild(sdkViewController)
26
+ view.addSubview(sdkViewController.view)
27
+ sdkViewController.view.frame = view.bounds
28
+ sdkViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
29
+ sdkViewController.didMove(toParent: self)
30
+
31
+ view.backgroundColor = .clear
32
+ sdkViewController.view.backgroundColor = .clear
33
+
34
+ // Enable presentation context to handle 3DS WebView presentation
35
+ // This is critical: allows 3DS WebView to present on top without dismissing the SDK
36
+ definesPresentationContext = true
37
+ providesPresentationContextTransitionStyle = true
38
+
39
+ // Ensure the SDK view controller also allows nested presentations
40
+ // This prevents it from being dismissed when 3DS presents its WebView
41
+ sdkViewController.definesPresentationContext = true
42
+ sdkViewController.providesPresentationContextTransitionStyle = true
43
+ }
44
+
45
+ override func viewDidAppear(_ animated: Bool) {
46
+ super.viewDidAppear(animated)
47
+ // Ensure container is ready for nested presentations
48
+ }
49
+
50
+ private func topmostPresentedViewController() -> UIViewController {
51
+ var topController: UIViewController = self
52
+ while let presented = topController.presentedViewController {
53
+ topController = presented
54
+ }
55
+ return topController
56
+ }
57
+
58
+ override func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) {
59
+ // If already presenting, present from the topmost controller
60
+ // This allows 3DS WebView to present on top without dismissing the SDK
61
+ if let presented = presentedViewController {
62
+ let topmost = topmostPresentedViewController()
63
+ topmost.present(viewControllerToPresent, animated: flag, completion: completion)
64
+ } else {
65
+ super.present(viewControllerToPresent, animated: flag, completion: completion)
66
+ }
67
+ }
68
+ }
69
+
6
70
  // MARK: - Fix UIViewController presentation for share sheets
7
71
  public extension UIViewController {
8
72
  static let swizzlePresentOnce: Void = {
@@ -28,8 +92,18 @@ public extension UIViewController {
28
92
  }
29
93
  }
30
94
 
31
- // Check if we're already presenting something
32
- if self.presentedViewController != nil {
95
+ // Special handling for ShareableContainerViewController and its children
96
+ // If presenting from a child of ShareableContainerViewController, forward to container
97
+ if let container = findShareableContainer() {
98
+ if container != self {
99
+ // We're a child of the container, forward to container
100
+ container.swizzled_present(viewControllerToPresent, animated: flag, completion: completion)
101
+ return
102
+ }
103
+ // We ARE the container - allow nested presentations
104
+ // Don't auto-dismiss, just present on top
105
+ } else if self.presentedViewController != nil && !self.definesPresentationContext {
106
+ // Not a container, and already presenting - auto-dismiss
33
107
  print("⚠️ Already presenting, dismissing first...")
34
108
  self.dismiss(animated: false) { [weak self] in
35
109
  self?.swizzled_present(viewControllerToPresent, animated: flag, completion: completion)
@@ -41,6 +115,21 @@ public extension UIViewController {
41
115
  self.swizzled_present(viewControllerToPresent, animated: flag, completion: completion)
42
116
  }
43
117
 
118
+ // Helper to find ShareableContainerViewController in parent hierarchy
119
+ private func findShareableContainer() -> ShareableContainerViewController? {
120
+ var current: UIViewController? = self
121
+ while let parent = current?.parent {
122
+ if let container = parent as? ShareableContainerViewController {
123
+ return container
124
+ }
125
+ current = parent
126
+ }
127
+ if let container = self as? ShareableContainerViewController {
128
+ return container
129
+ }
130
+ return nil
131
+ }
132
+
44
133
  static func getTopMostViewController() -> UIViewController? {
45
134
  var topController: UIViewController?
46
135
 
@@ -65,6 +154,7 @@ public extension UIViewController {
65
154
  @objc(ReactAmwalPay)
66
155
  open class ReactAmwalPay: RCTEventEmitter {
67
156
  private var hasListeners = false
157
+ private var sdkWindow: UIWindow? // Separate window for SDK to avoid modal dismissal issues
68
158
 
69
159
  // Initialize swizzling when the class is first loaded
70
160
  private static let initializeSwizzling: Void = {
@@ -197,6 +287,11 @@ open class ReactAmwalPay: RCTEventEmitter {
197
287
  print("🟠 Response type: \(type(of: response))")
198
288
  print("🟠 Response value: \(response ?? "nil")")
199
289
 
290
+ // Dismiss SDK window when payment completes
291
+ DispatchQueue.main.async {
292
+ self?.dismissSDKWindow()
293
+ }
294
+
200
295
  // The SDK returns a JSON string, we need to parse it
201
296
  if let responseString = response as? String,
202
297
  let data = responseString.data(using: .utf8),
@@ -222,11 +317,41 @@ open class ReactAmwalPay: RCTEventEmitter {
222
317
  }
223
318
  )
224
319
 
225
- print("🟠 SDK ViewController created successfully")
226
- print("🟠 About to present SDK ViewController...")
320
+ // Ensure transparency
321
+ sdkVC.view.backgroundColor = .clear
322
+ sdkVC.view.isOpaque = false
323
+
324
+ // Wrap SDK view controller in container
325
+ let containerVC = ShareableContainerViewController(sdkViewController: sdkVC)
326
+ containerVC.view.backgroundColor = .clear
327
+
328
+ print("🟠 SDK ViewController wrapped in container")
329
+ print("🟠 Creating separate window for SDK...")
227
330
 
228
- // Present modally (critical missing piece)
229
- rootVC.present(sdkVC, animated: true)
331
+ // Create a separate window for the SDK
332
+ // This prevents modal presentation issues - SDK lives in its own window
333
+ // 3DS can present on top without affecting the SDK
334
+ if #available(iOS 13.0, *) {
335
+ if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
336
+ self.sdkWindow = UIWindow(windowScene: windowScene)
337
+ }
338
+ } else {
339
+ self.sdkWindow = UIWindow(frame: UIScreen.main.bounds)
340
+ }
341
+
342
+ guard let sdkWindow = self.sdkWindow else {
343
+ print("🟠 Failed to create SDK window, falling back to modal presentation")
344
+ rootVC.present(containerVC, animated: true)
345
+ return
346
+ }
347
+
348
+ sdkWindow.rootViewController = containerVC
349
+ sdkWindow.windowLevel = .normal + 1 // Above main window
350
+ sdkWindow.backgroundColor = .clear
351
+ sdkWindow.isOpaque = false
352
+ sdkWindow.makeKeyAndVisible()
353
+
354
+ print("🟠 SDK window created and made visible")
230
355
  } catch {
231
356
  print("Presentation failed: \(error.localizedDescription)")
232
357
  let errorData: [String: Any] = [
@@ -260,4 +385,12 @@ open class ReactAmwalPay: RCTEventEmitter {
260
385
  public override static func requiresMainQueueSetup() -> Bool {
261
386
  return true
262
387
  }
388
+
389
+ // Dismiss SDK window when payment completes
390
+ private func dismissSDKWindow() {
391
+ print("🟠 Dismissing SDK window...")
392
+ sdkWindow?.isHidden = true
393
+ sdkWindow?.rootViewController = nil
394
+ sdkWindow = nil
395
+ }
263
396
  }
@@ -18,7 +18,12 @@ export let TransactionType = /*#__PURE__*/function (TransactionType) {
18
18
  return TransactionType;
19
19
  }({});
20
20
 
21
- // This interface is for JavaScript side only, not for the native module spec
21
+ /**
22
+ * Configuration interface for Amwal Pay SDK
23
+ *
24
+ * @interface AmwalPayConfig
25
+ * @description Complete configuration for initializing and starting a payment session
26
+ */
22
27
 
23
28
  // This is the configuration that will be passed to the native module
24
29
 
@@ -1 +1 @@
1
- {"version":3,"names":["TurboModuleRegistry","Environment","Currency","TransactionType","getEnforcing"],"sourceRoot":"../../src","sources":["NativeReactAmwalPay.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAElD,WAAYC,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAMvB,WAAYC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAIpB,WAAYC,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;;AAY3B;;AAmBA;;AAwBA,eAAeH,mBAAmB,CAACI,YAAY,CAAO,eAAe,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TurboModuleRegistry","Environment","Currency","TransactionType","getEnforcing"],"sourceRoot":"../../src","sources":["NativeReactAmwalPay.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAElD,WAAYC,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAMvB,WAAYC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAIpB,WAAYC,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;;AAY3B;AACA;AACA;AACA;AACA;AACA;;AAsDA;;AAwBA,eAAeH,mBAAmB,CAACI,YAAY,CAAO,eAAe,CAAC","ignoreList":[]}
@@ -17,23 +17,64 @@ export interface AmwalPayResponse {
17
17
  message: string;
18
18
  data?: Object;
19
19
  }
20
+ /**
21
+ * Configuration interface for Amwal Pay SDK
22
+ *
23
+ * @interface AmwalPayConfig
24
+ * @description Complete configuration for initializing and starting a payment session
25
+ */
20
26
  export interface AmwalPayConfig {
27
+ /** Target environment (SIT, UAT, or PROD) */
21
28
  environment: Environment;
29
+ /** Secure hash for authentication */
22
30
  secureHash: string;
31
+ /** Transaction currency */
23
32
  currency: Currency;
33
+ /** Transaction amount as string (e.g., "100.000") */
24
34
  amount: string;
35
+ /** Merchant identifier */
25
36
  merchantId: string;
37
+ /** Terminal identifier */
26
38
  terminalId: string;
39
+ /** Locale for UI language ('en' or 'ar') */
27
40
  locale: string;
41
+ /** Optional customer identifier */
28
42
  customerId: string | null;
43
+ /** Type of transaction (NFC, CARD_WALLET, APPLE_PAY) */
29
44
  transactionType: TransactionType;
45
+ /** Optional session token (auto-fetched if not provided) */
30
46
  sessionToken?: string;
47
+ /** Optional transaction ID (auto-generated if not provided) */
31
48
  transactionId?: string;
49
+ /**
50
+ * Optional additional configuration values
51
+ *
52
+ * Supported keys:
53
+ * - `useBottomSheetDesign`: 'true' | 'false' - Use bottom sheet design (v2) instead of full screen
54
+ * - `ignoreReceipt`: 'true' | 'false' - Skip receipt display after transaction
55
+ * - `primaryColor`: Hex color string (e.g., '#FF5733') - Primary theme color
56
+ * - `secondaryColor`: Hex color string (e.g., '#33FF57') - Secondary theme color
57
+ * - `merchantIdentifier`: String - Apple Pay merchant identifier (default: 'merchant.applepay.amwalpay')
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * additionValues: {
62
+ * useBottomSheetDesign: 'true',
63
+ * primaryColor: '#1E88E5',
64
+ * secondaryColor: '#FFC107',
65
+ * ignoreReceipt: 'false',
66
+ * merchantIdentifier: 'merchant.applepay.amwalpay'
67
+ * }
68
+ * ```
69
+ */
32
70
  additionValues?: {
33
71
  [key: string]: string;
34
72
  };
73
+ /** Optional merchant reference for transaction tracking */
35
74
  merchantReference?: string;
75
+ /** Callback for payment response */
36
76
  onResponse: (response: AmwalPayResponse) => void;
77
+ /** Callback for customer ID updates */
37
78
  onCustomerId: (customerId: string) => void;
38
79
  }
39
80
  export interface AmwalPayNativeConfig {
@@ -1 +1 @@
1
- {"version":3,"file":"NativeReactAmwalPay.d.ts","sourceRoot":"","sources":["../../../src/NativeReactAmwalPay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,oBAAY,WAAW;IACrB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED,oBAAY,QAAQ;IAClB,GAAG,QAAQ;CACZ;AAED,oBAAY,eAAe;IACzB,GAAG,QAAQ;IACX,WAAW,gBAAgB;IAC3B,SAAS,cAAc;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,eAAe,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACjD,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAGD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AAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IAEvC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC7C,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;;AAED,wBAAuE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-amwal-pay",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "amwal pay",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -4,7 +4,7 @@ import { TurboModuleRegistry } from 'react-native';
4
4
  export enum Environment {
5
5
  SIT = 'SIT',
6
6
  UAT = 'UAT',
7
- PROD = 'PROD'
7
+ PROD = 'PROD',
8
8
  }
9
9
 
10
10
  export enum Currency {
@@ -14,7 +14,7 @@ export enum Currency {
14
14
  export enum TransactionType {
15
15
  NFC = 'NFC',
16
16
  CARD_WALLET = 'CARD_WALLET',
17
- APPLE_PAY = 'APPLE_PAY'
17
+ APPLE_PAY = 'APPLE_PAY',
18
18
  }
19
19
 
20
20
  export interface AmwalPayResponse {
@@ -23,22 +23,62 @@ export interface AmwalPayResponse {
23
23
  data?: Object; // Changed from 'any' to 'Object'
24
24
  }
25
25
 
26
- // This interface is for JavaScript side only, not for the native module spec
26
+ /**
27
+ * Configuration interface for Amwal Pay SDK
28
+ *
29
+ * @interface AmwalPayConfig
30
+ * @description Complete configuration for initializing and starting a payment session
31
+ */
27
32
  export interface AmwalPayConfig {
33
+ /** Target environment (SIT, UAT, or PROD) */
28
34
  environment: Environment;
35
+ /** Secure hash for authentication */
29
36
  secureHash: string;
37
+ /** Transaction currency */
30
38
  currency: Currency;
39
+ /** Transaction amount as string (e.g., "100.000") */
31
40
  amount: string;
41
+ /** Merchant identifier */
32
42
  merchantId: string;
43
+ /** Terminal identifier */
33
44
  terminalId: string;
45
+ /** Locale for UI language ('en' or 'ar') */
34
46
  locale: string;
47
+ /** Optional customer identifier */
35
48
  customerId: string | null;
49
+ /** Type of transaction (NFC, CARD_WALLET, APPLE_PAY) */
36
50
  transactionType: TransactionType;
51
+ /** Optional session token (auto-fetched if not provided) */
37
52
  sessionToken?: string;
53
+ /** Optional transaction ID (auto-generated if not provided) */
38
54
  transactionId?: string;
55
+ /**
56
+ * Optional additional configuration values
57
+ *
58
+ * Supported keys:
59
+ * - `useBottomSheetDesign`: 'true' | 'false' - Use bottom sheet design (v2) instead of full screen
60
+ * - `ignoreReceipt`: 'true' | 'false' - Skip receipt display after transaction
61
+ * - `primaryColor`: Hex color string (e.g., '#FF5733') - Primary theme color
62
+ * - `secondaryColor`: Hex color string (e.g., '#33FF57') - Secondary theme color
63
+ * - `merchantIdentifier`: String - Apple Pay merchant identifier (default: 'merchant.applepay.amwalpay')
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * additionValues: {
68
+ * useBottomSheetDesign: 'true',
69
+ * primaryColor: '#1E88E5',
70
+ * secondaryColor: '#FFC107',
71
+ * ignoreReceipt: 'false',
72
+ * merchantIdentifier: 'merchant.applepay.amwalpay'
73
+ * }
74
+ * ```
75
+ */
39
76
  additionValues?: { [key: string]: string };
77
+ /** Optional merchant reference for transaction tracking */
40
78
  merchantReference?: string;
79
+ /** Callback for payment response */
41
80
  onResponse: (response: AmwalPayResponse) => void;
81
+ /** Callback for customer ID updates */
42
82
  onCustomerId: (customerId: string) => void;
43
83
  }
44
84