react-native-payengine 2.0.16 → 2.0.18-alpha.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 (155) hide show
  1. package/README.md +96 -65
  2. package/android/.gradle/checksums/checksums.lock +0 -0
  3. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  5. package/android/build.gradle +2 -2
  6. package/android/src/main/java/com/reactnativepayengine/v2/RNPayEngineNative.kt +65 -3
  7. package/android/src/main/java/com/reactnativepayengine/v2/securefields/RNPEEvents.kt +1 -0
  8. package/android/src/main/java/com/reactnativepayengine/v2/securefields/bankaccount/RNBankAccountViewManager.kt +16 -3
  9. package/android/src/main/java/com/reactnativepayengine/v2/securefields/creditcard/RNPECreditCardViewManager.kt +15 -4
  10. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/KDataCollector.h +4 -25
  11. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/KountAnalyticsViewController.h +0 -20
  12. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/KountPrivate.h +61 -0
  13. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +430 -133
  14. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Info.plist +0 -0
  15. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.abi.json +1848 -5121
  16. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +35 -117
  17. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface-e +35 -117
  18. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  19. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface +35 -117
  20. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface-e +35 -117
  21. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/PayEngineSDK +0 -0
  22. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Info.plist +0 -0
  23. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/KDataCollector.h +4 -25
  24. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/KountAnalyticsViewController.h +0 -20
  25. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/KountPrivate.h +61 -0
  26. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +860 -266
  27. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Info.plist +0 -0
  28. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +1848 -5121
  29. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +35 -117
  30. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface-e +35 -117
  31. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  32. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +35 -117
  33. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface-e +35 -117
  34. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1848 -5121
  35. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +35 -117
  36. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface-e +35 -117
  37. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  38. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +35 -117
  39. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface-e +35 -117
  40. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/PayEngineSDK +0 -0
  41. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Info.plist +0 -0
  42. package/ios/Sources/Classes/RNPEEventEmitter.swift +1 -1
  43. package/ios/Sources/Classes/RNPayEngineNative.swift +125 -64
  44. package/ios/Sources/Classes/SecureFields/RNPEEvents.swift +1 -0
  45. package/ios/Sources/Payengine.m +6 -0
  46. package/lib/commonjs/components/PayEngine.js +1 -1
  47. package/lib/commonjs/components/PayEngine.js.map +1 -1
  48. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js +124 -0
  49. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  50. package/lib/commonjs/components/v2/ApplePay/PEApplePayInterfaces.js +78 -0
  51. package/lib/commonjs/components/v2/ApplePay/PEApplePayInterfaces.js.map +1 -1
  52. package/lib/commonjs/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -1
  53. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js +53 -0
  54. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  55. package/lib/commonjs/components/v2/PEPaymentRequest.js +121 -0
  56. package/lib/commonjs/components/v2/PEPaymentRequest.js.map +1 -1
  57. package/lib/commonjs/components/v2/PayEngineNative.js +182 -4
  58. package/lib/commonjs/components/v2/PayEngineNative.js.map +1 -1
  59. package/lib/commonjs/components/v2/PayEngineProvider.js +52 -0
  60. package/lib/commonjs/components/v2/PayEngineProvider.js.map +1 -1
  61. package/lib/commonjs/components/v2/SecureFields/BankAccountView.js +71 -0
  62. package/lib/commonjs/components/v2/SecureFields/BankAccountView.js.map +1 -1
  63. package/lib/commonjs/components/v2/SecureFields/CreditCardView.js +82 -0
  64. package/lib/commonjs/components/v2/SecureFields/CreditCardView.js.map +1 -1
  65. package/lib/commonjs/components/v2/SecureFields/IPEField.js.map +1 -1
  66. package/lib/commonjs/components/v2/SecureFields/ITokenizationData.js.map +1 -1
  67. package/lib/commonjs/components/v2/SecureFields/PEBankAccount.js.map +1 -1
  68. package/lib/commonjs/components/v2/SecureFields/PECard.js.map +1 -1
  69. package/lib/commonjs/components/v2/SecureFields/PEKeyboardType.js +20 -3
  70. package/lib/commonjs/components/v2/SecureFields/PEKeyboardType.js.map +1 -1
  71. package/lib/commonjs/index.js +17 -13
  72. package/lib/commonjs/index.js.map +1 -1
  73. package/lib/commonjs/interfaces/index.js +20 -0
  74. package/lib/commonjs/interfaces/index.js.map +1 -1
  75. package/lib/commonjs/utils/index.js +26 -0
  76. package/lib/commonjs/utils/index.js.map +1 -1
  77. package/lib/module/components/PayEngine.js +1 -1
  78. package/lib/module/components/PayEngine.js.map +1 -1
  79. package/lib/module/components/v2/ApplePay/PEApplePayButton.js +124 -0
  80. package/lib/module/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  81. package/lib/module/components/v2/ApplePay/PEApplePayInterfaces.js +75 -0
  82. package/lib/module/components/v2/ApplePay/PEApplePayInterfaces.js.map +1 -1
  83. package/lib/module/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -1
  84. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js +53 -0
  85. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  86. package/lib/module/components/v2/PEPaymentRequest.js +119 -0
  87. package/lib/module/components/v2/PEPaymentRequest.js.map +1 -1
  88. package/lib/module/components/v2/PayEngineNative.js +184 -5
  89. package/lib/module/components/v2/PayEngineNative.js.map +1 -1
  90. package/lib/module/components/v2/PayEngineProvider.js +51 -0
  91. package/lib/module/components/v2/PayEngineProvider.js.map +1 -1
  92. package/lib/module/components/v2/SecureFields/BankAccountView.js +71 -0
  93. package/lib/module/components/v2/SecureFields/BankAccountView.js.map +1 -1
  94. package/lib/module/components/v2/SecureFields/CreditCardView.js +82 -0
  95. package/lib/module/components/v2/SecureFields/CreditCardView.js.map +1 -1
  96. package/lib/module/components/v2/SecureFields/IPEField.js.map +1 -1
  97. package/lib/module/components/v2/SecureFields/ITokenizationData.js.map +1 -1
  98. package/lib/module/components/v2/SecureFields/PEBankAccount.js.map +1 -1
  99. package/lib/module/components/v2/SecureFields/PECard.js.map +1 -1
  100. package/lib/module/components/v2/SecureFields/PEKeyboardType.js +16 -1
  101. package/lib/module/components/v2/SecureFields/PEKeyboardType.js.map +1 -1
  102. package/lib/module/index.js +10 -5
  103. package/lib/module/index.js.map +1 -1
  104. package/lib/module/interfaces/index.js +19 -0
  105. package/lib/module/interfaces/index.js.map +1 -1
  106. package/lib/module/utils/index.js +27 -0
  107. package/lib/module/utils/index.js.map +1 -1
  108. package/lib/typescript/components/PayEngine.d.ts +1 -1
  109. package/lib/typescript/components/v2/ApplePay/PEApplePayButton.d.ts +217 -12
  110. package/lib/typescript/components/v2/ApplePay/PEApplePayInterfaces.d.ts +180 -1
  111. package/lib/typescript/components/v2/GooglePay/PEGooglePayAddress.d.ts +30 -0
  112. package/lib/typescript/components/v2/GooglePay/PEGooglePayButton.d.ts +99 -0
  113. package/lib/typescript/components/v2/PEPaymentRequest.d.ts +130 -9
  114. package/lib/typescript/components/v2/PayEngineNative.d.ts +165 -7
  115. package/lib/typescript/components/v2/PayEngineProvider.d.ts +51 -0
  116. package/lib/typescript/components/v2/SecureFields/BankAccountView.d.ts +103 -0
  117. package/lib/typescript/components/v2/SecureFields/CreditCardView.d.ts +114 -0
  118. package/lib/typescript/components/v2/SecureFields/IPEField.d.ts +49 -0
  119. package/lib/typescript/components/v2/SecureFields/ITokenizationData.d.ts +14 -0
  120. package/lib/typescript/components/v2/SecureFields/PEBankAccount.d.ts +36 -0
  121. package/lib/typescript/components/v2/SecureFields/PECard.d.ts +44 -0
  122. package/lib/typescript/components/v2/SecureFields/PEKeyboardType.d.ts +16 -1
  123. package/lib/typescript/index.d.ts +11 -5
  124. package/lib/typescript/interfaces/index.d.ts +35 -1
  125. package/lib/typescript/utils/index.d.ts +21 -0
  126. package/package.json +6 -3
  127. package/react-native-payengine.podspec +1 -1
  128. package/src/components/PayEngine.tsx +1 -1
  129. package/src/components/v2/ApplePay/PEApplePayButton.tsx +225 -12
  130. package/src/components/v2/ApplePay/PEApplePayInterfaces.ts +221 -8
  131. package/src/components/v2/GooglePay/PEGooglePayAddress.ts +39 -1
  132. package/src/components/v2/GooglePay/PEGooglePayButton.tsx +113 -9
  133. package/src/components/v2/PEPaymentRequest.ts +151 -13
  134. package/src/components/v2/PayEngineNative.tsx +196 -9
  135. package/src/components/v2/PayEngineProvider.tsx +52 -1
  136. package/src/components/v2/SecureFields/BankAccountView.tsx +108 -1
  137. package/src/components/v2/SecureFields/CreditCardView.tsx +118 -1
  138. package/src/components/v2/SecureFields/IPEField.ts +55 -0
  139. package/src/components/v2/SecureFields/ITokenizationData.ts +17 -2
  140. package/src/components/v2/SecureFields/PEBankAccount.ts +42 -0
  141. package/src/components/v2/SecureFields/PECard.ts +52 -0
  142. package/src/components/v2/SecureFields/PEKeyboardType.ts +18 -1
  143. package/src/index.tsx +23 -5
  144. package/src/interfaces/index.ts +40 -2
  145. package/src/utils/index.ts +21 -0
  146. package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
  147. package/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
  148. package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
  149. package/android/.gradle/6.1.1/gc.properties +0 -0
  150. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/CustomWindow.h +0 -25
  151. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/UIControl+CustomControl.h +0 -33
  152. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/UIViewController+TouchControl.h +0 -27
  153. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/CustomWindow.h +0 -25
  154. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/UIControl+CustomControl.h +0 -33
  155. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/UIViewController+TouchControl.h +0 -27
@@ -1,20 +1,78 @@
1
- import { NativeModules, Platform } from "react-native";
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import { NativeEventEmitter, NativeModules, Platform } from "react-native";
2
4
  import { PayProvider } from "../../interfaces";
3
5
  const {
4
- RNPayEngineNative
6
+ RNPayEngineNative,
7
+ RNPEEventEmitter
5
8
  } = NativeModules;
