react-native-payengine 2.0.17 → 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 (156) 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/Info.plist +5 -5
  11. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/KDataCollector.h +4 -25
  12. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/KountAnalyticsViewController.h +0 -20
  13. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/KountPrivate.h +61 -0
  14. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +430 -149
  15. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Info.plist +0 -0
  16. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.abi.json +1962 -5715
  17. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +35 -129
  18. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface-e +35 -129
  19. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  20. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface +35 -129
  21. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface-e +35 -129
  22. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/PayEngineSDK +0 -0
  23. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Assets.car +0 -0
  24. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Info.plist +0 -0
  25. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/KDataCollector.h +4 -25
  26. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/KountAnalyticsViewController.h +0 -20
  27. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/KountPrivate.h +61 -0
  28. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +860 -298
  29. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Info.plist +0 -0
  30. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +1962 -5715
  31. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +35 -129
  32. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface-e +35 -129
  33. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  34. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +35 -129
  35. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface-e +35 -129
  36. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1962 -5715
  37. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +35 -129
  38. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface-e +35 -129
  39. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  40. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +35 -129
  41. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface-e +35 -129
  42. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/PayEngineSDK +0 -0
  43. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Info.plist +0 -0
  44. package/ios/Sources/Classes/RNPEEventEmitter.swift +1 -1
  45. package/ios/Sources/Classes/RNPayEngineNative.swift +125 -64
  46. package/ios/Sources/Classes/SecureFields/RNPEEvents.swift +1 -0
  47. package/ios/Sources/Payengine.m +6 -0
  48. package/lib/commonjs/components/PayEngine.js +1 -1
  49. package/lib/commonjs/components/PayEngine.js.map +1 -1
  50. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js +124 -0
  51. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  52. package/lib/commonjs/components/v2/ApplePay/PEApplePayInterfaces.js +78 -0
  53. package/lib/commonjs/components/v2/ApplePay/PEApplePayInterfaces.js.map +1 -1
  54. package/lib/commonjs/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -1
  55. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js +53 -0
  56. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  57. package/lib/commonjs/components/v2/PEPaymentRequest.js +121 -0
  58. package/lib/commonjs/components/v2/PEPaymentRequest.js.map +1 -1
  59. package/lib/commonjs/components/v2/PayEngineNative.js +182 -4
  60. package/lib/commonjs/components/v2/PayEngineNative.js.map +1 -1
  61. package/lib/commonjs/components/v2/PayEngineProvider.js +52 -0
  62. package/lib/commonjs/components/v2/PayEngineProvider.js.map +1 -1
  63. package/lib/commonjs/components/v2/SecureFields/BankAccountView.js +71 -0
  64. package/lib/commonjs/components/v2/SecureFields/BankAccountView.js.map +1 -1
  65. package/lib/commonjs/components/v2/SecureFields/CreditCardView.js +82 -0
  66. package/lib/commonjs/components/v2/SecureFields/CreditCardView.js.map +1 -1
  67. package/lib/commonjs/components/v2/SecureFields/IPEField.js.map +1 -1
  68. package/lib/commonjs/components/v2/SecureFields/ITokenizationData.js.map +1 -1
  69. package/lib/commonjs/components/v2/SecureFields/PEBankAccount.js.map +1 -1
  70. package/lib/commonjs/components/v2/SecureFields/PECard.js.map +1 -1
  71. package/lib/commonjs/components/v2/SecureFields/PEKeyboardType.js +20 -3
  72. package/lib/commonjs/components/v2/SecureFields/PEKeyboardType.js.map +1 -1
  73. package/lib/commonjs/index.js +17 -13
  74. package/lib/commonjs/index.js.map +1 -1
  75. package/lib/commonjs/interfaces/index.js +20 -0
  76. package/lib/commonjs/interfaces/index.js.map +1 -1
  77. package/lib/commonjs/utils/index.js +26 -0
  78. package/lib/commonjs/utils/index.js.map +1 -1
  79. package/lib/module/components/PayEngine.js +1 -1
  80. package/lib/module/components/PayEngine.js.map +1 -1
  81. package/lib/module/components/v2/ApplePay/PEApplePayButton.js +124 -0
  82. package/lib/module/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  83. package/lib/module/components/v2/ApplePay/PEApplePayInterfaces.js +75 -0
  84. package/lib/module/components/v2/ApplePay/PEApplePayInterfaces.js.map +1 -1
  85. package/lib/module/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -1
  86. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js +53 -0
  87. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  88. package/lib/module/components/v2/PEPaymentRequest.js +119 -0
  89. package/lib/module/components/v2/PEPaymentRequest.js.map +1 -1
  90. package/lib/module/components/v2/PayEngineNative.js +184 -5
  91. package/lib/module/components/v2/PayEngineNative.js.map +1 -1
  92. package/lib/module/components/v2/PayEngineProvider.js +51 -0
  93. package/lib/module/components/v2/PayEngineProvider.js.map +1 -1
  94. package/lib/module/components/v2/SecureFields/BankAccountView.js +71 -0
  95. package/lib/module/components/v2/SecureFields/BankAccountView.js.map +1 -1
  96. package/lib/module/components/v2/SecureFields/CreditCardView.js +82 -0
  97. package/lib/module/components/v2/SecureFields/CreditCardView.js.map +1 -1
  98. package/lib/module/components/v2/SecureFields/IPEField.js.map +1 -1
  99. package/lib/module/components/v2/SecureFields/ITokenizationData.js.map +1 -1
  100. package/lib/module/components/v2/SecureFields/PEBankAccount.js.map +1 -1
  101. package/lib/module/components/v2/SecureFields/PECard.js.map +1 -1
  102. package/lib/module/components/v2/SecureFields/PEKeyboardType.js +16 -1
  103. package/lib/module/components/v2/SecureFields/PEKeyboardType.js.map +1 -1
  104. package/lib/module/index.js +10 -5
  105. package/lib/module/index.js.map +1 -1
  106. package/lib/module/interfaces/index.js +19 -0
  107. package/lib/module/interfaces/index.js.map +1 -1
  108. package/lib/module/utils/index.js +27 -0
  109. package/lib/module/utils/index.js.map +1 -1
  110. package/lib/typescript/components/PayEngine.d.ts +1 -1
  111. package/lib/typescript/components/v2/ApplePay/PEApplePayButton.d.ts +217 -12
  112. package/lib/typescript/components/v2/ApplePay/PEApplePayInterfaces.d.ts +180 -1
  113. package/lib/typescript/components/v2/GooglePay/PEGooglePayAddress.d.ts +30 -0
  114. package/lib/typescript/components/v2/GooglePay/PEGooglePayButton.d.ts +99 -0
  115. package/lib/typescript/components/v2/PEPaymentRequest.d.ts +130 -9
  116. package/lib/typescript/components/v2/PayEngineNative.d.ts +165 -7
  117. package/lib/typescript/components/v2/PayEngineProvider.d.ts +51 -0
  118. package/lib/typescript/components/v2/SecureFields/BankAccountView.d.ts +103 -0
  119. package/lib/typescript/components/v2/SecureFields/CreditCardView.d.ts +114 -0
  120. package/lib/typescript/components/v2/SecureFields/IPEField.d.ts +49 -0
  121. package/lib/typescript/components/v2/SecureFields/ITokenizationData.d.ts +14 -0
  122. package/lib/typescript/components/v2/SecureFields/PEBankAccount.d.ts +36 -0
  123. package/lib/typescript/components/v2/SecureFields/PECard.d.ts +44 -0
  124. package/lib/typescript/components/v2/SecureFields/PEKeyboardType.d.ts +16 -1
  125. package/lib/typescript/index.d.ts +11 -5
  126. package/lib/typescript/interfaces/index.d.ts +35 -1
  127. package/lib/typescript/utils/index.d.ts +21 -0
  128. package/package.json +6 -3
  129. package/src/components/PayEngine.tsx +1 -1
  130. package/src/components/v2/ApplePay/PEApplePayButton.tsx +225 -12
  131. package/src/components/v2/ApplePay/PEApplePayInterfaces.ts +221 -8
  132. package/src/components/v2/GooglePay/PEGooglePayAddress.ts +39 -1
  133. package/src/components/v2/GooglePay/PEGooglePayButton.tsx +113 -9
  134. package/src/components/v2/PEPaymentRequest.ts +151 -13
  135. package/src/components/v2/PayEngineNative.tsx +196 -9
  136. package/src/components/v2/PayEngineProvider.tsx +52 -1
  137. package/src/components/v2/SecureFields/BankAccountView.tsx +108 -1
  138. package/src/components/v2/SecureFields/CreditCardView.tsx +118 -1
  139. package/src/components/v2/SecureFields/IPEField.ts +55 -0
  140. package/src/components/v2/SecureFields/ITokenizationData.ts +17 -2
  141. package/src/components/v2/SecureFields/PEBankAccount.ts +42 -0
  142. package/src/components/v2/SecureFields/PECard.ts +52 -0
  143. package/src/components/v2/SecureFields/PEKeyboardType.ts +18 -1
  144. package/src/index.tsx +23 -5
  145. package/src/interfaces/index.ts +40 -2
  146. package/src/utils/index.ts +21 -0
  147. package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
  148. package/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
  149. package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
  150. package/android/.gradle/6.1.1/gc.properties +0 -0
  151. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/CustomWindow.h +0 -25
  152. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/UIControl+CustomControl.h +0 -33
  153. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/UIViewController+TouchControl.h +0 -27
  154. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/CustomWindow.h +0 -25
  155. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/UIControl+CustomControl.h +0 -33
  156. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/UIViewController+TouchControl.h +0 -27
