@stripe/stripe-react-native 0.47.1 → 0.49.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 (47) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +85 -65
  4. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +18 -2
  5. package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +0 -2
  6. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +83 -3
  7. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +25 -0
  8. package/ios/PaymentSheetAppearance.swift +46 -1
  9. package/ios/StripeSdkImpl+PaymentSheet.swift +43 -5
  10. package/ios/StripeSdkImpl.swift +5 -1
  11. package/lib/commonjs/components/CustomerSheet.js +1 -1
  12. package/lib/commonjs/components/CustomerSheet.js.map +1 -1
  13. package/lib/commonjs/events.js.map +1 -1
  14. package/lib/commonjs/functions.js +1 -1
  15. package/lib/commonjs/functions.js.map +1 -1
  16. package/lib/commonjs/hooks/useStripe.js +1 -1
  17. package/lib/commonjs/hooks/useStripe.js.map +1 -1
  18. package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
  19. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
  20. package/lib/commonjs/types/PaymentSheet.js +1 -1
  21. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  22. package/lib/module/components/CustomerSheet.js +1 -1
  23. package/lib/module/components/CustomerSheet.js.map +1 -1
  24. package/lib/module/events.js.map +1 -1
  25. package/lib/module/functions.js +1 -1
  26. package/lib/module/functions.js.map +1 -1
  27. package/lib/module/hooks/useStripe.js +1 -1
  28. package/lib/module/hooks/useStripe.js.map +1 -1
  29. package/lib/module/types/EmbeddedPaymentElement.js +1 -1
  30. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
  31. package/lib/module/types/PaymentSheet.js +1 -1
  32. package/lib/module/types/PaymentSheet.js.map +1 -1
  33. package/lib/typescript/src/events.d.ts +1 -1
  34. package/lib/typescript/src/events.d.ts.map +1 -1
  35. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +27 -0
  36. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
  37. package/lib/typescript/src/types/PaymentIntent.d.ts +1 -1
  38. package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
  39. package/lib/typescript/src/types/PaymentSheet.d.ts +30 -2
  40. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
  41. package/package-lock.json +14114 -0
  42. package/package.json +1 -1
  43. package/src/events.ts +1 -0
  44. package/src/types/EmbeddedPaymentElement.tsx +47 -2
  45. package/src/types/PaymentIntent.ts +1 -1
  46. package/src/types/PaymentSheet.ts +35 -1
  47. package/stripe-react-native.podspec +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/stripe-react-native",
3
- "version": "0.47.1",
3
+ "version": "0.49.0",
4
4
  "author": "Stripe",
5
5
  "description": "Stripe SDK for React Native",
6
6
  "main": "lib/commonjs/index",
package/src/events.ts CHANGED
@@ -34,6 +34,7 @@ type Events =
34
34
  | 'onCustomerAdapterFetchSelectedPaymentOptionCallback'
35
35
  | 'onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback'
36
36
  | 'embeddedPaymentElementFormSheetConfirmComplete'
37
+ | 'embeddedPaymentElementRowSelectionImmediateAction'
37
38
  | 'embeddedPaymentElementDidUpdatePaymentOption'
38
39
  | 'embeddedPaymentElementDidUpdateHeight'
39
40
  | 'embeddedPaymentElementLoadingFailed';
@@ -92,6 +92,32 @@ export type EmbeddedFormSheetAction =
92
92
  type: 'continue';
93
93
  };
94
94
 