9
+ /**
10
+ * Represents an access token used for authenticating with the PayEngine SDK.
11
+ *
12
+ * @remarks
13
+ * The access token contains the actual token string and the duration (in seconds)
14
+ * for which the token remains valid. This is typically retrieved from your backend
15
+ * and used for making authenticated requests.
16
+ *
17
+ * @property accessToken - The access token string.
18
+ * @property expiresIn - The time (in seconds) until the token expires.
19
+ *
20
+ * @category PayEngine
21
+ */
22
+
23
+ /**
24
+ * Provides an interface for interacting with the native PayEngine SDK.
25
+ *
26
+ * @remarks
27
+ * `PayEngineNative` acts as a bridge between your React Native JavaScript code and
28
+ * the native PayEngine SDKs on iOS and Android. It utilizes React Native's
29
+ * Native Modules and platform channels to enable core payment functionalities.
30
+ *
31
+ * These include:
32
+ * - Fraud monitoring
33
+ * - Browser/device info retrieval
34
+ * - Support detection for Apple Pay and Google Pay
35
+ *
36
+ *
37
+ * @category PayEngine
38
+ */
6
39
  export default class PayEngineNative {
40
+ constructor() {}
41
+ /**
42
+ * Retrieves a fraud monitoring session ID from the native PayEngine SDK.
43
+ *
44
+ *
45
+ * @param merchantId - The unique identifier for the merchant.
46
+ * @returns A `Promise<string>` containing the fraud monitoring session ID.
47
+ */
48
+
49
+
7
50
  static async createFraudMonitorSession(merchantId) {
8
51
  return RNPayEngineNative.createFraudMonitorSession(merchantId);
9
52
  }
53
+ /**
54
+ * Retrieves browser-related information from the native PayEngine SDK.
55
+ *
56
+ * @returns A `Promise<string>` containing browser and device details.
57
+ *
58
+ */
59
+
10
60
 
11
61
  static async getBrowserInfo() {
12
62
  return RNPayEngineNative.getBrowserInfo();
13
63
  }
14
64
  /**
15
- * @deprecated use userCanPay instead
16
- * @param merchantId
17
- * @returns
65
+ * @deprecated Use {@link PayEngineNative.userCanPay} instead.
66
+ *
67
+ * Checks if platform-native payments (Apple Pay or Google Pay) are supported on the current device.
68
+ *
69
+ * @remarks
70
+ * This method has been deprecated in favor of {@link PayEngineNative.userCanPay}, which allows specifying
71
+ * the payment provider explicitly.
72
+ *
73
+ * @param merchantId - The unique identifier for the merchant.
74
+ * @returns A `Promise<boolean>` indicating whether the platform-specific payment method is supported.
75
+ *
18
76
  */
19
77
 
20
78
 
@@ -27,6 +85,22 @@ export default class PayEngineNative {
27
85
 
28
86
  return false;
29
87
  }
88
+ /**
89
+ * Checks if the user can make payments using Apple Pay (iOS) or Google Pay (Android).
90
+ *
91
+ * @remarks
92
+ * This method verifies whether the current device and platform support the selected payment provider.
93
+ * It performs a platform-specific check using the native PayEngine SDK for either Apple Pay or Google Pay.
94
+ *
95
+ * ## Supported Providers
96
+ * - `PayProvider.googlePay` (Android only)
97
+ * - `PayProvider.applePay` (iOS only)
98
+ *
99
+ * @param provider - The payment provider to check support for.
100
+ * @param merchantId - The unique identifier for the merchant.
101
+ * @returns A `Promise<boolean>` indicating whether the selected payment method is supported.
102
+ */
103
+
30
104
 
31
105
  static async userCanPay(provider, merchantId) {
32
106
  if (provider == PayProvider.applePay && Platform.OS == 'ios') {
@@ -37,6 +111,111 @@ export default class PayEngineNative {
37
111
 
38
112
  return false;
39
113
  }
114
+ /**
115
+ * Sets the callback function that provides an access token when required by PayEngine.
116
+ *
117
+ * @remarks
118
+ * When the PayEngine SDK needs an access token, it will call this callback function
119
+ * to request the host application to fetch a new token from its backend.
120
+ *
121
+ * The SDK uses this token internally to make calls to merchant related APIs which require merchant's credentials.
122
+ *
123
+ * ## Important:
124
+ * - PayEngine will invoke this callback **whenever an access token is needed or needs to be refreshed**.
125
+ * - The integrator must ensure that the token retrieval logic is secure and efficient in their backend.
126
+ * - For more details on how to retrieve the access token from Payengine, refer to the official documentation:
127
+ * [PayEngine Merchant Session](https://docs.payengine.co/merchant-session#obtaining-a-new-merchant-session)
128
+ *
129
+ * ## Example Usage
130
+ * ```ts
131
+ * const fetchAccessToken = async (): Promise<AccessToken> => {
132
+ * try {
133
+ * // Make a network request to your server to fetch the token
134
+ * // Your server then makes a request to Payengine securely and returns the results back in response
135
+ * const response = await fetch("https://yourserver.com/accessToken");
136
+ *
137
+ * if (!response.ok) {
138
+ * throw new Error(`Server responded with status ${response.status}`);
139
+ * }
140
+ *
141
+ * const data = await response.json();
142
+ *
143
+ * // Extract the token and expiration from your server's response
144
+ * const token = data.access_token;
145
+ * const expiresIn = data.expires_in;
146
+ *
147
+ * return { accessToken: token, expiresIn };
148
+ * } catch (e) {
149
+ * throw new Error("Failed to fetch access token: " + e);
150
+ * }
151
+ * };
152
+ *
153
+ * // This is where you supply the callback to the SDK
154
+ * PayEngineNative.setFetchAccessTokenCallback(fetchAccessToken);
155
+ * ```
156
+ *
157
+ * @param callback - A function that returns a `Promise<AccessToken>`. The function must handle
158
+ * errors properly in case token retrieval fails.
159
+ */
160
+
161
+
162
+ static async setFetchAccessTokenCallback(callback) {
163
+ PayEngineNative.fetchAccessTokenCallback = callback;
164
+
165
+ if (!PayEngineNative.isFetchCallbackListenerRegistered) {
166
+ PayEngineNative.emitter.addListener("fetchAccessToken", async () => {
167
+ try {
168
+ const result = await PayEngineNative.fetchAccessTokenCallback();
169
+ RNPayEngineNative.provideFetchAccessTokenResult(result);
170
+ } catch (error) {
171
+ RNPayEngineNative.provideFetchAccessTokenResult(null);
172
+ }
173
+ });
174
+ PayEngineNative.isFetchCallbackListenerRegistered = true;
175
+ }
176
+
177
+ RNPayEngineNative.configureFetchAccessTokenCallback();
178
+ }
179
+ /**
180
+ * Logs out the current merchant by invalidating the access token.
181
+ *
182
+ * @remarks
183
+ * While access tokens automatically expire, it's **strongly recommended** to explicitly invalidate
184
+ * them when a merchant's session ends on the server.
185
+ *
186
+ * Relying solely on token expiration can introduce **security vulnerabilities**
187
+ * and result in a **suboptimal user experience**.
188
+ *
189
+ * Calling this method ensures that the merchant's session is terminated,
190
+ * preventing any further authenticated requests until a new login is performed.
191
+ *
192
+ * For more details, refer to the official documentation:
193
+ * [PayEngine Merchant Session](https://docs.payengine.co/merchant-session)
194
+ *
195
+ * ## Example Usage
196
+ * ```ts
197
+ * const merchantId = "your_merchant_id_here";
198
+ * await PayEngineNative.logout(merchantId);
199
+ * console.log("Merchant session terminated.");
200
+ * ```
201
+ *
202
+ * This ensures that no further authenticated requests can be made
203
+ * until a new access token is fetched.
204
+ *
205
+ * @param merchantId - The unique identifier of the merchant whose session should be invalidated.
206
+ * @returns A `Promise` indicating the completion of the logout process.
207
+ */
208
+
209
+
210
+ static async logout(merchantId) {
211
+ return RNPayEngineNative.logout(merchantId);
212
+ }
40
213
 
41
214
  }
215
+
216
+ _defineProperty(PayEngineNative, "emitter", new NativeEventEmitter(RNPEEventEmitter));
217
+
218
+ _defineProperty(PayEngineNative, "isFetchCallbackListenerRegistered", false);
219
+
220
+ _defineProperty(PayEngineNative, "fetchAccessTokenCallback", null);
42
221
  //# sourceMappingURL=PayEngineNative.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","PayProvider","RNPayEngineNative","PayEngineNative","createFraudMonitorSession","merchantId","getBrowserInfo","isPlatformPaySupported","OS","isApplePaySupported","isGooglePaySupported","userCanPay","provider","applePay","googlePay"],"sources":["PayEngineNative.tsx"],"sourcesContent":["import { NativeModules, Platform } from \"react-native\";\nimport { PayProvider } from \"../../interfaces\";\n\nconst { RNPayEngineNative } = NativeModules;\n\nexport default class PayEngineNative {\n static async createFraudMonitorSession(merchantId: string) { \n return RNPayEngineNative.createFraudMonitorSession(merchantId);\n }\n\n static async getBrowserInfo() {\n return RNPayEngineNative.getBrowserInfo();\n }\n\n /**\n * @deprecated use userCanPay instead\n * @param merchantId \n * @returns \n */\n static async isPlatformPaySupported(merchantId: string) {\n if (Platform.OS === 'ios') {\n return await RNPayEngineNative.isApplePaySupported(merchantId);\n } else if (Platform.OS === 'android') {\n return await RNPayEngineNative.isGooglePaySupported(merchantId);\n }\n return false;\n }\n\n static async userCanPay(provider: PayProvider, merchantId: string) {\n if (provider == PayProvider.applePay && Platform.OS == 'ios') {\n return await RNPayEngineNative.isApplePaySupported(merchantId);\n } else if (provider === PayProvider.googlePay && Platform.OS === 'android') {\n return await RNPayEngineNative.isGooglePaySupported(merchantId);\n }\n return false;\n }\n}"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AACA,SAASC,WAAT,QAA4B,kBAA5B;AAEA,MAAM;EAAEC;AAAF,IAAwBH,aAA9B;AAEA,eAAe,MAAMI,eAAN,CAAsB;EACG,aAAzBC,yBAAyB,CAACC,UAAD,EAAqB;IACzD,OAAOH,iBAAiB,CAACE,yBAAlB,CAA4CC,UAA5C,CAAP;EACD;;EAE0B,aAAdC,cAAc,GAAG;IAC5B,OAAOJ,iBAAiB,CAACI,cAAlB,EAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACqC,aAAtBC,sBAAsB,CAACF,UAAD,EAAqB;IACtD,IAAIL,QAAQ,CAACQ,EAAT,KAAgB,KAApB,EAA2B;MACzB,OAAO,MAAMN,iBAAiB,CAACO,mBAAlB,CAAsCJ,UAAtC,CAAb;IACD,CAFD,MAEO,IAAIL,QAAQ,CAACQ,EAAT,KAAgB,SAApB,EAA+B;MACpC,OAAO,MAAMN,iBAAiB,CAACQ,oBAAlB,CAAuCL,UAAvC,CAAb;IACD;;IACD,OAAO,KAAP;EACD;;EAEsB,aAAVM,UAAU,CAACC,QAAD,EAAwBP,UAAxB,EAA4C;IACjE,IAAIO,QAAQ,IAAIX,WAAW,CAACY,QAAxB,IAAoCb,QAAQ,CAACQ,EAAT,IAAe,KAAvD,EAA8D;MAC5D,OAAO,MAAMN,iBAAiB,CAACO,mBAAlB,CAAsCJ,UAAtC,CAAb;IACD,CAFD,MAEO,IAAIO,QAAQ,KAAKX,WAAW,CAACa,SAAzB,IAAsCd,QAAQ,CAACQ,EAAT,KAAgB,SAA1D,EAAqE;MAC1E,OAAO,MAAMN,iBAAiB,CAACQ,oBAAlB,CAAuCL,UAAvC,CAAb;IACD;;IACD,OAAO,KAAP;EACD;;AA9BkC"}
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","Platform","PayProvider","RNPayEngineNative","RNPEEventEmitter","PayEngineNative","constructor","createFraudMonitorSession","merchantId","getBrowserInfo","isPlatformPaySupported","OS","isApplePaySupported","isGooglePaySupported","userCanPay","provider","applePay","googlePay","setFetchAccessTokenCallback","callback","fetchAccessTokenCallback","isFetchCallbackListenerRegistered","emitter","addListener","result","provideFetchAccessTokenResult","error","configureFetchAccessTokenCallback","logout"],"sources":["PayEngineNative.tsx"],"sourcesContent":["import { NativeEventEmitter, NativeModules, Platform } from \"react-native\";\nimport { PayProvider } from \"../../interfaces\";\n\nconst { RNPayEngineNative, RNPEEventEmitter } = NativeModules;\n\n/**\n * Represents an access token used for authenticating with the PayEngine SDK.\n *\n * @remarks\n * The access token contains the actual token string and the duration (in seconds)\n * for which the token remains valid. This is typically retrieved from your backend\n * and used for making authenticated requests.\n *\n * @property accessToken - The access token string.\n * @property expiresIn - The time (in seconds) until the token expires.\n * \n * @category PayEngine\n */\nexport type AccessToken = {\n accessToken: string;\n expiresIn: number;\n};\n\n/**\n * A callback function that provides an access token to the PayEngine SDK.\n *\n * @returns A promise resolving to a valid {@link AccessToken}.\n * \n * @category PayEngine\n */\nexport type FetchAccessTokenCallback = () => Promise<AccessToken>;\n\n/**\n * Provides an interface for interacting with the native PayEngine SDK.\n *\n * @remarks\n * `PayEngineNative` acts as a bridge between your React Native JavaScript code and\n * the native PayEngine SDKs on iOS and Android. It utilizes React Native's\n * Native Modules and platform channels to enable core payment functionalities.\n *\n * These include:\n * - Fraud monitoring\n * - Browser/device info retrieval\n * - Support detection for Apple Pay and Google Pay\n *\n *\n * @category PayEngine\n */\nexport default class PayEngineNative {\n private static emitter = new NativeEventEmitter(RNPEEventEmitter);\n\n private static isFetchCallbackListenerRegistered = false;\n\n private static fetchAccessTokenCallback: FetchAccessTokenCallback | null = null;\n\n\n private constructor() { }\n\n /**\n * Retrieves a fraud monitoring session ID from the native PayEngine SDK.\n *\n *\n * @param merchantId - The unique identifier for the merchant.\n * @returns A `Promise<string>` containing the fraud monitoring session ID.\n */\n static async createFraudMonitorSession(merchantId: string): Promise<string> {\n return RNPayEngineNative.createFraudMonitorSession(merchantId);\n }\n\n /**\n * Retrieves browser-related information from the native PayEngine SDK.\n *\n * @returns A `Promise<string>` containing browser and device details.\n *\n */\n static async getBrowserInfo(): Promise<string> {\n return RNPayEngineNative.getBrowserInfo();\n }\n\n /**\n * @deprecated Use {@link PayEngineNative.userCanPay} instead.\n *\n * Checks if platform-native payments (Apple Pay or Google Pay) are supported on the current device.\n *\n * @remarks\n * This method has been deprecated in favor of {@link PayEngineNative.userCanPay}, which allows specifying\n * the payment provider explicitly.\n *\n * @param merchantId - The unique identifier for the merchant.\n * @returns A `Promise<boolean>` indicating whether the platform-specific payment method is supported.\n *\n */\n static async isPlatformPaySupported(merchantId: string): Promise<boolean> {\n if (Platform.OS === 'ios') {\n return await RNPayEngineNative.isApplePaySupported(merchantId);\n } else if (Platform.OS === 'android') {\n return await RNPayEngineNative.isGooglePaySupported(merchantId);\n }\n return false;\n }\n\n /**\n * Checks if the user can make payments using Apple Pay (iOS) or Google Pay (Android).\n *\n * @remarks\n * This method verifies whether the current device and platform support the selected payment provider.\n * It performs a platform-specific check using the native PayEngine SDK for either Apple Pay or Google Pay.\n *\n * ## Supported Providers\n * - `PayProvider.googlePay` (Android only)\n * - `PayProvider.applePay` (iOS only)\n *\n * @param provider - The payment provider to check support for.\n * @param merchantId - The unique identifier for the merchant.\n * @returns A `Promise<boolean>` indicating whether the selected payment method is supported.\n */\n static async userCanPay(provider: PayProvider, merchantId: string): Promise<boolean> {\n if (provider == PayProvider.applePay && Platform.OS == 'ios') {\n return await RNPayEngineNative.isApplePaySupported(merchantId);\n } else if (provider === PayProvider.googlePay && Platform.OS === 'android') {\n return await RNPayEngineNative.isGooglePaySupported(merchantId);\n }\n return false;\n }\n\n\n /**\n * Sets the callback function that provides an access token when required by PayEngine.\n *\n * @remarks\n * When the PayEngine SDK needs an access token, it will call this callback function\n * to request the host application to fetch a new token from its backend.\n * \n * The SDK uses this token internally to make calls to merchant related APIs which require merchant's credentials.\n *\n * ## Important:\n * - PayEngine will invoke this callback **whenever an access token is needed or needs to be refreshed**.\n * - The integrator must ensure that the token retrieval logic is secure and efficient in their backend.\n * - For more details on how to retrieve the access token from Payengine, refer to the official documentation:\n * [PayEngine Merchant Session](https://docs.payengine.co/merchant-session#obtaining-a-new-merchant-session)\n *\n * ## Example Usage\n * ```ts\n * const fetchAccessToken = async (): Promise<AccessToken> => {\n * try {\n * // Make a network request to your server to fetch the token\n * // Your server then makes a request to Payengine securely and returns the results back in response\n * const response = await fetch(\"https://yourserver.com/accessToken\");\n * \n * if (!response.ok) {\n * throw new Error(`Server responded with status ${response.status}`);\n * }\n * \n * const data = await response.json();\n * \n * // Extract the token and expiration from your server's response\n * const token = data.access_token;\n * const expiresIn = data.expires_in;\n *\n * return { accessToken: token, expiresIn };\n * } catch (e) {\n * throw new Error(\"Failed to fetch access token: \" + e);\n * }\n * };\n * \n * // This is where you supply the callback to the SDK\n * PayEngineNative.setFetchAccessTokenCallback(fetchAccessToken);\n * ```\n *\n * @param callback - A function that returns a `Promise<AccessToken>`. The function must handle\n * errors properly in case token retrieval fails.\n */\n static async setFetchAccessTokenCallback(callback: FetchAccessTokenCallback) {\n PayEngineNative.fetchAccessTokenCallback = callback;\n\n if (!PayEngineNative.isFetchCallbackListenerRegistered) {\n PayEngineNative.emitter.addListener(\"fetchAccessToken\", async () => {\n try {\n const result = await PayEngineNative.fetchAccessTokenCallback!();\n RNPayEngineNative.provideFetchAccessTokenResult(result);\n } catch (error) {\n RNPayEngineNative.provideFetchAccessTokenResult(null);\n }\n });\n PayEngineNative.isFetchCallbackListenerRegistered = true;\n }\n\n\n RNPayEngineNative.configureFetchAccessTokenCallback();\n }\n\n /**\n * Logs out the current merchant by invalidating the access token.\n *\n * @remarks\n * While access tokens automatically expire, it's **strongly recommended** to explicitly invalidate\n * them when a merchant's session ends on the server.\n *\n * Relying solely on token expiration can introduce **security vulnerabilities** \n * and result in a **suboptimal user experience**.\n *\n * Calling this method ensures that the merchant's session is terminated, \n * preventing any further authenticated requests until a new login is performed.\n *\n * For more details, refer to the official documentation: \n * [PayEngine Merchant Session](https://docs.payengine.co/merchant-session)\n *\n * ## Example Usage\n * ```ts\n * const merchantId = \"your_merchant_id_here\";\n * await PayEngineNative.logout(merchantId);\n * console.log(\"Merchant session terminated.\");\n * ```\n *\n * This ensures that no further authenticated requests can be made\n * until a new access token is fetched.\n *\n * @param merchantId - The unique identifier of the merchant whose session should be invalidated.\n * @returns A `Promise` indicating the completion of the logout process.\n */\n static async logout(merchantId: string): Promise<void> {\n return RNPayEngineNative.logout(merchantId);\n }\n}"],"mappings":";;AAAA,SAASA,kBAAT,EAA6BC,aAA7B,EAA4CC,QAA5C,QAA4D,cAA5D;AACA,SAASC,WAAT,QAA4B,kBAA5B;AAEA,MAAM;EAAEC,iBAAF;EAAqBC;AAArB,IAA0CJ,aAAhD;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMK,eAAN,CAAsB;EAQ3BC,WAAW,GAAG,CAAG;EAEzB;AACF;AACA;AACA;AACA;AACA;AACA;;;EACwC,aAAzBC,yBAAyB,CAACC,UAAD,EAAsC;IAC1E,OAAOL,iBAAiB,CAACI,yBAAlB,CAA4CC,UAA5C,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;AACA;;;EAC6B,aAAdC,cAAc,GAAoB;IAC7C,OAAON,iBAAiB,CAACM,cAAlB,EAAP;EACD;EAED;AACF;AACA;AACA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B,OAAhB,CAAwBC,WAAxB,CAAoC,kBAApC,EAAwD,YAAY;QAClE,IAAI;UACF,MAAMC,MAAM,GAAG,MAAMnB,eAAe,CAACe,wBAAhB,EAArB;UACAjB,iBAAiB,CAACsB,6BAAlB,CAAgDD,MAAhD;QACD,CAHD,CAGE,OAAOE,KAAP,EAAc;UACdvB,iBAAiB,CAACsB,6BAAlB,CAAgD,IAAhD;QACD;MACF,CAPD;MAQApB,eAAe,CAACgB,iCAAhB,GAAoD,IAApD;IACD;;IAGDlB,iBAAiB,CAACwB,iCAAlB;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;EACqB,aAANC,MAAM,CAACpB,UAAD,EAAoC;IACrD,OAAOL,iBAAiB,CAACyB,MAAlB,CAAyBpB,UAAzB,CAAP;EACD;;AA9KkC;;gBAAhBH,e,aACM,IAAIN,kBAAJ,CAAuBK,gBAAvB,C;;gBADNC,e,uCAGgC,K;;gBAHhCA,e,8BAKwD,I"}
@@ -4,6 +4,57 @@ const {
4
4
  RNPayEngineNative
5
5
  } = NativeModules;
