react-native-payengine 2.0.17 → 2.0.18-alpha.2

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 (157) 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 +1785 -5517
  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 +1785 -5517
  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 +1785 -5517
  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/Assets.car +0 -0
  44. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Info.plist +0 -0
  45. package/ios/Sources/Classes/RNPEEventEmitter.swift +1 -1
  46. package/ios/Sources/Classes/RNPayEngineNative.swift +125 -64
  47. package/ios/Sources/Classes/SecureFields/RNPEEvents.swift +1 -0
  48. package/ios/Sources/Payengine.m +6 -0
  49. package/lib/commonjs/components/PayEngine.js +1 -1
  50. package/lib/commonjs/components/PayEngine.js.map +1 -1
  51. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js +124 -0
  52. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  53. package/lib/commonjs/components/v2/ApplePay/PEApplePayInterfaces.js +78 -0
  54. package/lib/commonjs/components/v2/ApplePay/PEApplePayInterfaces.js.map +1 -1
  55. package/lib/commonjs/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -1
  56. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js +53 -0
  57. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  58. package/lib/commonjs/components/v2/PEPaymentRequest.js +121 -0
  59. package/lib/commonjs/components/v2/PEPaymentRequest.js.map +1 -1
  60. package/lib/commonjs/components/v2/PayEngineNative.js +182 -4
  61. package/lib/commonjs/components/v2/PayEngineNative.js.map +1 -1
  62. package/lib/commonjs/components/v2/PayEngineProvider.js +52 -0
  63. package/lib/commonjs/components/v2/PayEngineProvider.js.map +1 -1
  64. package/lib/commonjs/components/v2/SecureFields/BankAccountView.js +71 -0
  65. package/lib/commonjs/components/v2/SecureFields/BankAccountView.js.map +1 -1
  66. package/lib/commonjs/components/v2/SecureFields/CreditCardView.js +82 -0
  67. package/lib/commonjs/components/v2/SecureFields/CreditCardView.js.map +1 -1
  68. package/lib/commonjs/components/v2/SecureFields/IPEField.js.map +1 -1
  69. package/lib/commonjs/components/v2/SecureFields/ITokenizationData.js.map +1 -1
  70. package/lib/commonjs/components/v2/SecureFields/PEBankAccount.js.map +1 -1
  71. package/lib/commonjs/components/v2/SecureFields/PECard.js.map +1 -1
  72. package/lib/commonjs/components/v2/SecureFields/PEKeyboardType.js +20 -3
  73. package/lib/commonjs/components/v2/SecureFields/PEKeyboardType.js.map +1 -1
  74. package/lib/commonjs/index.js +17 -13
  75. package/lib/commonjs/index.js.map +1 -1
  76. package/lib/commonjs/interfaces/index.js +20 -0
  77. package/lib/commonjs/interfaces/index.js.map +1 -1
  78. package/lib/commonjs/utils/index.js +26 -0
  79. package/lib/commonjs/utils/index.js.map +1 -1
  80. package/lib/module/components/PayEngine.js +1 -1
  81. package/lib/module/components/PayEngine.js.map +1 -1
  82. package/lib/module/components/v2/ApplePay/PEApplePayButton.js +124 -0
  83. package/lib/module/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  84. package/lib/module/components/v2/ApplePay/PEApplePayInterfaces.js +75 -0
  85. package/lib/module/components/v2/ApplePay/PEApplePayInterfaces.js.map +1 -1
  86. package/lib/module/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -1
  87. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js +53 -0
  88. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  89. package/lib/module/components/v2/PEPaymentRequest.js +119 -0
  90. package/lib/module/components/v2/PEPaymentRequest.js.map +1 -1
  91. package/lib/module/components/v2/PayEngineNative.js +184 -5
  92. package/lib/module/components/v2/PayEngineNative.js.map +1 -1
  93. package/lib/module/components/v2/PayEngineProvider.js +51 -0
  94. package/lib/module/components/v2/PayEngineProvider.js.map +1 -1
  95. package/lib/module/components/v2/SecureFields/BankAccountView.js +71 -0
  96. package/lib/module/components/v2/SecureFields/BankAccountView.js.map +1 -1
  97. package/lib/module/components/v2/SecureFields/CreditCardView.js +82 -0
  98. package/lib/module/components/v2/SecureFields/CreditCardView.js.map +1 -1
  99. package/lib/module/components/v2/SecureFields/IPEField.js.map +1 -1
  100. package/lib/module/components/v2/SecureFields/ITokenizationData.js.map +1 -1
  101. package/lib/module/components/v2/SecureFields/PEBankAccount.js.map +1 -1
  102. package/lib/module/components/v2/SecureFields/PECard.js.map +1 -1
  103. package/lib/module/components/v2/SecureFields/PEKeyboardType.js +16 -1
  104. package/lib/module/components/v2/SecureFields/PEKeyboardType.js.map +1 -1
  105. package/lib/module/index.js +10 -5
  106. package/lib/module/index.js.map +1 -1
  107. package/lib/module/interfaces/index.js +19 -0
  108. package/lib/module/interfaces/index.js.map +1 -1
  109. package/lib/module/utils/index.js +27 -0
  110. package/lib/module/utils/index.js.map +1 -1
  111. package/lib/typescript/components/PayEngine.d.ts +1 -1
  112. package/lib/typescript/components/v2/ApplePay/PEApplePayButton.d.ts +217 -12
  113. package/lib/typescript/components/v2/ApplePay/PEApplePayInterfaces.d.ts +180 -1
  114. package/lib/typescript/components/v2/GooglePay/PEGooglePayAddress.d.ts +30 -0
  115. package/lib/typescript/components/v2/GooglePay/PEGooglePayButton.d.ts +99 -0
  116. package/lib/typescript/components/v2/PEPaymentRequest.d.ts +130 -9
  117. package/lib/typescript/components/v2/PayEngineNative.d.ts +165 -7
  118. package/lib/typescript/components/v2/PayEngineProvider.d.ts +51 -0
  119. package/lib/typescript/components/v2/SecureFields/BankAccountView.d.ts +103 -0
  120. package/lib/typescript/components/v2/SecureFields/CreditCardView.d.ts +114 -0
  121. package/lib/typescript/components/v2/SecureFields/IPEField.d.ts +49 -0
  122. package/lib/typescript/components/v2/SecureFields/ITokenizationData.d.ts +14 -0
  123. package/lib/typescript/components/v2/SecureFields/PEBankAccount.d.ts +36 -0
  124. package/lib/typescript/components/v2/SecureFields/PECard.d.ts +44 -0
  125. package/lib/typescript/components/v2/SecureFields/PEKeyboardType.d.ts +16 -1
  126. package/lib/typescript/index.d.ts +11 -5
  127. package/lib/typescript/interfaces/index.d.ts +35 -1
  128. package/lib/typescript/utils/index.d.ts +21 -0
  129. package/package.json +6 -3
  130. package/src/components/PayEngine.tsx +1 -1
  131. package/src/components/v2/ApplePay/PEApplePayButton.tsx +225 -12
  132. package/src/components/v2/ApplePay/PEApplePayInterfaces.ts +221 -8
  133. package/src/components/v2/GooglePay/PEGooglePayAddress.ts +39 -1
  134. package/src/components/v2/GooglePay/PEGooglePayButton.tsx +113 -9
  135. package/src/components/v2/PEPaymentRequest.ts +151 -13
  136. package/src/components/v2/PayEngineNative.tsx +196 -9
  137. package/src/components/v2/PayEngineProvider.tsx +52 -1
  138. package/src/components/v2/SecureFields/BankAccountView.tsx +108 -1
  139. package/src/components/v2/SecureFields/CreditCardView.tsx +118 -1
  140. package/src/components/v2/SecureFields/IPEField.ts +55 -0
  141. package/src/components/v2/SecureFields/ITokenizationData.ts +17 -2
  142. package/src/components/v2/SecureFields/PEBankAccount.ts +42 -0
  143. package/src/components/v2/SecureFields/PECard.ts +52 -0
  144. package/src/components/v2/SecureFields/PEKeyboardType.ts +18 -1
  145. package/src/index.tsx +23 -5
  146. package/src/interfaces/index.ts +40 -2
  147. package/src/utils/index.ts +21 -0
  148. package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
  149. package/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
  150. package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
  151. package/android/.gradle/6.1.1/gc.properties +0 -0
  152. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/CustomWindow.h +0 -25
  153. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/UIControl+CustomControl.h +0 -33
  154. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/UIViewController+TouchControl.h +0 -27
  155. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/CustomWindow.h +0 -25
  156. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/UIControl+CustomControl.h +0 -33
  157. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/UIViewController+TouchControl.h +0 -27
