@stripe/stripe-react-native 0.22.0 → 0.23.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 (164) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +1 -2
  3. package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +2 -3
  4. package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +21 -9
  5. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +4 -2
  6. package/android/src/main/res/layout/googlepay_mark_button.xml +0 -2
  7. package/ios/ApplePayViewController.swift +23 -15
  8. package/ios/Mappers.swift +35 -16
  9. package/ios/PaymentMethodFactory.swift +1 -1
  10. package/ios/StripeSdk.m +1 -0
  11. package/ios/StripeSdk.swift +8 -5
  12. package/ios/Tests/ApplePayUtilsTests.swift +0 -1
  13. package/jest/mock.js +6 -0
  14. package/lib/commonjs/NativeStripeSdk.js.map +1 -1
  15. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  16. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  17. package/lib/commonjs/components/ApplePayButton.js +1 -1
  18. package/lib/commonjs/components/ApplePayButton.js.map +1 -1
  19. package/lib/commonjs/components/ApplePayButtonNative.js +2 -0
  20. package/lib/commonjs/components/ApplePayButtonNative.js.map +1 -0
  21. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  22. package/lib/commonjs/components/CardField.js.map +1 -1
  23. package/lib/commonjs/components/CardForm.js.map +1 -1
  24. package/lib/commonjs/components/GooglePayButton.js +1 -1
  25. package/lib/commonjs/components/GooglePayButton.js.map +1 -1
  26. package/lib/commonjs/components/GooglePayButtonNative.js +2 -0
  27. package/lib/commonjs/components/GooglePayButtonNative.js.map +1 -0
  28. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  29. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  30. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  31. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  32. package/lib/commonjs/functions.js +1 -1
  33. package/lib/commonjs/functions.js.map +1 -1
  34. package/lib/commonjs/helpers.js.map +1 -1
  35. package/lib/commonjs/hooks/useApplePay.js +1 -1
  36. package/lib/commonjs/hooks/useApplePay.js.map +1 -1
  37. package/lib/commonjs/hooks/useConfirmPayment.js.map +1 -1
  38. package/lib/commonjs/hooks/useConfirmSetupIntent.js.map +1 -1
  39. package/lib/commonjs/hooks/useFinancialConnectionsSheet.js.map +1 -1
  40. package/lib/commonjs/hooks/useGooglePay.js.map +1 -1
  41. package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
  42. package/lib/commonjs/hooks/usePlatformPay.js +1 -1
  43. package/lib/commonjs/hooks/usePlatformPay.js.map +1 -1
  44. package/lib/commonjs/hooks/useStripe.js +1 -1
  45. package/lib/commonjs/hooks/useStripe.js.map +1 -1
  46. package/lib/commonjs/index.js +1 -1
  47. package/lib/commonjs/index.js.map +1 -1
  48. package/lib/commonjs/plugin/withStripe.js.map +1 -1
  49. package/lib/commonjs/types/ApplePay.js.map +1 -1
  50. package/lib/commonjs/types/Common.js.map +1 -1
  51. package/lib/commonjs/types/Errors.js.map +1 -1
  52. package/lib/commonjs/types/FinancialConnections.js.map +1 -1
  53. package/lib/commonjs/types/GooglePay.js.map +1 -1
  54. package/lib/commonjs/types/NextAction.js.map +1 -1
  55. package/lib/commonjs/types/PaymentIntent.js.map +1 -1
  56. package/lib/commonjs/types/PaymentMethod.js.map +1 -1
  57. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  58. package/lib/commonjs/types/PlatformPay.js.map +1 -1
  59. package/lib/commonjs/types/PushProvisioning.js.map +1 -1
  60. package/lib/commonjs/types/SetupIntent.js.map +1 -1
  61. package/lib/commonjs/types/ThreeDSecure.js.map +1 -1
  62. package/lib/commonjs/types/Token.js.map +1 -1
  63. package/lib/commonjs/types/components/ApplePayButtonComponent.js.map +1 -1
  64. package/lib/commonjs/types/components/AuBECSDebitFormComponent.js.map +1 -1
  65. package/lib/commonjs/types/components/CardFieldInput.js.map +1 -1
  66. package/lib/commonjs/types/components/CardFormView.js.map +1 -1
  67. package/lib/commonjs/types/components/GooglePayButtonComponent.js +2 -0
  68. package/lib/commonjs/types/components/GooglePayButtonComponent.js.map +1 -0
  69. package/lib/commonjs/types/index.js +1 -1
  70. package/lib/commonjs/types/index.js.map +1 -1
  71. package/lib/module/NativeStripeSdk.js.map +1 -1
  72. package/lib/module/components/AddToWalletButton.js.map +1 -1
  73. package/lib/module/components/AddressSheet.js.map +1 -1
  74. package/lib/module/components/ApplePayButton.js +1 -1
  75. package/lib/module/components/ApplePayButton.js.map +1 -1
  76. package/lib/module/components/ApplePayButtonNative.js +2 -0
  77. package/lib/module/components/ApplePayButtonNative.js.map +1 -0
  78. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  79. package/lib/module/components/CardField.js.map +1 -1
  80. package/lib/module/components/CardForm.js.map +1 -1
  81. package/lib/module/components/GooglePayButton.js +1 -1
  82. package/lib/module/components/GooglePayButton.js.map +1 -1
  83. package/lib/module/components/GooglePayButtonNative.js +2 -0
  84. package/lib/module/components/GooglePayButtonNative.js.map +1 -0
  85. package/lib/module/components/PlatformPayButton.js +1 -1
  86. package/lib/module/components/PlatformPayButton.js.map +1 -1
  87. package/lib/module/components/StripeContainer.js.map +1 -1
  88. package/lib/module/components/StripeProvider.js.map +1 -1
  89. package/lib/module/functions.js +1 -1
  90. package/lib/module/functions.js.map +1 -1
  91. package/lib/module/helpers.js.map +1 -1
  92. package/lib/module/hooks/useApplePay.js +1 -1
  93. package/lib/module/hooks/useApplePay.js.map +1 -1
  94. package/lib/module/hooks/useConfirmPayment.js.map +1 -1
  95. package/lib/module/hooks/useConfirmSetupIntent.js.map +1 -1
  96. package/lib/module/hooks/useFinancialConnectionsSheet.js.map +1 -1
  97. package/lib/module/hooks/useGooglePay.js.map +1 -1
  98. package/lib/module/hooks/usePaymentSheet.js.map +1 -1
  99. package/lib/module/hooks/usePlatformPay.js +1 -1
  100. package/lib/module/hooks/usePlatformPay.js.map +1 -1
  101. package/lib/module/hooks/useStripe.js +1 -1
  102. package/lib/module/hooks/useStripe.js.map +1 -1
  103. package/lib/module/index.js +1 -1
  104. package/lib/module/index.js.map +1 -1
  105. package/lib/module/plugin/withStripe.js.map +1 -1
  106. package/lib/module/types/ApplePay.js.map +1 -1
  107. package/lib/module/types/Common.js.map +1 -1
  108. package/lib/module/types/Errors.js.map +1 -1
  109. package/lib/module/types/FinancialConnections.js.map +1 -1
  110. package/lib/module/types/GooglePay.js.map +1 -1
  111. package/lib/module/types/NextAction.js.map +1 -1
  112. package/lib/module/types/PaymentIntent.js.map +1 -1
  113. package/lib/module/types/PaymentMethod.js.map +1 -1
  114. package/lib/module/types/PaymentSheet.js.map +1 -1
  115. package/lib/module/types/PlatformPay.js.map +1 -1
  116. package/lib/module/types/PushProvisioning.js.map +1 -1
  117. package/lib/module/types/SetupIntent.js.map +1 -1
  118. package/lib/module/types/ThreeDSecure.js.map +1 -1
  119. package/lib/module/types/Token.js.map +1 -1
  120. package/lib/module/types/components/ApplePayButtonComponent.js.map +1 -1
  121. package/lib/module/types/components/AuBECSDebitFormComponent.js.map +1 -1
  122. package/lib/module/types/components/CardFieldInput.js.map +1 -1
  123. package/lib/module/types/components/CardFormView.js.map +1 -1
  124. package/lib/module/types/components/GooglePayButtonComponent.js +2 -0
  125. package/lib/module/types/components/GooglePayButtonComponent.js.map +1 -0
  126. package/lib/module/types/index.js +1 -1
  127. package/lib/module/types/index.js.map +1 -1
  128. package/lib/typescript/src/NativeStripeSdk.d.ts +1 -1
  129. package/lib/typescript/src/components/AddToWalletButton.d.ts +1 -1
  130. package/lib/typescript/src/components/ApplePayButton.d.ts +1 -1
  131. package/lib/typescript/src/components/ApplePayButtonNative.d.ts +3 -0
  132. package/lib/typescript/src/components/GooglePayButtonNative.d.ts +3 -0
  133. package/lib/typescript/src/functions.d.ts +8 -2
  134. package/lib/typescript/src/hooks/usePlatformPay.d.ts +6 -0
  135. package/lib/typescript/src/hooks/useStripe.d.ts +1 -0
  136. package/lib/typescript/src/index.d.ts +22 -11
  137. package/lib/typescript/src/types/PaymentSheet.d.ts +1 -1
  138. package/lib/typescript/src/types/PlatformPay.d.ts +6 -1
  139. package/lib/typescript/src/types/PushProvisioning.d.ts +1 -1
  140. package/lib/typescript/src/types/Token.d.ts +1 -0
  141. package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts +12 -1
  142. package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts +6 -0
  143. package/lib/typescript/src/types/index.d.ts +3 -2
  144. package/package.json +4 -4
  145. package/src/NativeStripeSdk.tsx +3 -2
  146. package/src/components/AddToWalletButton.tsx +1 -1
  147. package/src/components/ApplePayButton.tsx +3 -10
  148. package/src/components/ApplePayButtonNative.tsx +5 -0
  149. package/src/components/GooglePayButton.tsx +1 -3
  150. package/src/components/GooglePayButtonNative.tsx +7 -0
  151. package/src/components/PlatformPayButton.tsx +2 -4
  152. package/src/functions.ts +35 -4
  153. package/src/hooks/useApplePay.tsx +1 -2
  154. package/src/hooks/usePlatformPay.tsx +19 -0
  155. package/src/hooks/useStripe.tsx +11 -0
  156. package/src/index.tsx +22 -36
  157. package/src/types/PaymentSheet.ts +1 -1
  158. package/src/types/PlatformPay.ts +9 -1
  159. package/src/types/PushProvisioning.ts +1 -1
  160. package/src/types/Token.ts +1 -0
  161. package/src/types/components/ApplePayButtonComponent.ts +18 -2
  162. package/src/types/components/GooglePayButtonComponent.ts +6 -0
  163. package/src/types/index.ts +3 -1
  164. package/stripe-react-native.podspec +1 -1
