@stripe/stripe-react-native 0.68.0 → 0.70.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 (218) hide show
  1. package/android/.idea/AndroidProjectSystem.xml +6 -0
  2. package/android/.idea/caches/deviceStreaming.xml +835 -0
  3. package/android/.idea/compiler.xml +6 -0
  4. package/android/.idea/gradle.xml +17 -0
  5. package/android/.idea/migrations.xml +10 -0
  6. package/android/.idea/misc.xml +10 -0
  7. package/android/.idea/runConfigurations.xml +17 -0
  8. package/android/.idea/vcs.xml +6 -0
  9. package/android/gradle.properties +1 -1
  10. package/android/local.properties +8 -0
  11. package/android/src/main/java/com/reactnativestripesdk/LinkControllerManager.kt +175 -0
  12. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +31 -24
  13. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +7 -8
  14. package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +8 -0
  15. package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +8 -4
  16. package/android/src/onramp/java/com/reactnativestripesdk/OnrampErrors.kt +30 -35
  17. package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +48 -0
  18. package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +65 -2
  19. package/android/src/test/java/com/reactnativestripesdk/OnrampErrorsTest.kt +106 -27
  20. package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +37 -0
  21. package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentMethodMappersTest.kt +110 -0
  22. package/ios/CurrencySelectorElementView.swift +1 -1
  23. package/ios/Mappers+Checkout.swift +3 -3
  24. package/ios/Mappers.swift +19 -0
  25. package/ios/OnrampErrors.swift +21 -19
  26. package/ios/StripeOnrampSdk.mm +16 -0
  27. package/ios/StripeSdk.mm +15 -15
  28. package/ios/StripeSdkImpl+Checkout.swift +15 -39
  29. package/ios/StripeSdkImpl+LinkController.swift +108 -0
  30. package/ios/StripeSdkImpl.swift +64 -3
  31. package/jest/setup.js +2 -0
  32. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  33. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  34. package/lib/commonjs/components/AddressSheet.js +1 -1
  35. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  36. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  37. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  38. package/lib/commonjs/components/CardField.js +1 -1
  39. package/lib/commonjs/components/CardField.js.map +1 -1
  40. package/lib/commonjs/components/CardForm.js +1 -1
  41. package/lib/commonjs/components/CardForm.js.map +1 -1
  42. package/lib/commonjs/components/CurrencySelectorElement.js +1 -1
  43. package/lib/commonjs/components/CurrencySelectorElement.js.map +1 -1
  44. package/lib/commonjs/components/PaymentMethodMessagingElement.js +1 -1
  45. package/lib/commonjs/components/PaymentMethodMessagingElement.js.map +1 -1
  46. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  47. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  48. package/lib/commonjs/components/StripeContainer.js +1 -1
  49. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  50. package/lib/commonjs/components/StripeProvider.js +1 -1
  51. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  52. package/lib/commonjs/connect/Components.js +1 -1
  53. package/lib/commonjs/connect/Components.js.map +1 -1
  54. package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
  55. package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
  56. package/lib/commonjs/connect/EmbeddedComponent.js +1 -1
  57. package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
  58. package/lib/commonjs/connect/ModalCloseButton.js +1 -1
  59. package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
  60. package/lib/commonjs/connect/NavigationBar.js +1 -1
  61. package/lib/commonjs/connect/NavigationBar.js.map +1 -1
  62. package/lib/commonjs/functions.js +1 -1
  63. package/lib/commonjs/functions.js.map +1 -1
  64. package/lib/commonjs/helpers.js +1 -1
  65. package/lib/commonjs/hooks/useCheckout.js +1 -1
  66. package/lib/commonjs/hooks/useCheckout.js.map +1 -1
  67. package/lib/commonjs/hooks/useLinkController.js +2 -0
  68. package/lib/commonjs/hooks/useLinkController.js.map +1 -0
  69. package/lib/commonjs/hooks/useOnramp.js +1 -1
  70. package/lib/commonjs/hooks/useOnramp.js.map +1 -1
  71. package/lib/commonjs/index.js +1 -1
  72. package/lib/commonjs/index.js.map +1 -1
  73. package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
  74. package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
  75. package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
  76. package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
  77. package/lib/commonjs/specs/NativeCardField.js +1 -1
  78. package/lib/commonjs/specs/NativeCardField.js.map +1 -1
  79. package/lib/commonjs/specs/NativeCardForm.js +1 -1
  80. package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
  81. package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +1 -1
  82. package/lib/commonjs/specs/NativeCurrencySelectorElement.js +1 -1
  83. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
  84. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  85. package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
  86. package/lib/commonjs/specs/NativeNavigationBar.js +1 -1
  87. package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -1
  88. package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +1 -1
  89. package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
  90. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
  91. package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
  92. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
  93. package/lib/commonjs/types/Errors.js +1 -1
  94. package/lib/commonjs/types/Errors.js.map +1 -1
  95. package/lib/commonjs/types/LinkController.js +2 -0
  96. package/lib/commonjs/types/LinkController.js.map +1 -0
  97. package/lib/commonjs/types/Onramp.js +1 -1
  98. package/lib/commonjs/types/Onramp.js.map +1 -1
  99. package/lib/commonjs/types/index.js +1 -1
  100. package/lib/commonjs/types/index.js.map +1 -1
  101. package/lib/module/components/AddToWalletButton.js +1 -1
  102. package/lib/module/components/AddToWalletButton.js.map +1 -1
  103. package/lib/module/components/AddressSheet.js +1 -1
  104. package/lib/module/components/AddressSheet.js.map +1 -1
  105. package/lib/module/components/AuBECSDebitForm.js +1 -1
  106. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  107. package/lib/module/components/CardField.js +1 -1
  108. package/lib/module/components/CardField.js.map +1 -1
  109. package/lib/module/components/CardForm.js +1 -1
  110. package/lib/module/components/CardForm.js.map +1 -1
  111. package/lib/module/components/CurrencySelectorElement.js +1 -1
  112. package/lib/module/components/CurrencySelectorElement.js.map +1 -1
  113. package/lib/module/components/PaymentMethodMessagingElement.js +1 -1
  114. package/lib/module/components/PaymentMethodMessagingElement.js.map +1 -1
  115. package/lib/module/components/PlatformPayButton.js +1 -1
  116. package/lib/module/components/PlatformPayButton.js.map +1 -1
  117. package/lib/module/components/StripeContainer.js +1 -1
  118. package/lib/module/components/StripeContainer.js.map +1 -1
  119. package/lib/module/components/StripeProvider.js +1 -1
  120. package/lib/module/components/StripeProvider.js.map +1 -1
  121. package/lib/module/connect/Components.js +1 -1
  122. package/lib/module/connect/Components.js.map +1 -1
  123. package/lib/module/connect/ConnectComponentsProvider.js +1 -1
  124. package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
  125. package/lib/module/connect/EmbeddedComponent.js +1 -1
  126. package/lib/module/connect/EmbeddedComponent.js.map +1 -1
  127. package/lib/module/connect/ModalCloseButton.js +1 -1
  128. package/lib/module/connect/ModalCloseButton.js.map +1 -1
  129. package/lib/module/connect/NavigationBar.js +1 -1
  130. package/lib/module/connect/NavigationBar.js.map +1 -1
  131. package/lib/module/functions.js +1 -1
  132. package/lib/module/functions.js.map +1 -1
  133. package/lib/module/helpers.js +1 -1
  134. package/lib/module/hooks/useCheckout.js +1 -1
  135. package/lib/module/hooks/useCheckout.js.map +1 -1
  136. package/lib/module/hooks/useLinkController.js +2 -0
  137. package/lib/module/hooks/useLinkController.js.map +1 -0
  138. package/lib/module/hooks/useOnramp.js +1 -1
  139. package/lib/module/hooks/useOnramp.js.map +1 -1
  140. package/lib/module/index.js +1 -1
  141. package/lib/module/index.js.map +1 -1
  142. package/lib/module/specs/NativeAddToWalletButton.js +1 -1
  143. package/lib/module/specs/NativeAddressSheet.js +1 -1
  144. package/lib/module/specs/NativeApplePayButton.js +1 -1
  145. package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
  146. package/lib/module/specs/NativeCardField.js +1 -1
  147. package/lib/module/specs/NativeCardField.js.map +1 -1
  148. package/lib/module/specs/NativeCardForm.js +1 -1
  149. package/lib/module/specs/NativeCardForm.js.map +1 -1
  150. package/lib/module/specs/NativeConnectAccountOnboardingView.js +1 -1
  151. package/lib/module/specs/NativeCurrencySelectorElement.js +1 -1
  152. package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
  153. package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
  154. package/lib/module/specs/NativeGooglePayButton.js +1 -1
  155. package/lib/module/specs/NativeNavigationBar.js +1 -1
  156. package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -1
  157. package/lib/module/specs/NativePaymentMethodMessagingElement.js +1 -1
  158. package/lib/module/specs/NativeStripeContainer.js +1 -1
  159. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
  160. package/lib/module/types/EmbeddedPaymentElement.js +1 -1
  161. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
  162. package/lib/module/types/Errors.js +1 -1
  163. package/lib/module/types/Errors.js.map +1 -1
  164. package/lib/module/types/LinkController.js +2 -0
  165. package/lib/module/types/LinkController.js.map +1 -0
  166. package/lib/module/types/Onramp.js +1 -1
  167. package/lib/module/types/Onramp.js.map +1 -1
  168. package/lib/module/types/index.js +1 -1
  169. package/lib/module/types/index.js.map +1 -1
  170. package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
  171. package/lib/typescript/src/connect/Components.d.ts +1 -1
  172. package/lib/typescript/src/connect/Components.d.ts.map +1 -1
  173. package/lib/typescript/src/functions.d.ts +19 -1
  174. package/lib/typescript/src/functions.d.ts.map +1 -1
  175. package/lib/typescript/src/hooks/useCheckout.d.ts.map +1 -1
  176. package/lib/typescript/src/hooks/useLinkController.d.ts +28 -0
  177. package/lib/typescript/src/hooks/useLinkController.d.ts.map +1 -0
  178. package/lib/typescript/src/hooks/useOnramp.d.ts +18 -0
  179. package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
  180. package/lib/typescript/src/index.d.ts +1 -0
  181. package/lib/typescript/src/index.d.ts.map +1 -1
  182. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +2 -0
  183. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
  184. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +5 -2
  185. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
  186. package/lib/typescript/src/types/Checkout.d.ts +1 -14
  187. package/lib/typescript/src/types/Checkout.d.ts.map +1 -1
  188. package/lib/typescript/src/types/Errors.d.ts +8 -0
  189. package/lib/typescript/src/types/Errors.d.ts.map +1 -1
  190. package/lib/typescript/src/types/LinkController.d.ts +71 -0
  191. package/lib/typescript/src/types/LinkController.d.ts.map +1 -0
  192. package/lib/typescript/src/types/Onramp.d.ts +82 -21
  193. package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
  194. package/lib/typescript/src/types/index.d.ts +2 -1
  195. package/lib/typescript/src/types/index.d.ts.map +1 -1
  196. package/package.json +1 -1
  197. package/src/components/StripeProvider.tsx +0 -2
  198. package/src/connect/Components.tsx +10 -0
  199. package/src/functions.ts +48 -0
  200. package/src/hooks/useCheckout.tsx +0 -14
  201. package/src/hooks/useLinkController.tsx +54 -0
  202. package/src/hooks/useOnramp.tsx +50 -83
  203. package/src/index.tsx +1 -0
  204. package/src/specs/NativeOnrampSdkModule.ts +8 -0
  205. package/src/specs/NativeStripeSdkModule.ts +11 -7
  206. package/src/types/Checkout.ts +1 -19
  207. package/src/types/Errors.ts +9 -0
  208. package/src/types/LinkController.ts +75 -0
  209. package/src/types/Onramp.ts +98 -21
  210. package/src/types/index.ts +2 -0
  211. package/stripe-react-native.podspec +1 -1
  212. package/lib/commonjs/internal/stripeConfig.js +0 -2
  213. package/lib/commonjs/internal/stripeConfig.js.map +0 -1
  214. package/lib/module/internal/stripeConfig.js +0 -2
  215. package/lib/module/internal/stripeConfig.js.map +0 -1
  216. package/lib/typescript/src/internal/stripeConfig.d.ts +0 -3
  217. package/lib/typescript/src/internal/stripeConfig.d.ts.map +0 -1
  218. package/src/internal/stripeConfig.ts +0 -9