@@ -1,15 +1,21 @@
1
+ /**
2
+ * Main Module
3
+ * @module PayEngine SDK
4
+ */
1
5
  import PayEngine from './components/PayEngine';
2
6
  import type { IPayEngineConfig } from './interfaces/index';
3
7
  import { PayProvider } from './interfaces/index';
4
- import { PECreditCardView, PECreditCardViewMethods } from './components/v2/SecureFields/CreditCardView';
5
- import { PEBankAccountView, PEBankAccountViewMethods } from './components/v2/SecureFields/BankAccountView';
8
+ import type ITokenizationData from './components/v2/SecureFields/ITokenizationData';
9
+ import { PECreditCardView, type PECreditCardViewProps, type PECreditCardViewMethods } from './components/v2/SecureFields/CreditCardView';
10
+ import { PEBankAccountView, type PEBankAccountViewProps, type PEBankAccountViewMethods } from './components/v2/SecureFields/BankAccountView';
6
11
  import type IPEField from './components/v2/SecureFields/IPEField';
7
12
  import type PECard from './components/v2/SecureFields/PECard';
8
13
  import type PEBankAccount from './components/v2/SecureFields/PEBankAccount';
9
14
  import { PayEngineProvider } from './components/v2/PayEngineProvider';
10
15
  import PayEngineNative from './components/v2/PayEngineNative';