6
6
  const PayEngineContext = /*#__PURE__*/createContext(undefined);
7
+ /**
8
+ * A provider that initializes and manages PayEngine's configuration across the app.
9
+ *
10
+ * `PayEngineProvider` ensures that PayEngine's SDK is properly set up by loading
11
+ * the necessary configurations before rendering the app. It must wrap the root widget
12
+ * for the payment functionalities to work correctly.
13
+ *
14
+ * ## Usage
15
+ *
16
+ * Before using PayEngine in your application, wrap your app inside [PayEngineProvider]
17
+ * and pass an `IPayEngineConfig` instance containing your public key, script URL, and optional log level.
18
+ *
19
+ * ```tsx
20
+ * const PE_CONFIG: IPayEngineConfig = {
21
+ * publicKey: PUBLIC_KEY,
22
+ * scriptURL: "https://staging-sandbox.payengine.dev/",
23
+ * logLevel: 1,
24
+ * };
25
+ *
26
+ * return (
27
+ * <PayEngineProvider config={PE_CONFIG}>
28
+ * <NavigationContainer>
29
+ * <DrawerNavigator />
30
+ * </NavigationContainer>
31
+ * </PayEngineProvider>
32
+ * );
33
+ * ```
34
+ *
35
+ * ## How It Works
36
+ *
37
+ * 1. The `PayEngineProvider` component accepts a configuration object (`IPayEngineConfig`) containing
38
+ * the `publicKey`, `scriptURL`, and `logLevel`.
39
+ * 2. It initializes the PayEngine SDK with the `publicKey`
40
+ * and `scriptURL` from the configuration.
41
+ * 3. The provider uses the `React.useEffect` hook to ensure that the configuration is set up
42
+ * before rendering the children.
43
+ * 4. While loading the configuration, an `ActivityIndicator` is displayed. Once the SDK is set up,
44
+ * it renders the provided child components.
45
+ *
46
+ * ## Properties:
47
+ *
48
+ * - **`config`**: The configuration required for PayEngine (type: `IPayEngineConfig`).
49
+ * - `publicKey`: The public key for authentication.
50
+ * - `scriptURL`: The URL for the PayEngine script.
51
+ * - `logLevel`: The log level for debugging (optional).
52
+ *
53
+ * - **`children`**: The child components or widgets to be rendered after PayEngine is initialized.
54
+ *
55
+ *
56
+ * @category SecureFields
57
+ */
7
58
 