package/README.md CHANGED
@@ -1,14 +1,10 @@
1
- # react-native-payengine v2
2
-
3
- ## React Native SDK Version 2
4
-
5
- ### Overview
1
+ # Overview
6
2
 
7
3
  The new version of the PayEngine React Native SDK is designed to provide developers with a more flexible and customizable payment experience. Its primary goal is to integrate with PayEngine native SDKs for both iOS and Android. By leveraging native SDKs (xcframework for iOS and AAR for Android), the SDK ensures a more seamless user experience without requiring codebase changes from multiple repositories.
8
4
 
9
- ### Prerequisites
5
+ # Prerequisites
10
6
 
11
- #### Add PayEngine Registry to your project
7
+ ## Add PayEngine Registry to your project
12
8
 
13
9
  ```
14
10
  allprojects {
@@ -29,32 +25,32 @@ allprojects {
29
25
  ```
30
26
  Please contact PayEngine support for username and password
31
27
 
32
- #### Install Package
28
+ ## Install Package
33
29
 
34
30
  ```bash
35
31
  yarn add react-native-payengine@2
36
32
  ```
37
33
 
38
- #### Android
34
+ ## Important Configuration When Developing on Android
39
35
 
40
36
  To use secure fields components, you need to install and configure the Material Components theme in your app.