11
- import { PEApplePayButton } from './components/v2/ApplePay/PEApplePayButton';
12
- import { PEGooglePayButton } from './components/v2/GooglePay/PEGooglePayButton';
16
+ import { FetchAccessTokenCallback, AccessToken } from './components/v2/PayEngineNative';
17
+ import { PEApplePayButton, type PEApplePayButtonProps, type PEApplePayButtonMethods } from './components/v2/ApplePay/PEApplePayButton';
18
+ import { PEGooglePayButton, type PEGooglePayButtonProps, type PEGooglePayButtonMethods } from './components/v2/GooglePay/PEGooglePayButton';
13
19
  import * as PayEngineUtils from './utils/index';
14
20
  import PEKeyboardType from './components/v2/SecureFields/PEKeyboardType';
15
21
  import type { PEGooglePayAddress } from './components/v2/GooglePay/PEGooglePayAddress';
@@ -17,4 +23,4 @@ import type { PEApplePayContact } from './components/v2/ApplePay/PEApplePayInter
17
23
  export * from './components/v2/PEPaymentRequest';
18
24
  export * from './components/v2/ApplePay/PEApplePayInterfaces';
19
25
  declare const PayEngineStatic: any;
20
- export { PayEngineStatic, PayEngine, IPayEngineConfig, PayProvider, PayEngineUtils, PayEngineProvider, PayEngineNative, PEKeyboardType, IPEField, PECreditCardView, PECreditCardViewMethods, PECard, PEBankAccountView, PEBankAccountViewMethods, PEBankAccount, PEApplePayButton, PEApplePayContact, PEGooglePayButton, PEGooglePayAddress };
26
+ export { PayEngineStatic, PayEngine, IPayEngineConfig, PayProvider, PayEngineUtils, PayEngineProvider, PayEngineNative, AccessToken, FetchAccessTokenCallback, PEKeyboardType, IPEField, ITokenizationData, PECreditCardView, PECreditCardViewProps, PECreditCardViewMethods, PECard, PEBankAccountView, PEBankAccountViewProps, PEBankAccountViewMethods, PEBankAccount, PEApplePayButton, PEApplePayButtonProps, PEApplePayButtonMethods, PEApplePayContact, PEGooglePayButton, PEGooglePayAddress, PEGooglePayButtonProps, PEGooglePayButtonMethods };
@@ -1,10 +1,44 @@
1
+ /**
2
+ * Represents the configuration settings for PayEngine.
3
+ *
4
+ * The [IPayEngineConfig] interface holds essential details such as the public key,
5
+ * script version, and logging level. It is used to configure the PayEngine integration
6
+ * for API interactions.
7
+ *
8
+ */
1
9
  export interface IPayEngineConfig {
10
+ /**
11
+ * The public key associated with the PayEngine account.
12
+ * This key is required for authentication when making API requests.
13
+ */
2
14
  publicKey: string;
15
+ /**
16
+ * The version of the PayEngine integration.
17
+ * If provided, this specifies the version of the script or API being used.
18
+ */
3
19
  version?: string;
20
+ /**
21
+ * The script URL for loading the PayEngine JavaScript library.
22
+ * If provided, this URL is used instead of the default script URL.
23
+ */
4
24
  scriptURL?: string;
25
+ /**
26
+ * The log level for debugging.
27
+ * Higher values enable more detailed logging.
28
+ */
5
29
  logLevel?: number;
6
30
  }