package/src/functions.ts CHANGED
@@ -14,6 +14,7 @@ import type {
14
14
  HandleNextActionResult,
15
15
  HandleNextActionForSetupResult,
16
16
  InitPaymentSheetResult,
17
+ LinkController,
17
18
  PaymentMethod,
18
19
  PaymentSheet,
19
20
  PresentPaymentSheetResult,
@@ -959,3 +960,50 @@ export const setFinancialConnectionsForceNativeFlow = async (
959
960
  // no-op
960
961
  }
961
962
  };
963
+
964
+ /**
965
+ * Initializes the LinkController with the provided configuration.
966
+ * Must be called before `presentLinkController`.
967
+ *
968
+ * @PrivatePreview This API is in private preview and may change without notice.
969
+ * It will have no effect unless your Stripe account is enrolled in the private preview.
970
+ */
971
+ export const initLinkController = async (
972
+ params: LinkController.Configuration
973
+ ): Promise<LinkController.InitResult> => {
974
+ try {
975
+ const { error } = await NativeStripeSdk.initLinkController(params);
976
+ if (error) {
977
+ return { error };
978
+ }
979
+ return {};
980
+ } catch (error: any) {
981
+ return { error };
982
+ }
983
+ };
984
+
985
+ /**
986
+ * Presents the Link flow. Must be called after `initLinkController`.
987
+ *
988
+ * Handles the full end-to-end flow: consumer lookup, authentication or signup,
989
+ * wallet display, and payment method creation.
990
+ *
991
+ * @PrivatePreview This API is in private preview and may change without notice.
992
+ * It will have no effect unless your Stripe account is enrolled in the private preview.
993
+ */
994
+ export const presentLinkController =
995
+ async (): Promise<LinkController.PresentResult> => {
996
+ try {
997
+ const { paymentMethod, paymentMethodPreview, error } =
998
+ await NativeStripeSdk.presentLinkController();
999
+ if (error) {
1000
+ return { error };
1001
+ }
1002
+ return {
1003
+ paymentMethod: paymentMethod!,
1004
+ paymentMethodPreview,
1005
+ };
1006
+ } catch (error: any) {
1007
+ return { error };
1008
+ }
1009
+ };
@@ -114,18 +114,6 @@ export function useCheckout(
114
114
  ),
