@stripe/stripe-react-native 0.65.1 → 0.67.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 (107) hide show
  1. package/android/detekt/detekt-baseline.xml +0 -10
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +51 -57
  4. package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementEvent.kt +26 -0
  5. package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementView.kt +129 -16
  6. package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementViewManager.kt +17 -0
  7. package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -0
  8. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +8 -19
  9. package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +1 -0
  10. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +89 -31
  11. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +1 -0
  12. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +2 -16
  13. package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutMappers.kt +59 -33
  14. package/android/src/main/java/com/reactnativestripesdk/utils/DefaultActivityLifecycleCallbacks.kt +41 -0
  15. package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +11 -6
  16. package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +17 -3
  17. package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +2 -2
  18. package/android/src/onramp/java/com/reactnativestripesdk/OnrampErrors.kt +145 -0
  19. package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +125 -0
  20. package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +144 -22
  21. package/android/src/test/java/com/reactnativestripesdk/DrawableLoadingTest.kt +6 -2
  22. package/android/src/test/java/com/reactnativestripesdk/OnrampErrorsTest.kt +168 -0
  23. package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +107 -0
  24. package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutMappersTest.kt +39 -30
  25. package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutTestFixtures.java +8 -0
  26. package/ios/CurrencySelectorElementManager.m +7 -0
  27. package/ios/CurrencySelectorElementView.swift +142 -7
  28. package/ios/EmbeddedPaymentElementView.swift +1 -1
  29. package/ios/Mappers+Checkout.swift +251 -107
  30. package/ios/Mappers.swift +97 -7
  31. package/ios/NewArch/StripeCurrencySelectorElementComponentView.mm +14 -0
  32. package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
  33. package/ios/OldArch/StripeSdkEventEmitterCompat.m +6 -0
  34. package/ios/OnrampErrors.swift +132 -0
  35. package/ios/PaymentOptionDisplayData+ReactNative.swift +1 -1
  36. package/ios/PaymentSheetAppearance.swift +1 -1
  37. package/ios/StripeOnrampSdk.mm +19 -0
  38. package/ios/StripeSdk.mm +14 -14
  39. package/ios/StripeSdkEmitter.swift +1 -0
  40. package/ios/StripeSdkImpl+Checkout.swift +66 -31
  41. package/ios/StripeSdkImpl+CustomerSheet.swift +1 -1
  42. package/ios/StripeSdkImpl+Embedded.swift +1 -1
  43. package/ios/StripeSdkImpl+PaymentSheet.swift +1 -1
  44. package/ios/StripeSdkImpl.swift +116 -24
  45. package/lib/commonjs/components/PaymentMethodMessagingElement.js +1 -1
  46. package/lib/commonjs/components/PaymentMethodMessagingElement.js.map +1 -1
  47. package/lib/commonjs/components/StripeProvider.js +1 -1
  48. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  49. package/lib/commonjs/hooks/useCheckout.js +1 -1
  50. package/lib/commonjs/hooks/useCheckout.js.map +1 -1
  51. package/lib/commonjs/hooks/useOnramp.js +1 -1
  52. package/lib/commonjs/hooks/useOnramp.js.map +1 -1
  53. package/lib/commonjs/internal/stripeConfig.js +2 -0
  54. package/lib/commonjs/internal/stripeConfig.js.map +1 -0
  55. package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -1
  56. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
  57. package/lib/commonjs/types/Errors.js +1 -1
  58. package/lib/commonjs/types/Errors.js.map +1 -1
  59. package/lib/commonjs/types/Onramp.js +1 -1
  60. package/lib/commonjs/types/Onramp.js.map +1 -1
  61. package/lib/module/components/PaymentMethodMessagingElement.js +1 -1
  62. package/lib/module/components/PaymentMethodMessagingElement.js.map +1 -1
  63. package/lib/module/components/StripeProvider.js +1 -1
  64. package/lib/module/components/StripeProvider.js.map +1 -1
  65. package/lib/module/hooks/useCheckout.js +1 -1
  66. package/lib/module/hooks/useCheckout.js.map +1 -1
  67. package/lib/module/hooks/useOnramp.js +1 -1
  68. package/lib/module/hooks/useOnramp.js.map +1 -1
  69. package/lib/module/internal/stripeConfig.js +2 -0
  70. package/lib/module/internal/stripeConfig.js.map +1 -0
  71. package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -1
  72. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
  73. package/lib/module/types/Errors.js +1 -1
  74. package/lib/module/types/Errors.js.map +1 -1
  75. package/lib/module/types/Onramp.js +1 -1
  76. package/lib/module/types/Onramp.js.map +1 -1
  77. package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts +1 -1
  78. package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts.map +1 -1
  79. package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
  80. package/lib/typescript/src/hooks/useCheckout.d.ts.map +1 -1
  81. package/lib/typescript/src/hooks/useOnramp.d.ts +32 -10
  82. package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
  83. package/lib/typescript/src/internal/stripeConfig.d.ts +3 -0
  84. package/lib/typescript/src/internal/stripeConfig.d.ts.map +1 -0
  85. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +3 -0
  86. package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
  87. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +2 -2
  88. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
  89. package/lib/typescript/src/types/Checkout.d.ts +266 -92
  90. package/lib/typescript/src/types/Checkout.d.ts.map +1 -1
  91. package/lib/typescript/src/types/Errors.d.ts +0 -5
  92. package/lib/typescript/src/types/Errors.d.ts.map +1 -1
  93. package/lib/typescript/src/types/Onramp.d.ts +168 -9
  94. package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
  95. package/package.json +3 -2
  96. package/src/components/PaymentMethodMessagingElement.tsx +54 -52
  97. package/src/components/StripeProvider.tsx +2 -0
  98. package/src/hooks/useCheckout.tsx +20 -13
  99. package/src/hooks/useOnramp.tsx +139 -12
  100. package/src/internal/stripeConfig.ts +9 -0
  101. package/src/specs/NativeOnrampSdkModule.ts +5 -0
  102. package/src/specs/NativeStripeSdkModule.ts +6 -5
  103. package/src/types/Checkout.ts +289 -93
  104. package/src/types/Errors.ts +0 -6
  105. package/src/types/Onramp.ts +192 -9
  106. package/stripe-react-native.podspec +3 -3
  107. package/ios/CurrencySelectorElementManager.swift +0 -12