31
+ /**
32
+ * Enum representing supported payment providers.
33
+ *
34
+ * @remarks
35
+ * This enum specifies the available payment providers supported by the PayEngine SDK.
36
+ * It is used to check which payment method (Apple Pay or Google Pay) is available for use.
37
+ *
38
+ * @enum {string}
39
+ * @category PayEngine
40
+ */
7
41
  export declare enum PayProvider {
8
- googlePay = 0,
42
+ googlePay = 0,// Google Pay payment provider.
9
43
  applePay = 1
10
44
  }
@@ -1,11 +1,32 @@
1
1
  import type { IPayEngineConfig } from '../interfaces/index';
2
+ /**
3
+ * Custom error thrown when an obsolete method is called.
4
+ *
5
+ * The `PEDeprecationError` indicates that the method being used is deprecated,
6
+ * and the user should check the package README for updated usage.
7
+ */
2
8
  export declare class PEDeprecationError extends Error {
3
9
  constructor();
4
10
  }
11
+ /**
12
+ * @private
13
+ */
5
14
  export declare const getHttpHeaders: (config: IPayEngineConfig) => {
6
15
  Authorization: string;
7
16
  };
17
+ /**
18
+ * @private
19
+ */
8
20
  export declare const getBaseURL: (config: IPayEngineConfig) => string;
21
+ /**
22
+ * @private
23
+ */
9
24
  export declare const createHttpClient: (config: IPayEngineConfig) => import("axios").AxiosInstance;
25
+ /**
26
+ * @private
27
+ */
10
28
  export declare function getScriptURL(config: IPayEngineConfig): string;
29
+ /**
30
+ * @private
31
+ */
11
32
  export declare const debuggingScript = "\nconst consoleLog = (type, ...log) => window.ReactNativeWebView.postMessage(JSON.stringify({'type': 'Console', 'data': {'type': type, 'log': log}}));\nconsole = {\n log: (...log) => consoleLog('log', ...log),\n debug: (...log) => consoleLog('debug', ...log),\n info: (...log) => consoleLog('info', ...log),\n warn: (...log) => consoleLog('warn', ...log),\n error: (...log) => consoleLog('error', ...log),\n verbose: (...log) => consoleLog('verbose', ...log),\n};\n\nconst dispatchEvent_original = EventTarget.prototype.dispatchEvent;\nfunction dispatchEvent(event) {\n if (event.type && !event.type.startsWith('react')) {\n ReactNativeWebView.postMessage(JSON.stringify({\n type: 'PayEngine',\n event: {\n type: event.type,\n detail: event.detail\n }\n }))\n }\n}\nEventTarget.prototype.dispatchEvent = dispatchEvent;\n";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-payengine",
3
- "version": "2.0.17",
3
+ "version": "2.0.18-alpha.2",
4
4
  "description": "PayEngine SDK for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -32,7 +32,9 @@
32
32
  "update-release": "release-it --no-increment",
33
33
  "beta": "release-it major --preRelease=beta",
34
34
  "example": "yarn --cwd example",
35
- "bootstrap": "yarn example && yarn && yarn example pods"
35
+ "bootstrap": "yarn example && yarn && yarn example pods",
36
+ "docs": "typedoc src/index.tsx --out docs-temp",
37
+ "docs-watch": "typedoc src/index.tsx --watch --out docs-temp"
36
38
  },
37
39
  "keywords": [
38
40
  "react-native",
@@ -65,7 +67,8 @@
65
67
  "react-native": "0.68.2",
66
68
  "react-native-builder-bob": "^0.18.3",
67
69
  "release-it": "^15.0.0",
68
- "typescript": "^4.5.2"
70
+ "typedoc": "^0.28.1",
71
+ "typescript": "^5.8.2"
69
72
  },