41
37
 
42
38
  1. Add the following dependency to your `app/build.gradle` file with the specified version:
43
39
 
44
- ```gradle
40
+ ```
45
41
  implementation 'com.google.android.material:material:<version>'
46
42
  ```
47
43
 
48
44
  2. Enable Jetifier in your app's `gradle.properties` if you encounter duplicate class issues like:
49
45
 
50
- ```text
46
+ ```
51
47
  android.useAndroidX=true
52
48
  android.enableJetifier=true
53
49
  ```
54
50
 
55
51
  Example error:
56
52
 
57
- ```text
53
+ ```
58
54
  FAILURE: Build failed with an exception.
59
55
 
60
56
  * What went wrong:
@@ -79,9 +75,8 @@ public class MainApplication extends RNPEFraudAnalyticsApplication implements Re
79
75
  }
80
76
  ```
81
77
 
82
- ### Usage
83
78
 
84
- #### Wrap the Config in a Provider
79
+ ## Wrap the Config in a Provider
85
80
 
86
81
  ```jsx
87
82
  import { PEProvider } from 'react-native-payengine';
@@ -99,7 +94,17 @@ const App = () => {
99
94
  };
100
95
  ```
101
96
 
102
- #### Credit Card Form
97
+ ## Set the Fetch Access Token Callback
98
+
99
+ This is a required callback that you need to set in the SDK for the other functionalities to work properly.
100
+
101
+ Please check the documentation for `setFetchAccessTokenCallback` to understand the implementation details.
102
+
103
+ # Examples
104
+
105
+ The following examples demonstrate how to integrate and use the components provided by the PayEngine SDK within your application. Some features require additional configuration or platform-specific setup; these examples will also outline any prerequisites to ensure a smooth implementation.
106
+
107
+ ## Credit Card Form
103
108
 
104
109
  ```jsx
105
110
  import React from 'react';
@@ -144,7 +149,7 @@ const CreditCardForm = () => {
144
149
  };
145
150
  ```
146
151
 
147
- #### Bank Account Form
152
+ ## Bank Account Form
148
153
 
149
154
  ```jsx
150
155
  import React from 'react';
@@ -177,70 +182,77 @@ const BankAccountForm = () => {
177
182
  };
178
183
  ```
179
184
 
180
- #### Apple Pay
185
+ ## Google Pay
186
+
187
+ Google Pay is available on **Android** devices that support Google’s payment platform. After enabling Google Pay on your account, you can use the `PEGooglePayButton` component to initiate the Google Pay in-app payment flow.
188
+
189
+ Before implementing Google Pay through the PayEngine SDK, you must ensure that Google Pay is enabled for your PayEngine account. To do this, contact your PayEngine support representative to activate it.
190
+
191
+ For step-by-step instructions and additional details, refer to the official PayEngine documentation:
192
+ 👉 https://docs.payengine.co/developer-docs/processing-payments/google-pay-tm
193
+
194
+ Once Google Pay is enabled for your account, you can proceed with the implementation example shown below.
195
+
196
+
197
+ ### Example Usage
181
198
 
182
199
  ```jsx
