@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
package/android/.idea/gradle.xml
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="GradleMigrationSettings" migrationVersion="1" />
|
|
4
|
-
<component name="GradleSettings">
|
|
5
|
-
<option name="linkedExternalProjectsSettings">
|
|
6
|
-
<GradleProjectSettings>
|
|
7
|
-
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
|
8
|
-
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
9
|
-
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
|
10
|
-
<option name="modules">
|
|
11
|
-
<set>
|
|
12
|
-
<option value="$PROJECT_DIR$" />
|
|
13
|
-
</set>
|
|
14
|
-
</option>
|
|
15
|
-
</GradleProjectSettings>
|
|
16
|
-
</option>
|
|
17
|
-
</component>
|
|
18
|
-
</project>
|
package/android/.idea/misc.xml
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
|
4
|
-
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
|
5
|
-
<output url="file://$PROJECT_DIR$/build/classes" />
|
|
6
|
-
</component>
|
|
7
|
-
<component name="ProjectType">
|
|
8
|
-
<option name="id" value="Android" />
|
|
9
|
-
</component>
|
|
10
|
-
</project>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="RunConfigurationProducerService">
|
|
4
|
-
<option name="ignoredProducers">
|
|
5
|
-
<set>
|
|
6
|
-
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
|
7
|
-
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
|
8
|
-
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
|
9
|
-
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
|
10
|
-
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
|
11
|
-
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
|
12
|
-
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
|
13
|
-
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
|
14
|
-
</set>
|
|
15
|
-
</option>
|
|
16
|
-
</component>
|
|
17
|
-
</project>
|
package/android/.idea/vcs.xml
DELETED
package/android/local.properties
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
## This file must *NOT* be checked into Version Control Systems,
|
|
2
|
-
# as it contains information specific to your local configuration.
|
|
3
|
-
#
|
|
4
|
-
# Location of the SDK. This is only used by Gradle.
|
|
5
|
-
# For customization when using a Version Control System, please read the
|
|
6
|
-
# header note.
|
|
7
|
-
#Fri Aug 30 15:10:34 EDT 2024
|
|
8
|
-
sdk.dir=/Users/samer/Library/Android/sdk
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
package com.reactnativestripesdk
|
|
2
|
-
|
|
3
|
-
import androidx.fragment.app.FragmentActivity
|
|
4
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
-
import com.facebook.react.bridge.ReadableMap
|
|
6
|
-
import com.facebook.react.bridge.WritableMap
|
|
7
|
-
import com.reactnativestripesdk.utils.ErrorType
|
|
8
|
-
import com.reactnativestripesdk.utils.GooglePayErrorType
|
|
9
|
-
import com.reactnativestripesdk.utils.StripeFragment
|
|
10
|
-
import com.reactnativestripesdk.utils.createError
|
|
11
|
-
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
12
|
-
import com.reactnativestripesdk.utils.getBooleanOr
|
|
13
|
-
import com.reactnativestripesdk.utils.getIntOrNull
|
|
14
|
-
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
15
|
-
import com.stripe.android.googlepaylauncher.GooglePayLauncher
|
|
16
|
-
|
|
17
|
-
class GooglePayLauncherFragment : StripeFragment() {
|
|
18
|
-
enum class Mode {
|
|
19
|
-
ForSetup,
|
|
20
|
-
ForPayment,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private lateinit var launcher: GooglePayLauncher
|
|
24
|
-
private lateinit var clientSecret: String
|
|
25
|
-
private lateinit var mode: Mode
|
|
26
|
-
private lateinit var configuration: GooglePayLauncher.Config
|
|
27
|
-
private lateinit var currencyCode: String
|
|
28
|
-
private var amount: Int? = null
|
|
29
|
-
private var label: String? = null
|
|
30
|
-
private lateinit var callback: (result: GooglePayLauncher.Result?, error: WritableMap?) -> Unit
|
|
31
|
-
|
|
32
|
-
override fun prepare() {
|
|
33
|
-
launcher =
|
|
34
|
-
GooglePayLauncher(
|
|
35
|
-
fragment = this,
|
|
36
|
-
config = configuration,
|
|
37
|
-
readyCallback = ::onGooglePayReady,
|
|
38
|
-
resultCallback = ::onGooglePayResult,
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
fun presentGooglePaySheet(
|
|
43
|
-
clientSecret: String,
|
|
44
|
-
mode: Mode,
|
|
45
|
-
googlePayParams: ReadableMap,
|
|
46
|
-
context: ReactApplicationContext,
|
|
47
|
-
callback: (GooglePayLauncher.Result?, error: WritableMap?) -> Unit,
|
|
48
|
-
) {
|
|
49
|
-
this.clientSecret = clientSecret
|
|
50
|
-
this.mode = mode
|
|
51
|
-
this.callback = callback
|
|
52
|
-
this.currencyCode = googlePayParams.getString("currencyCode") ?: "USD"
|
|
53
|
-
this.amount = getIntOrNull(googlePayParams, "amount")
|
|
54
|
-
this.label = googlePayParams.getString("label")
|
|
55
|
-
this.configuration =
|
|
56
|
-
GooglePayLauncher.Config(
|
|
57
|
-
environment =
|
|
58
|
-
if (googlePayParams.getBoolean("testEnv")) {
|
|
59
|
-
GooglePayEnvironment.Test
|
|
60
|
-
} else {
|
|
61
|
-
GooglePayEnvironment.Production
|
|
62
|
-
},
|
|
63
|
-
merchantCountryCode = googlePayParams.getString("merchantCountryCode").orEmpty(),
|
|
64
|
-
merchantName = googlePayParams.getString("merchantName").orEmpty(),
|
|
65
|
-
isEmailRequired = googlePayParams.getBooleanOr("isEmailRequired", false),
|
|
66
|
-
billingAddressConfig =
|
|
67
|
-
buildBillingAddressParameters(googlePayParams.getMap("billingAddressConfig")),
|
|
68
|
-
existingPaymentMethodRequired =
|
|
69
|
-
googlePayParams.getBooleanOr("existingPaymentMethodRequired", false),
|
|
70
|
-
allowCreditCards = googlePayParams.getBooleanOr("allowCreditCards", true),
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
(context.currentActivity as? FragmentActivity)?.let {
|
|
74
|
-
attemptToCleanupPreviousFragment(it)
|
|
75
|
-
commitFragmentAndStartFlow(it)
|
|
76
|
-
}
|
|
77
|
-
?: run {
|
|
78
|
-
callback(null, createMissingActivityError())
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private fun attemptToCleanupPreviousFragment(currentActivity: FragmentActivity) {
|
|
84
|
-
currentActivity.supportFragmentManager
|
|
85
|
-
.beginTransaction()
|
|
86
|
-
.remove(this)
|
|
87
|
-
.commitAllowingStateLoss()
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private fun commitFragmentAndStartFlow(currentActivity: FragmentActivity) {
|
|
91
|
-
try {
|
|
92
|
-
currentActivity.supportFragmentManager
|
|
93
|
-
.beginTransaction()
|
|
94
|
-
.add(this, TAG)
|
|
95
|
-
.commit()
|
|
96
|
-
} catch (error: IllegalStateException) {
|
|
97
|
-
callback(null, createError(ErrorType.Failed.toString(), error.message))
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private fun onGooglePayReady(isReady: Boolean) {
|
|
102
|
-
if (isReady) {
|
|
103
|
-
when (mode) {
|
|
104
|
-
Mode.ForSetup -> {
|
|
105
|
-
launcher.presentForSetupIntent(clientSecret, currencyCode, amount?.toLong(), label)
|
|
106
|
-
}
|
|
107
|
-
Mode.ForPayment -> {
|
|
108
|
-
launcher.presentForPaymentIntent(clientSecret, label)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
} else {
|
|
112
|
-
callback(
|
|
113
|
-
null,
|
|
114
|
-
createError(
|
|
115
|
-
GooglePayErrorType.Failed.toString(),
|
|
116
|
-
"Google Pay is not available on this device. You can use isPlatformPaySupported to preemptively check for Google Pay support.",
|
|
117
|
-
),
|
|
118
|
-
)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private fun onGooglePayResult(result: GooglePayLauncher.Result) {
|
|
123
|
-
callback(result, null)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
companion object {
|
|
127
|
-
const val TAG = "google_pay_launcher_fragment"
|
|
128
|
-
|
|
129
|
-
private fun buildBillingAddressParameters(params: ReadableMap?): GooglePayLauncher.BillingAddressConfig {
|
|
130
|
-
val isRequired = params?.getBooleanOr("isRequired", false)
|
|
131
|
-
val isPhoneNumberRequired = params?.getBooleanOr("isPhoneNumberRequired", false)
|
|
132
|
-
val format =
|
|
133
|
-
when (params?.getString("format").orEmpty()) {
|
|
134
|
-
"FULL" -> GooglePayLauncher.BillingAddressConfig.Format.Full
|
|
135
|
-
"MIN" -> GooglePayLauncher.BillingAddressConfig.Format.Min
|
|
136
|
-
else -> GooglePayLauncher.BillingAddressConfig.Format.Min
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return GooglePayLauncher.BillingAddressConfig(
|
|
140
|
-
isRequired = isRequired ?: false,
|
|
141
|
-
format = format,
|
|
142
|
-
isPhoneNumberRequired = isPhoneNumberRequired ?: false,
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
package com.reactnativestripesdk
|
|
2
|
-
|
|
3
|
-
import android.os.Bundle
|
|
4
|
-
import android.view.LayoutInflater
|
|
5
|
-
import android.view.View
|
|
6
|
-
import android.view.ViewGroup
|
|
7
|
-
import android.widget.FrameLayout
|
|
8
|
-
import androidx.fragment.app.Fragment
|
|
9
|
-
import com.facebook.react.bridge.Promise
|
|
10
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
-
import com.reactnativestripesdk.utils.removeFragment
|
|
12
|
-
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
13
|
-
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher
|
|
14
|
-
|
|
15
|
-
class GooglePayPaymentMethodLauncherFragment : Fragment() {
|
|
16
|
-
private lateinit var context: ReactApplicationContext
|
|
17
|
-
private var isTestEnv = false
|
|
18
|
-
private var paymentMethodRequired = false
|
|
19
|
-
private lateinit var promise: Promise
|
|
20
|
-
|
|
21
|
-
override fun onCreateView(
|
|
22
|
-
inflater: LayoutInflater,
|
|
23
|
-
container: ViewGroup?,
|
|
24
|
-
savedInstanceState: Bundle?,
|
|
25
|
-
): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
26
|
-
|
|
27
|
-
override fun onViewCreated(
|
|
28
|
-
view: View,
|
|
29
|
-
savedInstanceState: Bundle?,
|
|
30
|
-
) {
|
|
31
|
-
super.onViewCreated(view, savedInstanceState)
|
|
32
|
-
GooglePayPaymentMethodLauncher(
|
|
33
|
-
this,
|
|
34
|
-
config =
|
|
35
|
-
GooglePayPaymentMethodLauncher.Config(
|
|
36
|
-
environment =
|
|
37
|
-
if (isTestEnv) GooglePayEnvironment.Test else GooglePayEnvironment.Production,
|
|
38
|
-
existingPaymentMethodRequired = paymentMethodRequired,
|
|
39
|
-
merchantCountryCode =
|
|
40
|
-
"", // Unnecessary since all we are checking for is Google Pay availability
|
|
41
|
-
merchantName = "", // Same as above
|
|
42
|
-
),
|
|
43
|
-
readyCallback = {
|
|
44
|
-
promise.resolve(it)
|
|
45
|
-
removeFragment(context)
|
|
46
|
-
},
|
|
47
|
-
resultCallback = {},
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
companion object {
|
|
52
|
-
const val TAG = "google_pay_support_fragment"
|
|
53
|
-
|
|
54
|
-
fun create(
|
|
55
|
-
context: ReactApplicationContext,
|
|
56
|
-
isTestEnv: Boolean,
|
|
57
|
-
paymentMethodRequired: Boolean,
|
|
58
|
-
promise: Promise,
|
|
59
|
-
): GooglePayPaymentMethodLauncherFragment {
|
|
60
|
-
val instance = GooglePayPaymentMethodLauncherFragment()
|
|
61
|
-
instance.context = context
|
|
62
|
-
instance.isTestEnv = isTestEnv
|
|
63
|
-
instance.paymentMethodRequired = paymentMethodRequired
|
|
64
|
-
instance.promise = promise
|
|
65
|
-
return instance
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
package com.reactnativestripesdk.addresssheet
|
|
2
|
-
|
|
3
|
-
import androidx.fragment.app.FragmentActivity
|
|
4
|
-
import com.facebook.react.bridge.ReactContext
|
|
5
|
-
import com.facebook.react.bridge.WritableMap
|
|
6
|
-
import com.reactnativestripesdk.utils.ErrorType
|
|
7
|
-
import com.reactnativestripesdk.utils.StripeFragment
|
|
8
|
-
import com.reactnativestripesdk.utils.createError
|
|
9
|
-
import com.stripe.android.paymentsheet.PaymentSheet
|
|
10
|
-
import com.stripe.android.paymentsheet.addresselement.AddressDetails
|
|
11
|
-
import com.stripe.android.paymentsheet.addresselement.AddressLauncher
|
|
12
|
-
import com.stripe.android.paymentsheet.addresselement.AddressLauncherResult
|
|
13
|
-
|
|
14
|
-
class AddressLauncherFragment : StripeFragment() {
|
|
15
|
-
companion object {
|
|
16
|
-
internal var publishableKey: String? = null
|
|
17
|
-
internal const val TAG = "address_launcher_fragment"
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private lateinit var addressLauncher: AddressLauncher
|
|
21
|
-
private var configuration = AddressLauncher.Configuration()
|
|
22
|
-
private var callback: ((error: WritableMap?, address: AddressDetails?) -> Unit)? = null
|
|
23
|
-
|
|
24
|
-
override fun prepare() {
|
|
25
|
-
publishableKey?.let { publishableKey ->
|
|
26
|
-
addressLauncher =
|
|
27
|
-
AddressLauncher(this, ::onAddressLauncherResult).also {
|
|
28
|
-
it.present(publishableKey = publishableKey, configuration = configuration)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
?: run {
|
|
32
|
-
callback?.invoke(
|
|
33
|
-
createError(
|
|
34
|
-
ErrorType.Failed.toString(),
|
|
35
|
-
"No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.",
|
|
36
|
-
),
|
|
37
|
-
null,
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private fun onAddressLauncherResult(result: AddressLauncherResult) {
|
|
43
|
-
when (result) {
|
|
44
|
-
is AddressLauncherResult.Canceled -> {
|
|
45
|
-
callback?.invoke(
|
|
46
|
-
createError(ErrorType.Canceled.toString(), "The flow has been canceled."),
|
|
47
|
-
null,
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
is AddressLauncherResult.Succeeded -> {
|
|
51
|
-
callback?.invoke(null, result.address)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
fun presentAddressSheet(
|
|
57
|
-
context: ReactContext,
|
|
58
|
-
appearance: PaymentSheet.Appearance,
|
|
59
|
-
defaultAddress: AddressDetails?,
|
|
60
|
-
allowedCountries: Set<String>,
|
|
61
|
-
buttonTitle: String?,
|
|
62
|
-
title: String?,
|
|
63
|
-
googlePlacesApiKey: String?,
|
|
64
|
-
autocompleteCountries: Set<String>,
|
|
65
|
-
additionalFields: AddressLauncher.AdditionalFieldsConfiguration?,
|
|
66
|
-
callback: ((error: WritableMap?, address: AddressDetails?) -> Unit),
|
|
67
|
-
) {
|
|
68
|
-
configuration =
|
|
69
|
-
AddressLauncher.Configuration(
|
|
70
|
-
appearance = appearance,
|
|
71
|
-
address = defaultAddress,
|
|
72
|
-
allowedCountries = allowedCountries,
|
|
73
|
-
buttonTitle = buttonTitle,
|
|
74
|
-
additionalFields = additionalFields,
|
|
75
|
-
title = title,
|
|
76
|
-
googlePlacesApiKey = googlePlacesApiKey,
|
|
77
|
-
autocompleteCountries = autocompleteCountries,
|
|
78
|
-
)
|
|
79
|
-
this.callback = callback
|
|
80
|
-
(context.currentActivity as? FragmentActivity)?.let {
|
|
81
|
-
attemptToCleanupPreviousFragment(it)
|
|
82
|
-
commitFragmentAndStartFlow(it)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private fun attemptToCleanupPreviousFragment(currentActivity: FragmentActivity) {
|
|
87
|
-
currentActivity.supportFragmentManager
|
|
88
|
-
.beginTransaction()
|
|
89
|
-
.remove(this)
|
|
90
|
-
.commitAllowingStateLoss()
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private fun commitFragmentAndStartFlow(currentActivity: FragmentActivity) {
|
|
94
|
-
try {
|
|
95
|
-
currentActivity.supportFragmentManager
|
|
96
|
-
.beginTransaction()
|
|
97
|
-
.add(this, TAG)
|
|
98
|
-
.commit()
|
|
99
|
-
} catch (_: IllegalStateException) {
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
package com.reactnativestripesdk.utils
|
|
2
|
-
|
|
3
|
-
import android.os.Bundle
|
|
4
|
-
import android.view.LayoutInflater
|
|
5
|
-
import android.view.View
|
|
6
|
-
import android.view.ViewGroup
|
|
7
|
-
import android.widget.FrameLayout
|
|
8
|
-
import androidx.fragment.app.Fragment
|
|
9
|
-
import androidx.fragment.app.FragmentActivity
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Base fragment class to be used to launch Stripe UI that requires a fragment. Use the prepare
|
|
13
|
-
* method to configure it.
|
|
14
|
-
*
|
|
15
|
-
* Note that subclasses of this must implement a no arguments constructor since that is what is
|
|
16
|
-
* invoked when fragments are restored after activity re-creation.
|
|
17
|
-
*/
|
|
18
|
-
abstract class StripeFragment : Fragment() {
|
|
19
|
-
private var isRestored = false
|
|
20
|
-
|
|
21
|
-
override fun onCreate(savedInstanceState: Bundle?) {
|
|
22
|
-
super.onCreate(savedInstanceState)
|
|
23
|
-
|
|
24
|
-
isRestored = savedInstanceState != null
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
override fun onCreateView(
|
|
28
|
-
inflater: LayoutInflater,
|
|
29
|
-
container: ViewGroup?,
|
|
30
|
-
savedInstanceState: Bundle?,
|
|
31
|
-
): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
32
|
-
|
|
33
|
-
override fun onViewCreated(
|
|
34
|
-
view: View,
|
|
35
|
-
savedInstanceState: Bundle?,
|
|
36
|
-
) {
|
|
37
|
-
super.onViewCreated(view, savedInstanceState)
|
|
38
|
-
|
|
39
|
-
// Prevent fragment from being re-created.
|
|
40
|
-
if (isRestored) {
|
|
41
|
-
(context as? FragmentActivity)
|
|
42
|
-
?.supportFragmentManager
|
|
43
|
-
?.beginTransaction()
|
|
44
|
-
?.remove(this)
|
|
45
|
-
?.commitAllowingStateLoss()
|
|
46
|
-
} else {
|
|
47
|
-
prepare()
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
abstract fun prepare()
|
|
52
|
-
}
|