@stripe/stripe-react-native 0.56.0 → 0.57.1
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/android/build.gradle +76 -118
- package/android/gradle.properties +1 -1
- package/android/settings.gradle +2 -0
- package/android/spotless.gradle +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +24 -20
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +20 -17
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +28 -32
- package/android/src/main/java/com/reactnativestripesdk/{CollectBankAccountLauncherFragment.kt → CollectBankAccountLauncherManager.kt} +23 -44
- package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +4 -11
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +52 -132
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +0 -8
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
- package/android/src/main/java/com/reactnativestripesdk/{FinancialConnectionsSheetFragment.kt → FinancialConnectionsSheetManager.kt} +43 -92
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +107 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherManager.kt +37 -0
- 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/{PaymentLauncherFragment.kt → PaymentLauncherManager.kt} +40 -77
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +11 -20
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +409 -483
- package/android/src/main/java/com/reactnativestripesdk/{PaymentSheetFragment.kt → PaymentSheetManager.kt} +65 -300
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +227 -232
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +78 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +52 -39
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/{CustomerSheetFragment.kt → CustomerSheetManager.kt} +64 -99
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -3
- 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 +87 -11
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +178 -185
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeUIManager.kt +62 -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 +26 -26
- 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 +212 -75
- 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 -41
- 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 +16 -18
- 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/StripeSdkEmitter.swift +4 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +31 -26
- package/ios/StripeSdkImpl+Embedded.swift +11 -9
- package/ios/StripeSdkImpl+PaymentSheet.swift +51 -42
- package/ios/StripeSdkImpl.swift +919 -191
- 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/PaymentIntent.js.map +1 -1
- 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/PaymentIntent.js.map +1 -1
- 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 +3 -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/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/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/PaymentIntent.d.ts +1 -9
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentMethod.d.ts +2 -8
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
- 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 +24 -12
- 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 +22 -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/NativeNavigationBar.ts +16 -0
- package/src/specs/NativeOnrampSdkModule.ts +47 -0
- package/src/specs/NativeStripeSdkModule.ts +5 -0
- package/src/types/Errors.ts +6 -0
- package/src/types/Onramp.ts +317 -0
- package/src/types/PaymentIntent.ts +0 -10
- package/src/types/PaymentMethod.ts +0 -9
- package/src/types/PaymentSheet.ts +7 -0
- package/src/types/index.ts +8 -0
- package/stripe-react-native.podspec +21 -8
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -703
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -18
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +0 -146
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +0 -68
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +0 -102
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeFragment.kt +0 -52
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { EventSubscription } from 'react-native';
|
|
2
|
+
import NativeOnrampSdk from '../specs/NativeOnrampSdkModule';
|
|
3
|
+
import { Onramp, OnrampError, StripeError } from '../types';
|
|
4
|
+
import type { Address, PlatformPay } from '../types';
|
|
5
|
+
import { useCallback } from 'react';
|
|
6
|
+
import { addOnrampListener } from '../events';
|
|
7
|
+
import { CryptoPaymentToken } from '../types/Onramp';
|
|
8
|
+
|
|
9
|
+
let onCheckoutClientSecretRequestedSubscription: EventSubscription | null =
|
|
10
|
+
null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* useOnramp hook
|
|
14
|
+
*/
|
|
15
|
+
export function useOnramp() {
|
|
16
|
+
const _configure = useCallback(
|
|
17
|
+
async (
|
|
18
|
+
config: Onramp.Configuration
|
|
19
|
+
): Promise<{ error?: StripeError<OnrampError> }> => {
|
|
20
|
+
return NativeOnrampSdk.configureOnramp(config);
|
|
21
|
+
},
|
|
22
|
+
[]
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const _hasLinkAccount = useCallback(
|
|
26
|
+
async (email: string): Promise<Onramp.HasLinkAccountResult> => {
|
|
27
|
+
return NativeOnrampSdk.hasLinkAccount(email);
|
|
28
|
+
},
|
|
29
|
+
[]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const _registerLinkUser = useCallback(
|
|
33
|
+
async (
|
|
34
|
+
info: Onramp.LinkUserInfo
|
|
35
|
+
): Promise<Onramp.RegisterLinkUserResult> => {
|
|
36
|
+
return NativeOnrampSdk.registerLinkUser(info);
|
|
37
|
+
},
|
|
38
|
+
[]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const _registerWalletAddress = useCallback(
|
|
42
|
+
async (
|
|
43
|
+
walletAddress: string,
|
|
44
|
+
network: Onramp.CryptoNetwork
|
|
45
|
+
): Promise<{ error?: StripeError<OnrampError> }> => {
|
|
46
|
+
return NativeOnrampSdk.registerWalletAddress(walletAddress, network);
|
|
47
|
+
},
|
|
48
|
+
[]
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const _attachKycInfo = useCallback(
|
|
52
|
+
async (
|
|
53
|
+
kycInfo: Onramp.KycInfo
|
|
54
|
+
): Promise<{ error?: StripeError<OnrampError> }> => {
|
|
55
|
+
return NativeOnrampSdk.attachKycInfo(kycInfo);
|
|
56
|
+
},
|
|
57
|
+
[]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const _presentKycInfoVerification = useCallback(
|
|
61
|
+
async (updatedAddress: Address | null): Promise<Onramp.VerifyKycResult> => {
|
|
62
|
+
return NativeOnrampSdk.presentKycInfoVerification(updatedAddress);
|
|
63
|
+
},
|
|
64
|
+
[]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const _authenticateUserWithToken = useCallback(
|
|
68
|
+
async (
|
|
69
|
+
linkAuthTokenClientSecret: string
|
|
70
|
+
): Promise<{ error?: StripeError<OnrampError> }> => {
|
|
71
|
+
return NativeOnrampSdk.authenticateUserWithToken(
|
|
72
|
+
linkAuthTokenClientSecret
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
[]
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const _updatePhoneNumber = useCallback(
|
|
79
|
+
async (phone: string): Promise<{ error?: StripeError<OnrampError> }> => {
|
|
80
|
+
return NativeOnrampSdk.updatePhoneNumber(phone);
|
|
81
|
+
},
|
|
82
|
+
[]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const _authenticateUser =
|
|
86
|
+
useCallback(async (): Promise<Onramp.AuthenticateUserResult> => {
|
|
87
|
+
return NativeOnrampSdk.authenticateUser();
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
const _verifyIdentity = useCallback(async (): Promise<{
|
|
91
|
+
error?: StripeError<OnrampError>;
|
|
92
|
+
}> => {
|
|
93
|
+
return NativeOnrampSdk.verifyIdentity();
|
|
94
|
+
}, []);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The set of payment methods supported by crypto onramp collection.
|
|
98
|
+
* - 'Card' and 'BankAccount' present Link for collection.
|
|
99
|
+
* - 'PlatformPay' presents Apple Pay / Google Pay using provided params.
|
|
100
|
+
*/
|
|
101
|
+
type OnrampPaymentMethod = 'Card' | 'BankAccount' | 'PlatformPay';
|
|
102
|
+
|
|
103
|
+
// Overloads for stronger type-safety at call-sites
|
|
104
|
+
const _collectPaymentMethod: {
|
|
105
|
+
(
|
|
106
|
+
paymentMethod: 'Card' | 'BankAccount',
|
|
107
|
+
platformPayParams?: undefined
|
|
108
|
+
): Promise<Onramp.CollectPaymentMethodResult>;
|
|
109
|
+
(
|
|
110
|
+
paymentMethod: 'PlatformPay',
|
|
111
|
+
platformPayParams: PlatformPay.PaymentMethodParams
|
|
112
|
+
): Promise<Onramp.CollectPaymentMethodResult>;
|
|
113
|
+
} = useCallback(
|
|
114
|
+
async (
|
|
115
|
+
paymentMethod: OnrampPaymentMethod,
|
|
116
|
+
platformPayParams?:
|
|
117
|
+
| PlatformPay.PaymentMethodParams
|
|
118
|
+
| Record<string, never>
|
|
119
|
+
): Promise<Onramp.CollectPaymentMethodResult> => {
|
|
120
|
+
return NativeOnrampSdk.collectPaymentMethod(
|
|
121
|
+
paymentMethod,
|
|
122
|
+
(platformPayParams ?? {}) as any
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
[]
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const _createCryptoPaymentToken =
|
|
129
|
+
useCallback(async (): Promise<Onramp.CreateCryptoPaymentTokenResult> => {
|
|
130
|
+
return NativeOnrampSdk.createCryptoPaymentToken();
|
|
131
|
+
}, []);
|
|
132
|
+
|
|
133
|
+
const _performCheckout = useCallback(
|
|
134
|
+
async (
|
|
135
|
+
onrampSessionId: string,
|
|
136
|
+
provideCheckoutClientSecret: () => Promise<string | null>
|
|
137
|
+
): Promise<{ error?: StripeError<OnrampError> }> => {
|
|
138
|
+
onCheckoutClientSecretRequestedSubscription?.remove();
|
|
139
|
+
onCheckoutClientSecretRequestedSubscription = addOnrampListener(
|
|
140
|
+
'onCheckoutClientSecretRequested',
|
|
141
|
+
async () => {
|
|
142
|
+
try {
|
|
143
|
+
const clientSecret = await provideCheckoutClientSecret();
|
|
144
|
+
NativeOnrampSdk.provideCheckoutClientSecret(clientSecret);
|
|
145
|
+
} catch (error: any) {
|
|
146
|
+
NativeOnrampSdk.provideCheckoutClientSecret(null);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
return NativeOnrampSdk.performCheckout(onrampSessionId);
|
|
151
|
+
},
|
|
152
|
+
[]
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const _authorize = useCallback(
|
|
156
|
+
async (linkAuthIntentId: string): Promise<Onramp.AuthorizeResult> => {
|
|
157
|
+
return NativeOnrampSdk.onrampAuthorize(linkAuthIntentId);
|
|
158
|
+
},
|
|
159
|
+
[]
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const _getCryptoTokenDisplayData = useCallback(
|
|
163
|
+
async (
|
|
164
|
+
token: CryptoPaymentToken
|
|
165
|
+
): Promise<Onramp.PaymentDisplayDataResult> => {
|
|
166
|
+
return NativeOnrampSdk.getCryptoTokenDisplayData(token);
|
|
167
|
+
},
|
|
168
|
+
[]
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const _logOut = useCallback(async (): Promise<{
|
|
172
|
+
error?: StripeError<OnrampError>;
|
|
173
|
+
}> => {
|
|
174
|
+
return NativeOnrampSdk.logout();
|
|
175
|
+
}, []);
|
|
176
|
+
|
|
177
|
+
const _isAuthError = (error: any): boolean => {
|
|
178
|
+
const stripeErrorCode = error?.stripeErrorCode;
|
|
179
|
+
const authErrorCodes = [
|
|
180
|
+
'consumer_session_credentials_invalid',
|
|
181
|
+
'consumer_session_expired',
|
|
182
|
+
];
|
|
183
|
+
return authErrorCodes.includes(stripeErrorCode);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
/**
|
|
188
|
+
* Creates a `CryptoOnrampCoordinator` to facilitate authentication, identity verification, payment collection, and checkouts.
|
|
189
|
+
*
|
|
190
|
+
* @param config Configuration object containing merchant display name and appearance settings
|
|
191
|
+
* @returns Promise that resolves to an object with an optional error property
|
|
192
|
+
*/
|
|
193
|
+
configure: _configure,
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Whether or not the provided email is associated with an existing Link consumer.
|
|
197
|
+
*
|
|
198
|
+
* @param email The email address to look up
|
|
199
|
+
* @returns Promise that resolves to an object with hasLinkAccount boolean or error
|
|
200
|
+
*/
|
|
201
|
+
hasLinkAccount: _hasLinkAccount,
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Registers a new Link user with the provided details.
|
|
205
|
+
*
|
|
206
|
+
* @param info User information including email, phone, country, and optional full name
|
|
207
|
+
* @returns Promise that resolves to an object with customerId or error
|
|
208
|
+
*/
|
|
209
|
+
registerLinkUser: _registerLinkUser,
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Registers the given crypto wallet address to the current Link account.
|
|
213
|
+
* Requires an authenticated Link user.
|
|
214
|
+
*
|
|
215
|
+
* @param walletAddress The crypto wallet address to register
|
|
216
|
+
* @param network The crypto network for the wallet address
|
|
217
|
+
* @returns Promise that resolves to an object with an optional error property
|
|
218
|
+
*/
|
|
219
|
+
registerWalletAddress: _registerWalletAddress,
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Attaches the specific KYC info to the current Link user. Requires an authenticated Link user.
|
|
223
|
+
*
|
|
224
|
+
* @param kycInfo The KYC info to attach to the Link user
|
|
225
|
+
* @returns Promise that resolves to an object with an optional error property
|
|
226
|
+
*/
|
|
227
|
+
attachKycInfo: _attachKycInfo,
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Presents UI to verify KYC information for the current Link user.
|
|
231
|
+
* Requires the user to be authenticated with prior calls to either `authenticateUser` or `authorize`, and also requires prior KYC info attachement via `attachKycInfo`.
|
|
232
|
+
*
|
|
233
|
+
* @param updatedAddress: An optional updated address. Specify this parameter if the user has elected to change the address after a prior call to this API returned `UpdateAddress`. Otherwise, specify `null` to show the user's existing KYC information on the presented flow.
|
|
234
|
+
*
|
|
235
|
+
* @returns Promise that resolves to an instance of `VerifyKycResult` indicating whether the user confirmed their address, elected to update their address, cancelled the flow, or an error occurred.
|
|
236
|
+
*/
|
|
237
|
+
presentKycInfoVerification: _presentKycInfoVerification,
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Updates the user's phone number in their Link account.
|
|
241
|
+
*
|
|
242
|
+
* @param phone The new phone number to set for the user in E.164 format (e.g., +12125551234)
|
|
243
|
+
* @returns Promise that resolves to an object with an optional error property
|
|
244
|
+
*/
|
|
245
|
+
updatePhoneNumber: _updatePhoneNumber,
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Presents Link UI to authenticate an existing Link user.
|
|
249
|
+
* `hasLinkAccount` must be called before this.
|
|
250
|
+
*
|
|
251
|
+
* @returns Promise that resolves to an object with customerId or error
|
|
252
|
+
*/
|
|
253
|
+
authenticateUser: _authenticateUser,
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Authenticates the user with an encrypted Link auth token.
|
|
257
|
+
* This token can be obtained by exchanging a previously consented Link OAuth token from your backend using Stripe's /v1/link/auth_token API. The response of this backend API includes information on token expiry.
|
|
258
|
+
*
|
|
259
|
+
* @param linkAuthTokenClientSecret An encrypted one-time-use auth token that, upon successful validation, leaves the Link account’s consumer session in an already-verified state, allowing the client to skip verification.
|
|
260
|
+
* @returns Promise that resolves to an object with an optional error property if authentication fails due to an invalid token that is expired, already used, revoked, or not found, or if a network error occurs.
|
|
261
|
+
*/
|
|
262
|
+
authenticateUserWithToken: _authenticateUserWithToken,
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Creates an identity verification session and launches the document verification flow.
|
|
266
|
+
* Requires an authenticated Link user.
|
|
267
|
+
*
|
|
268
|
+
* @returns Promise that resolves to an object with an optional error property
|
|
269
|
+
*/
|
|
270
|
+
verifyIdentity: _verifyIdentity,
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Presents UI to collect/select a payment method of the given type.
|
|
274
|
+
*
|
|
275
|
+
* @param paymentMethod The payment method type to collect.
|
|
276
|
+
* - 'Card' and 'BankAccount' present Link for collection.
|
|
277
|
+
* - 'PlatformPay' presents Apple Pay / Google Pay using the provided parameters.
|
|
278
|
+
* @param platformPayParams Platform-specific parameters (required when `paymentMethod` is 'PlatformPay').
|
|
279
|
+
* - iOS: provide `applePay` params
|
|
280
|
+
* - Android: provide `googlePay` params
|
|
281
|
+
* @returns Promise that resolves to an object with displayData or error
|
|
282
|
+
*/
|
|
283
|
+
collectPaymentMethod: _collectPaymentMethod,
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Creates a crypto payment token for the payment method currently selected on the coordinator.
|
|
287
|
+
* Call after a successful `collectPaymentMethod(...)`.
|
|
288
|
+
*
|
|
289
|
+
* @returns Promise that resolves to an object with cryptoPaymentToken or error
|
|
290
|
+
*/
|
|
291
|
+
createCryptoPaymentToken: _createCryptoPaymentToken,
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Performs the checkout flow for a crypto onramp session, handling any required authentication steps.
|
|
295
|
+
*
|
|
296
|
+
* @param onrampSessionId The onramp session identifier
|
|
297
|
+
* @returns Promise that resolves to an object with an optional error property
|
|
298
|
+
*/
|
|
299
|
+
performCheckout: _performCheckout,
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Authorizes a Link auth intent and authenticates the user if necessary.
|
|
303
|
+
*
|
|
304
|
+
* @param linkAuthIntentId The Link auth intent ID to authorize
|
|
305
|
+
* @returns Promise that resolves to an object with status and customerId or error
|
|
306
|
+
*/
|
|
307
|
+
authorize: _authorize,
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Retrieves display data (icon, label, sublabel) for the given payment method details.
|
|
311
|
+
* Suitable for rendering in the UI to summarize the selected payment method.
|
|
312
|
+
*
|
|
313
|
+
* @param token The token containing payment method details (card or bank account) to get display data for
|
|
314
|
+
* @returns Promise that resolves to an object with displayData or error
|
|
315
|
+
*/
|
|
316
|
+
getCryptoTokenDisplayData: _getCryptoTokenDisplayData,
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Logs out the current user from their Link account.
|
|
320
|
+
*
|
|
321
|
+
* @returns Promise that resolves to an object with an optional error property
|
|
322
|
+
*/
|
|
323
|
+
logOut: _logOut,
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Determines whether an error is an authentication-related error that requires re-authentication.
|
|
327
|
+
* Useful for implementing automatic re-authentication flows when sessions expire or become invalid.
|
|
328
|
+
*
|
|
329
|
+
* @param error The error object to check, typically from onramp method calls
|
|
330
|
+
* @returns True if the error indicates an authentication issue, false otherwise
|
|
331
|
+
*/
|
|
332
|
+
isAuthError: _isAuthError,
|
|
333
|
+
};
|
|
334
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -5,6 +5,7 @@ export { useStripe } from './hooks/useStripe';
|
|
|
5
5
|
export { usePlatformPay } from './hooks/usePlatformPay';
|
|
6
6
|
export { usePaymentSheet } from './hooks/usePaymentSheet';
|
|
7
7
|
export { useFinancialConnectionsSheet } from './hooks/useFinancialConnectionsSheet';
|
|
8
|
+
export { useOnramp } from './hooks/useOnramp';
|
|
8
9
|
|
|
9
10
|
//components
|
|
10
11
|
export { initStripe, StripeProvider } from './components/StripeProvider';
|
|
@@ -34,3 +35,15 @@ export type { Props as CustomerSheetProps } from './components/CustomerSheet';
|
|
|
34
35
|
export * from './types/EmbeddedPaymentElement';
|
|
35
36
|
export * from './types/PaymentSheet';
|
|
36
37
|
export * from './types/ConfirmationToken';
|
|
38
|
+
|
|
39
|
+
//connect components
|
|
40
|
+
export {
|
|
41
|
+
ConnectComponentsProvider,
|
|
42
|
+
loadConnectAndInitialize,
|
|
43
|
+
} from './connect/ConnectComponentsProvider';
|
|
44
|
+
export type {
|
|
45
|
+
StripeConnectInstance,
|
|
46
|
+
StripeConnectInitParams,
|
|
47
|
+
StripeConnectUpdateParams,
|
|
48
|
+
} from './connect/connectTypes';
|
|
49
|
+
export * from './connect/Components';
|
package/src/plugin/withStripe.ts
CHANGED
|
@@ -5,7 +5,10 @@ import {
|
|
|
5
5
|
IOSConfig,
|
|
6
6
|
withAndroidManifest,
|
|
7
7
|
withEntitlementsPlist,
|
|
8
|
+
withGradleProperties,
|
|
9
|
+
withPodfile,
|
|
8
10
|
} from '@expo/config-plugins';
|
|
11
|
+
import path from 'path';
|
|
9
12
|
|
|
10
13
|
const {
|
|
11
14
|
addMetaDataItemToMainApplication,
|
|
@@ -22,6 +25,13 @@ type StripePluginProps = {
|
|
|
22
25
|
*/
|
|
23
26
|
merchantIdentifier: string | string[];
|
|
24
27
|
enableGooglePay: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to include Onramp functionality in the build.
|
|
30
|
+
* When true, adds StripeSdk_includeOnramp=true to gradle.properties for Android
|
|
31
|
+
* and includes the Onramp pod for iOS.
|
|
32
|
+
* Defaults to false.
|
|
33
|
+
*/
|
|
34
|
+
includeOnramp?: boolean;
|
|
25
35
|
};
|
|
26
36
|
|
|
27
37
|
const withStripe: ConfigPlugin<StripePluginProps> = (config, props) => {
|
|
@@ -33,15 +43,48 @@ const withStripe: ConfigPlugin<StripePluginProps> = (config, props) => {
|
|
|
33
43
|
|
|
34
44
|
const withStripeIos: ConfigPlugin<StripePluginProps> = (
|
|
35
45
|
expoConfig,
|
|
36
|
-
{ merchantIdentifier }
|
|
46
|
+
{ merchantIdentifier, includeOnramp = false }
|
|
37
47
|
) => {
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
let resultConfig = withEntitlementsPlist(expoConfig, (entitlementsConfig) => {
|
|
49
|
+
entitlementsConfig.modResults = setApplePayEntitlement(
|
|
40
50
|
merchantIdentifier,
|
|
41
|
-
|
|
51
|
+
entitlementsConfig.modResults
|
|
42
52
|
);
|
|
43
|
-
return
|
|
53
|
+
return entitlementsConfig;
|
|
44
54
|
});
|
|
55
|
+
|
|
56
|
+
// Conditionally include Onramp pod for iOS.
|
|
57
|
+
if (includeOnramp) {
|
|
58
|
+
resultConfig = withPodfile(resultConfig, (config) => {
|
|
59
|
+
const podfile = config.modResults.contents;
|
|
60
|
+
|
|
61
|
+
const localPodPath = path.dirname(
|
|
62
|
+
require.resolve('@stripe/stripe-react-native/package.json', {
|
|
63
|
+
paths: [config.modRequest.projectRoot],
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
const relativePodPath = path.relative(
|
|
67
|
+
path.join(config.modRequest.projectRoot, 'ios'),
|
|
68
|
+
localPodPath
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Using Expo BuildProperties with `extraPods` unfortunately results in
|
|
72
|
+
// an empty pod, so we're modifying the Podfile directly. The pod line
|
|
73
|
+
// *must* come after the use_native_modules! call.
|
|
74
|
+
const podLine = ` pod 'stripe-react-native/Onramp', :path => '${relativePodPath}'`;
|
|
75
|
+
|
|
76
|
+
if (!podfile.includes(podLine)) {
|
|
77
|
+
config.modResults.contents = podfile.replace(
|
|
78
|
+
'config = use_native_modules!(config_command)',
|
|
79
|
+
(match) => `${match}\n${podLine}`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return config;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return resultConfig;
|
|
45
88
|
};
|
|
46
89
|
|
|
47
90
|
/**
|
|
@@ -94,9 +137,9 @@ export const withNoopSwiftFile: ConfigPlugin = (config) => {
|
|
|
94
137
|
|
|
95
138
|
const withStripeAndroid: ConfigPlugin<StripePluginProps> = (
|
|
96
139
|
expoConfig,
|
|
97
|
-
{ enableGooglePay = false }
|
|
140
|
+
{ enableGooglePay = false, includeOnramp = false }
|
|
98
141
|
) => {
|
|
99
|
-
|
|
142
|
+
let resultConfig = withAndroidManifest(expoConfig, (config) => {
|
|
100
143
|
config.modResults = setGooglePayMetaData(
|
|
101
144
|
enableGooglePay,
|
|
102
145
|
config.modResults
|
|
@@ -104,6 +147,17 @@ const withStripeAndroid: ConfigPlugin<StripePluginProps> = (
|
|
|
104
147
|
|
|
105
148
|
return config;
|
|
106
149
|
});
|
|
150
|
+
|
|
151
|
+
resultConfig = withGradleProperties(resultConfig, (config) => {
|
|
152
|
+
config.modResults = setOnrampGradleProperty(
|
|
153
|
+
includeOnramp,
|
|
154
|
+
config.modResults
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
return config;
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return resultConfig;
|
|
107
161
|
};
|
|
108
162
|
|
|
109
163
|
/**
|
|
@@ -138,4 +192,47 @@ export function setGooglePayMetaData(
|
|
|
138
192
|
return modResults;
|
|
139
193
|
}
|
|
140
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Adds or removes the StripeSdk_includeOnramp property in gradle.properties.
|
|
197
|
+
*
|
|
198
|
+
* @param includeOnramp Whether to include Onramp functionality
|
|
199
|
+
* @param modResults The current gradle.properties as PropertiesItem array
|
|
200
|
+
* @returns Modified PropertiesItem array
|
|
201
|
+
*/
|
|
202
|
+
export function setOnrampGradleProperty(
|
|
203
|
+
includeOnramp: boolean,
|
|
204
|
+
modResults: AndroidConfig.Properties.PropertiesItem[]
|
|
205
|
+
): AndroidConfig.Properties.PropertiesItem[] {
|
|
206
|
+
const ONRAMP_PROPERTY_KEY = 'StripeSdk_includeOnramp';
|
|
207
|
+
|
|
208
|
+
// Find existing property if it exists
|
|
209
|
+
const existingPropertyIndex = modResults.findIndex(
|
|
210
|
+
(item) => item.type === 'property' && item.key === ONRAMP_PROPERTY_KEY
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
if (includeOnramp) {
|
|
214
|
+
// Add or update the property to true
|
|
215
|
+
const propertyItem = {
|
|
216
|
+
type: 'property' as const,
|
|
217
|
+
key: ONRAMP_PROPERTY_KEY,
|
|
218
|
+
value: 'true',
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
if (existingPropertyIndex >= 0) {
|
|
222
|
+
// Update existing property
|
|
223
|
+
modResults[existingPropertyIndex] = propertyItem;
|
|
224
|
+
} else {
|
|
225
|
+
// Add new property at the end
|
|
226
|
+
modResults.push(propertyItem);
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
// Remove the property if it exists
|
|
230
|
+
if (existingPropertyIndex >= 0) {
|
|
231
|
+
modResults.splice(existingPropertyIndex, 1);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return modResults;
|
|
236
|
+
}
|
|
237
|
+
|
|
141
238
|
export default createRunOncePlugin(withStripe, pkg.name, pkg.version);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
2
|
+
import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
4
|
+
|
|
5
|
+
type OnExitActionEvent = Readonly<{}>;
|
|
6
|
+
|
|
7
|
+
export interface NativeProps extends ViewProps {
|
|
8
|
+
visible: boolean;
|
|
9
|
+
title?: string;
|
|
10
|
+
backgroundColor?: string;
|
|
11
|
+
textColor?: string;
|
|
12
|
+
onExitAction: DirectEventHandler<OnExitActionEvent>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
16
|
+
|
|
17
|
+
export default codegenNativeComponent<NativeProps>(
|
|
18
|
+
'ConnectAccountOnboardingView'
|
|
19
|
+
) as ComponentType;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
2
|
+
import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
4
|
+
|
|
5
|
+
export type CloseButtonPressEvent = Readonly<{}>;
|
|
6
|
+
|
|
7
|
+
export interface NativeProps extends ViewProps {
|
|
8
|
+
title?: string;
|
|
9
|
+
onCloseButtonPress?: DirectEventHandler<CloseButtonPressEvent>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
13
|
+
|
|
14
|
+
export default codegenNativeComponent<NativeProps>(
|
|
15
|
+
'NavigationBar'
|
|
16
|
+
) as ComponentType;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
2
|
+
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
|
|
3
|
+
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
import type { Address, InitialiseParams, Onramp } from '../types';
|
|
5
|
+
import type { UnsafeObject } from './utils';
|
|
6
|
+
|
|
7
|
+
export interface Spec extends TurboModule {
|
|
8
|
+
initialise(params: UnsafeObject<InitialiseParams>): Promise<void>;
|
|
9
|
+
configureOnramp(
|
|
10
|
+
config: UnsafeObject<Onramp.Configuration>
|
|
11
|
+
): Promise<Onramp.VoidResult>;
|
|
12
|
+
hasLinkAccount(email: string): Promise<Onramp.HasLinkAccountResult>;
|
|
13
|
+
registerLinkUser(
|
|
14
|
+
info: UnsafeObject<Onramp.LinkUserInfo>
|
|
15
|
+
): Promise<Onramp.RegisterLinkUserResult>;
|
|
16
|
+
registerWalletAddress(
|
|
17
|
+
walletAddress: string,
|
|
18
|
+
network: string
|
|
19
|
+
): Promise<Onramp.VoidResult>;
|
|
20
|
+
attachKycInfo(
|
|
21
|
+
kycInfo: UnsafeObject<Onramp.KycInfo>
|
|
22
|
+
): Promise<Onramp.VoidResult>;
|
|
23
|
+
presentKycInfoVerification: (
|
|
24
|
+
updatedAddress: UnsafeObject<Address> | null
|
|
25
|
+
) => Promise<Onramp.VerifyKycResult>;
|
|
26
|
+
updatePhoneNumber(phone: string): Promise<Onramp.VoidResult>;
|
|
27
|
+
authenticateUser(): Promise<Onramp.AuthenticateUserResult>;
|
|
28
|
+
authenticateUserWithToken(
|
|
29
|
+
linkAuthTokenClientSecret: string
|
|
30
|
+
): Promise<Onramp.VoidResult>;
|
|
31
|
+
verifyIdentity(): Promise<Onramp.VoidResult>;
|
|
32
|
+
collectPaymentMethod(
|
|
33
|
+
paymentMethod: string,
|
|
34
|
+
platformPayParams: UnsafeObject<any>
|
|
35
|
+
): Promise<Onramp.CollectPaymentMethodResult>;
|
|
36
|
+
provideCheckoutClientSecret(clientSecret: string | null): void;
|
|
37
|
+
onCheckoutClientSecretRequested: EventEmitter<UnsafeObject<any>>;
|
|
38
|
+
createCryptoPaymentToken(): Promise<Onramp.CreateCryptoPaymentTokenResult>;
|
|
39
|
+
performCheckout(onrampSessionId: string): Promise<Onramp.VoidResult>;
|
|
40
|
+
onrampAuthorize(linkAuthIntentId: string): Promise<Onramp.AuthorizeResult>;
|
|
41
|
+
getCryptoTokenDisplayData(
|
|
42
|
+
token: UnsafeObject<Onramp.CryptoPaymentToken>
|
|
43
|
+
): Promise<Onramp.PaymentDisplayDataResult>;
|
|
44
|
+
logout(): Promise<Onramp.VoidResult>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('OnrampSdk');
|
|
@@ -196,6 +196,11 @@ export interface Spec extends TurboModule {
|
|
|
196
196
|
|
|
197
197
|
setFinancialConnectionsForceNativeFlow(enabled: boolean): Promise<void>;
|
|
198
198
|
|
|
199
|
+
openAuthenticatedWebView(
|
|
200
|
+
id: string,
|
|
201
|
+
url: string
|
|
202
|
+
): Promise<{ url?: string } | null>;
|
|
203
|
+
|
|
199
204
|
// Events
|
|
200
205
|
addListener: (eventType: string) => void;
|
|
201
206
|
removeListeners: (count: number) => void;
|
package/src/types/Errors.ts
CHANGED