@@ -1,10 +1,19 @@
1
1
  import type { Address } from './Common';
2
- import type { OnrampError, StripeError } from './Errors';
2
+ import type { StripeError } from './Errors';
3
3
  import type {
4
4
  ApplePayBaseParams,
5
5
  ApplePayPaymentMethodParams,
6
6
  } from './PlatformPay';
7
7
 
8
+ /**
9
+ * Generic error codes returned by Crypto Onramp APIs.
10
+ */
11
+ export enum OnrampError {
12
+ Failed = 'Failed',
13
+ Canceled = 'Canceled',
14
+ Unknown = 'Unknown',
15
+ }
16
+
8
17
  /**
9
18
  * Configuration used to initialize and customize the crypto onramp experience.
10
19
  *
@@ -199,7 +208,181 @@ export type KycInfo = {
199
208
  dateOfBirth?: DateOfBirth;
200
209
  /** Customer’s address, if collected. */
201
210
  address?: Address;
211
+ /** Two-letter ISO 3166-1 alpha-2 code for the country where the customer was born. */
212
+ birthCountry?: string;
213
+ /** City where the customer was born. */
214
+ birthCity?: string;
215
+ /** Two-letter ISO 3166-1 alpha-2 codes for the customer's nationalities. */
216
+ nationalities?: string[];
217
+ };
218
+
219
+ /**
220
+ * The type of compliance identifier required or submitted for regulatory compliance.
221
+ */
222
+ export type ComplianceIdentifierType = string;
223
+
224
+ /**
225
+ * The regulation requiring a compliance identifier.
226
+ */
227
+ export type ComplianceRegulation = 'eu_carf' | 'eu_mica';
228
+
229
+ /**
230
+ * A compliance identifier collected for MiCA or CRS/CARF compliance.
231
+ */
232
+ export type ComplianceIdentifier = {
233
+ /** The type of identifier provided. */
234
+ type: ComplianceIdentifierType;
235
+ /** The identifier value. */
236
+ value: string;
237
+ };
238
+
239
+ /**
240
+ * A compliance identifier the customer still needs to provide.
241
+ */
242
+ export type ComplianceIdentifierRequirement = {
243
+ /** The type of identifier required. */
244
+ type: ComplianceIdentifierType;
245
+ /** The regulation requiring this identifier. */
246
+ regulation: ComplianceRegulation;
247
+ };
248
+
249
+ /**
250
+ * A group describing alternative identifier types that may satisfy a requirement.
251
+ */
252
+ export type ComplianceIdentifierAlternativeGroup = {
253
+ /** The original identifier types required. */
254
+ originalMissingIdentifiers: ComplianceIdentifierType[];
255
+ /** Alternative identifier types that may satisfy the original requirement. */
256
+ alternativeMissingIdentifiers: ComplianceIdentifierType[];
257
+ };
258
+
259
+ /**
260
+ * The compliance identifiers a customer still needs to provide.
261
+ */
262
+ export type ComplianceIdentifierRequirements = {
263
+ /** Required identifier types and the regulations requiring them. */
264
+ identifiers: ComplianceIdentifierRequirement[];
265
+ /** Alternative identifier groups that may satisfy one or more requirements. */
266
+ alternatives: ComplianceIdentifierAlternativeGroup[];
267
+ /** Whether at least one CRS/CARF tax identification number still needs to be collected. */
268
+ carfTinRequired: boolean;
269
+ };
270
+
271
+ /**
272
+ * Typed Crypto Onramp error discriminants returned by newer native SDKs.
273
+ */
274
+ export type OnrampErrorType = 'AppAttestationError' | 'UncategorizedApiError';
275
+
276
+ /**
277
+ * A native SDK component and version included in Crypto Onramp diagnostics.
278
+ */
279
+ export type SDKVersion = {
280
+ /** The SDK component name. */
281
+ name: string;
282
+ /** The SDK component version. */
283
+ version: string;
284
+ };
285
+
286
+ export type OnrampApiError = StripeError<OnrampError> & {
287
+ onrampErrorType: string;
288
+ developerMessage: string;
289
+ userMessage: string;
290
+ reason?: string;
291
+ operation: string;
292
+ appPackageName: string;
293
+ mode?: 'live' | 'test';
294
+ sdkVersions?: SDKVersion[];
295
+ requestId?: string;
296
+ apiErrorCode?: string;
297
+ apiErrorType?: string;
298
+ apiErrorMessage?: string;
299
+ apiUserMessage?: string;
300
+ docUrl?: string;
202
301
  };