@@ -15,6 +15,7 @@ export function usePlatformPay() {
15
15
  confirmPlatformPaySetupIntent,
16
16
  confirmPlatformPayPayment,
17
17
  createPlatformPayPaymentMethod,
18
+ createPlatformPayToken,
18
19
  dismissPlatformPay,
19
20
  updatePlatformPaySheet,
20
21
  canAddCardToWallet,
@@ -70,6 +71,18 @@ export function usePlatformPay() {
70
71
  [createPlatformPayPaymentMethod]
71
72
  );
72
73
 
74
+ const _createPlatformPayToken = useCallback(
75
+ async (params: PlatformPay.PaymentMethodParams) => {
76
+ setLoading(true);
77
+
78
+ const result = await createPlatformPayToken(params);
79
+ setLoading(false);
80
+
81
+ return result;
82
+ },
83
+ [createPlatformPayToken]
84
+ );
85
+
73
86
  const _dismissPlatformPay = useCallback(async () => {
74
87
  setLoading(true);
75
88
 
@@ -143,6 +156,12 @@ export function usePlatformPay() {
143
156
  * @returns An object with an error field if something went wrong or the flow was cancelled, otherwise an object with both `paymentMethod` and `token` fields.
144
157
  */
145
158
  createPlatformPayPaymentMethod: _createPlatformPayPaymentMethod,
159
+ /**
160
+ * @deprecated The Tokens API is deprecated, you should use Payment Methods and `createPlatformPayPaymentMethod` instead. Launches the relevant native wallet sheet (Apple Pay on iOS, Google Pay on Android) in order to create a Stripe [token](https://stripe.com/docs/api/tokens).
161
+ * @param params an object describing the Apple Pay and Google Pay configurations.
162
+ * @returns An object with an error field if something went wrong or the flow was cancelled, otherwise an object with a `token` field.
163
+ */
164
+ createPlatformPayToken: _createPlatformPayToken,
146
165
  /**
147
166
  * Dismiss the Apple Pay sheet if it is open. iOS only, this is a no-op on Android.
148
167
  * @returns A boolean indicating whether or not the sheet was successfully closed. Will return false if the Apple Pay sheet was not open.
@@ -72,6 +72,7 @@ import {
72
72
  confirmPlatformPayPayment,
73
73
  dismissPlatformPay,
74
74
  createPlatformPayPaymentMethod,
75
+ createPlatformPayToken,
75
76
  updatePlatformPaySheet,
76
77
  openPlatformPaySetup,
77
78
  } from '../functions';
@@ -367,6 +368,15 @@ export function useStripe() {
367
368
  []
368
369
  );
369
370
 
371
+ const _createPlatformPayToken = useCallback(
372
+ async (
373
+ params: PlatformPay.PaymentMethodParams
374
+ ): Promise<PlatformPay.TokenResult> => {
375
+ return createPlatformPayToken(params);
376
+ },
377
+ []
378
+ );
379
+
370
380
  const _updatePlatformPaySheet = useCallback(
371
381
  async (params: {
372
382
  applePay: {
@@ -426,6 +436,7 @@ export function useStripe() {
426
436
  confirmPlatformPayPayment: _confirmPlatformPayPayment,
427
437
  dismissPlatformPay: _dismissPlatformPay,
428
438
  createPlatformPayPaymentMethod: _createPlatformPayPaymentMethod,
439
+ createPlatformPayToken: _createPlatformPayToken,
429
440
  updatePlatformPaySheet: _updatePlatformPaySheet,
430
441
  openPlatformPaySetup: _openPlatformPaySetup,
431
442
  };
package/src/index.tsx CHANGED
@@ -3,47 +3,33 @@ export { useConfirmPayment } from './hooks/useConfirmPayment';
3
3
  export { useConfirmSetupIntent } from './hooks/useConfirmSetupIntent';
4
4
  export { useStripe } from './hooks/useStripe';
5
5
  export { usePlatformPay } from './hooks/usePlatformPay';
6
- export { useApplePay, Props as UseApplePayProps } from './hooks/useApplePay';
6
+ export { useApplePay } from './hooks/useApplePay';
7
+ export type { Props as UseApplePayProps } from './hooks/useApplePay';
7
8
  export { usePaymentSheet } from './hooks/usePaymentSheet';
8
9
  export { useGooglePay } from './hooks/useGooglePay';
9
10
  export { useFinancialConnectionsSheet } from './hooks/useFinancialConnectionsSheet';
10
11
 
11
12
  //components
12
- export {
13
- initStripe,
14
- StripeProvider,
15
- Props as StripeProviderProps,
16
- } from './components/StripeProvider';
17
- export { CardField, Props as CardFieldProps } from './components/CardField';
18
- export { CardForm, Props as CardFormProps } from './components/CardForm';
19
- export {
20
- ApplePayButton,
21
- Props as ApplePayButtonProps,
22
- } from './components/ApplePayButton';
23
- export {
24
- AuBECSDebitForm,
25
- Props as AuBECSDebitFormProps,
26
- } from './components/AuBECSDebitForm';
27
- export {
28
- StripeContainer,
29
- Props as StripeContainerProps,
30
- } from './components/StripeContainer';
31
- export {
32
- GooglePayButton,
33
- Props as GooglePayButtonProps,
34
- } from './components/GooglePayButton';
35
- export {
36
- AddToWalletButton,
37
- Props as AddToWalletButtonProps,
38
- } from './components/AddToWalletButton';
39
- export {
40
- AddressSheet,
41
- Props as AddressSheetProps,
42
- } from './components/AddressSheet';
43
- export {
44
- PlatformPayButton,
45
- Props as PlatformPayButtonProps,
46
- } from './components/PlatformPayButton';
13
+ export { initStripe, StripeProvider } from './components/StripeProvider';
14
+ export type { Props as StripeProviderProps } from './components/StripeProvider';
15
+ export { CardField } from './components/CardField';
16
+ export type { Props as CardFieldProps } from './components/CardField';
17
+ export { CardForm } from './components/CardForm';
18
+ export type { Props as CardFormProps } from './components/CardForm';
19
+ export { ApplePayButton } from './components/ApplePayButton';
20
+ export type { Props as ApplePayButtonProps } from './components/ApplePayButton';
21
+ export { AuBECSDebitForm } from './components/AuBECSDebitForm';
22
+ export type { Props as AuBECSDebitFormProps } from './components/AuBECSDebitForm';
23
+ export { StripeContainer } from './components/StripeContainer';
24
+ export type { Props as StripeContainerProps } from './components/StripeContainer';
25
+ export { GooglePayButton } from './components/GooglePayButton';
26
+ export type { Props as GooglePayButtonProps } from './components/GooglePayButton';
27
+ export { AddToWalletButton } from './components/AddToWalletButton';
28
+ export type { Props as AddToWalletButtonProps } from './components/AddToWalletButton';
29
+ export { AddressSheet } from './components/AddressSheet';
30
+ export type { Props as AddressSheetProps } from './components/AddressSheet';
31
+ export { PlatformPayButton } from './components/PlatformPayButton';
32
+ export type { Props as PlatformPayButtonProps } from './components/PlatformPayButton';
47
33
 
48
34
  export * from './functions';
49
35
 
@@ -19,7 +19,7 @@ export type SetupParams = ClientSecretParams & {
19
19
  style?: 'alwaysLight' | 'alwaysDark' | 'automatic';
20
20
  /** A URL that redirects back to your app that PaymentSheet can use to auto-dismiss web views used for additional authentication, e.g. 3DS2 */
21
21
  returnURL?: string;
22
- /** PaymentSheet pre-populates the billing fields with the values provided. */
22
+ /** PaymentSheet pre-populates the billing fields that are displayed in the Payment Sheet (only country and postal code, as of this version) with the values provided. */
23
23
  defaultBillingDetails?: BillingDetails;
24
24
  /**
25
25
  * The shipping information for the customer. If set, PaymentSheet will pre-populate the form fields with the values provided.
@@ -296,11 +296,19 @@ export type IsGooglePaySupportedParams = IsSupportedParams;
296
296
  export type PaymentMethodResult =
297
297
  | {
298
298
  paymentMethod: PaymentMethod;
299
- token: Token;
300
299
  error?: undefined;
301
300
  }
302
301
  | {
303
302
  paymentMethod?: undefined;
303
+ error: StripeError<PlatformPayError>;
304
+ };
305
+
306
+ export type TokenResult =
307
+ | {
308
+ token: Token;
309
+ error?: undefined;
310
+ }
311
+ | {
304
312
  token?: undefined;
305
313
  error: StripeError<PlatformPayError>;
306
314
  };
@@ -41,7 +41,7 @@ export type CanAddCardToWalletParams = {
41
41
  primaryAccountIdentifier: string | null;
42
42
  /** Last 4 digits of the card number. */
43
43
  cardLastFour: string;
44
- /** iOS only. Set this to `true` until shipping through TestFlight || App Store. If true, you must be using live cards, and have the proper iOS entitlement set up. See https://stripe.com/docs/issuing/cards/digital-wallets?platform=react-native#requesting-access-for-ios */
44
+ /** iOS only. Set this to `true` until shipping through TestFlight || App Store. If false, you must be using live cards, and have the proper iOS entitlement set up. See https://stripe.com/docs/issuing/cards/digital-wallets?platform=react-native#requesting-access-for-ios */
45
45
  testEnv?: boolean;
46
46
  /** iOS only. Set this to `true` if: your user has an Apple Watch device currently paired, and you want to check that device for the presence of the specified card. */
47
47
  hasPairedAppleWatch?: boolean;
@@ -56,6 +56,7 @@ export type BankAccountStatus =
56
56
  | 'Verified';
57
57
 
58
58
  export interface Card {
59
+ id: string;
59
60
  country: string;
60
61
  brand: CardBrand;
61
62
  currency?: string;
@@ -1,11 +1,27 @@
1
- import type { StyleProp, ViewStyle } from 'react-native';
2
-
1
+ import type { StyleProp, ViewStyle, NativeSyntheticEvent } from 'react-native';
2
+ import type { ShippingMethod, ShippingContact } from '../PlatformPay';
3
3
  export interface NativeProps {
4
4
  style?: StyleProp<ViewStyle>;
5
+ disabled?: boolean;
5
6
  type?: number;
6
7
  buttonStyle?: number;
7
8
  borderRadius?: number;
8
9
  onPressAction?(): void;
10
+ onShippingMethodSelectedAction?: (
11
+ value: NativeSyntheticEvent<{
12
+ shippingMethod: ShippingMethod;
13
+ }>
14
+ ) => void;
15
+ onShippingContactSelectedAction?: (
16
+ value: NativeSyntheticEvent<{
17
+ shippingContact: ShippingContact;
18
+ }>
19
+ ) => void;
20
+ onCouponCodeEnteredAction?: (
21
+ value: NativeSyntheticEvent<{
22
+ couponCode: string;
23
+ }>
24
+ ) => void;
9
25
  }
10
26
 
11
27
  export type Type =
@@ -0,0 +1,6 @@
1
+ import type { StyleProp, ViewStyle } from 'react-native';
2
+ export interface NativeProps {
3
+ style?: StyleProp<ViewStyle>;
4
+ type?: number;
5
+ buttonType?: string;
6
+ }
@@ -21,6 +21,7 @@ import * as SetupIntent from './SetupIntent';
21
21
  import * as ThreeDSecure from './ThreeDSecure';
22
22
  import * as GooglePay from './GooglePay';
23
23
  import * as ApplePayButtonComponent from './components/ApplePayButtonComponent';
24
+ import * as GooglePayButtonComponent from './components/GooglePayButtonComponent';
24
25
  import * as AuBECSDebitFormComponent from './components/AuBECSDebitFormComponent';
25
26
  import * as CardFieldInput from './components/CardFieldInput';
26
27
  import * as CardFormView from './components/CardFormView';
@@ -37,6 +38,7 @@ export {
37
38
  ThreeDSecure,
38
39
  GooglePay,
39
40
  ApplePayButtonComponent,
41
+ GooglePayButtonComponent,
40
42
  AuBECSDebitFormComponent,
41
43
  CardFieldInput,
42
44
  CardFormView,
@@ -47,7 +49,7 @@ export {
47
49
 
48
50
  export * from './PushProvisioning';
49
51
  export * from './Errors';
50
- export { Address, BillingDetails, AddressDetails } from './Common';
52
+ export type { Address, BillingDetails, AddressDetails } from './Common';
51
53
 
52
54
  /**
53
55
  * @ignore
@@ -1,7 +1,7 @@
1
1
  require 'json'
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
- stripe_version = '~> 23.2.0'
4
+ stripe_version = '~> 23.3.0'
5
5
 
6
6
  Pod::Spec.new do |s|
7
7
  s.name = 'stripe-react-native'