@stripe/stripe-react-native 0.52.0-crypto-onramp-2-private-beta.2 → 0.53.0

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 (175) hide show
  1. package/android/.idea/caches/deviceStreaming.xml +0 -13
  2. package/android/.idea/gradle.xml +1 -0
  3. package/android/.idea/misc.xml +1 -1
  4. package/android/build.gradle +0 -14
  5. package/android/gradle.properties +1 -1
  6. package/android/local.properties +2 -2
  7. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +48 -25
  8. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +2 -0
  9. package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +1 -1
  10. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +14 -13
  11. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +1 -19
  12. package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +0 -10
  13. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +3 -12
  14. package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerDelegate.java +0 -12
  15. package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerInterface.java +0 -4
  16. package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -4
  17. package/ios/Mappers.swift +1 -134
  18. package/ios/OldArch/StripeSdkEventEmitterCompat.h +0 -1
  19. package/ios/OldArch/StripeSdkEventEmitterCompat.m +1 -7
  20. package/ios/StripeSdk.mm +7 -0
  21. package/ios/StripeSdkEmitter.swift +0 -4
  22. package/ios/StripeSdkImpl.swift +13 -584
  23. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  24. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  25. package/lib/commonjs/components/AddressSheet.js +1 -1
  26. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  27. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  28. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  29. package/lib/commonjs/components/CardField.js +1 -1
  30. package/lib/commonjs/components/CardField.js.map +1 -1
  31. package/lib/commonjs/components/CardForm.js +1 -1
  32. package/lib/commonjs/components/CardForm.js.map +1 -1
  33. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  34. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  35. package/lib/commonjs/components/StripeContainer.js +1 -1
  36. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  37. package/lib/commonjs/components/StripeProvider.js +1 -1
  38. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  39. package/lib/commonjs/events.js +1 -1
  40. package/lib/commonjs/events.js.map +1 -1
  41. package/lib/commonjs/functions.js +1 -1
  42. package/lib/commonjs/functions.js.map +1 -1
  43. package/lib/commonjs/index.js +1 -1
  44. package/lib/commonjs/index.js.map +1 -1
  45. package/lib/commonjs/plugin/withStripe.js +1 -1
  46. package/lib/commonjs/plugin/withStripe.js.map +1 -1
  47. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
  48. package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
  49. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
  50. package/lib/commonjs/types/Errors.js +1 -1
  51. package/lib/commonjs/types/Errors.js.map +1 -1
  52. package/lib/commonjs/types/PlatformPay.js.map +1 -1
  53. package/lib/commonjs/types/index.js +1 -1
  54. package/lib/commonjs/types/index.js.map +1 -1
  55. package/lib/module/components/AddToWalletButton.js +1 -1
  56. package/lib/module/components/AddToWalletButton.js.map +1 -1
  57. package/lib/module/components/AddressSheet.js +1 -1
  58. package/lib/module/components/AddressSheet.js.map +1 -1
  59. package/lib/module/components/AuBECSDebitForm.js +1 -1
  60. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  61. package/lib/module/components/CardField.js +1 -1
  62. package/lib/module/components/CardField.js.map +1 -1
  63. package/lib/module/components/CardForm.js +1 -1
  64. package/lib/module/components/CardForm.js.map +1 -1
  65. package/lib/module/components/PlatformPayButton.js +1 -1
  66. package/lib/module/components/PlatformPayButton.js.map +1 -1
  67. package/lib/module/components/StripeContainer.js +1 -1
  68. package/lib/module/components/StripeContainer.js.map +1 -1
  69. package/lib/module/components/StripeProvider.js +1 -1
  70. package/lib/module/components/StripeProvider.js.map +1 -1
  71. package/lib/module/events.js +1 -1
  72. package/lib/module/events.js.map +1 -1
  73. package/lib/module/functions.js +1 -1
  74. package/lib/module/functions.js.map +1 -1
  75. package/lib/module/index.js +1 -1
  76. package/lib/module/index.js.map +1 -1
  77. package/lib/module/plugin/withStripe.js +1 -1
  78. package/lib/module/plugin/withStripe.js.map +1 -1
  79. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
  80. package/lib/module/types/EmbeddedPaymentElement.js +1 -1
  81. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
  82. package/lib/module/types/Errors.js +1 -1
  83. package/lib/module/types/Errors.js.map +1 -1
  84. package/lib/module/types/PlatformPay.js.map +1 -1
  85. package/lib/module/types/index.js +1 -1
  86. package/lib/module/types/index.js.map +1 -1
  87. package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
  88. package/lib/typescript/src/events.d.ts +0 -3
  89. package/lib/typescript/src/events.d.ts.map +1 -1
  90. package/lib/typescript/src/functions.d.ts +1 -0
  91. package/lib/typescript/src/functions.d.ts.map +1 -1
  92. package/lib/typescript/src/index.d.ts +0 -1
  93. package/lib/typescript/src/index.d.ts.map +1 -1
  94. package/lib/typescript/src/plugin/withStripe.d.ts +0 -15
  95. package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
  96. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +1 -0
  97. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
  98. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +1 -0
  99. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
  100. package/lib/typescript/src/types/Errors.d.ts +0 -5
  101. package/lib/typescript/src/types/Errors.d.ts.map +1 -1
  102. package/lib/typescript/src/types/PlatformPay.d.ts +7 -1
  103. package/lib/typescript/src/types/PlatformPay.d.ts.map +1 -1
  104. package/lib/typescript/src/types/index.d.ts +1 -7
  105. package/lib/typescript/src/types/index.d.ts.map +1 -1
  106. package/package.json +21 -2
  107. package/src/components/StripeProvider.tsx +0 -9
  108. package/src/events.ts +0 -22
  109. package/src/functions.ts +11 -0
  110. package/src/index.tsx +0 -1
  111. package/src/plugin/withStripe.ts +7 -104
  112. package/src/specs/NativeStripeSdkModule.ts +2 -0
  113. package/src/types/EmbeddedPaymentElement.tsx +7 -0
  114. package/src/types/Errors.ts +0 -6
  115. package/src/types/PlatformPay.ts +7 -1
  116. package/src/types/index.ts +0 -8
  117. package/stripe-react-native.podspec +8 -21
  118. package/.clang-format +0 -90
  119. package/.claude/settings.local.json +0 -11
  120. package/.editorconfig +0 -18
  121. package/.husky/pre-commit +0 -1
  122. package/.idea/GitLink.xml +0 -6
  123. package/.idea/codeStyles/Project.xml +0 -162
  124. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  125. package/.idea/misc.xml +0 -851
  126. package/.idea/modules.xml +0 -8
  127. package/.idea/stripe-react-native.iml +0 -9
  128. package/.idea/vcs.xml +0 -6
  129. package/.vscode/settings.json +0 -3
  130. package/CHANGELOG.md +0 -931
  131. package/CLAUDE.md +0 -148
  132. package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
  133. package/android/.gradle/8.11.1/executionHistory/executionHistory.bin +0 -0
  134. package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
  135. package/android/.gradle/8.11.1/fileChanges/last-build.bin +0 -0
  136. package/android/.gradle/8.11.1/fileHashes/fileHashes.bin +0 -0
  137. package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
  138. package/android/.gradle/8.11.1/gc.properties +0 -0
  139. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  140. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  141. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  142. package/android/.gradle/file-system.probe +0 -0
  143. package/android/.gradle/vcs-1/gc.properties +0 -0
  144. package/android/.idea/AndroidProjectSystem.xml +0 -6
  145. package/android/.idea/GitLink.xml +0 -6
  146. package/android/.idea/appInsightsSettings.xml +0 -23
  147. package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +0 -138
  148. package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +0 -110
  149. package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +0 -844
  150. package/ios/StripeOnrampSdk.h +0 -17
  151. package/ios/StripeOnrampSdk.mm +0 -144
  152. package/lib/commonjs/hooks/useOnramp.js +0 -2
  153. package/lib/commonjs/hooks/useOnramp.js.map +0 -1
  154. package/lib/commonjs/specs/NativeOnrampSdkModule.js +0 -2
  155. package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +0 -1
  156. package/lib/commonjs/types/Onramp.js +0 -2
  157. package/lib/commonjs/types/Onramp.js.map +0 -1
  158. package/lib/module/hooks/useOnramp.js +0 -2
  159. package/lib/module/hooks/useOnramp.js.map +0 -1
  160. package/lib/module/specs/NativeOnrampSdkModule.js +0 -2
  161. package/lib/module/specs/NativeOnrampSdkModule.js.map +0 -1
  162. package/lib/module/types/Onramp.js +0 -2
  163. package/lib/module/types/Onramp.js.map +0 -1
  164. package/lib/typescript/src/hooks/useOnramp.d.ts +0 -139
  165. package/lib/typescript/src/hooks/useOnramp.d.ts.map +0 -1
  166. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +0 -26
  167. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +0 -1
  168. package/lib/typescript/src/types/Onramp.d.ts +0 -259
  169. package/lib/typescript/src/types/Onramp.d.ts.map +0 -1
  170. package/package-lock.json +0 -14114
  171. package/patches/README.md +0 -55
  172. package/patches/old-arch-codegen-fix.patch +0 -91
  173. package/src/hooks/useOnramp.tsx +0 -297
  174. package/src/specs/NativeOnrampSdkModule.ts +0 -41
  175. package/src/types/Onramp.ts +0 -297