302
+ /**
303
+ * A typed Crypto Onramp app attestation failure.
304
+ */
305
+ export type AppAttestationError = OnrampApiError & {
306
+ onrampErrorType: 'AppAttestationError';
307
+ };
308
+
309
+ /**
310
+ * A typed Crypto Onramp API error that did not map to a narrower category.
311
+ */
312
+ export type UncategorizedApiError = OnrampApiError & {
313
+ onrampErrorType: 'UncategorizedApiError';
314
+ };
315
+
316
+ /**
317
+ * Error returned by Crypto Onramp APIs.
318
+ *
319
+ * Most failures use the generic Stripe error envelope. Newer native SDK
320
+ * versions may instead return typed SDK-owned errors via
321
+ * `onrampErrorType`.
322
+ */
323
+ export type CryptoOnrampError =
324
+ | (StripeError<OnrampError> & {
325
+ onrampErrorType?: undefined;
326
+ })
327
+ | AppAttestationError
328
+ | UncategorizedApiError;
329
+
330
+ /**
331
+ * Result of retrieving missing compliance identifiers.
332
+ */
333
+ export type RetrieveMissingIdentifiersResult =
334
+ | (ComplianceIdentifierRequirements & {
335
+ error?: undefined;
336
+ })
337
+ | {
338
+ identifiers?: undefined;
339
+ alternatives?: undefined;
340
+ carfTinRequired?: undefined;
341
+ /** Present if retrieval failed with an error. */
342
+ error: CryptoOnrampError;
343
+ };
344
+
345
+ /**
346
+ * Result of submitting compliance identifiers for MiCA and CRS/CARF compliance.
347
+ */
348
+ export type SubmitIdentifiersResult =
349
+ | {
350
+ /** Whether all required MiCA identifiers and CRS/CARF tax identification numbers have been submitted. */
351
+ completed: boolean;
352
+ /** Any identifiers that still need to be collected. */
353
+ identifiers: ComplianceIdentifierRequirement[];
354
+ /** Alternative identifier groups that may satisfy one or more requirements. */
355
+ alternatives: ComplianceIdentifierAlternativeGroup[];
356
+ /** Whether at least one CRS/CARF tax identification number still needs to be collected. */
357
+ carfTinRequired: boolean;
358
+ /** Submitted identifier types whose values were invalid. */
359
+ invalidIdentifiers: ComplianceIdentifierType[];
360
+ error?: undefined;
361
+ }
362
+ | {
363
+ completed?: undefined;
364
+ identifiers?: undefined;
365
+ alternatives?: undefined;
366
+ carfTinRequired?: undefined;
367
+ invalidIdentifiers?: undefined;
368
+ /** Present if submission failed with an error. */
369
+ error: CryptoOnrampError;
370
+ };
371
+
372
+ /**
373
+ * Result of presenting user attestation.
374
+ */
375
+ export type UserAttestationResult =
376
+ | {
377
+ /** The customer accepted the attestation. */
378
+ status: 'Confirmed';
379
+ error?: undefined;
380
+ }
381
+ | {
382
+ status?: undefined;
383
+ /** Present if attestation failed or was cancelled. */
384
+ error: CryptoOnrampError;
385
+ };
203
386
 
204
387
  /**
205
388
  * Result of KYC verification.
@@ -218,7 +401,7 @@ export type VerifyKycResult =
218
401
  | {
219
402
  status?: undefined;
220
403
  /** Present if the verification failed with an error. */