8
59
  const PayEngineProvider = _ref => {
9
60
  let {
@@ -1 +1 @@
1
- {"version":3,"names":["React","createContext","ActivityIndicator","NativeModules","RNPayEngineNative","PayEngineContext","undefined","PayEngineProvider","config","children","loading","setLoading","useState","useEffect","setConfig","publicKey","scriptURL","Error"],"sources":["PayEngineProvider.tsx"],"sourcesContent":["import React, { createContext } from \"react\";\nimport type { IPayEngineConfig } from \"../../interfaces\";\nimport { ActivityIndicator, NativeModules } from \"react-native\";\n\nconst { RNPayEngineNative } = NativeModules;\n\nconst PayEngineContext = createContext<IPayEngineConfig | undefined>(undefined);\n\nconst PayEngineProvider = ({ config, children }: { config: IPayEngineConfig, children: React.ReactNode }) => {\n const [loading, setLoading] = React.useState(true);\n\n React.useEffect(() => {\n setLoading(true);\n RNPayEngineNative.setConfig(config.publicKey, config.scriptURL)\n setLoading(false);\n }, [config]);\n\n if (!config) {\n throw new Error('PayEngineProvider: config is required');\n }\n\n return <PayEngineContext.Provider value={config}>\n {loading ? <ActivityIndicator /> : children}\n </PayEngineContext.Provider>\n}\n\nexport {\n PayEngineContext,\n PayEngineProvider\n};"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,aAAhB,QAAqC,OAArC;AAEA,SAASC,iBAAT,EAA4BC,aAA5B,QAAiD,cAAjD;AAEA,MAAM;EAAEC;AAAF,IAAwBD,aAA9B;AAEA,MAAME,gBAAgB,gBAAGJ,aAAa,CAA+BK,SAA/B,CAAtC;;AAEA,MAAMC,iBAAiB,GAAG,QAAmF;EAAA,IAAlF;IAAEC,MAAF;IAAUC;EAAV,CAAkF;EAC3G,MAAM,CAACC,OAAD,EAAUC,UAAV,IAAwBX,KAAK,CAACY,QAAN,CAAe,IAAf,CAA9B;EAEAZ,KAAK,CAACa,SAAN,CAAgB,MAAM;IACpBF,UAAU,CAAC,IAAD,CAAV;IACAP,iBAAiB,CAACU,SAAlB,CAA4BN,MAAM,CAACO,SAAnC,EAA8CP,MAAM,CAACQ,SAArD;IACAL,UAAU,CAAC,KAAD,CAAV;EACD,CAJD,EAIG,CAACH,MAAD,CAJH;;EAMA,IAAI,CAACA,MAAL,EAAa;IACX,MAAM,IAAIS,KAAJ,CAAU,uCAAV,CAAN;EACD;;EAED,oBAAO,oBAAC,gBAAD,CAAkB,QAAlB;IAA2B,KAAK,EAAET;EAAlC,GACJE,OAAO,gBAAG,oBAAC,iBAAD,OAAH,GAA2BD,QAD9B,CAAP;AAGD,CAhBD;;AAkBA,SACEJ,gBADF,EAEEE,iBAFF"}
1
+ {"version":3,"names":["React","createContext","ActivityIndicator","NativeModules","RNPayEngineNative","PayEngineContext","undefined","PayEngineProvider","config","children","loading","setLoading","useState","useEffect","setConfig","publicKey","scriptURL","Error"],"sources":["PayEngineProvider.tsx"],"sourcesContent":["import React, { createContext } from \"react\";\nimport type { IPayEngineConfig } from \"../../interfaces\";\nimport { ActivityIndicator, NativeModules } from \"react-native\";\n\nconst { RNPayEngineNative } = NativeModules;\n\nconst PayEngineContext = createContext<IPayEngineConfig | undefined>(undefined);\n\n/**\n * A provider that initializes and manages PayEngine's configuration across the app.\n *\n * `PayEngineProvider` ensures that PayEngine's SDK is properly set up by loading\n * the necessary configurations before rendering the app. It must wrap the root widget\n * for the payment functionalities to work correctly.\n *\n * ## Usage\n *\n * Before using PayEngine in your application, wrap your app inside [PayEngineProvider]\n * and pass an `IPayEngineConfig` instance containing your public key, script URL, and optional log level.\n *\n * ```tsx\n * const PE_CONFIG: IPayEngineConfig = {\n * publicKey: PUBLIC_KEY,\n * scriptURL: \"https://staging-sandbox.payengine.dev/\",\n * logLevel: 1,\n * };\n *\n * return (\n * <PayEngineProvider config={PE_CONFIG}>\n * <NavigationContainer>\n * <DrawerNavigator />\n * </NavigationContainer>\n * </PayEngineProvider>\n * );\n * ```\n *\n * ## How It Works\n *\n * 1. The `PayEngineProvider` component accepts a configuration object (`IPayEngineConfig`) containing \n * the `publicKey`, `scriptURL`, and `logLevel`.\n * 2. It initializes the PayEngine SDK with the `publicKey` \n * and `scriptURL` from the configuration.\n * 3. The provider uses the `React.useEffect` hook to ensure that the configuration is set up \n * before rendering the children.\n * 4. While loading the configuration, an `ActivityIndicator` is displayed. Once the SDK is set up, \n * it renders the provided child components.\n *\n * ## Properties:\n *\n * - **`config`**: The configuration required for PayEngine (type: `IPayEngineConfig`).\n * - `publicKey`: The public key for authentication.\n * - `scriptURL`: The URL for the PayEngine script.\n * - `logLevel`: The log level for debugging (optional).\n *\n * - **`children`**: The child components or widgets to be rendered after PayEngine is initialized.\n *\n *\n * @category SecureFields\n */\nconst PayEngineProvider = ({ config, children }: { config: IPayEngineConfig, children: React.ReactNode }) => {\n const [loading, setLoading] = React.useState(true);\n\n React.useEffect(() => {\n setLoading(true);\n RNPayEngineNative.setConfig(config.publicKey, config.scriptURL)\n setLoading(false);\n }, [config]);\n\n if (!config) {\n throw new Error('PayEngineProvider: config is required');\n }\n\n return <PayEngineContext.Provider value={config}>\n {loading ? <ActivityIndicator /> : children}\n </PayEngineContext.Provider>\n};\n\nexport {\n PayEngineContext,\n PayEngineProvider\n};"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,aAAhB,QAAqC,OAArC;AAEA,SAASC,iBAAT,EAA4BC,aAA5B,QAAiD,cAAjD;AAEA,MAAM;EAAEC;AAAF,IAAwBD,aAA9B;AAEA,MAAME,gBAAgB,gBAAGJ,aAAa,CAA+BK,SAA/B,CAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,iBAAiB,GAAG,QAAmF;EAAA,IAAlF;IAAEC,MAAF;IAAUC;EAAV,CAAkF;EAC3G,MAAM,CAACC,OAAD,EAAUC,UAAV,IAAwBX,KAAK,CAACY,QAAN,CAAe,IAAf,CAA9B;EAEAZ,KAAK,CAACa,SAAN,CAAgB,MAAM;IACpBF,UAAU,CAAC,IAAD,CAAV;IACAP,iBAAiB,CAACU,SAAlB,CAA4BN,MAAM,CAACO,SAAnC,EAA8CP,MAAM,CAACQ,SAArD;IACAL,UAAU,CAAC,KAAD,CAAV;EACD,CAJD,EAIG,CAACH,MAAD,CAJH;;EAMA,IAAI,CAACA,MAAL,EAAa;IACX,MAAM,IAAIS,KAAJ,CAAU,uCAAV,CAAN;EACD;;EAED,oBAAO,oBAAC,gBAAD,CAAkB,QAAlB;IAA2B,KAAK,EAAET;EAAlC,GACJE,OAAO,gBAAG,oBAAC,iBAAD,OAAH,GAA2BD,QAD9B,CAAP;AAGD,CAhBD;;AAkBA,SACEJ,gBADF,EAEEE,iBAFF"}
@@ -8,6 +8,77 @@ const RNPEBankAccountView = requireNativeComponent(COMPONENT_NAME); // @ts-ignor
8
8
 
9
9
  const RNPEBankAccountViewManager = UIManager[COMPONENT_NAME];
10
10
  const peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);
11
+ /**
12
+ * Props for the `PEBankAccountView` component.
13
+ *
14
+ * Allows optional configuration of additional input fields that can be rendered
15
+ * alongside the standard bank account fields.
16
+ *
17
+ * These fields can be used to collect extra information such as account holder type,
18
+ * billing address, or custom metadata required by the merchant.
19
+ *
20
+ * @category SecureFields
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const fields: IPEField[] = [
25
+ * {
26
+ * name: "accountHolderType",
27
+ * type: "text",
28
+ * placeholder: "Account Holder Type",
29
+ * keyboardType: PEKeyboardType.Alphabet,
30
+ * isRequired: false
31
+ * }
32
+ * ];
33
+ *
34
+ * <PEBankAccountView additionalFields={fields} />
35
+ * ```
36
+ */
37
+
38
+ /**
39
+ * A secure form widget for entering a customer's bank account information.
40
+ *
41
+ * [PEBankAccountView] provides a UI component for securely collecting bank account details.
42
+ * It does not store data locally and instead tokenizes the information using PayEngine.
43
+ *
44
+ * ## Features:
45
+ * - Securely collects bank account details.
46
+ * - Supports additional customizable fields.
47
+ * - Provides methods to show/hide the keyboard.
48
+ * - Allows tokenizing the entered data for safe storage.
49
+ *
50
+ * ## Usage Example:
51
+ *
52
+ * ```tsx
53
+ * const formRef = React.createRef<PEBankAccountViewMethods>();
54
+ *
55
+ * return (
56
+ * <View style={styles.container}>
57
+ * <Text>Welcome to PayEngine React Native SDK example</Text>
58
+ * <View style={{ width: '100%' }}>
59
+ * <PEBankAccountView ref={formRef} />
60
+ * <Button disabled={submitting} onPress={() => createBankAccount()} title="Create Bank Account" />
61
+ * </View>
62
+ * <ScrollView style={{ flex: 1, width: '100%', backgroundColor: 'lightyellow', padding: 10, marginVertical: 20 }}>
63
+ * <Text>{JSON.stringify(secureFieldsResult, null, 4)}</Text>
64
+ * </ScrollView>
65
+ * </View>
66
+ * );
67
+ * ```
68
+ *
69
+ * ## How It Works:
70
+ * 1. Create an instance of [PEBankAccountView], optionally passing additional fields.
71
+ * 2. Display the form inside your widget tree.
72
+ * 3. Use [showKeyboard] and [hideKeyboard] to manage input focus.
73
+ * 4. Call [submit] to securely send the bank account data and receive a token.
74
+ *
75
+ * ## Methods:
76
+ * - **`showKeyboard()`**: Manually shows the on-screen keyboard.
77
+ * - **`hideKeyboard()`**: Hides the on-screen keyboard.
78
+ * - **`submit()`**: Submits the entered data and retrieves a tokenized version of the bank account data.
79
+ *
80
+ * @category SecureFields
81
+ */
11
82
  export const PEBankAccountView = /*#__PURE__*/React.forwardRef((props, ref) => {
12
83
  const formRef = React.useRef();
13
84
  const [height, setHeight] = React.useState(0);
@@ -1 +1 @@
1
- {"version":3,"names":["React","requireNativeComponent","NativeModules","NativeEventEmitter","findNodeHandle","UIManager","ActivityIndicator","Platform","RNPEEventEmitter","COMPONENT_NAME","RNPEBankAccountView","RNPEBankAccountViewManager","peEventEmitter","PEBankAccountView","forwardRef","props","ref","formRef","useRef","height","setHeight","useState","useImperativeHandle","submit","data","Promise","resolve","reject","Error","listener","addListener","args","remove","error","bankAccount","json","JSON","parse","callNativeMethod","merchantId","additionalData","showKeyboard","hideKeyboard","useCallback","methodName","params","viewId","current","commandId","Commands","toString","OS","Number","dispatchViewManagerCommand","useEffect","eventListener","width","_","frameHeight","stringify","additionalFields"],"sources":["BankAccountView.tsx"],"sourcesContent":["\nimport * as React from 'react';\nimport { requireNativeComponent, NativeModules, NativeEventEmitter, ViewProps, findNodeHandle, UIManager, ActivityIndicator, Platform } from 'react-native';\nimport type IPEField from './IPEField';\nimport type PEBankAccount from './PEBankAccount';\nimport type ITokenizationData from './ITokenizationData';\n\nconst { RNPEEventEmitter } = NativeModules;\n\ninterface NativePEBankAccountViewProps extends ViewProps {\n additionalFields: string;\n}\n\nconst COMPONENT_NAME = 'RNPEBankAccountView'\nconst RNPEBankAccountView = requireNativeComponent<NativePEBankAccountViewProps>(COMPONENT_NAME);\n// @ts-ignore\nconst RNPEBankAccountViewManager = UIManager[COMPONENT_NAME]\n\nconst peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);\n\nexport interface PEBankAccountViewProps {\n additionalFields?: IPEField[];\n}\n\nexport interface PEBankAccountViewMethods {\n submit: (data: ITokenizationData) => Promise<PEBankAccount>;\n showKeyboard: () => void;\n hideKeyboard: () => void;\n}\n\nexport const PEBankAccountView = React.forwardRef<\n PEBankAccountViewMethods,\n PEBankAccountViewProps\n>((props, ref) => {\n const formRef = React.useRef<any>();\n const [height, setHeight] = React.useState(0);\n\n React.useImperativeHandle(ref, () => ({\n submit: async (data: ITokenizationData = {}) => {\n return new Promise((resolve, reject) => {\n if (height === 0) {\n return reject(new Error('Form is not ready'))\n }\n \n const listener = peEventEmitter.addListener('onBankAccountRespond', args => {\n listener.remove()\n\n const { error, bankAccount: json } = args;\n if (error) {\n reject(new Error(error))\n } else {\n const bankAccount = JSON.parse(json) as PEBankAccount;\n resolve(bankAccount)\n }\n });\n\n callNativeMethod(\"submit\", [data.merchantId, data.additionalData],)\n });\n },\n showKeyboard: () => {\n callNativeMethod(\"showKeyboard\")\n },\n hideKeyboard: () => {\n callNativeMethod(\"hideKeyboard\")\n }\n }));\n\n const callNativeMethod = React.useCallback((methodName: string, params: any[] = []) => {\n const viewId = findNodeHandle(formRef.current);\n let commandId = RNPEBankAccountViewManager.Commands[methodName].toString()\n if (Platform.OS === 'ios') {\n commandId = Number(commandId)\n }\n UIManager.dispatchViewManagerCommand(\n viewId,\n commandId,\n params,\n );\n }, [formRef.current])\n\n\n React.useEffect(() => {\n const eventListener = peEventEmitter.addListener('onSizeChanges', args => {\n const { width: _, height: frameHeight } = args;\n setHeight(frameHeight);\n });\n return () => eventListener.remove();\n }, []);\n\n return (\n <>\n {height === 0 && <ActivityIndicator />}\n <RNPEBankAccountView ref={formRef} additionalFields={JSON.stringify(props.additionalFields ?? [])} style={{ height: height }} />\n </>\n );\n});\n"],"mappings":"A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AND,EAMG,EANH;EAQA,oBACE,0CACGb,MAAM,KAAK,CAAX,iBAAgB,oBAAC,iBAAD,OADnB,eAEE,oBAAC,mBAAD;IAAqB,GAAG,EAAEF,OAA1B;IAAmC,gBAAgB,EAAEmB,IAAI,CAACuB,SAAL,CAAe5C,KAAK,CAAC6C,gBAAN,IAA0B,EAAzC,CAArD;IAAmG,KAAK,EAAE;MAAEzC,MAAM,EAAEA;IAAV;EAA1G,EAFF,CADF;AAMD,CAjEgC,CAA1B"}
1
+ {"version":3,"names":["React","requireNativeComponent","NativeModules","NativeEventEmitter","findNodeHandle","UIManager","ActivityIndicator","Platform","RNPEEventEmitter","COMPONENT_NAME","RNPEBankAccountView","RNPEBankAccountViewManager","peEventEmitter","PEBankAccountView","forwardRef","props","ref","formRef","useRef","height","setHeight","useState","useImperativeHandle","submit","data","Promise","resolve","reject","Error","listener","addListener","args","remove","error","bankAccount","json","JSON","parse","callNativeMethod","merchantId","additionalData","showKeyboard","hideKeyboard","useCallback","methodName","params","viewId","current","commandId","Commands","toString","OS","Number","dispatchViewManagerCommand","useEffect","eventListener","width","_","frameHeight","stringify","additionalFields"],"sources":["BankAccountView.tsx"],"sourcesContent":["\nimport * as React from 'react';\nimport { requireNativeComponent, NativeModules, NativeEventEmitter, type ViewProps, findNodeHandle, UIManager, ActivityIndicator, Platform } from 'react-native';\nimport type IPEField from './IPEField';\nimport type PEBankAccount from './PEBankAccount';\nimport type ITokenizationData from './ITokenizationData';\n\nconst { RNPEEventEmitter } = NativeModules;\n\ninterface NativePEBankAccountViewProps extends ViewProps {\n additionalFields: string;\n}\n\nconst COMPONENT_NAME = 'RNPEBankAccountView'\nconst RNPEBankAccountView = requireNativeComponent<NativePEBankAccountViewProps>(COMPONENT_NAME);\n// @ts-ignore\nconst RNPEBankAccountViewManager = UIManager[COMPONENT_NAME]\n\nconst peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);\n\n/**\n * Props for the `PEBankAccountView` component.\n *\n * Allows optional configuration of additional input fields that can be rendered\n * alongside the standard bank account fields.\n *\n * These fields can be used to collect extra information such as account holder type,\n * billing address, or custom metadata required by the merchant.\n *\n * @category SecureFields\n *\n * @example\n * ```ts\n * const fields: IPEField[] = [\n * {\n * name: \"accountHolderType\",\n * type: \"text\",\n * placeholder: \"Account Holder Type\",\n * keyboardType: PEKeyboardType.Alphabet,\n * isRequired: false\n * }\n * ];\n *\n * <PEBankAccountView additionalFields={fields} />\n * ```\n */\nexport interface PEBankAccountViewProps {\n /**\n * (Optional) A list of additional fields to be displayed in the bank account form.\n *\n * These are rendered below the standard account number and routing number fields.\n */\n additionalFields?: IPEField[];\n}\n\n\n/**\n * Provides methods to control and interact with the PayEngine Bank Account input view.\n *\n * This interface defines methods for submitting bank account details for tokenization\n * and managing keyboard visibility.\n *\n * @category SecureFields\n */\nexport interface PEBankAccountViewMethods {\n /**\n * Submits the entered bank account information to PayEngine for tokenization.\n *\n * @param data - Optional merchant info and additional metadata.\n * @returns A promise that resolves to a tokenized bank account object (`PEBankAccount`).\n *\n * @example\n * ```ts\n * const result = await bankAccountRef.current?.submit({\n * merchantId: \"merchant_456\",\n * additionalData: { accountType: \"checking\" }\n * });\n * ```\n */\n submit: (data: ITokenizationData) => Promise<PEBankAccount>;\n\n /**\n * Programmatically displays the keyboard for the bank account input fields.\n */\n showKeyboard: () => void;\n\n /**\n * Programmatically hides the keyboard for the bank account input fields.\n */\n hideKeyboard: () => void;\n}\n\n\n/**\n * A secure form widget for entering a customer's bank account information.\n *\n * [PEBankAccountView] provides a UI component for securely collecting bank account details.\n * It does not store data locally and instead tokenizes the information using PayEngine.\n *\n * ## Features:\n * - Securely collects bank account details.\n * - Supports additional customizable fields.\n * - Provides methods to show/hide the keyboard.\n * - Allows tokenizing the entered data for safe storage.\n *\n * ## Usage Example:\n *\n * ```tsx\n * const formRef = React.createRef<PEBankAccountViewMethods>();\n *\n * return (\n * <View style={styles.container}>\n * <Text>Welcome to PayEngine React Native SDK example</Text>\n * <View style={{ width: '100%' }}>\n * <PEBankAccountView ref={formRef} />\n * <Button disabled={submitting} onPress={() => createBankAccount()} title=\"Create Bank Account\" />\n * </View>\n * <ScrollView style={{ flex: 1, width: '100%', backgroundColor: 'lightyellow', padding: 10, marginVertical: 20 }}>\n * <Text>{JSON.stringify(secureFieldsResult, null, 4)}</Text>\n * </ScrollView>\n * </View>\n * );\n * ```\n *\n * ## How It Works:\n * 1. Create an instance of [PEBankAccountView], optionally passing additional fields.\n * 2. Display the form inside your widget tree.\n * 3. Use [showKeyboard] and [hideKeyboard] to manage input focus.\n * 4. Call [submit] to securely send the bank account data and receive a token.\n *\n * ## Methods:\n * - **`showKeyboard()`**: Manually shows the on-screen keyboard.\n * - **`hideKeyboard()`**: Hides the on-screen keyboard.\n * - **`submit()`**: Submits the entered data and retrieves a tokenized version of the bank account data.\n *\n * @category SecureFields\n */\nexport const PEBankAccountView = React.forwardRef<\n PEBankAccountViewMethods,\n PEBankAccountViewProps\n>((props, ref) => {\n const formRef = React.useRef<any>();\n const [height, setHeight] = React.useState(0);\n\n React.useImperativeHandle(ref, () => ({\n submit: async (data: ITokenizationData = {}) => {\n return new Promise((resolve, reject) => {\n if (height === 0) {\n return reject(new Error('Form is not ready'))\n }\n \n const listener = peEventEmitter.addListener('onBankAccountRespond', args => {\n listener.remove()\n\n const { error, bankAccount: json } = args;\n if (error) {\n reject(new Error(error))\n } else {\n const bankAccount = JSON.parse(json) as PEBankAccount;\n resolve(bankAccount)\n }\n });\n\n callNativeMethod(\"submit\", [data.merchantId, data.additionalData],)\n });\n },\n showKeyboard: () => {\n callNativeMethod(\"showKeyboard\")\n },\n hideKeyboard: () => {\n callNativeMethod(\"hideKeyboard\")\n }\n }));\n\n const callNativeMethod = React.useCallback((methodName: string, params: any[] = []) => {\n const viewId = findNodeHandle(formRef.current);\n let commandId = RNPEBankAccountViewManager.Commands[methodName].toString()\n if (Platform.OS === 'ios') {\n commandId = Number(commandId)\n }\n UIManager.dispatchViewManagerCommand(\n viewId,\n commandId,\n params,\n );\n }, [formRef.current])\n\n\n React.useEffect(() => {\n const eventListener = peEventEmitter.addListener('onSizeChanges', args => {\n const { width: _, height: frameHeight } = args;\n setHeight(frameHeight);\n });\n return () => eventListener.remove();\n }, []);\n\n return (\n <>\n {height === 0 && <ActivityIndicator />}\n <RNPEBankAccountView ref={formRef} additionalFields={JSON.stringify(props.additionalFields ?? [])} style={{ height: height }} />\n </>\n );\n});\n"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,sBAAT,EAAiCC,aAAjC,EAAgDC,kBAAhD,EAAoFC,cAApF,EAAoGC,SAApG,EAA+GC,iBAA/G,EAAkIC,QAAlI,QAAkJ,cAAlJ;AAKA,MAAM;EAAEC;AAAF,IAAuBN,aAA7B;AAMA,MAAMO,cAAc,GAAG,qBAAvB;AACA,MAAMC,mBAAmB,GAAGT,sBAAsB,CAA+BQ,cAA/B,CAAlD,C,CACA;;AACA,MAAME,0BAA0B,GAAGN,SAAS,CAACI,cAAD,CAA5C;AAEA,MAAMG,cAAc,GAAG,IAAIT,kBAAJ,CAAuBK,gBAAvB,CAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMK,iBAAiB,gBAAGb,KAAK,CAACc,UAAN,CAG/B,CAACC,KAAD,EAAQC,GAAR,KAAgB;EAChB,MAAMC,OAAO,GAAGjB,KAAK,CAACkB,MAAN,EAAhB;EACA,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBp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AAGrC,0BAA0B,CAACsC,QAA3B,CAAoCL,UAApC,EAAgDM,QAAhD,EAAhB;;IACA,IAAI3C,QAAQ,CAAC4C,EAAT,KAAgB,KAApB,EAA2B;MACzBH,SAAS,GAAGI,MAAM,CAACJ,SAAD,CAAlB;IACD;;IACD3C,SAAS,CAACgD,0BAAV,CACEP,MADF,EAEEE,SAFF,EAGEH,MAHF;EAKD,CAXwB,EAWtB,CAAC5B,OAAO,CAAC8B,OAAT,CAXsB,CAAzB;EAcA/C,KAAK,CAACsD,SAAN,CAAgB,MAAM;IACpB,MAAMC,aAAa,GAAG3C,cAAc,CAACkB,WAAf,CAA2B,eAA3B,EAA4CC,IAAI,IAAI;MACxE,MAAM;QAAEyB,KAAK,EAAEC,CAAT;QAAYtC,MAAM,EAAEuC;MAApB,IAAoC3B,IAA1C;MACAX,SAAS,CAACsC,WAAD,CAAT;IACD,CAHqB,CAAtB;IAIA,OAAO,MAAMH,aAAa,CAACvB,MAAd,EAAb;EACD,CAND,EAMG,EANH;EAQA,oBACE,0CACGb,MAAM,KAAK,CAAX,iBAAgB,oBAAC,iBAAD,OADnB,eAEE,oBAAC,mBAAD;IAAqB,GAAG,EAAEF,OAA1B;IAAmC,gBAAgB,EAAEmB,IAAI,CAACuB,SAAL,CAAe5C,KAAK,CAAC6C,gBAAN,IAA0B,EAAzC,CAArD;IAAmG,KAAK,EAAE;MAAEzC,MAAM,EAAEA;IAAV;EAA1G,EAFF,CADF;AAMD,CAjEgC,CAA1B"}
@@ -8,6 +8,88 @@ const RNPECreditCardView = requireNativeComponent(COMPONENT_NAME); // @ts-ignore
8
8
 
9
9
  const RNPECreditCardViewManager = UIManager[COMPONENT_NAME];
10
10
  const peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);
11
+ /**
12
+ * Props for the `PECreditCardView` component.
13
+ *
14
+ * Allows optional configuration of additional input fields that can be rendered
15
+ * alongside the standard credit card fields.
16
+ *
17
+ * These fields can be used to collect extra information such as ZIP code, billing address,
18
+ * or custom metadata required by the merchant.
19
+ *
20
+ * @category SecureFields
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const fields: IPEField[] = [
25
+ * {
26
+ * name: "zipCode",
27
+ * type: "text",
28
+ * placeholder: "ZIP Code",
29
+ * keyboardType: PEKeyboardType.Numeric,
30
+ * isRequired: true
31
+ * }
32
+ * ];
33
+ *
34
+ * <PECreditCardView additionalFields={fields} />
35
+ * ```
36
+ */
37
+
38
+ /**
39
+ * A secure form for entering a customer's credit card information safely.
40
+ *
41
+ * [PECreditCardView] provides an interface for users to input their credit card details securely.
42
+ * It integrates with PayEngine to tokenize the card details and forward them to a PCI-compliant
43
+ * third party without storing sensitive information locally.
44
+ *
45
+ * ## How It Works
46
+ *
47
+ * 1. Create an instance of [PECreditCardView], optionally passing additional fields.
48
+ * 2. Display the form inside your UI.
49
+ * 3. Once the user enters their details, call [submit] to securely process and retrieve a tokenized version of the card.
50
+ * 4. Use [showKeyboard] and [hideKeyboard] to manually control the keyboard.
51
+ *
52
+ * ## Example Usage
53
+ *
54
+ * ```tsx
55
+ * const formRef = React.createRef<PECreditCardViewMethods>();
56
+ *
57
+ *
58
+ * const additionalFields = [
59
+ * {
60
+ * name: 'address_zip',
61
+ * type: 'text',
62
+ * placeholder: 'Zip code',
63
+ * keyboardType: PEKeyboardType.alphabet,
64
+ * isRequired: true,
65
+ * pattern: '^(?:\\d{5}(?:-\\d{4})?|[ABCEGHJKLMNPRSTVXY]\\d[A-Z] ?\\d[A-Z]\\d)$'
66
+ * }
67
+ * ]
68
+ *
69
+ * return (
70
+ * <View style={styles.container}>
71
+ * <Text>Welcome to PayEngine React Native SDK example</Text>
72
+ * <View style={{ width: '100%' }}>
73
+ * <PECreditCardView ref={formRef} additionalFields={additionalFields} />
74
+ * <Button disabled={submitting} onPress={() => createCard()} title="Create Card" />
75
+ * <Button onPress={() => formRef.current?.showKeyboard()} title="Show keyboard" />
76
+ * <Button onPress={() => formRef.current?.hideKeyboard()} title="Hide keyboard" />
77
+ * </View>
78
+ * <ScrollView style={{ flex: 1, width: '100%', backgroundColor: 'lightyellow', padding: 10, marginVertical: 20 }}>
79
+ * <Text>{JSON.stringify(secureFieldsResult, null, 4)}</Text>
80
+ * </ScrollView>
81
+ * </View>
82
+ * );
83
+ * ```
84
+ *
85
+ * ## Features:
86
+ * - Securely collects credit card details.
87
+ * - Supports additional customizable fields.
88
+ * - Provides methods to show/hide the keyboard.
89
+ * - Allows submitting the entered data for tokenization and safe storage.
90
+ *
91
+ * @category SecureFields
92
+ */
11
93
  export const PECreditCardView = /*#__PURE__*/React.forwardRef((props, ref) => {
12
94
  const formRef = React.useRef();
13
95
  const [height, setHeight] = React.useState(0);
@@ -1 +1 @@
1
- {"version":3,"names":["React","requireNativeComponent","NativeModules","NativeEventEmitter","Platform","findNodeHandle","UIManager","ActivityIndicator","RNPEEventEmitter","COMPONENT_NAME","RNPECreditCardView","RNPECreditCardViewManager","peEventEmitter","PECreditCardView","forwardRef","props","ref","formRef","useRef","height","setHeight","useState","useImperativeHandle","submit","data","Promise","resolve","reject","Error","listener","addListener","args","remove","error","card","json","JSON","parse","callNativeMethod","merchantId","additionalData","showKeyboard","hideKeyboard","useCallback","methodName","params","console","log","viewId","current","commandId","Commands","toString","OS","Number","dispatchViewManagerCommand","useEffect","eventListener","width","_","frameHeight","stringify","additionalFields"],"sources":["CreditCardView.tsx"],"sourcesContent":["\nimport * as React from 'react';\nimport { requireNativeComponent, NativeModules, NativeEventEmitter, ViewProps, Platform, findNodeHandle, UIManager, ActivityIndicator } from 'react-native';\nimport type IPEField from './IPEField';\nimport type PECard from './PECard';\nimport type ITokenizationData from './ITokenizationData';\n\nconst { RNPEEventEmitter } = NativeModules;\n\ninterface NativePECreditCardViewProps extends ViewProps {\n additionalFields: string;\n}\n\nconst COMPONENT_NAME = 'RNPECreditCardView'\nconst RNPECreditCardView = requireNativeComponent<NativePECreditCardViewProps>(COMPONENT_NAME);\n// @ts-ignore\nconst RNPECreditCardViewManager = UIManager[COMPONENT_NAME]\nconst peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);\n\nexport interface PECreditCardViewProps {\n additionalFields?: IPEField[];\n}\n\nexport interface PECreditCardViewMethods {\n submit: (data: ITokenizationData) => Promise<PECard>;\n showKeyboard: () => void;\n hideKeyboard: () => void;\n}\n\nexport const PECreditCardView = React.forwardRef<\n PECreditCardViewMethods,\n PECreditCardViewProps\n>((props, ref) => {\n const formRef = React.useRef<any>();\n const [height, setHeight] = React.useState(0);\n\n React.useImperativeHandle(ref, () => ({\n submit: async (data: ITokenizationData = {}) => {\n return new Promise((resolve, reject) => {\n if (height === 0) {\n return reject(new Error('Form is not ready'))\n }\n\n const listener = peEventEmitter.addListener('onCardRespond', args => {\n listener.remove()\n\n const { error, card: json } = args;\n if (error) {\n reject(new Error(error))\n } else {\n const card = JSON.parse(json) as PECard;\n resolve(card)\n }\n });\n\n callNativeMethod(\"submit\", [data.merchantId, data.additionalData])\n });\n },\n showKeyboard: () => {\n callNativeMethod(\"showKeyboard\")\n },\n hideKeyboard: () => {\n callNativeMethod(\"hideKeyboard\")\n }\n }));\n\n const callNativeMethod = React.useCallback((methodName: string, params: any[] = []) => {\n console.log(\"callNativeMethod\", methodName, params)\n const viewId = findNodeHandle(formRef.current);\n let commandId = RNPECreditCardViewManager.Commands[methodName].toString()\n if (Platform.OS === 'ios') {\n commandId = Number(commandId)\n }\n UIManager.dispatchViewManagerCommand(\n viewId,\n commandId,\n params,\n );\n }, [formRef.current])\n\n React.useEffect(() => {\n const eventListener = peEventEmitter.addListener('onSizeChanges', args => {\n const { width: _, height: frameHeight } = args;\n setHeight(frameHeight);\n });\n\n return () => eventListener.remove();\n }, []);\n\n\n return (\n <>\n {height === 0 && <ActivityIndicator />}\n <RNPECreditCardView ref={formRef} additionalFields={JSON.stringify(props.additionalFields ?? [])} style={{ height: height }} />\n </>\n );\n});\n"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,sBAAT,EAAiCC,a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D,EAOG,EAPH;EAUA,oBACE,0CACGb,MAAM,KAAK,CAAX,iBAAgB,oBAAC,iBAAD,OADnB,eAEE,oBAAC,kBAAD;IAAoB,GAAG,EAAEF,OAAzB;IAAkC,gBAAgB,EAAEmB,IAAI,CAACyB,SAAL,CAAe9C,KAAK,CAAC+C,gBAAN,IAA0B,EAAzC,CAApD;IAAkG,KAAK,EAAE;MAAE3C,MAAM,EAAEA;IAAV;EAAzG,EAFF,CADF;AAMD,CAnE+B,CAAzB"}
1
+ {"version":3,"names":["React","requireNativeComponent","NativeModules","NativeEventEmitter","Platform","findNodeHandle","UIManager","ActivityIndicator","RNPEEventEmitter","COMPONENT_NAME","RNPECreditCardView","RNPECreditCardViewManager","peEventEmitter","PECreditCardView","forwardRef","props","ref","formRef","useRef","height","setHeight","useState","useImperativeHandle","submit","data","Promise","resolve","reject","Error","listener","addListener","args","remove","error","card","json","JSON","parse","callNativeMethod","merchantId","additionalData","showKeyboard","hideKeyboard","useCallback","methodName","params","console","log","viewId","current","commandId","Commands","toString","OS","Number","dispatchViewManagerCommand","useEffect","eventListener","width","_","frameHeight","stringify","additionalFields"],"sources":["CreditCardView.tsx"],"sourcesContent":["\nimport * as React from 'react';\nimport { requireNativeComponent, NativeModules, NativeEventEmitter, type ViewProps, Platform, findNodeHandle, UIManager, ActivityIndicator } from 'react-native';\nimport type IPEField from './IPEField';\nimport type PECard from './PECard';\nimport type ITokenizationData from './ITokenizationData';\n\nconst { RNPEEventEmitter } = NativeModules;\n\ninterface NativePECreditCardViewProps extends ViewProps {\n additionalFields: string;\n}\n\nconst COMPONENT_NAME = 'RNPECreditCardView'\nconst RNPECreditCardView = requireNativeComponent<NativePECreditCardViewProps>(COMPONENT_NAME);\n// @ts-ignore\nconst RNPECreditCardViewManager = UIManager[COMPONENT_NAME]\nconst peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);\n\n/**\n * Props for the `PECreditCardView` component.\n *\n * Allows optional configuration of additional input fields that can be rendered\n * alongside the standard credit card fields.\n *\n * These fields can be used to collect extra information such as ZIP code, billing address,\n * or custom metadata required by the merchant.\n *\n * @category SecureFields\n *\n * @example\n * ```ts\n * const fields: IPEField[] = [\n * {\n * name: \"zipCode\",\n * type: \"text\",\n * placeholder: \"ZIP Code\",\n * keyboardType: PEKeyboardType.Numeric,\n * isRequired: true\n * }\n * ];\n *\n * <PECreditCardView additionalFields={fields} />\n * ```\n */\nexport interface PECreditCardViewProps {\n /**\n * (Optional) A list of additional fields to be displayed in the credit card form.\n *\n * These are rendered below the standard card number, expiry, and CVV fields.\n */\n additionalFields?: IPEField[];\n}\n\n\n/**\n * Provides methods to control and interact with the PayEngine Credit Card input view.\n *\n * This interface defines methods for submitting credit card details for tokenization\n * and managing keyboard visibility.\n *\n * @category SecureFields\n */\nexport interface PECreditCardViewMethods {\n /**\n * Submits the entered credit card information to PayEngine for tokenization.\n *\n * @param data - Optional merchant info and additional metadata.\n * @returns A promise that resolves to a tokenized credit card object (`PECard`).\n *\n * @example\n * ```ts\n * const result = await creditCardRef.current?.submit({\n * merchantId: \"merchant_123\",\n * additionalData: { source: \"checkout\" }\n * });\n * ```\n */\n submit: (data: ITokenizationData) => Promise<PECard>;\n\n /**\n * Programmatically displays the keyboard for the credit card input fields.\n */\n showKeyboard: () => void;\n\n /**\n * Programmatically hides the keyboard for the credit card input fields.\n */\n hideKeyboard: () => void;\n}\n\n/**\n * A secure form for entering a customer's credit card information safely.\n *\n * [PECreditCardView] provides an interface for users to input their credit card details securely.\n * It integrates with PayEngine to tokenize the card details and forward them to a PCI-compliant\n * third party without storing sensitive information locally.\n *\n * ## How It Works\n *\n * 1. Create an instance of [PECreditCardView], optionally passing additional fields.\n * 2. Display the form inside your UI.\n * 3. Once the user enters their details, call [submit] to securely process and retrieve a tokenized version of the card.\n * 4. Use [showKeyboard] and [hideKeyboard] to manually control the keyboard.\n *\n * ## Example Usage\n *\n * ```tsx\n * const formRef = React.createRef<PECreditCardViewMethods>();\n * \n * \n * const additionalFields = [\n * {\n * name: 'address_zip',\n * type: 'text',\n * placeholder: 'Zip code',\n * keyboardType: PEKeyboardType.alphabet,\n * isRequired: true,\n * pattern: '^(?:\\\\d{5}(?:-\\\\d{4})?|[ABCEGHJKLMNPRSTVXY]\\\\d[A-Z] ?\\\\d[A-Z]\\\\d)$'\n * }\n * ]\n *\n * return (\n * <View style={styles.container}>\n * <Text>Welcome to PayEngine React Native SDK example</Text>\n * <View style={{ width: '100%' }}>\n * <PECreditCardView ref={formRef} additionalFields={additionalFields} />\n * <Button disabled={submitting} onPress={() => createCard()} title=\"Create Card\" />\n * <Button onPress={() => formRef.current?.showKeyboard()} title=\"Show keyboard\" />\n * <Button onPress={() => formRef.current?.hideKeyboard()} title=\"Hide keyboard\" />\n * </View>\n * <ScrollView style={{ flex: 1, width: '100%', backgroundColor: 'lightyellow', padding: 10, marginVertical: 20 }}>\n * <Text>{JSON.stringify(secureFieldsResult, null, 4)}</Text>\n * </ScrollView>\n * </View>\n * );\n * ```\n *\n * ## Features:\n * - Securely collects credit card details.\n * - Supports additional customizable fields.\n * - Provides methods to show/hide the keyboard.\n * - Allows submitting the entered data for tokenization and safe storage.\n * \n * @category SecureFields\n */\nexport const PECreditCardView = React.forwardRef<\n PECreditCardViewMethods,\n PECreditCardViewProps\n>((props, ref) => {\n const formRef = React.useRef<any>();\n const [height, setHeight] = React.useState(0);\n\n React.useImperativeHandle(ref, () => ({\n submit: async (data: ITokenizationData = {}) => {\n return new Promise((resolve, reject) => {\n if (height === 0) {\n return reject(new Error('Form is not ready'))\n }\n\n const listener = peEventEmitter.addListener('onCardRespond', args => {\n listener.remove()\n\n const { error, card: json } = args;\n if (error) {\n reject(new Error(error))\n } else {\n const card = JSON.parse(json) as PECard;\n resolve(card)\n }\n });\n\n callNativeMethod(\"submit\", [data.merchantId, data.additionalData])\n });\n },\n showKeyboard: () => {\n callNativeMethod(\"showKeyboard\")\n },\n hideKeyboard: () => {\n callNativeMethod(\"hideKeyboard\")\n }\n }));\n\n const callNativeMethod = React.useCallback((methodName: string, params: any[] = []) => {\n console.log(\"callNativeMethod\", methodName, params)\n const viewId = findNodeHandle(formRef.current);\n let commandId = RNPECreditCardViewManager.Commands[methodName].toString()\n if (Platform.OS === 'ios') {\n commandId = Number(commandId)\n }\n UIManager.dispatchViewManagerCommand(\n viewId,\n commandId,\n params,\n );\n }, [formRef.current])\n\n React.useEffect(() => {\n const eventListener = peEventEmitter.addListener('onSizeChanges', args => {\n const { width: _, height: frameHeight } = args;\n setHeight(frameHeight);\n });\n\n return () => eventListener.remove();\n }, []);\n\n\n return (\n <>\n {height === 0 && <ActivityIndicator />}\n <RNPECreditCardView ref={formRef} additionalFields={JSON.stringify(props.additionalFields ?? [])} style={{ height: height }} />\n </>\n );\n});\n"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,sBAAT,EAAiCC,aAAjC,EAAgDC,kBAAhD,EAAoFC,QAApF,EAA8FC,cAA9F,EAA8GC,SAA9G,EAAyHC,iBAAzH,QAAkJ,cAAlJ;AAKA,MAAM;EAAEC;AAAF,IAAuBN,aAA7B;AAMA,MAAMO,cAAc,GAAG,oBAAvB;AACA,MAAMC,kBAAkB,GAAGT,sBAAsB,CAA8BQ,cAA9B,CAAjD,C,CACA;;AACA,MAAME,yBAAyB,GAAGL,SAAS,CAACG,cAAD,CAA3C;AACA,MAAMG,cAAc,GAAG,IAAIT,kBAAJ,CAAuBK,gBAAvB,CAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA+CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AnE+B,CAAzB"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["IPEField.ts"],"sourcesContent":["import type PEKeyboardType from \"./PEKeyboardType\";\n\ninterface IPEField {\n name: string;\n type: string;\n placeholder: string;\n keyboardType: PEKeyboardType;\n isRequired: boolean;\n pattern?: string;\n}\n\nexport default IPEField;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["IPEField.ts"],"sourcesContent":["import type PEKeyboardType from \"./PEKeyboardType\";\n\n/**\n * Represents an input field in the PayEngine system.\n *\n * The `IPEField` interface defines a form field with properties such as\n * its name, type, placeholder, keyboard type, whether it is required, and\n * an optional validation pattern.\n *\n * @category SecureFields\n *\n * @example\n * ```ts\n * const emailField: IPEField = {\n * name: \"email\",\n * type: \"text\",\n * placeholder: \"Enter your email\",\n * keyboardType: PEKeyboardType.Alphabet,\n * isRequired: true,\n * pattern: \"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,}$\"\n * };\n * ```\n */\ninterface IPEField {\n /**\n * The unique identifier for the field.\n *\n * Typically used as the key when submitting form data.\n */\n name: string;\n\n /**\n * The type of the field (e.g., \"text\", \"password\", \"email\").\n *\n * Defines how the field’s value should be interpreted.\n */\n type: string;\n\n /**\n * The placeholder text shown when the field is empty.\n */\n placeholder: string;\n\n /**\n * Specifies the type of keyboard to display for this field.\n *\n * Example: `PEKeyboardType.Numeric`, `PEKeyboardType.Alphabet`\n */\n keyboardType: PEKeyboardType;\n\n /**\n * Indicates whether the field is required for form submission.\n *\n * If `true`, the field must be filled in with a valid value.\n */\n isRequired: boolean;\n\n /**\n * Optional regular expression used to validate the field's value.\n *\n * If omitted, no validation is enforced.\n */\n pattern?: string;\n}\n\n\nexport default IPEField;\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["ITokenizationData.ts"],"sourcesContent":["interface ITokenizationData {\n merchantId?: string;\n additionalData?: { \n [key: string]: string \n };\n}\n\nexport default ITokenizationData;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["ITokenizationData.ts"],"sourcesContent":["/**\n * Represents the data used for tokenizing a credit card or bank account.\n *\n * This interface allows passing additional metadata or specifying the merchant\n * for whom the data is being tokenized.\n *\n * @category SecureFields\n */\ninterface ITokenizationData {\n /**\n * (Optional) The merchant ID on behalf of whom the tokenization is performed.\n */\n merchantId?: string;\n\n /**\n * (Optional) A key-value map of additional metadata to include in the request.\n */\n additionalData?: {\n [key: string]: string;\n };\n}\n\nexport default ITokenizationData;\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["PEBankAccount.ts"],"sourcesContent":["interface PEBankAccount {\n id: string;\n token: string;\n account_data: {\n first_name: string;\n last_name: string;\n routing_number: string;\n last_4: string;\n };\n}\n\nexport default PEBankAccount;"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["PEBankAccount.ts"],"sourcesContent":["/**\n * Represents a bank account stored within PayEngine.\n *\n * This interface contains a secure token and account details, ensuring sensitive banking\n * information is securely managed within the system.\n *\n * @category SecureFields\n */\ninterface PEBankAccount {\n /**\n * A unique identifier for the bank account.\n *\n * This may be used internally to reference the bank account object.\n */\n id: string;\n\n /**\n * A secure token representing the bank account.\n *\n * This token is used for referencing the account in API operations without exposing raw bank details.\n */\n token: string;\n\n /**\n * The associated bank account details.\n *\n * Includes essential information such as the account holder's name,\n * the routing number, and the last four digits of the account number.\n */\n account_data: {\n /**\n * The first name of the account holder.\n */\n first_name: string;\n\n /**\n * The last name of the account holder.\n */\n last_name: string;\n\n /**\n * The bank's routing number.\n */\n routing_number: string;\n\n /**\n * The last four digits of the bank account number.\n */\n last_4: string;\n };\n}\n\n\nexport default PEBankAccount;"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["PECard.ts"],"sourcesContent":["interface PECard {\n token: string;\n card_data: {\n id: string;\n brand: string;\n last_4: string;\n exp_year: string;\n exp_month: string;\n name: string;\n address_zip?: string;\n };\n}\n\nexport default PECard;"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["PECard.ts"],"sourcesContent":["/**\n * Represents a payment card stored with PayEngine.\n *\n * This interface contains a secure token and associated card details,\n * ensuring sensitive payment information is securely managed within the system.\n *\n * @category SecureFields\n */\ninterface PECard {\n /**\n * A secure token representing the card.\n *\n * This token is used to safely reference the card in API operations without exposing raw card data.\n */\n token: string;\n\n /**\n * The associated card details.\n *\n * Includes essential information such as brand, expiration date,\n * the last four digits, cardholder name, and optional billing ZIP code.\n */\n card_data: {\n /**\n * A unique identifier for the card.\n *\n * This ID is typically used to reference the card object in system operations.\n */\n id: string;\n\n /**\n * The brand of the card (e.g., Visa, MasterCard).\n */\n brand: string;\n\n /**\n * The last four digits of the card number.\n *\n * Useful for displaying or confirming the card to the user.\n */\n last_4: string;\n\n /**\n * The expiration year of the card.\n */\n exp_year: string;\n\n /**\n * The expiration month of the card.\n */\n exp_month: string;\n\n /**\n * The name of the cardholder.\n */\n name: string;\n\n /**\n * The ZIP code associated with the card's billing address (optional).\n */\n address_zip?: string;\n };\n}\n\n\nexport default PECard;"],"mappings":""}
@@ -1,4 +1,19 @@
1
- var PEKeyboardType;
1
+ /**
2
+ * Defines the keyboard type for a PayEngine secure input field.
3
+ *
4
+ * @remarks
5
+ * This enum is used in {@link IPEField.keyboardType} to control the keyboard layout
6
+ * shown to the user based on the input field's context.
7
+ *
8
+ * The available keyboard types are:
9
+ * - {@link PEKeyboardType.alphabet} — Optimized for alphabetic characters.
10
+ * - {@link PEKeyboardType.number} — Optimized for numeric input.
11
+ * - {@link PEKeyboardType.phone} — Designed for entering phone numbers.
12
+ * - {@link PEKeyboardType.normal} — Standard keyboard with alphanumeric characters.
13
+ *
14
+ * @category SecureFields
15
+ */
16
+ export let PEKeyboardType;
2
17
 
3
18
  (function (PEKeyboardType) {
4
19
  PEKeyboardType["alphabet"] = "alphabet";
@@ -1 +1 @@
1
- {"version":3,"names":["PEKeyboardType"],"sources":["PEKeyboardType.ts"],"sourcesContent":["enum PEKeyboardType {\n alphabet = 'alphabet',\n number = 'number',\n phone = 'phone',\n normal = 'normal',\n}\n\nexport default PEKeyboardType;\n"],"mappings":"IAAKA,c;;WAAAA,c;EAAAA,c;EAAAA,c;EAAAA,c;EAAAA,c;GAAAA,c,KAAAA,c;;AAOL,eAAeA,cAAf"}
1
+ {"version":3,"names":["PEKeyboardType"],"sources":["PEKeyboardType.ts"],"sourcesContent":["import type IPEField from './IPEField';\n\n/**\n * Defines the keyboard type for a PayEngine secure input field.\n *\n * @remarks\n * This enum is used in {@link IPEField.keyboardType} to control the keyboard layout\n * shown to the user based on the input field's context.\n *\n * The available keyboard types are:\n * - {@link PEKeyboardType.alphabet} — Optimized for alphabetic characters.\n * - {@link PEKeyboardType.number} — Optimized for numeric input.\n * - {@link PEKeyboardType.phone} — Designed for entering phone numbers.\n * - {@link PEKeyboardType.normal} — Standard keyboard with alphanumeric characters.\n *\n * @category SecureFields\n */\nexport enum PEKeyboardType {\n alphabet = 'alphabet',\n number = 'number',\n phone = 'phone',\n normal = 'normal',\n}\n\nexport default PEKeyboardType;\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,cAAZ;;WAAYA,c;EAAAA,c;EAAAA,c;EAAAA,c;EAAAA,c;GAAAA,c,KAAAA,c;;AAOZ,eAAeA,cAAf"}