95
+ /**
96
+ * Describes how you handle row selections in EmbeddedPaymentElement.
97
+ * The embedded view may show payment method options that can be selected without further collecting further details in a form sheet.
98
+ * This type determines what happens upon a user tapping one of these payment options methods:
99
+ * - In the `default` case, the payment method option row enters a selected state.
100
+ * - In the `immediateAction` case, `onSelectPaymentOption` is called.
101
+ */
102
+ export type EmbeddedRowSelectionBehavior =
103
+ | {
104
+ /**
105
+ * When a payment method option is selected, the customer taps a button to continue or confirm payment.
106
+ * This is the default recommended integration.
107
+ */
108
+ type: 'default';
109
+ }
110
+ | {
111
+ /**
112
+ * When a payment method option is selected, `onSelectPaymentOption` is triggered.
113
+ * You can implement this function to immediately perform an action such as going back to the checkout screen or confirming the payment.
114
+ * Note that certain payment options like Apple Pay and saved payment methods are disabled in this mode if you set
115
+ * `EmbeddedPaymentElementConfiguration.formSheetAction` to `continue`
116
+ */
117
+ type: 'immediateAction';
118
+ onSelectPaymentOption?: () => void;
119
+ };
120
+
95
121
  /**
96
122
  * Configuration object (subset of EmbeddedPaymentElement.Configuration).
97
123
  */
@@ -166,6 +192,10 @@ export interface EmbeddedPaymentElementConfiguration {
166
192
  * The sheet has a button at the bottom. `formSheetAction` controls the action the button performs.
167
193
  */
168
194
  formSheetAction?: EmbeddedFormSheetAction;
195
+ /** The view can display payment methods that, when tapped, do not open a sheet to collect additional details.
196
+ * `rowSelectionBehavior` controls the behavior tapping on these payment methods performs.
197
+ */
198
+ rowSelectionBehavior?: EmbeddedRowSelectionBehavior;
169
199
  }
170
200
 
171
201
  // -----------------------------------------------------------------------------
