@stripe/stripe-react-native 0.57.0 → 0.57.2
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.
- package/README.md +0 -8
- package/android/.idea/AndroidProjectSystem.xml +6 -0
- package/android/.idea/caches/deviceStreaming.xml +1029 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +19 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/runConfigurations.xml +17 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +76 -118
- package/android/gradle.properties +1 -1
- package/android/local.properties +8 -0
- package/android/settings.gradle +2 -0
- package/android/spotless.gradle +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +20 -17
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +13 -11
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +17 -21
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherManager.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +53 -11
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +105 -117
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -8
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetManager.kt +13 -15
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +7 -5
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarManager.kt +31 -0
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +120 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +228 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherManager.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +73 -30
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +19 -245
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +52 -14
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +15 -35
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +5 -10
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +90 -77
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +6 -4
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +13 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +41 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +92 -44
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +3 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +2 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +118 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +922 -0
- package/android/src/test/java/com/facebook/testutils/shadows/ShadowArguments.kt +29 -0
- package/android/src/test/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManagerTest.kt +163 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +976 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetAppearanceTest.kt +801 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +523 -0
- package/android/src/test/java/com/reactnativestripesdk/addresssheet/AddressSheetViewTest.kt +551 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +567 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +456 -0
- package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +43 -0
- package/android/src/test/resources/robolectric.properties +2 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +3 -3
- package/ios/AddressSheet/AddressSheetView.swift +25 -25
- package/ios/AddressSheet/AddressSheetViewManager.swift +2 -2
- package/ios/ApplePayButtonManager.swift +1 -1
- package/ios/ApplePayButtonView.swift +9 -10
- package/ios/ApplePayUtils.swift +51 -51
- package/ios/ApplePayViewController.swift +25 -29
- package/ios/AuBECSDebitFormManager.swift +1 -1
- package/ios/AuBECSDebitFormView.swift +13 -15
- package/ios/CardFieldManager.swift +4 -4
- package/ios/CardFieldView.swift +9 -9
- package/ios/CardFormManager.swift +3 -3
- package/ios/CardFormView.swift +28 -28
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +97 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +133 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.m +16 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.swift +17 -0
- package/ios/CustomerSheet/CustomerSheetUtils.swift +15 -16
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +19 -19
- package/ios/EmbeddedPaymentElementView.swift +2 -2
- package/ios/Errors.swift +22 -23
- package/ios/FinancialConnections.swift +37 -37
- package/ios/Mappers.swift +210 -71
- package/ios/NavigationBarManager.m +13 -0
- package/ios/NavigationBarManager.swift +17 -0
- package/ios/NavigationBarView.swift +65 -0
- package/ios/NewArch/NavigationBarComponentView.h +10 -0
- package/ios/NewArch/NavigationBarComponentView.mm +86 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +7 -1
- package/ios/PaymentMethodFactory.swift +24 -24
- package/ios/PaymentOptionDisplayData+ReactNative.swift +4 -4
- package/ios/PaymentPassFinder.swift +9 -10
- package/ios/PaymentSheetAppearance.swift +137 -138
- package/ios/PushProvisioning/AddToWalletButtonManager.swift +2 -2
- package/ios/PushProvisioning/AddToWalletButtonView.swift +15 -17
- package/ios/PushProvisioning/PushProvisioningUtils.swift +11 -11
- package/ios/StripeContainerManager.swift +1 -1
- package/ios/StripeContainerView.swift +3 -3
- package/ios/StripeOnrampSdk.h +17 -0
- package/ios/StripeOnrampSdk.mm +158 -0
- package/ios/StripeSdk.mm +8 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcuserdata/tianzhao.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/StripeSdk.xcodeproj/xcuserdata/tianzhao.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/ios/StripeSdkEmitter.swift +4 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +30 -25
- package/ios/StripeSdkImpl+Embedded.swift +11 -9
- package/ios/StripeSdkImpl+PaymentSheet.swift +36 -34
- package/ios/StripeSdkImpl.swift +913 -185
- package/ios/UIColorExtension.swift +72 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/connect/Components.js +2 -0
- package/lib/commonjs/connect/Components.js.map +1 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js +2 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/commonjs/connect/EmbeddedComponent.js +19 -0
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -0
- package/lib/commonjs/connect/ModalCloseButton.js +2 -0
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -0
- package/lib/commonjs/connect/NavigationBar.js +2 -0
- package/lib/commonjs/connect/NavigationBar.js.map +1 -0
- package/lib/commonjs/connect/connectTypes.js +2 -0
- package/lib/commonjs/connect/connectTypes.js.map +1 -0
- package/lib/commonjs/events.js +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +2 -0
- package/lib/commonjs/hooks/useOnramp.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +2 -0
- package/lib/commonjs/specs/NativeNavigationBar.js.map +1 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/Onramp.js +2 -0
- package/lib/commonjs/types/Onramp.js.map +1 -0
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/connect/Components.js +2 -0
- package/lib/module/connect/Components.js.map +1 -0
- package/lib/module/connect/ConnectComponentsProvider.js +2 -0
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/module/connect/EmbeddedComponent.js +19 -0
- package/lib/module/connect/EmbeddedComponent.js.map +1 -0
- package/lib/module/connect/ModalCloseButton.js +2 -0
- package/lib/module/connect/ModalCloseButton.js.map +1 -0
- package/lib/module/connect/NavigationBar.js +2 -0
- package/lib/module/connect/NavigationBar.js.map +1 -0
- package/lib/module/connect/connectTypes.js +2 -0
- package/lib/module/connect/connectTypes.js.map +1 -0
- package/lib/module/events.js +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +2 -0
- package/lib/module/hooks/useOnramp.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js.map +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js.map +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/module/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/module/specs/NativeNavigationBar.js +2 -0
- package/lib/module/specs/NativeNavigationBar.js.map +1 -0
- package/lib/module/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/Onramp.js +2 -0
- package/lib/module/types/Onramp.js.map +1 -0
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
- package/lib/typescript/src/connect/Components.d.ts +23 -0
- package/lib/typescript/src/connect/Components.d.ts.map +1 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +22 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts +18 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts +7 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts.map +1 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts +8 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/connect/connectTypes.d.ts +464 -0
- package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +4 -0
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/helpers.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +158 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugin/withStripe.d.ts +15 -0
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts +14 -0
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts +11 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +28 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +5 -0
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +275 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +7 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +25 -14
- package/src/components/StripeProvider.tsx +5 -0
- package/src/connect/Components.tsx +279 -0
- package/src/connect/ConnectComponentsProvider.tsx +93 -0
- package/src/connect/EmbeddedComponent.tsx +407 -0
- package/src/connect/ModalCloseButton.tsx +44 -0
- package/src/connect/NavigationBar.tsx +29 -0
- package/src/connect/connectTypes.ts +626 -0
- package/src/events.ts +23 -0
- package/src/hooks/useOnramp.tsx +334 -0
- package/src/index.tsx +13 -0
- package/src/plugin/withStripe.ts +104 -7
- package/src/specs/NativeConnectAccountOnboardingView.ts +19 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +5 -1
- package/src/specs/NativeNavigationBar.ts +16 -0
- package/src/specs/NativeOnrampSdkModule.ts +47 -0
- package/src/specs/NativeStripeSdkModule.ts +5 -0
- package/src/types/EmbeddedPaymentElement.tsx +24 -3
- package/src/types/Errors.ts +6 -0
- package/src/types/Onramp.ts +317 -0
- package/src/types/PaymentSheet.ts +7 -0
- package/src/types/index.ts +8 -0
- package/stripe-react-native.podspec +20 -7
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useMemo,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import {
|
|
9
|
+
AppState,
|
|
10
|
+
AppStateStatus,
|
|
11
|
+
Platform,
|
|
12
|
+
StyleProp,
|
|
13
|
+
ViewStyle,
|
|
14
|
+
} from 'react-native';
|
|
15
|
+
import type { WebView, WebViewMessageEvent } from 'react-native-webview';
|
|
16
|
+
import pjson from '../../package.json';
|
|
17
|
+
import NativeStripeSdk from '../specs/NativeStripeSdkModule';
|
|
18
|
+
import {
|
|
19
|
+
ConnectComponentsPayload,
|
|
20
|
+
useConnectComponents,
|
|
21
|
+
} from './ConnectComponentsProvider';
|
|
22
|
+
import type { LoadError, LoaderStart } from './connectTypes';
|
|
23
|
+
|
|
24
|
+
const DEVELOPMENT_MODE = false;
|
|
25
|
+
const DEVELOPMENT_URL =
|
|
26
|
+
Platform.OS === 'android' ? 'http://10.0.2.2:3001' : 'http://localhost:3001';
|
|
27
|
+
const PRODUCTION_URL = 'https://connect-js.stripe.com';
|
|
28
|
+
const BASE_URL = DEVELOPMENT_MODE ? DEVELOPMENT_URL : PRODUCTION_URL;
|
|
29
|
+
|
|
30
|
+
const sdkVersion = pjson.version;
|
|
31
|
+
|
|
32
|
+
// react-native-webview.html will only load versions in the format X.Y.Z
|
|
33
|
+
if (!/^\d+\.\d+\.\d+$/.test(sdkVersion)) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
`Invalid SDK version: ${sdkVersion}. Must be in format X.Y.Z`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const userAgent = [
|
|
40
|
+
'Mobile',
|
|
41
|
+
`Stripe ReactNative SDK ${Platform.OS}/${Platform.Version}`,
|
|
42
|
+
`stripe-react_native/${sdkVersion}`,
|
|
43
|
+
].join(' - ');
|
|
44
|
+
|
|
45
|
+
export interface CommonComponentProps {
|
|
46
|
+
onLoaderStart?: ({ elementTagName }: LoaderStart) => void;
|
|
47
|
+
onLoadError?: ({ error, elementTagName }: LoadError) => void;
|
|
48
|
+
|
|
49
|
+
onPageDidLoad?: () => void;
|
|
50
|
+
|
|
51
|
+
style?: StyleProp<ViewStyle>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type EmbeddedComponentType =
|
|
55
|
+
| 'invoice-history'
|
|
56
|
+
| 'transactions-list'
|
|
57
|
+
| 'payments'
|
|
58
|
+
| 'payment-details'
|
|
59
|
+
| 'payment-disputes'
|
|
60
|
+
| 'payouts'
|
|
61
|
+
| 'payouts-list'
|
|
62
|
+
| 'balances'
|
|
63
|
+
| 'account-management'
|
|
64
|
+
| 'account-management-form'
|
|
65
|
+
| 'account-onboarding'
|
|
66
|
+
| 'disputes-list'
|
|
67
|
+
| 'instant-payouts'
|
|
68
|
+
| 'instant-payouts-promotion'
|
|
69
|
+
| 'notification-banner'
|
|
70
|
+
| 'debug-utils'
|
|
71
|
+
| 'debug-ui-config'
|
|
72
|
+
| 'debug-ui-library'
|
|
73
|
+
| 'debug-ui-preview'
|
|
74
|
+
| 'debug-components-list'
|
|
75
|
+
| 'debug-hosted-dashboard-preview'
|
|
76
|
+
| 'app-onboarding'
|
|
77
|
+
| 'app-install'
|
|
78
|
+
| 'app-viewport'
|
|
79
|
+
| 'payment-method-settings'
|
|
80
|
+
| 'capital-financing'
|
|
81
|
+
| 'capital-financing-application'
|
|
82
|
+
| 'capital-financing-promotion'
|
|
83
|
+
| 'capital-overview'
|
|
84
|
+
| 'terminal-hardware-orders'
|
|
85
|
+
| 'terminal-hardware-shop'
|
|
86
|
+
| 'app-settings'
|
|
87
|
+
| 'instant-payouts-promotion'
|
|
88
|
+
| 'issuing-cards-list'
|
|
89
|
+
| 'issuing-card'
|
|
90
|
+
| 'financial-account'
|
|
91
|
+
| 'financial-account-transactions'
|
|
92
|
+
| 'recipients'
|
|
93
|
+
| 'product-tax-code-selector'
|
|
94
|
+
| 'check-scanning'
|
|
95
|
+
| 'tax-threshold-monitoring'
|
|
96
|
+
| 'export-tax-transactions'
|
|
97
|
+
| 'tax-settings'
|
|
98
|
+
| 'tax-registrations'
|
|
99
|
+
| 'documents'
|
|
100
|
+
| 'earnings-chart'
|
|
101
|
+
| 'reporting-chart'
|
|
102
|
+
| 'payout-details'
|
|
103
|
+
| 'balance-report'
|
|
104
|
+
| 'payout-reconciliation-report';
|
|
105
|
+
|
|
106
|
+
type EmbeddedComponentProps = CommonComponentProps & {
|
|
107
|
+
component: EmbeddedComponentType;
|
|
108
|
+
componentProps?: Record<string, unknown>;
|
|
109
|
+
|
|
110
|
+
callbacks?: Record<string, ((data: any) => void) | undefined>;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
type ConnectComponentsPayloadInternal = ConnectComponentsPayload & {
|
|
114
|
+
overrides?: Record<string, string>;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export function EmbeddedComponent(props: EmbeddedComponentProps) {
|
|
118
|
+
const [dynamicWebview, setDynamicWebview] = useState<{
|
|
119
|
+
WebView: typeof WebView | null;
|
|
120
|
+
} | null>(null);
|
|
121
|
+
|
|
122
|
+
// Store pending authenticated webview promise (for Android Custom Tabs)
|
|
123
|
+
const pendingAuthWebViewPromise = useRef<{
|
|
124
|
+
id: string;
|
|
125
|
+
callback: (id: string, url: string | null) => void;
|
|
126
|
+
} | null>(null);
|
|
127
|
+
|
|
128
|
+
const loadWebViewComponent = useCallback(async () => {
|
|
129
|
+
if (dynamicWebview) return;
|
|
130
|
+
|
|
131
|
+
setDynamicWebview({ WebView: null });
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
const mod = await import('react-native-webview');
|
|
135
|
+
setDynamicWebview({ WebView: mod.WebView });
|
|
136
|
+
} catch (err) {
|
|
137
|
+
console.error('Failed to import react-native-webview:', err);
|
|
138
|
+
}
|
|
139
|
+
}, [dynamicWebview]);
|
|
140
|
+
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
loadWebViewComponent();
|
|
143
|
+
}, [loadWebViewComponent]);
|
|
144
|
+
|
|
145
|
+
const appState = useRef<AppStateStatus>(AppState.currentState);
|
|
146
|
+
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
const subscription = AppState.addEventListener('change', (nextAppState) => {
|
|
149
|
+
if (
|
|
150
|
+
appState.current.match(/inactive|background/) &&
|
|
151
|
+
nextAppState === 'active'
|
|
152
|
+
) {
|
|
153
|
+
if (pendingAuthWebViewPromise.current) {
|
|
154
|
+
const { id, callback } = pendingAuthWebViewPromise.current;
|
|
155
|
+
pendingAuthWebViewPromise.current = null;
|
|
156
|
+
callback(id, null);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
appState.current = nextAppState;
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
return () => {
|
|
164
|
+
pendingAuthWebViewPromise.current = null;
|
|
165
|
+
subscription.remove();
|
|
166
|
+
};
|
|
167
|
+
}, []);
|
|
168
|
+
|
|
169
|
+
const { connectInstance, appearance, locale, overrides } =
|
|
170
|
+
useConnectComponents() as ConnectComponentsPayloadInternal;
|
|
171
|
+
const { fonts, publishableKey, fetchClientSecret } =
|
|
172
|
+
connectInstance.initParams;
|
|
173
|
+
|
|
174
|
+
const {
|
|
175
|
+
component,
|
|
176
|
+
componentProps,
|
|
177
|
+
onLoadError,
|
|
178
|
+
onLoaderStart,
|
|
179
|
+
onPageDidLoad,
|
|
180
|
+
callbacks,
|
|
181
|
+
style,
|
|
182
|
+
} = props;
|
|
183
|
+
|
|
184
|
+
const hashParams = {
|
|
185
|
+
component,
|
|
186
|
+
publicKey: publishableKey,
|
|
187
|
+
merchantIdOverride: overrides?.merchantId,
|
|
188
|
+
platformIdOverride: overrides?.platformId,
|
|
189
|
+
apiKeyOverride: overrides?.apiKey,
|
|
190
|
+
livemodeOverride: overrides?.livemode,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const hash = Object.entries(hashParams)
|
|
194
|
+
.filter(([_, value]) => value != null)
|
|
195
|
+
.map(
|
|
196
|
+
([key, value]) =>
|
|
197
|
+
`${encodeURIComponent(key)}=${encodeURIComponent(value!)}`
|
|
198
|
+
)
|
|
199
|
+
.join('&');
|
|
200
|
+
|
|
201
|
+
const connectURL = `${BASE_URL}/v1.0/react_native_webview.html#${hash}`;
|
|
202
|
+
const source = useMemo(() => ({ uri: connectURL }), [connectURL]);
|
|
203
|
+
|
|
204
|
+
const ref = useRef<WebView>(null);
|
|
205
|
+
|
|
206
|
+
const [prevAppearance, setPrevAppearance] = useState(appearance);
|
|
207
|
+
const [prevLocale, setPrevLocale] = useState(locale);
|
|
208
|
+
|
|
209
|
+
if (prevAppearance !== appearance || prevLocale !== locale) {
|
|
210
|
+
setPrevAppearance(appearance);
|
|
211
|
+
setPrevLocale(locale);
|
|
212
|
+
|
|
213
|
+
const patchedAppearance = withDefaultFontFamily(appearance);
|
|
214
|
+
|
|
215
|
+
ref.current?.injectJavaScript(`
|
|
216
|
+
(function() {
|
|
217
|
+
window.updateConnectInstance(${JSON.stringify({ appearance: patchedAppearance, locale })});
|
|
218
|
+
true;
|
|
219
|
+
})();
|
|
220
|
+
`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const [prevComponentProps, setPrevComponentProps] = useState(componentProps);
|
|
224
|
+
if (prevComponentProps !== componentProps) {
|
|
225
|
+
setPrevComponentProps(componentProps);
|
|
226
|
+
|
|
227
|
+
Object.entries(componentProps || {}).forEach(([key, value]) => {
|
|
228
|
+
ref.current?.injectJavaScript(`
|
|
229
|
+
(function() {
|
|
230
|
+
window.callSetterWithSerializableValue(${JSON.stringify({
|
|
231
|
+
setter: key,
|
|
232
|
+
value,
|
|
233
|
+
})});
|
|
234
|
+
true;
|
|
235
|
+
})();
|
|
236
|
+
`);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const handleUnexpectedError = useCallback((error: unknown) => {
|
|
241
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
242
|
+
console.error(`Unexpected error: ${errorMessage}`);
|
|
243
|
+
}, []);
|
|
244
|
+
|
|
245
|
+
const WebViewComponent = dynamicWebview?.WebView;
|
|
246
|
+
|
|
247
|
+
const handleAuthWebViewResult = (id: string, resultUrl: string | null) => {
|
|
248
|
+
ref.current?.injectJavaScript(`
|
|
249
|
+
(function() {
|
|
250
|
+
window.returnedFromAuthenticatedWebView(${JSON.stringify({
|
|
251
|
+
id,
|
|
252
|
+
url: resultUrl,
|
|
253
|
+
})});
|
|
254
|
+
true;
|
|
255
|
+
})();
|
|
256
|
+
`);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const onMessageCallback = useCallback(
|
|
260
|
+
async (event: WebViewMessageEvent) => {
|
|
261
|
+
const message = JSON.parse(event.nativeEvent.data) as {
|
|
262
|
+
type: string;
|
|
263
|
+
data?: unknown;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
if (message.type === 'fetchClientSecret') {
|
|
267
|
+
const clientSecret = await fetchClientSecret().catch((error) => {
|
|
268
|
+
handleUnexpectedError(error);
|
|
269
|
+
return null;
|
|
270
|
+
});
|
|
271
|
+
if (!clientSecret) return;
|
|
272
|
+
|
|
273
|
+
ref.current?.injectJavaScript(`
|
|
274
|
+
window.clientSecretDeferred.resolve(${JSON.stringify(
|
|
275
|
+
clientSecret
|
|
276
|
+
)});
|
|
277
|
+
`);
|
|
278
|
+
} else if (message.type === 'debug') {
|
|
279
|
+
// message.data is of type string
|
|
280
|
+
console.debug(`[EmbeddedComponent ${component}]: ${message.data}`);
|
|
281
|
+
} else if (message.type === 'pageDidLoad') {
|
|
282
|
+
onPageDidLoad?.();
|
|
283
|
+
} else if (message.type === 'accountSessionClaimed') {
|
|
284
|
+
// message.data is of type {elementTagName: string, merchantId: string}
|
|
285
|
+
} else if (message.type === 'openFinancialConnections') {
|
|
286
|
+
// message.data is of type {clientSecret: string; id: string; connectedAccountId: string;}
|
|
287
|
+
} else if (message.type === 'closeWebView') {
|
|
288
|
+
// message.data is empty
|
|
289
|
+
callbacks?.onCloseWebView?.({});
|
|
290
|
+
} else if (message.type === 'callSupplementalFunction') {
|
|
291
|
+
// message.data is of type {[key]: {functionName: string; args: unknown[]; invocationId: string;}}
|
|
292
|
+
} else if (message.type === 'onSetterFunctionCalled') {
|
|
293
|
+
const { setter, value } = message.data as {
|
|
294
|
+
setter: string;
|
|
295
|
+
value: unknown;
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
if (setter === 'setOnLoaderStart') {
|
|
299
|
+
onLoaderStart?.(value as LoaderStart);
|
|
300
|
+
} else if (setter === 'setOnLoadError') {
|
|
301
|
+
onLoadError?.(value as LoadError);
|
|
302
|
+
} else {
|
|
303
|
+
// remove the 'set' prefix and lowercase the first letter
|
|
304
|
+
const functionName =
|
|
305
|
+
setter.charAt(3).toLowerCase() + setter.substring(4);
|
|
306
|
+
callbacks?.[functionName]?.(value);
|
|
307
|
+
}
|
|
308
|
+
} else if (message.type === 'openAuthenticatedWebView') {
|
|
309
|
+
const { url, id } = message.data as { id: string; url: string };
|
|
310
|
+
|
|
311
|
+
// Validate URL before opening
|
|
312
|
+
if (!isValidUrl(url)) {
|
|
313
|
+
handleUnexpectedError(
|
|
314
|
+
new Error(`Invalid URL for authenticated webview: ${url}`)
|
|
315
|
+
);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// On Android, we need to wait for the deep link callback
|
|
320
|
+
// On iOS, the promise resolves with the redirect URL
|
|
321
|
+
NativeStripeSdk.openAuthenticatedWebView(id, url)
|
|
322
|
+
.then((result) => {
|
|
323
|
+
if (Platform.OS === 'ios') {
|
|
324
|
+
// iOS returns the redirect URL directly
|
|
325
|
+
handleAuthWebViewResult(id, result?.url ?? null);
|
|
326
|
+
} else {
|
|
327
|
+
// Android: Store promise to be resolved by deep link listener
|
|
328
|
+
pendingAuthWebViewPromise.current = {
|
|
329
|
+
id,
|
|
330
|
+
callback: handleAuthWebViewResult,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
})
|
|
334
|
+
.catch(handleUnexpectedError);
|
|
335
|
+
} else {
|
|
336
|
+
// unhandled message
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
[
|
|
340
|
+
callbacks,
|
|
341
|
+
component,
|
|
342
|
+
fetchClientSecret,
|
|
343
|
+
handleUnexpectedError,
|
|
344
|
+
onLoadError,
|
|
345
|
+
onLoaderStart,
|
|
346
|
+
onPageDidLoad,
|
|
347
|
+
]
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
const backgroundColor = appearance?.variables?.colorBackground || '#FFFFFF';
|
|
351
|
+
|
|
352
|
+
const mergedStyle = useMemo(
|
|
353
|
+
() => [{ backgroundColor }, style],
|
|
354
|
+
[backgroundColor, style]
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
if (!WebViewComponent) return null;
|
|
358
|
+
|
|
359
|
+
return (
|
|
360
|
+
<WebViewComponent
|
|
361
|
+
ref={ref}
|
|
362
|
+
style={mergedStyle}
|
|
363
|
+
webviewDebuggingEnabled={DEVELOPMENT_MODE}
|
|
364
|
+
source={source}
|
|
365
|
+
userAgent={userAgent}
|
|
366
|
+
injectedJavaScriptObject={{
|
|
367
|
+
initParams: {
|
|
368
|
+
appearance: withDefaultFontFamily(appearance),
|
|
369
|
+
locale,
|
|
370
|
+
fonts,
|
|
371
|
+
},
|
|
372
|
+
initComponentProps: componentProps,
|
|
373
|
+
appInfo: { applicationId: overrides?.applicationId },
|
|
374
|
+
}}
|
|
375
|
+
// Fixes injectedJavaScriptObject in Android https://github.com/react-native-webview/react-native-webview/issues/3326#issuecomment-3048111789
|
|
376
|
+
injectedJavaScriptBeforeContentLoaded={'(function() {})();'}
|
|
377
|
+
onMessage={onMessageCallback}
|
|
378
|
+
/>
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const DEFAULT_FONT =
|
|
383
|
+
"-apple-system, 'system-ui', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'";
|
|
384
|
+
|
|
385
|
+
// Returns appearance with fontFamily set if not defined
|
|
386
|
+
function withDefaultFontFamily(appearance: any) {
|
|
387
|
+
if (appearance?.variables?.fontFamily) {
|
|
388
|
+
return appearance;
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
...appearance,
|
|
392
|
+
variables: {
|
|
393
|
+
...appearance?.variables,
|
|
394
|
+
fontFamily: DEFAULT_FONT,
|
|
395
|
+
},
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Validates that a URL is well-formed and uses http or https protocol
|
|
400
|
+
function isValidUrl(url: string): boolean {
|
|
401
|
+
try {
|
|
402
|
+
const parsedUrl = new URL(url);
|
|
403
|
+
return parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:';
|
|
404
|
+
} catch {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacity, Text, StyleSheet } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const size = 36;
|
|
5
|
+
const hitSlop = { top: 10, bottom: 10, left: 10, right: 10 };
|
|
6
|
+
|
|
7
|
+
interface ModalCloseButtonProps {
|
|
8
|
+
onPress: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function ModalCloseButton({ onPress }: ModalCloseButtonProps) {
|
|
12
|
+
return (
|
|
13
|
+
<TouchableOpacity
|
|
14
|
+
onPress={onPress}
|
|
15
|
+
accessibilityRole="button"
|
|
16
|
+
hitSlop={hitSlop}
|
|
17
|
+
style={[
|
|
18
|
+
styles.button,
|
|
19
|
+
{
|
|
20
|
+
width: size,
|
|
21
|
+
height: size,
|
|
22
|
+
borderRadius: size / 2,
|
|
23
|
+
},
|
|
24
|
+
]}
|
|
25
|
+
activeOpacity={0.7}
|
|
26
|
+
>
|
|
27
|
+
<Text style={[styles.cross, { fontSize: Math.round(size * 0.6) }]}>
|
|
28
|
+
×
|
|
29
|
+
</Text>
|
|
30
|
+
</TouchableOpacity>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const styles = StyleSheet.create({
|
|
35
|
+
button: {
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
justifyContent: 'center',
|
|
38
|
+
},
|
|
39
|
+
cross: {
|
|
40
|
+
lineHeight: undefined,
|
|
41
|
+
includeFontPadding: false,
|
|
42
|
+
textAlign: 'center',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import NativeNavigationBar from '../specs/NativeNavigationBar';
|
|
4
|
+
|
|
5
|
+
export interface NavigationBarProps extends ViewProps {
|
|
6
|
+
title?: string;
|
|
7
|
+
onCloseButtonPress?: () => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const NavigationBar = forwardRef<any, NavigationBarProps>(
|
|
11
|
+
({ title, onCloseButtonPress, ...rest }, ref) => {
|
|
12
|
+
return (
|
|
13
|
+
<NativeNavigationBar
|
|
14
|
+
ref={ref}
|
|
15
|
+
title={title}
|
|
16
|
+
onCloseButtonPress={
|
|
17
|
+
onCloseButtonPress
|
|
18
|
+
? (_event) => {
|
|
19
|
+
onCloseButtonPress();
|
|
20
|
+
}
|
|
21
|
+
: undefined
|
|
22
|
+
}
|
|
23
|
+
{...rest}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
NavigationBar.displayName = 'NavigationBar';
|