221
- error: StripeError<OnrampError>;
404
+ error: CryptoOnrampError;
222
405
  };
223
406
 
224
407
  /**
@@ -226,7 +409,7 @@ export type VerifyKycResult =
226
409
  */
227
410
  export type VoidResult = {
228
411
  /** Present if the operation failed. */
229
- error?: StripeError<OnrampError>;
412
+ error?: CryptoOnrampError;
230
413
  };
231
414
 
232
415
  /**
@@ -254,7 +437,7 @@ export type AuthorizeResult =
254
437
  status?: undefined;
255
438
  customerId?: undefined;
256
439
  /** Present if the authorization failed with an error. */
257
- error: StripeError<OnrampError>;
440
+ error: CryptoOnrampError;
258
441
  };
259
442
 
260
443
  /**
@@ -269,7 +452,7 @@ export type HasLinkAccountResult =
269
452
  | {
270
453
  hasLinkAccount?: undefined;
271
454
  /** Present if the lookup failed with an error. */
272
- error: StripeError<OnrampError>;
455
+ error: CryptoOnrampError;
273
456
  };
274
457
 
275
458
  /**
@@ -284,7 +467,7 @@ export type RegisterLinkUserResult =
284
467
  | {
285
468
  customerId?: undefined;
286
469
  /** Present if registration failed with an error. */
287
- error: StripeError<OnrampError>;
470
+ error: CryptoOnrampError;
288
471
  };
289
472
 
290
473
  /**
@@ -319,7 +502,7 @@ export type CollectPaymentMethodResult =
319
502
  displayData?: undefined;
320
503
  kycInfo?: undefined;
321
504
  /** Present if collection/selection failed with an error. */
322
- error: StripeError<OnrampError>;
505
+ error: CryptoOnrampError;
323
506
  };
324
507
 
325
508
  /**
@@ -334,7 +517,7 @@ export type CreateCryptoPaymentTokenResult =
334
517
  | {
335
518
  cryptoPaymentToken?: undefined;
336
519
  /** Present if token creation failed with an error. */
337
- error: StripeError<OnrampError>;
520
+ error: CryptoOnrampError;
338
521
  };
339
522
 
340
523
  /**
@@ -375,5 +558,5 @@ export type PaymentDisplayDataResult =
375
558
  | {
376
559
  displayData?: undefined;
377
560
  /** Present if collection/selection failed with an error. */
378
- error: StripeError<OnrampError>;
561
+ error: CryptoOnrampError;
379
562
  };
@@ -2,7 +2,7 @@ require 'json'
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
4
  # Keep stripe_version in sync with https://github.com/stripe/stripe-identity-react-native/blob/main/stripe-identity-react-native.podspec
5
- stripe_version = '~> 25.12.0'
5
+ stripe_version = '~> 25.17.0'
6
6
 
7
7
  fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
8
8
 
@@ -38,7 +38,7 @@ Pod::Spec.new do |s|
38
38
 
39
39
  s.subspec 'Core' do |core|
40
40
  core.source_files = 'ios/**/*.{h,m,mm,swift}'
41
- core.exclude_files = [ 'ios/Tests/', 'ios/NewArch/', 'ios/StripeOnrampSdk.h', 'ios/StripeOnrampSdk.mm' ]
41
+ core.exclude_files = [ 'ios/Tests/', 'ios/NewArch/', 'ios/StripeOnrampSdk.h', 'ios/StripeOnrampSdk.mm', 'ios/OnrampErrors.swift' ]
42
42
  # These headers contain c++ code so make sure they are private to avoid
43
43
  # being exported to the umbrella header, which is used by swift interop.
44
44
  # StripeSwiftInterop.h will cause circular dependency issues.
@@ -53,7 +53,7 @@ Pod::Spec.new do |s|
53
53
  end
54
54
 
55
55
  s.subspec 'Onramp' do |onramp|
56
- onramp.source_files = [ 'ios/StripeOnrampSdk.h', 'ios/StripeOnrampSdk.mm' ]
56
+ onramp.source_files = [ 'ios/StripeOnrampSdk.h', 'ios/StripeOnrampSdk.mm', 'ios/OnrampErrors.swift' ]
57
57
  onramp.dependency 'stripe-react-native/Core'
58
58
  onramp.dependency 'StripeCryptoOnramp', stripe_version
59
59
  end
@@ -1,12 +0,0 @@
1
- import Foundation
2
-
3
- @objc(StripeCurrencySelectorElementManager)
4
- class StripeCurrencySelectorElementManager: RCTViewManager {
5
- override static func requiresMainQueueSetup() -> Bool {
6
- return true
7
- }
8
-
9
- override func view() -> UIView! {
10
- return StripeCurrencySelectorElementContainerView(frame: .zero)
11
- }
12
- }