@@ -209,12 +239,13 @@ class EmbeddedPaymentElement {
209
239
  // -----------------------------------------------------------------------------
210
240
  let confirmHandlerCallback: EventSubscription | null = null;
211
241
  let formSheetActionConfirmCallback: EventSubscription | null = null;
242
+ let rowSelectionCallback: EventSubscription | null = null;
212
243
 
213
244
  async function createEmbeddedPaymentElement(
214
245
  intentConfig: PaymentSheetTypes.IntentConfiguration,
215
246
  configuration: EmbeddedPaymentElementConfiguration
216
247
  ): Promise<EmbeddedPaymentElement> {
217
- setupConfirmHandlers(intentConfig, configuration);
248
+ setupConfirmAndSelectionHandlers(intentConfig, configuration);
218
249
 
219
250
  await NativeStripeSdkModule.createEmbeddedPaymentElement(
220
251
  intentConfig,
@@ -223,7 +254,7 @@ async function createEmbeddedPaymentElement(
223
254
  return new EmbeddedPaymentElement();
224
255
  }
225
256
 
226
- function setupConfirmHandlers(
257
+ function setupConfirmAndSelectionHandlers(
227
258
  intentConfig: PaymentSheetTypes.IntentConfiguration,
228
259
  configuration: EmbeddedPaymentElementConfiguration
229
260
  ) {
@@ -262,6 +293,20 @@ function setupConfirmHandlers(
262
293
  );
263
294
  }
264
295
  }
296
+
297
+ if (configuration.rowSelectionBehavior?.type === 'immediateAction') {
298
+ const rowSelectionHandler =
299
+ configuration.rowSelectionBehavior.onSelectPaymentOption;
300
+ if (rowSelectionHandler) {
301
+ rowSelectionCallback?.remove();
302
+ rowSelectionCallback = addListener(
303
+ 'embeddedPaymentElementRowSelectionImmediateAction',
304
+ () => {
305
+ rowSelectionHandler();
306
+ }
307
+ );
308
+ }
309
+ }
265
310
  }
266
311
 
267
312
  // -----------------------------------------------------------------------------
@@ -58,7 +58,7 @@ export type LastPaymentError = StripeError<string> & {
58
58
  paymentMethod: PaymentMethodResult;
59
59
  };
60
60
 
61
- export type FutureUsage = 'OffSession' | 'OnSession';
61
+ export type FutureUsage = 'OffSession' | 'OnSession' | 'None';
62
62
 
63
63
  export interface ShippingDetails {
64
64
  address: Required<Address>;
@@ -206,6 +206,9 @@ export type AppearanceParams = RecursivePartial<{
206
206
 
207
207
  /** Describes the appearance of the Embedded Mobile Payment Element */
208
208
  embeddedPaymentElement: EmbeddedPaymentElementAppearance;
209
+
210
+ /** Describes the inset values applied to Mobile Payment Element forms */
211
+ formInsetValues: EdgeInsetsConfig;
209
212
  }>;
210
213
 
211
214
  export type FontConfig = {
@@ -313,6 +316,11 @@ export type PrimaryButtonConfig = {
313
316
  * @default The root `appearance.shapes.shadow`
314
317
  */
315
318
  shadow: ShadowConfig;
319
+ /**
320
+ * The height of the primary button
321
+ * @default 48
322
+ */
323
+ height: number;
316
324
  };
317
325
  };
318
326
 
@@ -350,6 +358,10 @@ export enum RowStyle {
350
358
  FloatingButton = 'floatingButton',
351
359
  /** A flat style with a checkmark */
352
360
  FlatWithCheckmark = 'flatWithCheckmark',
361
+ /** A flat style with a chevron
362
+ * Note that the EmbeddedPaymentElementConfiguration.rowSelectionBehavior must be set to `immediateAction` to use this style.
363
+ */
364
+ FlatWithChevron = 'flatWithChevron',
353
365
  }
354
366
 
355
367
  /** Describes the appearance of the radio button */
@@ -373,6 +385,14 @@ export interface CheckmarkConfig {
373
385
  color?: ThemedColor;
374
386
  }
375
387
 
388
+ /** Describes the appearance of the chevron */
389
+ export interface ChevronConfig {
390
+ /** The color of the chevron, represented as a hex string #AARRGGBB or #RRGGBB.
391
+ * @default The iOS or Android system gray color
392
+ */
393
+ color?: ThemedColor;
394
+ }
395
+
376
396
  /** Describes the appearance of the flat style row */
377
397
  export interface FlatConfig {
378
398
  /** The thickness of the separator line between rows.
@@ -387,7 +407,7 @@ export interface FlatConfig {
387
407
 
388
408
  /** The insets of the separator line between rows.
389
409
  * @default { top: 0, left: 30, bottom: 0, right: 0 } for RowStyle.FlatWithRadio
390
- * @default { top: 0, left: 0, bottom: 0, right: 0 } for RowStyle.FlatWithCheckmark and RowStyle.FloatingButton
410
+ * @default { top: 0, left: 0, bottom: 0, right: 0 } for RowStyle.FlatWithCheckmark, RowStyle.FlatWithChevron, and RowStyle.FloatingButton
391
411
  */
392
412
  separatorInsets?: EdgeInsetsConfig;
393
413
 
@@ -406,6 +426,9 @@ export interface FlatConfig {
406
426
 
407
427
  /** Appearance settings for the checkmark (used when RowStyle is FlatWithCheckmark) */
408
428
  checkmark?: CheckmarkConfig;
429
+
430
+ /** Appearance settings for the chevron (used when RowStyle is FlatWithChevron) */
431
+ chevron?: ChevronConfig;
409
432
  }
410
433
 
411
434
  /** Describes the appearance of the floating button style payment method row */
@@ -554,6 +577,17 @@ export type PaymentMode = {
554
577
  /* Controls when the funds will be captured.
555
578
  Seealso: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-capture_method */
556
579
  captureMethod?: CaptureMethod;
580
+ /** Additional payment method options params.
581
+ Seealso: https://docs.stripe.com/api/payment_intents/create#create_payment_intent-payment_method_options */
582
+ paymentMethodOptions?: PaymentMethodOptions;
583
+ };
584
+
585
+ export type PaymentMethodOptions = {
586
+ /* This is an experimental feature that may be removed at any time
587
+ A map of payment method types to setup_future_usage value. (e.g. card: 'OffSession') */
588
+ setupFutureUsageValues: {
589
+ [key: string]: FutureUsage;
590
+ };
557
591
  };
558
592
 
559
593
  /* Use this if your integration creates a SetupIntent */
@@ -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 = '~> 24.14.0'
5
+ stripe_version = '~> 24.16.1'
6
6
 
7
7
  fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
8
8