70
73
  "resolutions": {
71
74
  "@types/react": "17.0.21"
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Text } from 'react-native';
3
3
 
4
- const PayEngine = () => {
4
+ const PayEngine = (_props: any) => {
5
5
  return <Text>Obsolete. Please check out the package readme</Text>;
6
6
  };
7
7
 
@@ -63,40 +63,94 @@ interface NativePEApplePayViewProps extends ViewProps {
63
63
  }) => void;
64
64
  }
65
65
 
66
+ /**
67
+ * Props for the Apple Pay button component.
68
+ *
69
+ * This interface defines the properties you can pass to the Apple Pay button,
70
+ * including the payment request and various event callbacks triggered throughout
71
+ * the Apple Pay flow.
72
+ *
73
+ * @category Apple Pay
74
+ */
66
75
  export interface PEApplePayButtonProps extends ViewProps {
76
+ /**
77
+ * The payment request containing transaction details such as the total amount,
78
+ * currency, supported networks, and required contact fields.
79
+ */
67
80
  paymentRequest: PEPaymentRequest;
81
+
82
+ /**
83
+ * Callback triggered when the Apple Pay token is successfully generated.
84
+ *
85
+ * @param token - A string representing the Apple Pay payment token.
86
+ * @param metadata - Optional metadata related to the transaction.
87
+ * @param billingContact - The billing contact information (if available).
88
+ * @param shippingContact - The shipping contact information (if available).
89
+ *
90
+ * Example:
91
+ * ```ts
92
+ * onTokenDidReturn: (token, metadata, billing, shipping) => {
93
+ * console.log('Token:', token);
94
+ * console.log('Billing contact:', billing?.givenName);
95
+ * console.log('Shipping contact:', shipping?.givenName);
96
+ * }
97
+ * ```
98
+ */
68
99
  onTokenDidReturn?: (
69
100
  token: string,
70
101
  metadata?: any,
71
102
  billingContact?: PEApplePayContact,
72
103
  shippingContact?: PEApplePayContact
73
104
  ) => void;
105
+
106
+ /**
107
+ * Callback triggered when the Apple Pay sheet is dismissed,
108
+ * either by completing the payment or canceling it.
109
+ */
74
110
  onPaymentSheetDismissed?: () => void;
111
+
112
+ /**
113
+ * Callback triggered when the Apple Pay process fails.
114
+ *
115
+ * @param error - The error that occurred during the payment flow.
116
+ */
75
117
  onPaymentFailed?: (error: Error) => void;
118
+
76
119
  /**
77
- * This callback is triggered whenever the payment method changes in the Apple Pay sheet.
78
- * You MUST update the Apple Pay sheet in your callback using the updatePaymentSheet function,
79
- * otherwise the Apple Pay sheet will hang and the payment flow will automatically cancel.
120
+ * Callback triggered when the user selects or changes the payment method
121
+ * within the Apple Pay sheet.
122
+ *
123
+ * You MUST call `updatePaymentSheet` in response to this callback to update
124
+ * the Apple Pay sheet. Failing to do so will cause the sheet to hang
125
+ * and the transaction will automatically cancel.
80
126
  */
81
127
  onPaymentMethodSelected?: (event: {
82
128
  nativeEvent: {
83
129
  paymentMethod: PEApplePayPaymentMethod;
84
130
  };
85
131
  }) => void;
132
+
86
133
  /**
87
- * This callback is triggered whenever the user selects a shipping method in the Apple Pay sheet.
88
- * You MUST update the Apple Pay sheet in your callback using the updatePaymentSheet function,
89
- * otherwise the Apple Pay sheet will hang and the payment flow will automatically cancel.
134
+ * Callback triggered when the user selects a shipping contact
135
+ * (e.g., their shipping address) within the Apple Pay sheet.
136
+ *
137
+ * You MUST call `updatePaymentSheet` in response to this callback to update
138
+ * shipping methods, summary items, or errors. Failure to do so will hang the
139
+ * sheet and cancel the transaction automatically.
90
140
  */
91
141
  onShippingContactSelected?: (event: {
92
142
  nativeEvent: {
93
143
  contact: PEApplePayContact;
94
144
  };
95
145
  }) => void;
146
+
96
147
  /**
97
- * This callback is triggered whenever the user selects a shipping contact in the Apple Pay sheet.
98
- * You MUST update the Apple Pay sheet in your callback using the updatePaymentSheet function,
99
- * otherwise the Apple Pay sheet will hang and the payment flow will automatically cancel.
148
+ * Callback triggered when the user selects a shipping method (e.g., standard or express)
149
+ * in the Apple Pay sheet.
150
+ *
151
+ * You MUST call `updatePaymentSheet` in response to this callback to reflect
152
+ * any changes in pricing or available options. If you don't, the Apple Pay sheet
153
+ * will hang and the payment will be canceled.
100
154
  */
101
155
  onShippingMethodSelected?: (event: {
102
156
  nativeEvent: {
@@ -105,11 +159,46 @@ export interface PEApplePayButtonProps extends ViewProps {
105
159
  }) => void;
106
160
  }
107
161
 
162
+
163
+ /**
164
+ * Exposes imperative methods for controlling the Apple Pay payment sheet.
165
+ *
166
+ * This interface is typically used via a `ref` to programmatically update
167
+ * the state of the Apple Pay sheet after certain user interactions.
168
+ *
169
+ * Specifically, the `updatePaymentSheet` method should be called in response to
170
+ * any of the following events:
171
+ * - `onPaymentMethodSelected`
172
+ * - `onShippingContactSelected`
173
+ * - `onShippingMethodSelected`
174
+ *
175
+ * @category Apple Pay
176
+ */
108
177
  export interface PEApplePayButtonMethods {
109
178
  /**
110
- * This method must be called after either onPaymentMethodSelected, onShippingContactSelected or
111
- * onShippingMethodSelected callbacks are triggered.
112
- * `shippingMethods` and `errors` are only applicable for onShippingContactSelected callback
179
+ * Updates the Apple Pay payment sheet with new summary items, shipping methods, and validation errors.
180
+ *
181
+ * This method should be called in response to user selections made on the Apple Pay sheet,
182
+ * such as selecting a new payment method, shipping contact, or shipping method.
183
+ *
184
+ * ### Parameters:
185
+ * - `summaryItems`: The updated list of items summarizing the total payment amount (e.g., subtotal, tax, total).
186
+ * - `shippingMethods`: A list of available shipping methods based on the selected shipping contact.
187
+ * - Only applicable when the `onShippingContactSelected` callback is triggered.
188
+ * - `errors`: A list of validation errors (e.g., invalid address or unsupported shipping region).
189
+ * - Also only applicable for `onShippingContactSelected`.
190
+ *
191
+ * ### Returns:
192
+ * - A `Promise<boolean>` indicating whether the update was successful.
193
+ *
194
+ * ### Example:
195
+ * ```ts
196
+ * await ref.current?.updatePaymentSheet(
197
+ * updatedSummaryItems,
198
+ * availableShippingMethods,
199
+ * validationErrors
200
+ * );
201
+ * ```
113
202
  */
114
203
  updatePaymentSheet: (
115
204
  summaryItems: PESummaryItem[],
@@ -118,6 +207,130 @@ export interface PEApplePayButtonMethods {
118
207
  ) => Promise<boolean>;
119
208
  }
120
209
 
210
+
211
+ /**
212
+ * A React component for initiating an Apple Pay transaction.
213
+ *
214
+ * This button wraps the Apple Pay experience, including presenting the Apple Pay sheet,
215
+ * handling user interactions, processing the payment, and managing callbacks such as
216
+ * payment success, failure, and contact/method selection.
217
+ *
218
+ * It exposes imperative methods via `ref` to allow control over the Apple Pay sheet,
219
+ * such as updating summary items or shipping options in response to user input.
220
+ *
221
+ * ## Example Usage:
222
+ *
223
+ * ```tsx
224
+ * const paymentRequest = {
225
+ * merchantId: "merchant.com.example",
226
+ * countryCode: "US",
227
+ * currencyCode: "USD",
228
+ * paymentAmount: 10.00,
229
+ * paymentSummaryItems: [
230
+ * { label: "Test Item", amount: "10.00" }
231
+ * ],
232
+ * requiredShippingContactFields: ["name", "postalAddress"]
233
+ * };
234
+ *
235
+ * <PEApplePayButton
236
+ * paymentRequest={paymentRequest}
237
+ *
238
+ * // Triggered when payment fails
239
+ * onPaymentFailed={(error) => console.error("Payment failed:", error)}
240
+ *
241
+ * // Triggered when Apple Pay sheet is dismissed by the user
242
+ * onPaymentSheetDismissed={() => console.log("Payment sheet dismissed")}
243
+ *
244
+ * // Triggered when a valid token is generated after successful Apple Pay authorization
245
+ * onTokenDidReturn={(token, metadata, billingContact, shippingContact) => {
246
+ * console.log('Apple Pay token:', token, metadata, billingContact, shippingContact);
247
+ * // TODO: Send token to your server for processing
248
+ * purchaseWithToken(token);
249
+ * }}
250
+ *
251
+ * // Triggered when user selects or updates their shipping contact info
252
+ * onShippingContactSelected={(event) => {
253
+ * console.log('onShippingContactSelected', event.nativeEvent);
254
+ *
255
+ * if (!event.nativeEvent.contact.postalCode) {
256
+ * // Invalid postal code — update Apple Pay sheet with an error
257
+ * buttonRef?.current?.updatePaymentSheet([], [], [{
258
+ * errorType: PEApplePaySheetErrorType.InvalidShippingAddress,
259
+ * field: PEApplePayInvalidShippingField.PostalCode,
260
+ * message: 'Please update postal code to continue'
261
+ * }]);
262
+ * } else {
263
+ * // Provide updated shipping methods if contact is valid
264
+ * buttonRef?.current?.updatePaymentSheet([], [
265
+ * {
266
+ * identifier: 'new-shipping1',
267
+ * label: 'Updated shipping 1',
268
+ * amount: 3.99
269
+ * },
270
+ * {
271
+ * identifier: 'new-shipping2',
272
+ * label: 'Updated shipping 2',
273
+ * amount: 5.99
274
+ * }
275
+ * ], []);
276
+ * }
277
+ * }}
278
+ *
279
+ * // Triggered when user selects a shipping method
280
+ * onShippingMethodSelected={(event) => {
281
+ * console.log('onShippingMethodSelected', event.nativeEvent);
282
+ *
283
+ * const shippingFee = event.nativeEvent.shippingMethod.amount;
284
+ * const items = [
285
+ * {
286
+ * label: 'Product price',
287
+ * amount: paymentRequest.paymentAmount
288
+ * },
289
+ * ...(shippingFee > 0 ? [{
290
+ * label: 'Shipping Fee',
291
+ * amount: shippingFee
292
+ * }] : []),
293
+ * {
294
+ * label: 'Total',
295
+ * amount: paymentRequest.paymentAmount + shippingFee
296
+ * }
297
+ * ];
298
+ *
299
+ * buttonRef?.current?.updatePaymentSheet(items, [], []);
300
+ * }}
301
+ *
302
+ * // Triggered when user selects a payment method (e.g., credit, debit)
303
+ * onPaymentMethodSelected={(event) => {
304
+ * console.log('onPaymentMethodSelected', event.nativeEvent);
305
+ *
306
+ * const isCredit = event.nativeEvent.paymentMethod.type === PEApplePayPaymentMethodType.credit;
307
+ * const items = [
308
+ * {
309
+ * label: 'Product price',
310
+ * amount: paymentRequest.paymentAmount
311
+ * },
312
+ * ...(isCredit ? [{
313
+ * label: 'Credit discount',
314
+ * amount: 10
315
+ * }] : []),
316
+ * {
317
+ * label: 'Total',
318
+ * amount: paymentRequest.paymentAmount - (isCredit ? 1.00 : 0.00)
319
+ * }
320
+ * ];
321
+ *
322
+ * buttonRef?.current?.updatePaymentSheet(items, [], []);
323
+ * }}
324
+ *
325
+ * ref={applePayRef}
326
+ * />
327
+ * ```
328
+ *
329
+ * @param props - The props for configuring the Apple Pay button behavior.
330
+ * @param ref - A ref to access Apple Pay sheet update methods imperatively.
331
+ *
332
+ * @category Apple Pay
333
+ */
121
334
  export const PEApplePayButton = React.forwardRef<
122
335
  PEApplePayButtonMethods,
123
336
  PEApplePayButtonProps