115
115
  [withLoading]
116
116
  );
117
- const updateBillingAddress = useCallback<Checkout['updateBillingAddress']>(
118
- (address, name, phone) =>
119
- withLoading((key) =>
120
- NativeStripeSdk.checkoutUpdateBillingAddress(
121
- key,
122
- address,
123
- name ?? null,
124
- phone ?? null
125
- )
126
- ),
127
- [withLoading]
128
- );
129
117
  const applyPromotionCode = useCallback<Checkout['applyPromotionCode']>(
130
118
  (code) =>
131
119
  withLoading((key) =>
@@ -192,7 +180,6 @@ export function useCheckout(
192
180
  return sessionKeyRef.current;
193
181
  },
194
182
  updateShippingAddress,
195
- updateBillingAddress,
196
183
  applyPromotionCode,
197
184
  removePromotionCode,
198
185
  updateLineItemQuantity,
@@ -201,7 +188,6 @@ export function useCheckout(
201
188
  }),
202
189
  [
203
190
  updateShippingAddress,
204
- updateBillingAddress,
205
191
  applyPromotionCode,
206
192
  removePromotionCode,
207
193
  updateLineItemQuantity,
@@ -0,0 +1,54 @@
1
+ import { useState, useCallback } from 'react';
2
+ import { initLinkController, presentLinkController } from '../functions';
3
+ import type { LinkController } from '../types';
4
+
5
+ /**
6
+ * `useLinkController` hook.
7
+ *
8
+ * Provides `initLinkController` and `presentLinkController` methods with a shared
9
+ * `loading` state. Call `initLinkController` once when your checkout screen loads,
10
+ * then `presentLinkController` when the customer taps your Link button.
11
+ *
12
+ * @PrivatePreview This API is in private preview and may change without notice.
13
+ */
14
+ export function useLinkController() {
15
+ const [loading, setLoading] = useState(false);
16
+
17
+ const init = useCallback(
18
+ async (
19
+ params: LinkController.Configuration
20
+ ): Promise<LinkController.InitResult> => {
21
+ setLoading(true);
22
+ const result = await initLinkController(params);
23
+ setLoading(false);
24
+ return result;
25
+ },
26
+ []
27
+ );
28
+
29
+ const present =
30
+ useCallback(async (): Promise<LinkController.PresentResult> => {
31
+ setLoading(true);
32
+ const result = await presentLinkController();
33
+ setLoading(false);
34
+ return result;
35
+ }, []);
36
+
37
+ return {
38
+ /** Whether an operation is currently in progress. */
39
+ loading,
40
+ /**
41
+ * Initializes the LinkController with the provided configuration.
42
+ * Must be called before `presentLinkController`.
43
+ *
44
+ * @PrivatePreview
45
+ */
46
+ initLinkController: init,
47
+ /**
48
+ * Presents the Link flow. Must be called after `initLinkController`.
49
+ *
50
+ * @PrivatePreview
51
+ */
52
+ presentLinkController: present,
53
+ };
54
+ }
@@ -5,8 +5,6 @@ import type { Address } from '../types';
5
5
  import { useCallback } from 'react';
6
6
  import { addOnrampListener } from '../events';
7
7
  import { CryptoPaymentToken } from '../types/Onramp';
8
- import { getCurrentPublishableKey } from '../internal/stripeConfig';
9
- import pjson from '../../package.json';
10
8
 
11
9
  export function requireOnrampModule() {
12
10
  if (NativeOnrampSdk == null) {
@@ -26,83 +24,6 @@ export function requireOnrampModule() {
26
24
  let onCheckoutClientSecretRequestedSubscription: EventSubscription | null =
27
25
  null;
28
26
 
29
- const legacyAppAttestationUnavailableMessages = [
30
- 'App attestation is missing or device cannot use native Link.',
31
- 'Native Link is not available',
32
- ];
33
- const cryptoOnrampAppAttestationUnavailableCode = 'app_attestation_unavailable';
34
-
35
- function isLegacyAppAttestationUnavailableMessage(message?: string): boolean {
36
- return (
37
- message != null && legacyAppAttestationUnavailableMessages.includes(message)
38
- );
39
- }
40
-
41
- function publishableKeyMode(): 'live' | 'test' | undefined {
42
- const publishableKey = getCurrentPublishableKey();
43
- if (publishableKey?.startsWith('pk_live_')) {
44
- return 'live';
45
- }
46
- if (publishableKey?.startsWith('pk_test_')) {
47
- return 'test';
48
- }
49
- return undefined;
50
- }
51
-
52
- // Temporary React Native shim: iOS/Android currently surface this configure/create
53
- // failure as a legacy SDK-level message instead of a typed rich error. This can be
54
- // removed once the native SDKs map it themselves, though keeping it is harmless as
55
- // a compatibility fallback for older native SDK versions.
56
- function mapLegacyConfigureAppAttestationError(result: {
57
- error?: Onramp.CryptoOnrampError;
58
- }): { error?: Onramp.CryptoOnrampError } {
59
- const error = result.error;
60
- if (
61
- error == null ||
62
- error.onrampErrorType != null ||
63
- (!isLegacyAppAttestationUnavailableMessage(error.message) &&
64
- !isLegacyAppAttestationUnavailableMessage(error.localizedMessage))
65
- ) {
66
- return result;
67
- }
68
-
69
- const userMessage =
70
- "This app couldn't be verified. Contact the app developer for help.";
71
- const mode = publishableKeyMode();
72
-
73
- const context = [
74
- 'Context:',
75
- ' operation: configure',
76
- mode != null ? ` mode: ${mode}` : undefined,
77
- ].filter((line): line is string => line != null);
78
- const appAttestationError = {
79
- ...error,
80
- message: userMessage,
81
- localizedMessage: userMessage,
82
- stripeErrorCode: cryptoOnrampAppAttestationUnavailableCode,
83
- developerMessage: [
84
- "App attestation unavailable: this app isn't configured to use Stripe Crypto Onramp.",
85
- '',
86
- "This usually means app attestation isn't enabled for this Stripe account, or this app isn't registered as a trusted application. Use your iOS bundle ID or Android package name and contact Stripe to enable app attestation or register the app for this account.",
87
- '',
88
- ...context,
89
- '',
90
- `Code: ${cryptoOnrampAppAttestationUnavailableCode}`,
91
- '',
92
- 'Next step: confirm app attestation is enabled for this Stripe account and that the app identifier is registered as trusted, then call configure again.',
93
- `SDK: stripe-react-native@${pjson.version}`,
94
- ].join('\n'),
95
- userMessage,
96
- operation: 'configure',
97
- mode,
98
- } as unknown as Onramp.CryptoOnrampError;
99
-
100
- return {
101
- ...result,
102
- error: appAttestationError,
103
- };
104
- }
105
-
106
27
  /**
107
28
  * useOnramp hook
108
29
  */
@@ -111,9 +32,7 @@ export function useOnramp() {
111
32
  async (
112
33
  config: Onramp.Configuration
113
34
  ): Promise<{ error?: Onramp.CryptoOnrampError }> => {
114
- return mapLegacyConfigureAppAttestationError(
115
- await requireOnrampModule().configureOnramp(config)
116
- );
35
+ return requireOnrampModule().configureOnramp(config);
117
36
  },
118
37
  []
119
38
  );
@@ -147,6 +66,32 @@ export function useOnramp() {
147
66
  []
148
67
  );
149
68
 
69
+ const _getWalletOwnershipChallenge = useCallback(
70
+ async (
71
+ walletAddress: string,
72
+ network: Onramp.CryptoNetwork
73
+ ): Promise<Onramp.GetWalletOwnershipChallengeResult> => {
74
+ return requireOnrampModule().getWalletOwnershipChallenge(
75
+ walletAddress,
76
+ network
77
+ );
78
+ },
79
+ []
80
+ );
81
+
82
+ const _submitWalletOwnershipSignature = useCallback(
83
+ async (
84
+ challengeId: string,
85
+ signature: string
86
+ ): Promise<Onramp.SubmitWalletOwnershipSignatureResult> => {
87
+ return requireOnrampModule().submitWalletOwnershipSignature(
88
+ challengeId,
89
+ signature
90
+ );
91
+ },
92
+ []
93
+ );
94
+
150
95
  const _attachKycInfo = useCallback(
151
96
  async (
152
97
  kycInfo: Onramp.KycInfo
@@ -292,7 +237,9 @@ export function useOnramp() {
292
237
  const _isAuthError = (error?: Onramp.CryptoOnrampError): boolean => {
293
238
  const stripeErrorCode =
294
239
  error?.stripeErrorCode ??
295
- (error?.onrampErrorType ? error.apiErrorCode : undefined);
240
+ (error != null && 'apiErrorCode' in error
241
+ ? error.apiErrorCode
242
+ : undefined);
296
243
  if (stripeErrorCode == null) {
297
244
  return false;
298
245
  }
@@ -338,6 +285,26 @@ export function useOnramp() {
338
285
  */
339
286
  registerWalletAddress: _registerWalletAddress,
340
287
 
288
+ /**
289
+ * Creates a short-lived challenge for proving ownership of a registered wallet.
290
+ * Requires an authenticated Link user.
291
+ *
292
+ * @param walletAddress The registered crypto wallet address to verify
293
+ * @param network The crypto network for the wallet address
294
+ * @returns Promise that resolves to the challenge whose message must be signed, or an error
295
+ */
296
+ getWalletOwnershipChallenge: _getWalletOwnershipChallenge,
297
+
298
+ /**
299
+ * Verifies a signature over a previously issued wallet ownership challenge.
300
+ * Requires an authenticated Link user.
301
+ *
302
+ * @param challengeId The opaque identifier returned by `getWalletOwnershipChallenge`
303
+ * @param signature The signature produced over the exact challenge message
304
+ * @returns Promise that resolves to the verified consumer wallet, or an error
305
+ */
306
+ submitWalletOwnershipSignature: _submitWalletOwnershipSignature,
307
+
341
308
  /**
342
309
  * Attaches the specific KYC info to the current Link user. Requires an authenticated Link user.
343
310
  *
package/src/index.tsx CHANGED
@@ -6,6 +6,7 @@ export { usePlatformPay } from './hooks/usePlatformPay';
6
6
  export { usePaymentSheet } from './hooks/usePaymentSheet';
7
7
  export { useFinancialConnectionsSheet } from './hooks/useFinancialConnectionsSheet';
8
8
  export { useOnramp } from './hooks/useOnramp';
9
+ export { useLinkController } from './hooks/useLinkController';
9
10
 
10
11
  //components
11
12
  export { initStripe, StripeProvider } from './components/StripeProvider';
@@ -16,6 +16,14 @@ export interface Spec extends TurboModule {
16
16
  walletAddress: string,
17
17
  network: string
18
18
  ): Promise<Onramp.VoidResult>;
19
+ getWalletOwnershipChallenge(
20
+ walletAddress: string,
21
+ network: string
22
+ ): Promise<Onramp.GetWalletOwnershipChallengeResult>;
23
+ submitWalletOwnershipSignature(
24
+ challengeId: string,
25
+ signature: string
26
+ ): Promise<Onramp.SubmitWalletOwnershipSignatureResult>;
19
27
  attachKycInfo(
20
28
  kycInfo: UnsafeObject<Onramp.KycInfo>
21
29
  ): Promise<Onramp.VoidResult>;
@@ -22,6 +22,7 @@ import type {
22
22
  InitialiseParams,
23
23
  InitPaymentSheetResult,
24
24
  IsCardInWalletResult,
25
+ LinkController,
25
26
  OpenApplePaySetupResult,
26
27
  PaymentIntent,
27
28
  PaymentMethod,
@@ -226,13 +227,6 @@ export interface Spec extends TurboModule {
226
227
  phone: string | null
227
228
  ): Promise<UnsafeObject<Checkout.State>>;
228
229
 
229
- checkoutUpdateBillingAddress(
230
- sessionKey: string,
231
- address: UnsafeObject<Checkout.Address>,
232
- name: string | null,
233
- phone: string | null
234
- ): Promise<UnsafeObject<Checkout.State>>;
235
-
236
230
  checkoutApplyPromotionCode(
237
231
  sessionKey: string,
238
232
  code: string
@@ -278,6 +272,16 @@ export interface Spec extends TurboModule {
278
272
  storeStripeConnectDeepLink(url: string): Promise<void>;
279
273
  pollAndClearPendingStripeConnectUrls(): Promise<string[]>;
280
274
 
275
+ // LinkController - Private Preview
276
+
277
+ /** @PrivatePreview */
278
+ initLinkController(
279
+ params: UnsafeObject<LinkController.Configuration>
280
+ ): Promise<UnsafeObject<LinkController.InitResult>>;
281
+
282
+ /** @PrivatePreview */
283
+ presentLinkController(): Promise<UnsafeObject<LinkController.PresentResult>>;
284
+
281
285
  // Events
282
286
  addListener: (eventType: string) => void;
283
287
  removeListeners: (count: number) => void;
@@ -103,7 +103,7 @@ export namespace Checkout {
103
103
  tax: Tax;
104
104
  /** Tax and discount details for the computed total amount. */
105
105
  total?: Total;
106
- /** The billing address set via `updateBillingAddress`, if any. */
106
+ /** The billing address for this session, if any. */
107
107
  billingAddress?: ContactAddress;
108
108
  }
109
109
 
@@ -507,24 +507,6 @@ export interface Checkout {
507
507
  phone?: string
508
508
  ): Promise<void>;
509
509
 
510
- /**
511
- * Sets the billing address for this checkout.
512
- *
513
- * The address is stored locally and merged into PaymentSheet configuration
514
- * when presenting payment UI. If automatic tax is enabled and the tax
515
- * address source is "billing", the address is also sent to the server to
516
- * compute updated tax amounts.
517
- *
518
- * @param address - The billing address to set.
519
- * @param name - The customer's name.
520
- * @param phone - The customer's phone number.
521
- */
522
- updateBillingAddress(
523
- address: Checkout.Address,
524
- name?: string,
525
- phone?: string
526
- ): Promise<void>;
527
-
528
510
  /**
529
511
  * Applies a promotion code to the session.
530
512
  * - Parameter code: The promotion code to apply (e.g. `"SUMMER2026"`).
@@ -106,3 +106,12 @@ export enum RadarError {
106
106
  Failed = 'Failed',
107
107
  Unknown = 'Unknown',
108
108
  }
109
+
110
+ /**
111
+ * @PrivatePreview
112
+ */
113
+ export enum LinkControllerError {
114
+ Failed = 'Failed',
115
+ Canceled = 'Canceled',
116
+ Unknown = 'Unknown',
117
+ }
@@ -0,0 +1,75 @@
1
+ import type { Result as PaymentMethodResult } from './PaymentMethod';
2
+ import type { LinkControllerError, StripeError } from './Errors';
3
+
4
+ /**
5
+ * @PrivatePreview Payment method types supported by the Link flow.
6
+ */
7
+ export enum LinkPaymentMethodType {
8
+ Card = 'card',
9
+ BankAccount = 'bankAccount',
10
+ }
11
+
12
+ /**
13
+ * @PrivatePreview Configuration for initializing the Link controller.
14
+ */
15
+ export type Configuration = {
16
+ /** The customer's email address used for Link consumer lookup. */
17
+ email?: string;
18
+ /** Your customer-facing business name, displayed in Link UI. */
19
+ merchantDisplayName: string;
20
+ /** Payment method types to support in the Link sheet. If omitted, all available types are shown. */
21
+ supportedPaymentMethodTypes?: LinkPaymentMethodType[];
22
+ /** Customer phone number in E.164 format to prefill during signup. */
23
+ phoneNumber?: string;
24
+ /** Whether to allow the user to log out. Defaults to true. */
25
+ allowLogout?: boolean;
26
+ /**
27
+ * Optional SetupIntent client secret. When provided, the SDK confirms the SetupIntent
28
+ * with the selected payment method automatically before returning.
29
+ */
30
+ setupIntentClientSecret?: string;
31
+ };
32
+
33
+ /**
34
+ * @PrivatePreview A preview of the payment method the user selected in Link.
35
+ * Intended for display in the host app's checkout UI after the flow completes.
36
+ */
37
+ export type PaymentMethodPreview = {
38
+ /**
39
+ * Payment method icon as a data URI PNG string (e.g., "data:image/png;base64,...").
40
+ * Suitable for rendering directly in a React Native `<Image source={{ uri: icon }}>` component.
41
+ */
42
+ icon: string;
43
+ /** The Link label to render in your screen. */
44
+ label: string;
45
+ /** Details about the selected Link payment method. This will typically render the display name of the payment method followed by the last four digits, e.g. `Visa Credit •••• 4242`. */
46
+ sublabel?: string;
47
+ };
48
+
49
+ /**
50
+ * @PrivatePreview Result returned from `initLinkController`.
51
+ */
52
+ export type InitResult =
53
+ | { error?: undefined }
54
+ | { error: StripeError<LinkControllerError> };
55
+
56
+ /**
57
+ * @PrivatePreview Result returned from `presentLinkController`.
58
+ */
59
+ export type PresentResult =
60
+ | {
61
+ /** The payment method created from the user's Link selection. */
62
+ paymentMethod: PaymentMethodResult;
63
+ /** A preview of the selected payment method for display purposes. */
64
+ paymentMethodPreview?: PaymentMethodPreview;
65
+ error?: undefined;
66
+ }
67
+ | {
68
+ paymentMethod?: undefined;
69
+ paymentMethodPreview?: undefined;
70
+ /**
71
+ * Set when the operation failed or was canceled.
72
+ * Cancellation has `error.code === LinkControllerError.Canceled`.
73
+ */
74
+ error: StripeError<LinkControllerError>;
75
+ };
@@ -6,9 +6,9 @@ import type {
6
6
  } from './PlatformPay';
7
7
 
8
8
  /**
9
- * Generic error codes returned by Crypto Onramp APIs.
9
+ * Generic error statuses returned by Crypto Onramp APIs.
10
10
  */
11
- export enum OnrampError {
11
+ export enum OnrampErrorStatus {
12
12
  Failed = 'Failed',
13
13
  Canceled = 'Canceled',
14
14
  Unknown = 'Unknown',
@@ -175,8 +175,39 @@ export enum CryptoNetwork {
175
175
  worldchain = 'worldchain',
176
176
  xrpl = 'xrpl',
177
177
  sui = 'sui',
178
+ arbitrum = 'arbitrum',
178
179
  }
179
180
 
181
+ /**
182
+ * A short-lived server-issued challenge used to prove ownership of a registered wallet.
183
+ */
184
+ export type WalletOwnershipChallenge = {
185
+ /** Opaque identifier for this challenge. */
186
+ challengeId: string;
187
+ /** The wallet address bound to this challenge. */
188
+ walletAddress: string;
189
+ /** The crypto network bound to this challenge. */
190
+ network: CryptoNetwork;
191
+ /** The exact opaque message the wallet must sign. */
192
+ message: string;
193
+ /** ISO 8601 timestamp indicating when this challenge expires. */
194
+ expiresAt: string;
195
+ };
196
+
197
+ /**
198
+ * A registered crypto consumer wallet.
199
+ */
200
+ export type CryptoConsumerWallet = {
201
+ /** The consumer wallet's unique identifier. */
202
+ id: string;
203
+ /** The registered wallet address. */
204
+ walletAddress: string;
205
+ /** The crypto network for the registered wallet. */
206
+ network: CryptoNetwork;
207
+ /** Whether ownership of this wallet has been verified. */
208
+ verifiedOwnership: boolean;
209
+ };
210
+
180
211
  /**
181
212
  * Represents a calendar date using day, month, and year components.
182
213
  * Example: March 31st, 1975 -> { day: 31, month: 3, year: 1975 }
@@ -269,36 +300,42 @@ export type ComplianceIdentifierRequirements = {
269
300
  };
270
301
 
271
302
  /**
272
- * Typed Crypto Onramp error discriminants returned by newer native SDKs.
303
+ * Typed Crypto Onramp API error discriminants.
273
304
  */
274
- export type OnrampErrorType = 'AppAttestationError' | 'UncategorizedApiError';
305
+ export type OnrampApiErrorType =
306
+ | 'AppAttestationError'
307
+ | 'UncategorizedApiError';
275
308
 
276
309
  /**
277
- * A native SDK component and version included in Crypto Onramp diagnostics.
310
+ * Typed Crypto Onramp error discriminants returned by newer native SDKs.
278
311
  */
279
- export type SDKVersion = {
280
- /** The SDK component name. */
281
- name: string;
282
- /** The SDK component version. */
283
- version: string;
284
- };
312
+ export type OnrampErrorType =
313
+ | OnrampApiErrorType
314
+ | 'AppAttestationUnavailableError';
285
315
 
286
- export type OnrampApiError = StripeError<OnrampError> & {
287
- onrampErrorType: string;
316
+ /**
317
+ * Base rich error shape returned by native Crypto Onramp SDK errors.
318
+ */
319
+ export type OnrampSdkError = StripeError<OnrampErrorStatus> & {
320
+ onrampErrorType: OnrampErrorType;
288
321
  developerMessage: string;
289
322
  userMessage: string;
323
+ docUrl?: string;
324
+ };
325
+
326
+ /**
327
+ * API-context fields returned for Crypto Onramp API errors.
328
+ */
329
+ export type OnrampApiError = OnrampSdkError & {
330
+ onrampErrorType: OnrampApiErrorType;
290
331
  reason?: string;
291
- operation: string;
292
- appPackageName: string;
293
- mode?: 'live' | 'test';
294
- sdkVersions?: SDKVersion[];
295
332
  requestId?: string;
296
333
  apiErrorCode?: string;
297
334
  apiErrorType?: string;
298
335
  apiErrorMessage?: string;
299
336
  apiUserMessage?: string;
300
- docUrl?: string;
301
337
  };
338
+
302
339
  /**
303
340
  * A typed Crypto Onramp app attestation failure.
304
341
  */
@@ -313,6 +350,13 @@ export type UncategorizedApiError = OnrampApiError & {
313
350
  onrampErrorType: 'UncategorizedApiError';
314
351
  };
315
352
 
353
+ /**
354
+ * A typed Crypto Onramp local SDK error for app attestation setup failures.
355
+ */
356
+ export type AppAttestationUnavailableError = OnrampSdkError & {
357
+ onrampErrorType: 'AppAttestationUnavailableError';
358
+ };
359
+
316
360
  /**
317
361
  * Error returned by Crypto Onramp APIs.
318
362
  *
@@ -321,11 +365,14 @@ export type UncategorizedApiError = OnrampApiError & {
321
365
  * `onrampErrorType`.
322
366
  */
323
367
  export type CryptoOnrampError =
324
- | (StripeError<OnrampError> & {
325
- onrampErrorType?: undefined;
368
+ | (StripeError<OnrampErrorStatus> & {
369
+ onrampErrorType?: never;
370
+ developerMessage?: never;
371
+ userMessage?: never;
326
372
  })
327
373
  | AppAttestationError
328
- | UncategorizedApiError;
374
+ | UncategorizedApiError
375
+ | AppAttestationUnavailableError;
329
376
 
330
377
  /**
331
378
  * Result of retrieving missing compliance identifiers.
@@ -470,6 +517,36 @@ export type RegisterLinkUserResult =
470
517
  error: CryptoOnrampError;
471
518
  };
472
519
 
520
+ /**
521
+ * Result of creating a wallet ownership challenge.
522
+ */
523
+ export type GetWalletOwnershipChallengeResult =
524
+ | {
525
+ /** The short-lived challenge whose message must be signed by the wallet. */
526
+ challenge: WalletOwnershipChallenge;
527
+ error?: undefined;
528
+ }
529
+ | {
530
+ challenge?: undefined;
531
+ /** Present if challenge creation failed with an error. */
532
+ error: CryptoOnrampError;
533
+ };
534
+
535
+ /**
536
+ * Result of submitting a wallet ownership signature.
537
+ */
538
+ export type SubmitWalletOwnershipSignatureResult =
539
+ | {
540
+ /** The registered wallet after ownership verification. */
541
+ consumerWallet: CryptoConsumerWallet;
542
+ error?: undefined;
543
+ }
544
+ | {
545
+ consumerWallet?: undefined;
546
+ /** Present if signature verification failed with an error. */
547
+ error: CryptoOnrampError;
548
+ };
549
+
473
550
  /**
474
551
  * Describes the payment method currently selected by the user.
475
552
  */