183
200
  import React from 'react';
184
201
  import { View, Text, ScrollView } from 'react-native';
185
202
  import {
186
- PEApplePayButton,
203
+ PEGooglePayButton,
187
204
  PEPaymentRequest,
188
205
  PayEngineNative,
189
- PayEngineUtils,
190
- RNPEContactField,
191
206
  PayProvider
192
207
  } from 'react-native-payengine';
193
- import axios from 'axios';
194
208
 
195
- const ApplePayScreen = () => {
209
+ const GooglePayScreen = () => {
210
+ const MERCHANT_ID = 'Your merchant\'s id in the PayEngine system'
196
211
  const [canMakePayment, setCanMakePayment] = React.useState(false);
197
212
  const [paymentResult, setPaymentResult] = React.useState(null);
198
213
 
214
+ // Checking if the device supports Google Pay
199
215
  React.useEffect(() => {
200
216
  const checkSupport = async () => {
201
217
  try {
202
- const isSupported = await PayEngineNative.userCanPay(PayProvider.applePay,
218
+ const isSupported = await PayEngineNative.userCanPay(PayProvider.googlePay,
203
219
  MERCHANT_ID
204
220
  );
205
221
  console.log('isSupported', isSupported);
206
222
  setCanMakePayment(isSupported);
207
223
  } catch (e) {
208
- console.error('Apple Pay not supported', e);
224
+ console.error('Google Pay not supported', e);
209
225
  }
210
226
  };
211
227
  checkSupport();
212
228
  }, []);
213
229
 
214
- const paymentRequest: PEPaymentRequest = {
230
+ const paymentRequest = {
231
+ paymentAmount: amount,
215
232
  merchantId: MERCHANT_ID,
216
- paymentAmount: 10.15,
217
- currencyCode: 'USD',
218
- paymentItems: [
219
- {
220
- amount: 10.15,
221
- label: 'Total Amount',
222
- },
223
- ],
224
233
  platformOptions: {
225
- requiredBillingContactFields: [RNPEContactField.postalAddress],
226
- requiredShippingContactFields: []
234
+ billingAddressRequired: true,
235
+ billingAddressParameters: {
236
+ format: 'FULL'
237
+ },
238
+ shippingAddressRequired: false
227
239
  }
228
- }
240
+ };
229
241
 
230
242
  const purchaseWithToken = async (token) => {
231
- // send the token to your server to make a purchase
232
- // ...
243
+ // Send the token to your server.
244
+ // Your server then forwards the token PayEngine APIs to perform a transaction.
233
245
  };
234
246
 
235
247
  return (
236
248
  <View style={styles.container}>
237
- <Text>Apple Pay Demo</Text>
249
+ <Text>Google Pay Demo</Text>
238
250
  {canMakePayment && (
239
251
  <>
240
- <PEApplePayButton
252
+ <PEGooglePayButton
241
253
  paymentRequest={paymentRequest}
242
254
  onTokenDidReturn={(token) => {
243
- console.log('Apple Pay token', token);
255
+ console.log('google Pay token', token);
244
256
  // Send token to server
245
257
  purchaseWithToken(token);
246
258
  }}
@@ -272,26 +284,44 @@ const ApplePayScreen = () => {
272
284
  ```
273
285
 
274
286
 
275
- #### Google Pay
287
+ ## Apple Pay
288
+
289
+ Apple Pay is available only on **iOS** devices, in accordance with Apple’s platform requirements. After completing the required configuration and confirming support, you can use the `PEApplePayButton` component to launch the Apple Pay payment sheet.
290
+
291
+ Before implementing Apple Pay through the PayEngine SDK, you must complete the necessary native iOS setup. This includes configuring merchant identifier, enabling Apple Pay capability in XCode, creating and uploading the required certificate.
292
+
293
+ For step-by-step instructions, refer to the official PayEngine documentation:
294
+ 👉 https://docs.payengine.co/developer-docs/processing-payments/apple-pay/apple-pay-in-your-native-app
295
+
296
+ When the guide refers to **“Integrate with Xcode”**, it means opening the iOS project located in your React Native application’s `./ios` directory. Once opened in Xcode, follow the steps outlined in the documentation to enable Apple Pay support for your app.
297
+
298
+ After completing the native setup, you can proceed with the implementation example shown below.
299
+
300
+ ### Example Usage
276
301
 
277
302
  ```jsx
278
303
  import React from 'react';
279
304
  import { View, Text, ScrollView } from 'react-native';
280
305
  import {
281
- PEGooglePayButton,
306
+ PEApplePayButton,
282
307
  PEPaymentRequest,
283
308
  PayEngineNative,
309
+ PayEngineUtils,
310
+ RNPEContactField,
284
311
  PayProvider
285
312
  } from 'react-native-payengine';
313
+ import axios from 'axios';
286
314
 
287
- const GooglePayScreen = () => {
315
+ const ApplePayScreen = () => {
316
+ const MERCHANT_ID = 'Your merchant\'s id in the PayEngine system'
288
317
  const [canMakePayment, setCanMakePayment] = React.useState(false);
289
318
  const [paymentResult, setPaymentResult] = React.useState(null);
290
319
 
320
+ // Checking if the device supports Apple Pay
291
321
  React.useEffect(() => {
292
322
  const checkSupport = async () => {
293
323
  try {
294
- const isSupported = await PayEngineNative.userCanPay(PayProvider.googlePay,
324
+ const isSupported = await PayEngineNative.userCanPay(PayProvider.applePay,
295
325
  MERCHANT_ID
296
326
  );
297
327
  console.log('isSupported', isSupported);
@@ -303,32 +333,36 @@ const GooglePayScreen = () => {
303
333
  checkSupport();
304
334
  }, []);
305
335
 
306
- const paymentRequest = {
307
- paymentAmount: amount,
336
+ const paymentRequest: PEPaymentRequest = {
308
337
  merchantId: MERCHANT_ID,
309
- platformOptions: {
310
- billingAddressRequired: true,
311
- billingAddressParameters: {
312
- format: 'FULL'
338
+ paymentAmount: 10.15,
339
+ currencyCode: 'USD',
340
+ paymentItems: [
341
+ {
342
+ amount: 10.15,
343
+ label: 'Total Amount',
313
344
  },
314
- shippingAddressRequired: false
345
+ ],
346
+ platformOptions: {
347
+ requiredBillingContactFields: [RNPEContactField.postalAddress],
348
+ requiredShippingContactFields: []
315
349
  }
316
- };
350
+ }
317
351
 
318
352
  const purchaseWithToken = async (token) => {
319
- // send the token to your server to make a purchase
320
- // ...
353
+ // Send the token to your server.
354
+ // Your server then forwards the token PayEngine APIs to perform a transaction.
321
355
  };
322
356
 
323
357
  return (
324
358
  <View style={styles.container}>
325
- <Text>Google Pay Demo</Text>
359
+ <Text>Apple Pay Demo</Text>
326
360
  {canMakePayment && (
327
361
  <>
328
- <PEGooglePayButton
362
+ <PEApplePayButton
329
363
  paymentRequest={paymentRequest}
330
364
  onTokenDidReturn={(token) => {
331
- console.log('google Pay token', token);
365
+ console.log('Apple Pay token', token);
332
366
  // Send token to server
333
367
  purchaseWithToken(token);
334
368
  }}
@@ -359,7 +393,7 @@ const GooglePayScreen = () => {
359
393
  };
360
394
  ```
361
395
 
362
- #### Dynamic Pricing
396
+ ## Dynamic Pricing
363
397
 
364
398
  **Note**: Android doesn't support Dynamic pricing yet although it's supported on Web. Track the issue here https://issuetracker.google.com/issues/331369810?pli=1
365
399
 
@@ -394,11 +428,9 @@ const paymentRequest = {
394
428
  }
395
429
  ```
396
430
 
397
- Implement the callbacks:
398
-
399
- ```javascript
431
+ ```jsx
400
432
  <PEApplePayButton
401
- ...buttonOptions
433
+ paymentRequest={paymentRequest}
402
434
  ref={buttonRef}
403
435
  onPaymentMethodSelected={(event) => {
404
436
  console.log('onPaymentMethodSelected', event.nativeEvent)
@@ -472,5 +504,4 @@ Implement the callbacks:
472
504
 
473
505
  **Important**:
474
506
 
475
- If either of `onPaymentMethodSelected`, `onShippingContactSelected` or `onShippingMethodSelected` callbacks are registered, you must update the Apple Pay sheet in your callback using `buttonRef.current?.updatePaymentSheet(...)` function, otherwise the Apple Pay shset will hang and the payment flow will automatically cancel.
476
-
507
+ If either of `onPaymentMethodSelected`, `onShippingContactSelected` or `onShippingMethodSelected` callbacks are registered, you must update the Apple Pay sheet in your callback using `buttonRef.current?.updatePaymentSheet(...)` function, otherwise the Apple Pay shset will hang and the payment flow will automatically cancel.
@@ -171,8 +171,8 @@ dependencies {
171
171
  // implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
172
172
  // implementation "com.google.android.gms:play-services-wallet:19.2.1"
173
173
 
174
- debugApi("com.payengine.sdk:payment-sdk-release:1.0.10")
175
- releaseApi("com.payengine.sdk:payment-sdk-release:1.0.10")
174
+ debugApi("com.payengine.sdk:payment-sdk-debug:1.1.1-alpha.0")
175
+ releaseApi("com.payengine.sdk:payment-sdk-release:1.1.1-alpha.0")
176
176
  implementation("com.google.android.gms:play-services-wallet:19.2.1")
177
177
 
178
178
  // From node_modules
@@ -1,22 +1,32 @@
1
1
  package com.reactnativepayengine.v2
2
2
 
3
- import android.app.Activity
4
3
  import android.util.Log
4
+ import com.facebook.react.bridge.Arguments
5
5
  import com.facebook.react.bridge.Promise
6
6
  import com.facebook.react.bridge.ReactApplicationContext
7
7
  import com.facebook.react.bridge.ReactContextBaseJavaModule
8
8
  import com.facebook.react.bridge.ReactMethod
9
+ import com.facebook.react.bridge.ReadableMap
9
10
  import com.facebook.react.bridge.UiThreadUtil.runOnUiThread
11
+ import com.facebook.react.modules.core.DeviceEventManagerModule
10
12
  import com.payengine.paymentsdk.PayEngine
11
13
  import com.payengine.paymentsdk.features.googlepay.PEGooglePayInterface
12
14
  import com.payengine.paymentsdk.features.googlepay.PEGooglePayStatus
13
15
  import com.payengine.paymentsdk.models.PEConfig
14
- import kotlin.concurrent.thread
16
+ import com.payengine.paymentsdk.utils.PEAccessToken
17
+ import com.reactnativepayengine.v2.securefields.RNPEEvents
18
+ import java.util.concurrent.CountDownLatch
19
+ import java.util.concurrent.TimeUnit
15
20
 
16
21
  class RNPayEngineNative: ReactContextBaseJavaModule {
22
+ private var context: ReactApplicationContext
17
23
 
18
- constructor(context: ReactApplicationContext): super(context) {
24
+ private var accessTokenProvider: (() -> PEAccessToken)? = null
25
+ private var latch: CountDownLatch? = null
26
+ private var resultFromJS: ReadableMap? = null
19
27
 
28
+ constructor(context: ReactApplicationContext): super(context) {
29
+ this.context = context
20
30
  }
21
31
 
22
32
  override fun getName(): String {
@@ -87,8 +97,60 @@ class RNPayEngineNative: ReactContextBaseJavaModule {
87
97
  }
88
98
  }
89
99
 
100
+ @ReactMethod
101
+ fun configureFetchAccessTokenCallback(promise: Promise) {
102
+ accessTokenProvider = { fetchAccessTokenFromReact() }
103
+ PayEngine.setFetchAccessTokenCallback(accessTokenProvider!!)
104
+ promise.resolve(null)
105
+ }
106
+
107
+ // Blocking function to fetch access token synchronously
108
+ private fun fetchAccessTokenFromReact(): PEAccessToken {
109
+ latch = CountDownLatch(1)
110
+ resultFromJS = null
111
+
112
+ // Send event to JS
113
+ val params = Arguments.createMap()
114
+ context
115
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
116
+ .emit(RNPEEvents.ON_FETCH_ACCESS_TOKEN, params)
117
+
118
+ // Wait (max 5 seconds)
119
+ try {
120
+ latch?.await(5, TimeUnit.SECONDS)
121
+ } catch (e: Exception) {
122
+ e.printStackTrace()
123
+ }
124
+
125
+ val accessToken = resultFromJS?.getString("accessToken")
126
+ val expiresIn = resultFromJS?.getInt("expiresIn")?.toLong()
127
+
128
+ if (accessToken != null && expiresIn != null) {
129
+ return object : PEAccessToken {
130
+ override val accessToken: String = accessToken
131
+ override val expiresIn: Long = expiresIn
132
+ }
133
+ }
134
+
135
+ throw Exception("No token received from Flutter")
136
+ }
137
+
138
+ @ReactMethod
139
+ fun provideFetchAccessTokenResult(value: ReadableMap?, promise: Promise) {
140
+ resultFromJS = value
141
+ latch?.countDown()
142
+ promise.resolve(null)
143
+ }
144
+
90
145
  companion object {
91
146
  var instance: PayEngine? = null
92
147
  var googlePay: PEGooglePayInterface? = null
93
148
  }
149
+
150
+
151
+ @ReactMethod
152
+ fun logout(merchantId: String, promise: Promise) {
153
+ PayEngine.logout(merchantId)
154
+ promise.resolve(null)
155
+ }
94
156
  }
@@ -8,4 +8,5 @@ object RNPEEvents {
8
8
  val ON_GOOGLE_PAY_RESPOND = "onGooglePayRespond"
9
9
  val ON_GOOGLE_PAY_ERROR = "onGooglePayError"
10
10
  val ON_GOOGLE_PAY_DISMISS = "onGooglePayDismiss"
11
+ const val ON_FETCH_ACCESS_TOKEN = "fetchAccessToken"
11
12
  }
@@ -58,12 +58,25 @@ class RNPEBankAccountViewManager: SimpleViewManager<RNPEBankAccountView> {
58
58
  "hideKeyboard" to COMMAND_HIDE_KEYBOARD
59
59
  )
60
60
 
61
+ // Legacy receiveCommand for old architecture compatibility
61
62
  override fun receiveCommand(root: RNPEBankAccountView, commandId: String?, args: ReadableArray?) {
62
63
  super.receiveCommand(root, commandId, args)
63
- when (commandId?.toInt()) {
64
+ executeCommand(root, commandId?.toIntOrNull() ?: -1, args)
65
+ }
66
+
67
+ // New Architecture (Fabric) receiveCommand override with Int commandId
68
+ @Suppress("DEPRECATION")
69
+ override fun receiveCommand(root: RNPEBankAccountView, commandId: Int, args: ReadableArray?) {
70
+ executeCommand(root, commandId, args)
71
+ }
72
+
73
+ private fun executeCommand(root: RNPEBankAccountView, commandId: Int, args: ReadableArray?) {
74
+ when (commandId) {
64
75
  COMMAND_SUBMIT -> {
65
- val merchantId = if (args?.isNull(0) == true) null else args!!.getString(0)
66
- val additionalData = if (args?.isNull(1) == true) java.util.HashMap() else args.getMap(1).toHashMap()
76
+ val merchantId = if (args?.isNull(0) == true) null else args?.getString(0)
77
+ @Suppress("UNCHECKED_CAST")
78
+ val additionalData: Map<String, Any> = if (args?.isNull(1) == true) emptyMap() else (args?.getMap(1)?.toHashMap()?.filterValues { it != null } as? Map<String, Any>) ?: emptyMap()
79
+
67
80
  root.submit(merchantId, additionalData) { bankAccount ->
68
81
  Log.d("PE", Gson().toJson(bankAccount))
69
82
  if (bankAccount.STATUS == "FAILED") {
@@ -59,14 +59,25 @@ class RNPECreditCardViewManager: SimpleViewManager<RNPECreditCardView> {
59
59
  "hideKeyboard" to COMMAND_HIDE_KEYBOARD
60
60
  )
61
61
 
62
+ // Legacy receiveCommand for old architecture compatibility
62
63
  override fun receiveCommand(root: RNPECreditCardView, commandId: String?, args: ReadableArray?) {
63
64
  super.receiveCommand(root, commandId, args)
64
- Log.d("PE", "Received command $commandId")
65
- when (commandId?.toInt()) {
65
+ executeCommand(root, commandId?.toIntOrNull() ?: -1, args)
66
+ }
67
+
68
+ // New Architecture (Fabric) receiveCommand override with Int commandId
69
+ @Suppress("DEPRECATION")
70
+ override fun receiveCommand(root: RNPECreditCardView, commandId: Int, args: ReadableArray?) {
71
+ executeCommand(root, commandId, args)
72
+ }
73
+
74
+ private fun executeCommand(root: RNPECreditCardView, commandId: Int, args: ReadableArray?) {
75
+ when (commandId) {
66
76
  COMMAND_SUBMIT -> {
77
+ val merchantId = if (args?.isNull(0) == true) null else args?.getString(0)
78
+ @Suppress("UNCHECKED_CAST")
79
+ val additionalData: Map<String, Any> = if (args?.isNull(1) == true) emptyMap() else (args?.getMap(1)?.toHashMap()?.filterValues { it != null } as? Map<String, Any>) ?: emptyMap()
67
80
 
68
- val merchantId = if (args?.isNull(0) == true) null else args!!.getString(0)
69
- val additionalData = if (args?.isNull(1) == true) java.util.HashMap() else args.getMap(1).toHashMap()
70
81
  root.submit(merchantId, additionalData) { card ->
71
82
  if (card.STATUS == "FAILED") {
72
83
  val params = Arguments.createMap().apply {
@@ -8,32 +8,32 @@
8
8
  <key>BinaryPath</key>
9
9
  <string>PayEngineSDK.framework/PayEngineSDK</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>ios-arm64</string>
11
+ <string>ios-arm64_x86_64-simulator</string>
12
12
  <key>LibraryPath</key>
13
13
  <string>PayEngineSDK.framework</string>
14
14
  <key>SupportedArchitectures</key>
15
15
  <array>
16
16
  <string>arm64</string>
17
+ <string>x86_64</string>
17
18
  </array>
18
19
  <key>SupportedPlatform</key>
19
20
  <string>ios</string>
21
+ <key>SupportedPlatformVariant</key>
22
+ <string>simulator</string>
20
23
  </dict>
21
24
  <dict>
22
25
  <key>BinaryPath</key>
23
26
  <string>PayEngineSDK.framework/PayEngineSDK</string>
24
27
  <key>LibraryIdentifier</key>
25
- <string>ios-arm64_x86_64-simulator</string>
28
+ <string>ios-arm64</string>
26
29
  <key>LibraryPath</key>
27
30
  <string>PayEngineSDK.framework</string>
28
31
  <key>SupportedArchitectures</key>
29
32
  <array>
30
33
  <string>arm64</string>
31
- <string>x86_64</string>
32
34
  </array>
33
35
  <key>SupportedPlatform</key>
34
36
  <string>ios</string>
35
- <key>SupportedPlatformVariant</key>
36
- <string>simulator</string>
37
37
  </dict>
38
38
  </array>
39
39
  <key>CFBundlePackageType</key>
@@ -7,33 +7,9 @@
7
7
 
8
8
  #import <Foundation/Foundation.h>
9
9
 
10
- // Error Codes
11
- typedef NS_ENUM(NSInteger, KDataCollectorErrorCode) {
12
-
13
- KDataCollectorErrorCodeUnknown = 0,
14
-
15
- // A system error occurred
16
- KDataCollectorErrorCodeNSError,
17
-
18
- // A required collector timed out
19
- KDataCollectorErrorCodeTimeout,
20
-
21
- // A bad parameter was passed into the data collector
22
- KDataCollectorErrorCodeBadParameter,
23
-
24
- // A network connection isn't available
25
- KDataCollectorErrorCodeNoNetwork,
26
-
27
- // An error occurred while validating a response from the server
28
- KDataCollectorErrorCodeResponseValidation,
29
- };
30
-
31
10
  NS_ASSUME_NONNULL_BEGIN
32
11
 
33
- extern NSString *const KDataCollectorErrorDomain;
34
12
 
35
- // Version of the Kount Data Collector SDK
36
- extern NSString *const KDataCollectorVersion;
37
13
 
38
14
  // Configuration settings for location collection
39
15
  typedef NS_ENUM(NSInteger, KLocationCollectorConfig) {
@@ -49,11 +25,12 @@ typedef NS_ENUM(NSInteger, KLocationCollectorConfig) {
49
25
  KLocationCollectorConfigSkip,
50
26
  };
51
27
 
28
+
52
29
  // Configuration settings Kount collection environment
53
30
  typedef NS_ENUM(NSInteger, KEnvironment) {
54
31
 
55
32
  // Unknown Environment
56
- KEnvironmentUnknown = 0,
33
+ KEnvironmentUnknown = 0,
57
34
 
58
35
  // Test Environment
59
36
  KEnvironmentTest,
@@ -62,6 +39,8 @@ typedef NS_ENUM(NSInteger, KEnvironment) {
62
39
  KEnvironmentProduction,
63
40
  };
64
41
 
42
+
43
+
65
44
  // KDataCollector enables you to collect device information for the given session
66
45
  //
67
46
  // First, configure the collector during the initialization of your application
@@ -12,26 +12,6 @@
12
12
  #import "KDataCollector.h"
13
13
 
14
14
  NS_ASSUME_NONNULL_BEGIN
15
- // DMD-352: Device Collection Status
16
- typedef NS_ENUM(NSInteger, KDataCollectorStatus) {
17
-
18
- // A device data collection not started
19
- KDataCollectorStatusNotStarted = 0,
20
-
21
- // A device data collection started
22
- KDataCollectorStatusStarted,
23
-
24
- // A device data collection completed successfully
25
- KDataCollectorStatusCompleted,
26
-
27
- // A device data collection failed with error
28
- KDataCollectorStatusFailedWithError,
29
-
30
- // A device data collection failed without error
31
- KDataCollectorStatusFailedWithOutError,
32
-
33
- };
34
-
35
15
 
36
16
  @interface KountAnalyticsViewController : UIViewController <UITextFieldDelegate, UITextViewDelegate, UISearchBarDelegate> {
37
17