package/patches/README.md DELETED
@@ -1,55 +0,0 @@
1
- # Old Architecture Codegen Fix
2
-
3
- This patch fixes the codegen issue that occurs when using `@stripe/stripe-react-native` with React Native 0.74+ in the old architecture.
4
-
5
- ## The Problem
6
-
7
- When using React Native 0.74+ with the old architecture, you may encounter this error during pod install:
8
-
9
- ```
10
- UnsupportedModulePropertyParserError: Module NativeStripeSdkModule: TypeScript interfaces extending TurboModule must only contain 'FunctionTypeAnnotation's. Property 'onConfirmHandlerCallback' refers to a 'TSTypeReference'.
11
- ```
12
-
13
- This occurs because the React Native codegen in the old architecture doesn't support `EventEmitter` properties in TurboModule interfaces.
14
-
15
- ## The Solution
16
-
17
- This patch converts all `EventEmitter` properties to callback function methods, making them compatible with the old architecture codegen.
18
-
19
- ## How to Apply
20
-
21
- ### Option 1: Manual patch command
22
-
23
- ```bash
24
- cd node_modules/@stripe/stripe-react-native
25
- patch -p0 < patches/old-arch-codegen-fix.patch
26
- ```
27
-
28
- ### Option 2: Using patch-package (Recommended)
29
-
30
- 1. Install patch-package as a dev dependency:
31
- ```bash
32
- npm install --save-dev patch-package
33
- ```
34
-
35
- 2. Apply the patch manually first:
36
- ```bash
37
- cd node_modules/@stripe/stripe-react-native
38
- patch -p0 < ../../patches/old-arch-codegen-fix.patch
39
- ```
40
-
41
- 3. Generate a patch-package patch:
42
- ```bash
43
- npx patch-package @stripe/stripe-react-native
44
- ```
45
-
46
- 4. Add postinstall script to your `package.json`:
47
- ```json
48
- {
49
- "scripts": {
50
- "postinstall": "patch-package"
51
- }
52
- }
53
- ```
54
-
55
- This ensures the patch is automatically applied whenever you run `npm install`.
@@ -1,91 +0,0 @@
1
- --- src/specs/NativeStripeSdkModule.ts.orig 2025-07-09 10:31:12.373374861 -0600
2
- +++ src/specs/NativeStripeSdkModule.ts 2025-07-09 10:31:34.254519742 -0600
3
- @@ -1,7 +1,6 @@
4
- import { TurboModuleRegistry } from 'react-native';
5
- import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
6
- import type {
7
- - EventEmitter,
8
- Int32,
9
- } from 'react-native/Libraries/Types/CodegenTypes';
10
- import type {
11
- @@ -185,35 +184,47 @@
12
- ): Promise<void>;
13
- clearEmbeddedPaymentOption(viewTag: Int32): Promise<void>;
14
-
15
- - // Events
16
- - onConfirmHandlerCallback: EventEmitter<{
17
- - paymentMethod: UnsafeObject<PaymentMethod.Result>;
18
- - shouldSavePaymentMethod: boolean;
19
- - }>;
20
- - onFinancialConnectionsEvent: EventEmitter<
21
- - UnsafeObject<FinancialConnectionsEvent>
22
- - >;
23
- - onOrderTrackingCallback: EventEmitter<void>;
24
- - onCustomerAdapterFetchPaymentMethodsCallback: EventEmitter<void>;
25
- - onCustomerAdapterAttachPaymentMethodCallback: EventEmitter<{
26
- - paymentMethodId: string;
27
- - }>;
28
- - onCustomerAdapterDetachPaymentMethodCallback: EventEmitter<{
29
- - paymentMethodId: string;
30
- - }>;
31
- - onCustomerAdapterSetSelectedPaymentOptionCallback: EventEmitter<{
32
- - paymentOption: string;
33
- - }>;
34
- - onCustomerAdapterFetchSelectedPaymentOptionCallback: EventEmitter<void>;
35
- - onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback: EventEmitter<void>;
36
- - embeddedPaymentElementDidUpdateHeight: EventEmitter<UnsafeObject<any>>;
37
- - embeddedPaymentElementWillPresent: EventEmitter<void>;
38
- - embeddedPaymentElementDidUpdatePaymentOption: EventEmitter<UnsafeObject<any>>;
39
- - embeddedPaymentElementFormSheetConfirmComplete: EventEmitter<
40
- - UnsafeObject<any>
41
- - >;
42
- - embeddedPaymentElementRowSelectionImmediateAction: EventEmitter<void>;
43
- - embeddedPaymentElementLoadingFailed: EventEmitter<UnsafeObject<any>>;
44
- - onCustomPaymentMethodConfirmHandlerCallback: EventEmitter<UnsafeObject<any>>;
45
- + // Events (callback form for old architecture)
46
- + onConfirmHandlerCallback(
47
- + callback: (event: {
48
- + paymentMethod: UnsafeObject<PaymentMethod.Result>;
49
- + shouldSavePaymentMethod: boolean;
50
- + }) => void
51
- + ): void;
52
- + onFinancialConnectionsEvent(
53
- + callback: (event: UnsafeObject<FinancialConnectionsEvent>) => void
54
- + ): void;
55
- + onOrderTrackingCallback(callback: () => void): void;
56
- + onCustomerAdapterFetchPaymentMethodsCallback(callback: () => void): void;
57
- + onCustomerAdapterAttachPaymentMethodCallback(
58
- + callback: (event: { paymentMethodId: string }) => void
59
- + ): void;
60
- + onCustomerAdapterDetachPaymentMethodCallback(
61
- + callback: (event: { paymentMethodId: string }) => void
62
- + ): void;
63
- + onCustomerAdapterSetSelectedPaymentOptionCallback(
64
- + callback: (event: { paymentOption: string }) => void
65
- + ): void;
66
- + onCustomerAdapterFetchSelectedPaymentOptionCallback(
67
- + callback: () => void
68
- + ): void;
69
- + onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback(
70
- + callback: () => void
71
- + ): void;
72
- + embeddedPaymentElementDidUpdateHeight(
73
- + callback: (event: UnsafeObject<any>) => void
74
- + ): void;
75
- + embeddedPaymentElementWillPresent(callback: () => void): void;
76
- + embeddedPaymentElementDidUpdatePaymentOption(
77
- + callback: (event: UnsafeObject<any>) => void
78
- + ): void;
79
- + embeddedPaymentElementFormSheetConfirmComplete(
80
- + callback: (event: UnsafeObject<any>) => void
81
- + ): void;
82
- + embeddedPaymentElementRowSelectionImmediateAction(callback: () => void): void;
83
- + embeddedPaymentElementLoadingFailed(
84
- + callback: (event: UnsafeObject<any>) => void
85
- + ): void;
86
- + onCustomPaymentMethodConfirmHandlerCallback(
87
- + callback: (event: UnsafeObject<any>) => void
88
- + ): void;
89
- }
90
-
91
- export default TurboModuleRegistry.getEnforcing<Spec>('StripeSdk');
@@ -1,297 +0,0 @@
1
- import { EventSubscription } from 'react-native';
2
- import NativeOnrampSdk from '../specs/NativeOnrampSdkModule';
3
- import { Onramp, OnrampError, StripeError } from '../types';
4
- import type { PlatformPay } from '../types';
5
- import { useCallback } from 'react';
6
- import { addOnrampListener } from '../events';
7
- import { CryptoPaymentToken } from '../types/Onramp';
8
-
9
- let onCheckoutClientSecretRequestedSubscription: EventSubscription | null =
10
- null;
11
-
12
- /**
13
- * useOnramp hook
14
- */
15
- export function useOnramp() {
16
- const _configure = useCallback(
17
- async (
18
- config: Onramp.Configuration
19
- ): Promise<{ error?: StripeError<OnrampError> }> => {
20
- return NativeOnrampSdk.configureOnramp(config);
21
- },
22
- []
23
- );
24
-
25
- const _hasLinkAccount = useCallback(
26
- async (email: string): Promise<Onramp.HasLinkAccountResult> => {
27
- return NativeOnrampSdk.hasLinkAccount(email);
28
- },
29
- []
30
- );
31
-
32
- const _registerLinkUser = useCallback(
33
- async (
34
- info: Onramp.LinkUserInfo
35
- ): Promise<Onramp.RegisterLinkUserResult> => {
36
- return NativeOnrampSdk.registerLinkUser(info);
37
- },
38
- []
39
- );
40
-
41
- const _registerWalletAddress = useCallback(
42
- async (
43
- walletAddress: string,
44
- network: Onramp.CryptoNetwork
45
- ): Promise<{ error?: StripeError<OnrampError> }> => {
46
- return NativeOnrampSdk.registerWalletAddress(walletAddress, network);
47
- },
48
- []
49
- );
50
-
51
- const _attachKycInfo = useCallback(
52
- async (
53
- kycInfo: Onramp.KycInfo
54
- ): Promise<{ error?: StripeError<OnrampError> }> => {
55
- return NativeOnrampSdk.attachKycInfo(kycInfo);
56
- },
57
- []
58
- );
59
-
60
- const _updatePhoneNumber = useCallback(
61
- async (phone: string): Promise<{ error?: StripeError<OnrampError> }> => {
62
- return NativeOnrampSdk.updatePhoneNumber(phone);
63
- },
64
- []
65
- );
66
-
67
- const _authenticateUser =
68
- useCallback(async (): Promise<Onramp.AuthenticateUserResult> => {
69
- return NativeOnrampSdk.authenticateUser();
70
- }, []);
71
-
72
- const _verifyIdentity = useCallback(async (): Promise<{
73
- error?: StripeError<OnrampError>;
74
- }> => {
75
- return NativeOnrampSdk.verifyIdentity();
76
- }, []);
77
-
78
- /**
79
- * The set of payment methods supported by crypto onramp collection.
80
- * - 'Card' and 'BankAccount' present Link for collection.
81
- * - 'PlatformPay' presents Apple Pay / Google Pay using provided params.
82
- */
83
- type OnrampPaymentMethod = 'Card' | 'BankAccount' | 'PlatformPay';
84
-
85
- // Overloads for stronger type-safety at call-sites
86
- const _collectPaymentMethod: {
87
- (
88
- paymentMethod: 'Card' | 'BankAccount',
89
- platformPayParams?: undefined
90
- ): Promise<Onramp.CollectPaymentMethodResult>;
91
- (
92
- paymentMethod: 'PlatformPay',
93
- platformPayParams: PlatformPay.PaymentMethodParams
94
- ): Promise<Onramp.CollectPaymentMethodResult>;
95
- } = useCallback(
96
- async (
97
- paymentMethod: OnrampPaymentMethod,
98
- platformPayParams?:
99
- | PlatformPay.PaymentMethodParams
100
- | Record<string, never>
101
- ): Promise<Onramp.CollectPaymentMethodResult> => {
102
- return NativeOnrampSdk.collectPaymentMethod(
103
- paymentMethod,
104
- (platformPayParams ?? {}) as any
105
- );
106
- },
107
- []
108
- );
109
-
110
- const _createCryptoPaymentToken =
111
- useCallback(async (): Promise<Onramp.CreateCryptoPaymentTokenResult> => {
112
- return NativeOnrampSdk.createCryptoPaymentToken();
113
- }, []);
114
-
115
- const _performCheckout = useCallback(
116
- async (
117
- onrampSessionId: string,
118
- provideCheckoutClientSecret: () => Promise<string | null>
119
- ): Promise<{ error?: StripeError<OnrampError> }> => {
120
- onCheckoutClientSecretRequestedSubscription?.remove();
121
- onCheckoutClientSecretRequestedSubscription = addOnrampListener(
122
- 'onCheckoutClientSecretRequested',
123
- async () => {
124
- try {
125
- const clientSecret = await provideCheckoutClientSecret();
126
- NativeOnrampSdk.provideCheckoutClientSecret(clientSecret);
127
- } catch (error: any) {
128
- NativeOnrampSdk.provideCheckoutClientSecret(null);
129
- }
130
- }
131
- );
132
- return NativeOnrampSdk.performCheckout(onrampSessionId);
133
- },
134
- []
135
- );
136
-
137
- const _authorize = useCallback(
138
- async (linkAuthIntentId: string): Promise<Onramp.AuthorizeResult> => {
139
- return NativeOnrampSdk.onrampAuthorize(linkAuthIntentId);
140
- },
141
- []
142
- );
143
-
144
- const _getCryptoTokenDisplayData = useCallback(
145
- async (
146
- token: CryptoPaymentToken
147
- ): Promise<Onramp.PaymentDisplayDataResult> => {
148
- return NativeOnrampSdk.getCryptoTokenDisplayData(token);
149
- },
150
- []
151
- );
152
-
153
- const _logOut = useCallback(async (): Promise<{
154
- error?: StripeError<OnrampError>;
155
- }> => {
156
- return NativeOnrampSdk.logout();
157
- }, []);
158
-
159
- const _isAuthError = (error: any): boolean => {
160
- const stripeErrorCode = error?.stripeErrorCode;
161
- const authErrorCodes = [
162
- 'consumer_session_credentials_invalid',
163
- 'consumer_session_expired',
164
- ];
165
- return authErrorCodes.includes(stripeErrorCode);
166
- };
167
-
168
- return {
169
- /**
170
- * Creates a `CryptoOnrampCoordinator` to facilitate authentication, identity verification, payment collection, and checkouts.
171
- *
172
- * @param config Configuration object containing merchant display name and appearance settings
173
- * @returns Promise that resolves to an object with an optional error property
174
- */
175
- configure: _configure,
176
-
177
- /**
178
- * Whether or not the provided email is associated with an existing Link consumer.
179
- *
180
- * @param email The email address to look up
181
- * @returns Promise that resolves to an object with hasLinkAccount boolean or error
182
- */
183
- hasLinkAccount: _hasLinkAccount,
184
-
185
- /**
186
- * Registers a new Link user with the provided details.
187
- *
188
- * @param info User information including email, phone, country, and optional full name
189
- * @returns Promise that resolves to an object with customerId or error
190
- */
191
- registerLinkUser: _registerLinkUser,
192
-
193
- /**
194
- * Registers the given crypto wallet address to the current Link account.
195
- * Requires an authenticated Link user.
196
- *
197
- * @param walletAddress The crypto wallet address to register
198
- * @param network The crypto network for the wallet address
199
- * @returns Promise that resolves to an object with an optional error property
200
- */
201
- registerWalletAddress: _registerWalletAddress,
202
-
203
- /**
204
- * Attaches the specific KYC info to the current Link user. Requires an authenticated Link user.
205
- *
206
- * @param kycInfo The KYC info to attach to the Link user
207
- * @returns Promise that resolves to an object with an optional error property
208
- */
209
- attachKycInfo: _attachKycInfo,
210
-
211
- /**
212
- * Updates the user's phone number in their Link account.
213
- *
214
- * @param phone The new phone number to set for the user in E.164 format (e.g., +12125551234)
215
- * @returns Promise that resolves to an object with an optional error property
216
- */
217
- updatePhoneNumber: _updatePhoneNumber,
218
-
219
- /**
220
- * Presents Link UI to authenticate an existing Link user.
221
- * `hasLinkAccount` must be called before this.
222
- *
223
- * @returns Promise that resolves to an object with customerId or error
224
- */
225
- authenticateUser: _authenticateUser,
226
-
227
- /**
228
- * Creates an identity verification session and launches the document verification flow.
229
- * Requires an authenticated Link user.
230
- *
231
- * @returns Promise that resolves to an object with an optional error property
232
- */
233
- verifyIdentity: _verifyIdentity,
234
-
235
- /**
236
- * Presents UI to collect/select a payment method of the given type.
237
- *
238
- * @param paymentMethod The payment method type to collect.
239
- * - 'Card' and 'BankAccount' present Link for collection.
240
- * - 'PlatformPay' presents Apple Pay / Google Pay using the provided parameters.
241
- * @param platformPayParams Platform-specific parameters (required when `paymentMethod` is 'PlatformPay').
242
- * - iOS: provide `applePay` params
243
- * - Android: provide `googlePay` params
244
- * @returns Promise that resolves to an object with displayData or error
245
- */
246
- collectPaymentMethod: _collectPaymentMethod,
247
-
248
- /**
249
- * Creates a crypto payment token for the payment method currently selected on the coordinator.
250
- * Call after a successful `collectPaymentMethod(...)`.
251
- *
252
- * @returns Promise that resolves to an object with cryptoPaymentToken or error
253
- */
254
- createCryptoPaymentToken: _createCryptoPaymentToken,
255
-
256
- /**
257
- * Performs the checkout flow for a crypto onramp session, handling any required authentication steps.
258
- *
259
- * @param onrampSessionId The onramp session identifier
260
- * @returns Promise that resolves to an object with an optional error property
261
- */
262
- performCheckout: _performCheckout,
263
-
264
- /**
265
- * Authorizes a Link auth intent and authenticates the user if necessary.
266
- *
267
- * @param linkAuthIntentId The Link auth intent ID to authorize
268
- * @returns Promise that resolves to an object with status and customerId or error
269
- */
270
- authorize: _authorize,
271
-
272
- /**
273
- * Retrieves display data (icon, label, sublabel) for the given payment method details.
274
- * Suitable for rendering in the UI to summarize the selected payment method.
275
- *
276
- * @param token The token containing payment method details (card or bank account) to get display data for
277
- * @returns Promise that resolves to an object with displayData or error
278
- */
279
- getCryptoTokenDisplayData: _getCryptoTokenDisplayData,
280
-
281
- /**
282
- * Logs out the current user from their Link account.
283
- *
284
- * @returns Promise that resolves to an object with an optional error property
285
- */
286
- logOut: _logOut,
287
-
288
- /**
289
- * Determines whether an error is an authentication-related error that requires re-authentication.
290
- * Useful for implementing automatic re-authentication flows when sessions expire or become invalid.
291
- *
292
- * @param error The error object to check, typically from onramp method calls
293
- * @returns True if the error indicates an authentication issue, false otherwise
294
- */
295
- isAuthError: _isAuthError,
296
- };
297
- }
@@ -1,41 +0,0 @@
1
- import { TurboModuleRegistry } from 'react-native';
2
- import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
3
- import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
4
- import type { InitialiseParams, Onramp } from '../types';
5
- import type { UnsafeObject } from './utils';
6
-
7
- export interface Spec extends TurboModule {
8
- initialise(params: UnsafeObject<InitialiseParams>): Promise<void>;
9
- configureOnramp(
10
- config: UnsafeObject<Onramp.Configuration>
11
- ): Promise<Onramp.VoidResult>;
12
- hasLinkAccount(email: string): Promise<Onramp.HasLinkAccountResult>;
13
- registerLinkUser(
14
- info: UnsafeObject<Onramp.LinkUserInfo>
15
- ): Promise<Onramp.RegisterLinkUserResult>;
16
- registerWalletAddress(
17
- walletAddress: string,
18
- network: string
19
- ): Promise<Onramp.VoidResult>;
20
- attachKycInfo(
21
- kycInfo: UnsafeObject<Onramp.KycInfo>
22
- ): Promise<Onramp.VoidResult>;
23
- updatePhoneNumber(phone: string): Promise<Onramp.VoidResult>;
24
- authenticateUser(): Promise<Onramp.AuthenticateUserResult>;
25
- verifyIdentity(): Promise<Onramp.VoidResult>;
26
- collectPaymentMethod(
27
- paymentMethod: string,
28
- platformPayParams: UnsafeObject<any>
29
- ): Promise<Onramp.CollectPaymentMethodResult>;
30
- provideCheckoutClientSecret(clientSecret: string | null): void;
31
- onCheckoutClientSecretRequested: EventEmitter<UnsafeObject<any>>;
32
- createCryptoPaymentToken(): Promise<Onramp.CreateCryptoPaymentTokenResult>;
33
- performCheckout(onrampSessionId: string): Promise<Onramp.VoidResult>;
34
- onrampAuthorize(linkAuthIntentId: string): Promise<Onramp.AuthorizeResult>;
35
- getCryptoTokenDisplayData(
36
- token: UnsafeObject<Onramp.CryptoPaymentToken>
37
- ): Promise<Onramp.PaymentDisplayDataResult>;
38
- logout(): Promise<Onramp.VoidResult>;
39
- }
40
-
41
- export default TurboModuleRegistry.getEnforcing<Spec>('OnrampSdk');