@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
|
@@ -2,12 +2,11 @@ package com.reactnativestripesdk
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.res.ColorStateList
|
|
5
|
-
import android.graphics.Color
|
|
6
5
|
import android.os.Build
|
|
7
6
|
import android.text.InputFilter
|
|
8
7
|
import android.view.View
|
|
9
|
-
import android.view.View.OnFocusChangeListener
|
|
10
8
|
import android.widget.FrameLayout
|
|
9
|
+
import androidx.core.graphics.toColorInt
|
|
11
10
|
import androidx.core.view.setMargins
|
|
12
11
|
import com.facebook.react.bridge.ReadableMap
|
|
13
12
|
import com.facebook.react.uimanager.PixelUtil
|
|
@@ -18,6 +17,7 @@ import com.google.android.material.shape.CornerFamily
|
|
|
18
17
|
import com.google.android.material.shape.MaterialShapeDrawable
|
|
19
18
|
import com.google.android.material.shape.ShapeAppearanceModel
|
|
20
19
|
import com.reactnativestripesdk.utils.PostalCodeUtilities
|
|
20
|
+
import com.reactnativestripesdk.utils.getIntOr
|
|
21
21
|
import com.reactnativestripesdk.utils.getIntOrNull
|
|
22
22
|
import com.reactnativestripesdk.utils.getValOr
|
|
23
23
|
import com.reactnativestripesdk.utils.hideSoftKeyboard
|
|
@@ -36,6 +36,7 @@ import com.stripe.android.view.CardInputListener
|
|
|
36
36
|
class CardFormView(
|
|
37
37
|
private val context: ThemedReactContext,
|
|
38
38
|
) : FrameLayout(context) {
|
|
39
|
+
@SuppressLint("PrivateResource")
|
|
39
40
|
private var cardForm: CardFormView =
|
|
40
41
|
CardFormView(context, null, com.stripe.android.R.style.StripeCardFormView_Borderless)
|
|
41
42
|
private var dangerouslyGetFullCardDetails: Boolean = false
|
|
@@ -77,7 +78,7 @@ class CardFormView(
|
|
|
77
78
|
cardForm.setPreferredNetworks(mapToPreferredNetworks(preferredNetworks))
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
@SuppressLint("RestrictedApi")
|
|
81
|
+
@SuppressLint("RestrictedApi", "VisibleForTests")
|
|
81
82
|
private fun setCountry(countryString: String?) {
|
|
82
83
|
if (countryString != null) {
|
|
83
84
|
cardFormViewBinding.countryLayout.setSelectedCountryCode(CountryCode(countryString))
|
|
@@ -126,27 +127,20 @@ class CardFormView(
|
|
|
126
127
|
cardNumberEditText.clearFocus()
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
fun requestClearFromJS() {
|
|
130
|
-
multilineWidgetBinding.etCardNumber.setText("")
|
|
131
|
-
multilineWidgetBinding.etCvc.setText("")
|
|
132
|
-
multilineWidgetBinding.etExpiry.setText("")
|
|
133
|
-
cardFormViewBinding.postalCode.setText("")
|
|
134
|
-
}
|
|
135
|
-
|
|
136
130
|
private fun onChangeFocus() {
|
|
137
131
|
UIManagerHelper
|
|
138
132
|
.getEventDispatcherForReactTag(context, id)
|
|
139
133
|
?.dispatchEvent(CardFocusChangeEvent(context.surfaceId, id, currentFocusedField))
|
|
140
134
|
}
|
|
141
135
|
|
|
142
|
-
@SuppressLint("RestrictedApi")
|
|
136
|
+
@SuppressLint("RestrictedApi", "VisibleForTests")
|
|
143
137
|
fun setCardStyle(value: ReadableMap?) {
|
|
144
138
|
val backgroundColor = getValOr(value, "backgroundColor", null)
|
|
145
139
|
val textColor = getValOr(value, "textColor", null)
|
|
146
|
-
val borderWidth = getIntOrNull(
|
|
140
|
+
val borderWidth = value.getIntOrNull("borderWidth")
|
|
147
141
|
val borderColor = getValOr(value, "borderColor", null)
|
|
148
|
-
val borderRadius =
|
|
149
|
-
val fontSize = getIntOrNull(
|
|
142
|
+
val borderRadius = value.getIntOr("borderRadius", 0)
|
|
143
|
+
val fontSize = value.getIntOrNull("fontSize")
|
|
150
144
|
val fontFamily = getValOr(value, "fontFamily")
|
|
151
145
|
val placeholderColor = getValOr(value, "placeholderColor", null)
|
|
152
146
|
val textErrorColor = getValOr(value, "textErrorColor", null)
|
|
@@ -169,19 +163,19 @@ class CardFormView(
|
|
|
169
163
|
|
|
170
164
|
textColor?.let {
|
|
171
165
|
for (binding in editTextBindings) {
|
|
172
|
-
binding.setTextColor(
|
|
166
|
+
binding.setTextColor(it.toColorInt())
|
|
173
167
|
}
|
|
174
|
-
cardFormViewBinding.countryLayout.countryAutocomplete.setTextColor(
|
|
168
|
+
cardFormViewBinding.countryLayout.countryAutocomplete.setTextColor(it.toColorInt())
|
|
175
169
|
}
|
|
176
170
|
textErrorColor?.let {
|
|
177
171
|
for (binding in editTextBindings) {
|
|
178
|
-
binding.setErrorColor(
|
|
179
|
-
cardFormViewBinding.postalCode.setErrorColor(
|
|
172
|
+
binding.setErrorColor(it.toColorInt())
|
|
173
|
+
cardFormViewBinding.postalCode.setErrorColor(it.toColorInt())
|
|
180
174
|
}
|
|
181
175
|
}
|
|
182
176
|
placeholderColor?.let {
|
|
183
177
|
for (binding in placeholderTextBindings) {
|
|
184
|
-
binding.defaultHintTextColor = ColorStateList.valueOf(
|
|
178
|
+
binding.defaultHintTextColor = ColorStateList.valueOf(it.toColorInt())
|
|
185
179
|
}
|
|
186
180
|
}
|
|
187
181
|
fontSize?.let {
|
|
@@ -205,7 +199,7 @@ class CardFormView(
|
|
|
205
199
|
}
|
|
206
200
|
cursorColor?.let {
|
|
207
201
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
208
|
-
val color =
|
|
202
|
+
val color = it.toColorInt()
|
|
209
203
|
for (binding in editTextBindings) {
|
|
210
204
|
binding.textCursorDrawable?.setTint(color)
|
|
211
205
|
binding.textSelectHandle?.setTint(color)
|
|
@@ -224,16 +218,16 @@ class CardFormView(
|
|
|
224
218
|
.build(),
|
|
225
219
|
).also { shape ->
|
|
226
220
|
shape.strokeWidth = 0.0f
|
|
227
|
-
shape.strokeColor = ColorStateList.valueOf(
|
|
228
|
-
shape.fillColor = ColorStateList.valueOf(
|
|
221
|
+
shape.strokeColor = ColorStateList.valueOf("#000000".toColorInt())
|
|
222
|
+
shape.fillColor = ColorStateList.valueOf("#FFFFFF".toColorInt())
|
|
229
223
|
borderWidth?.let {
|
|
230
224
|
shape.strokeWidth = PixelUtil.toPixelFromDIP(it.toDouble())
|
|
231
225
|
}
|
|
232
226
|
borderColor?.let {
|
|
233
|
-
shape.strokeColor = ColorStateList.valueOf(
|
|
227
|
+
shape.strokeColor = ColorStateList.valueOf(it.toColorInt())
|
|
234
228
|
}
|
|
235
229
|
backgroundColor?.let {
|
|
236
|
-
shape.fillColor = ColorStateList.valueOf(
|
|
230
|
+
shape.fillColor = ColorStateList.valueOf(it.toColorInt())
|
|
237
231
|
}
|
|
238
232
|
}
|
|
239
233
|
}
|
|
@@ -245,16 +239,18 @@ class CardFormView(
|
|
|
245
239
|
private fun setListeners() {
|
|
246
240
|
cardForm.setCardValidCallback { isValid, _ ->
|
|
247
241
|
if (isValid) {
|
|
248
|
-
cardForm.
|
|
242
|
+
cardForm.paymentMethodCreateParams?.let {
|
|
249
243
|
val cardParamsMap = it.toParamMap()["card"] as HashMap<*, *>
|
|
244
|
+
|
|
245
|
+
@SuppressLint("RestrictedApi")
|
|
250
246
|
val cardDetails: MutableMap<String, Any> =
|
|
251
247
|
mutableMapOf(
|
|
252
248
|
"expiryMonth" to cardParamsMap["exp_month"] as Int,
|
|
253
249
|
"expiryYear" to cardParamsMap["exp_year"] as Int,
|
|
254
|
-
"last4" to it.
|
|
255
|
-
"brand" to mapCardBrand(
|
|
256
|
-
"postalCode" to (it.address?.postalCode ?: ""),
|
|
257
|
-
"country" to (it.address?.country ?: ""),
|
|
250
|
+
"last4" to (it.cardLast4() ?: ""),
|
|
251
|
+
"brand" to mapCardBrand(cardForm.brand),
|
|
252
|
+
"postalCode" to (it.billingDetails?.address?.postalCode ?: ""),
|
|
253
|
+
"country" to (it.billingDetails?.address?.country ?: ""),
|
|
258
254
|
)
|
|
259
255
|
|
|
260
256
|
if (dangerouslyGetFullCardDetails) {
|
|
@@ -277,8 +273,8 @@ class CardFormView(
|
|
|
277
273
|
cardAddress =
|
|
278
274
|
Address
|
|
279
275
|
.Builder()
|
|
280
|
-
.setPostalCode(it.address?.postalCode)
|
|
281
|
-
.setCountry(it.address?.country)
|
|
276
|
+
.setPostalCode(it.billingDetails?.address?.postalCode)
|
|
277
|
+
.setCountry(it.billingDetails?.address?.country)
|
|
282
278
|
.build()
|
|
283
279
|
|
|
284
280
|
cardFormViewBinding.cardMultilineWidget.paymentMethodCard?.let { params ->
|
|
@@ -340,7 +336,7 @@ class CardFormView(
|
|
|
340
336
|
)
|
|
341
337
|
}
|
|
342
338
|
|
|
343
|
-
@SuppressLint("RestrictedApi")
|
|
339
|
+
@SuppressLint("RestrictedApi", "VisibleForTests")
|
|
344
340
|
private fun createPostalCodeInputFilter(): InputFilter {
|
|
345
341
|
return InputFilter { charSequence, start, end, _, _, _ ->
|
|
346
342
|
if (cardFormViewBinding.countryLayout.getSelectedCountryCode() == CountryCode.US) {
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import androidx.activity.ComponentActivity
|
|
4
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
6
|
import com.reactnativestripesdk.utils.ErrorType
|
|
6
|
-
import com.reactnativestripesdk.utils.
|
|
7
|
+
import com.reactnativestripesdk.utils.StripeUIManager
|
|
7
8
|
import com.reactnativestripesdk.utils.createError
|
|
8
9
|
import com.reactnativestripesdk.utils.createResult
|
|
9
10
|
import com.reactnativestripesdk.utils.mapFromFinancialConnectionsEvent
|
|
10
11
|
import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
|
|
11
12
|
import com.reactnativestripesdk.utils.mapFromSetupIntentResult
|
|
12
|
-
import com.
|
|
13
|
+
import com.stripe.android.core.reactnative.ReactNativeSdkInternal
|
|
13
14
|
import com.stripe.android.financialconnections.FinancialConnections
|
|
14
15
|
import com.stripe.android.model.PaymentIntent
|
|
15
16
|
import com.stripe.android.model.SetupIntent
|
|
@@ -18,18 +19,20 @@ import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
|
|
|
18
19
|
import com.stripe.android.payments.bankaccount.CollectBankAccountLauncher
|
|
19
20
|
import com.stripe.android.payments.bankaccount.navigation.CollectBankAccountResult
|
|
20
21
|
|
|
21
|
-
class
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
private
|
|
22
|
+
@OptIn(ReactNativeSdkInternal::class)
|
|
23
|
+
class CollectBankAccountLauncherManager(
|
|
24
|
+
context: ReactApplicationContext,
|
|
25
|
+
private val publishableKey: String,
|
|
26
|
+
private val stripeAccountId: String? = null,
|
|
27
|
+
private val clientSecret: String,
|
|
28
|
+
private val isPaymentIntent: Boolean,
|
|
29
|
+
private val collectParams: CollectBankAccountConfiguration.USBankAccount,
|
|
30
|
+
) : StripeUIManager(context) {
|
|
29
31
|
private lateinit var collectBankAccountLauncher: CollectBankAccountLauncher
|
|
30
32
|
|
|
31
|
-
override fun
|
|
32
|
-
|
|
33
|
+
override fun onPresent() {
|
|
34
|
+
val activity = getCurrentActivityOrResolveWithError(promise) ?: return
|
|
35
|
+
collectBankAccountLauncher = createBankAccountLauncher(activity)
|
|
33
36
|
|
|
34
37
|
val stripeSdkModule: StripeSdkModule? = context.getNativeModule(StripeSdkModule::class.java)
|
|
35
38
|
if (stripeSdkModule != null) {
|
|
@@ -63,17 +66,18 @@ class CollectBankAccountLauncherFragment : StripeFragment() {
|
|
|
63
66
|
FinancialConnections.clearEventListener()
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
private fun createBankAccountLauncher(): CollectBankAccountLauncher =
|
|
67
|
-
|
|
69
|
+
private fun createBankAccountLauncher(activity: ComponentActivity): CollectBankAccountLauncher =
|
|
70
|
+
@SuppressLint("RestrictedApi")
|
|
71
|
+
CollectBankAccountLauncher.create(activity, signal) { result ->
|
|
68
72
|
when (result) {
|
|
69
73
|
is CollectBankAccountResult.Completed -> {
|
|
70
74
|
val intent = result.response.intent
|
|
71
75
|
if (intent.status === StripeIntent.Status.RequiresPaymentMethod) {
|
|
72
|
-
promise
|
|
76
|
+
promise?.resolve(
|
|
73
77
|
createError(ErrorType.Canceled.toString(), "Bank account collection was canceled."),
|
|
74
78
|
)
|
|
75
79
|
} else if (intent.status === StripeIntent.Status.RequiresConfirmation) {
|
|
76
|
-
promise
|
|
80
|
+
promise?.resolve(
|
|
77
81
|
if (isPaymentIntent) {
|
|
78
82
|
createResult(
|
|
79
83
|
"paymentIntent",
|
|
@@ -87,39 +91,14 @@ class CollectBankAccountLauncherFragment : StripeFragment() {
|
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
is CollectBankAccountResult.Cancelled -> {
|
|
90
|
-
promise
|
|
94
|
+
promise?.resolve(
|
|
91
95
|
createError(ErrorType.Canceled.toString(), "Bank account collection was canceled."),
|
|
92
96
|
)
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
is CollectBankAccountResult.Failed -> {
|
|
96
|
-
promise
|
|
100
|
+
promise?.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
|
-
removeFragment(context)
|
|
100
103
|
}
|
|
101
|
-
|
|
102
|
-
companion object {
|
|
103
|
-
internal const val TAG = "collect_bank_account_launcher_fragment"
|
|
104
|
-
|
|
105
|
-
fun create(
|
|
106
|
-
context: ReactApplicationContext,
|
|
107
|
-
publishableKey: String,
|
|
108
|
-
stripeAccountId: String? = null,
|
|
109
|
-
clientSecret: String,
|
|
110
|
-
isPaymentIntent: Boolean,
|
|
111
|
-
collectParams: CollectBankAccountConfiguration.USBankAccount,
|
|
112
|
-
promise: Promise,
|
|
113
|
-
): CollectBankAccountLauncherFragment {
|
|
114
|
-
val instance = CollectBankAccountLauncherFragment()
|
|
115
|
-
instance.context = context
|
|
116
|
-
instance.publishableKey = publishableKey
|
|
117
|
-
instance.stripeAccountId = stripeAccountId
|
|
118
|
-
instance.clientSecret = clientSecret
|
|
119
|
-
instance.isPaymentIntent = isPaymentIntent
|
|
120
|
-
instance.collectParams = collectParams
|
|
121
|
-
instance.promise = promise
|
|
122
|
-
return instance
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
104
|
}
|
|
@@ -22,6 +22,7 @@ import java.lang.ref.WeakReference
|
|
|
22
22
|
class CustomPaymentMethodActivity : ReactActivity() {
|
|
23
23
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
24
24
|
// Disable the transition animation to make it truly invisible
|
|
25
|
+
@Suppress("DEPRECATION")
|
|
25
26
|
overridePendingTransition(0, 0)
|
|
26
27
|
super.onCreate(savedInstanceState)
|
|
27
28
|
}
|
|
@@ -53,6 +54,7 @@ class CustomPaymentMethodActivity : ReactActivity() {
|
|
|
53
54
|
override fun finish() {
|
|
54
55
|
super.finish()
|
|
55
56
|
// Disable the exit animation as well
|
|
57
|
+
@Suppress("DEPRECATION")
|
|
56
58
|
overridePendingTransition(0, 0)
|
|
57
59
|
|
|
58
60
|
// Clear the weak reference when finished
|
|
@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.requiredHeight
|
|
|
9
9
|
import androidx.compose.runtime.Composable
|
|
10
10
|
import androidx.compose.runtime.LaunchedEffect
|
|
11
11
|
import androidx.compose.runtime.getValue
|
|
12
|
-
import androidx.compose.runtime.mutableIntStateOf
|
|
13
12
|
import androidx.compose.runtime.mutableStateOf
|
|
14
13
|
import androidx.compose.runtime.remember
|
|
15
14
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
@@ -22,7 +21,6 @@ import androidx.compose.ui.unit.IntOffset
|
|
|
22
21
|
import androidx.compose.ui.unit.dp
|
|
23
22
|
import com.facebook.react.bridge.Arguments
|
|
24
23
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
25
|
-
import com.reactnativestripesdk.toWritableMap
|
|
26
24
|
import com.reactnativestripesdk.utils.KeepJsAwakeTask
|
|
27
25
|
import com.reactnativestripesdk.utils.mapFromConfirmationToken
|
|
28
26
|
import com.reactnativestripesdk.utils.mapFromCustomPaymentMethod
|
|
@@ -196,7 +194,7 @@ class EmbeddedPaymentElementView(
|
|
|
196
194
|
val stripeSdkModule =
|
|
197
195
|
try {
|
|
198
196
|
requireStripeSdkModule()
|
|
199
|
-
} catch (
|
|
197
|
+
} catch (_: IllegalArgumentException) {
|
|
200
198
|
return@Builder CreateIntentResult.Failure(
|
|
201
199
|
cause =
|
|
202
200
|
Exception(
|
|
@@ -242,7 +240,7 @@ class EmbeddedPaymentElementView(
|
|
|
242
240
|
val stripeSdkModule =
|
|
243
241
|
try {
|
|
244
242
|
requireStripeSdkModule()
|
|
245
|
-
} catch (
|
|
243
|
+
} catch (_: IllegalArgumentException) {
|
|
246
244
|
return@Builder CreateIntentResult.Failure(
|
|
247
245
|
cause =
|
|
248
246
|
Exception(
|
|
@@ -295,9 +293,6 @@ class EmbeddedPaymentElementView(
|
|
|
295
293
|
}
|
|
296
294
|
|
|
297
295
|
val embedded = rememberEmbeddedPaymentElement(builder)
|
|
298
|
-
var height by remember {
|
|
299
|
-
mutableIntStateOf(0)
|
|
300
|
-
}
|
|
301
296
|
|
|
302
297
|
// collect events: configure, confirm, clear
|
|
303
298
|
LaunchedEffect(Unit) {
|
|
@@ -348,10 +343,8 @@ class EmbeddedPaymentElementView(
|
|
|
348
343
|
}
|
|
349
344
|
}
|
|
350
345
|
|
|
351
|
-
val density = LocalDensity.current
|
|
352
|
-
|
|
353
346
|
Box {
|
|
354
|
-
|
|
347
|
+
MeasuredEmbeddedElement(
|
|
355
348
|
reportHeightChange = { h -> reportHeightChange(h) },
|
|
356
349
|
) {
|
|
357
350
|
embedded.Content()
|
|
@@ -360,7 +353,7 @@ class EmbeddedPaymentElementView(
|
|
|
360
353
|
}
|
|
361
354
|
|
|
362
355
|
@Composable
|
|
363
|
-
private fun
|
|
356
|
+
private fun MeasuredEmbeddedElement(
|
|
364
357
|
reportHeightChange: (Float) -> Unit,
|
|
365
358
|
content: @Composable () -> Unit,
|
|
366
359
|
) {
|
|
@@ -3,24 +3,22 @@ package com.reactnativestripesdk
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
5
|
import com.facebook.react.bridge.Dynamic
|
|
6
|
-
import com.facebook.react.bridge.ReadableArray
|
|
7
6
|
import com.facebook.react.bridge.ReadableMap
|
|
8
|
-
import com.facebook.react.bridge.ReadableType
|
|
9
7
|
import com.facebook.react.module.annotations.ReactModule
|
|
10
8
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
11
9
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
12
10
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
13
11
|
import com.facebook.react.viewmanagers.EmbeddedPaymentElementViewManagerDelegate
|
|
14
12
|
import com.facebook.react.viewmanagers.EmbeddedPaymentElementViewManagerInterface
|
|
15
|
-
import com.reactnativestripesdk.PaymentSheetFragment.Companion.buildCustomerConfiguration
|
|
16
|
-
import com.reactnativestripesdk.PaymentSheetFragment.Companion.buildGooglePayConfig
|
|
17
13
|
import com.reactnativestripesdk.addresssheet.AddressSheetView
|
|
18
14
|
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
19
15
|
import com.reactnativestripesdk.utils.PaymentSheetException
|
|
16
|
+
import com.reactnativestripesdk.utils.asMapOrNull
|
|
20
17
|
import com.reactnativestripesdk.utils.getBooleanOr
|
|
18
|
+
import com.reactnativestripesdk.utils.getIntegerList
|
|
19
|
+
import com.reactnativestripesdk.utils.getStringList
|
|
21
20
|
import com.reactnativestripesdk.utils.mapToPreferredNetworks
|
|
22
21
|
import com.reactnativestripesdk.utils.parseCustomPaymentMethods
|
|
23
|
-
import com.reactnativestripesdk.utils.toBundleObject
|
|
24
22
|
import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi
|
|
25
23
|
import com.stripe.android.paymentelement.EmbeddedPaymentElement
|
|
26
24
|
import com.stripe.android.paymentelement.ExperimentalCustomPaymentMethodsApi
|
|
@@ -55,10 +53,10 @@ class EmbeddedPaymentElementViewManager :
|
|
|
55
53
|
view: EmbeddedPaymentElementView,
|
|
56
54
|
cfg: Dynamic,
|
|
57
55
|
) {
|
|
58
|
-
val readableMap = cfg.
|
|
56
|
+
val readableMap = cfg.asMapOrNull()
|
|
59
57
|
if (readableMap == null) return
|
|
60
58
|
|
|
61
|
-
val rowSelectionBehaviorType =
|
|
59
|
+
val rowSelectionBehaviorType = mapToRowSelectionBehaviorType(readableMap)
|
|
62
60
|
view.rowSelectionBehaviorType.value = rowSelectionBehaviorType
|
|
63
61
|
|
|
64
62
|
val elementConfig = parseElementConfiguration(readableMap, view.context)
|
|
@@ -78,7 +76,7 @@ class EmbeddedPaymentElementViewManager :
|
|
|
78
76
|
view: EmbeddedPaymentElementView,
|
|
79
77
|
cfg: Dynamic,
|
|
80
78
|
) {
|
|
81
|
-
val readableMap = cfg.
|
|
79
|
+
val readableMap = cfg.asMapOrNull()
|
|
82
80
|
if (readableMap == null) return
|
|
83
81
|
|
|
84
82
|
// Detect which callback type to use based on the presence of the confirmation token handler
|
|
@@ -102,91 +100,43 @@ class EmbeddedPaymentElementViewManager :
|
|
|
102
100
|
context: Context,
|
|
103
101
|
): EmbeddedPaymentElement.Configuration {
|
|
104
102
|
val merchantDisplayName = map.getString("merchantDisplayName").orEmpty()
|
|
105
|
-
val allowsDelayedPaymentMethods
|
|
106
|
-
|
|
107
|
-
map.getType("allowsDelayedPaymentMethods") == ReadableType.Boolean
|
|
108
|
-
) {
|
|
109
|
-
map.getBoolean("allowsDelayedPaymentMethods")
|
|
110
|
-
} else {
|
|
111
|
-
false // default
|
|
112
|
-
}
|
|
113
|
-
var defaultBillingDetails: PaymentSheet.BillingDetails? = null
|
|
114
|
-
val billingDetailsMap = map.getMap("defaultBillingDetails")
|
|
115
|
-
if (billingDetailsMap != null) {
|
|
116
|
-
val addressBundle = billingDetailsMap.getMap("address")
|
|
117
|
-
val address =
|
|
118
|
-
PaymentSheet.Address(
|
|
119
|
-
addressBundle?.getString("city"),
|
|
120
|
-
addressBundle?.getString("country"),
|
|
121
|
-
addressBundle?.getString("line1"),
|
|
122
|
-
addressBundle?.getString("line2"),
|
|
123
|
-
addressBundle?.getString("postalCode"),
|
|
124
|
-
addressBundle?.getString("state"),
|
|
125
|
-
)
|
|
126
|
-
defaultBillingDetails =
|
|
127
|
-
PaymentSheet.BillingDetails(
|
|
128
|
-
address,
|
|
129
|
-
billingDetailsMap.getString("email"),
|
|
130
|
-
billingDetailsMap.getString("name"),
|
|
131
|
-
billingDetailsMap.getString("phone"),
|
|
132
|
-
)
|
|
133
|
-
}
|
|
103
|
+
val allowsDelayedPaymentMethods = map.getBooleanOr("allowsDelayedPaymentMethods", false)
|
|
104
|
+
val defaultBillingDetails = buildBillingDetails(map.getMap("defaultBillingDetails"))
|
|
134
105
|
|
|
135
106
|
val customerConfiguration =
|
|
136
107
|
try {
|
|
137
|
-
buildCustomerConfiguration(
|
|
138
|
-
} catch (
|
|
108
|
+
buildCustomerConfiguration(map)
|
|
109
|
+
} catch (_: PaymentSheetException) {
|
|
139
110
|
throw Error() // TODO handle error
|
|
140
111
|
}
|
|
141
112
|
|
|
142
|
-
val googlePayConfig = buildGooglePayConfig(
|
|
143
|
-
val linkConfig =
|
|
113
|
+
val googlePayConfig = buildGooglePayConfig(map.getMap("googlePay"))
|
|
114
|
+
val linkConfig = buildLinkConfig(map.getMap("link"))
|
|
144
115
|
val shippingDetails =
|
|
145
116
|
map.getMap("defaultShippingDetails")?.let {
|
|
146
117
|
AddressSheetView.buildAddressDetails(it)
|
|
147
118
|
}
|
|
148
119
|
val appearance =
|
|
149
120
|
try {
|
|
150
|
-
buildPaymentSheetAppearance(
|
|
151
|
-
} catch (
|
|
121
|
+
buildPaymentSheetAppearance(map.getMap("appearance"), context)
|
|
122
|
+
} catch (_: PaymentSheetAppearanceException) {
|
|
152
123
|
throw Error() // TODO handle error
|
|
153
124
|
}
|
|
154
|
-
val billingConfigParams = map.getMap("billingDetailsCollectionConfiguration")
|
|
155
125
|
val billingDetailsConfig =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
phone = mapToCollectionMode(billingConfigParams?.getString("phone")),
|
|
159
|
-
email = mapToCollectionMode(billingConfigParams?.getString("email")),
|
|
160
|
-
address = mapToAddressCollectionMode(billingConfigParams?.getString("address")),
|
|
161
|
-
attachDefaultsToPaymentMethod =
|
|
162
|
-
billingConfigParams?.getBooleanOr("attachDefaultsToPaymentMethod", false) ?: false,
|
|
126
|
+
buildBillingDetailsCollectionConfiguration(
|
|
127
|
+
map.getMap("billingDetailsCollectionConfiguration"),
|
|
163
128
|
)
|
|
164
|
-
val allowsRemovalOfLastSavedPaymentMethod =
|
|
165
|
-
if (map.hasKey("allowsRemovalOfLastSavedPaymentMethod")) {
|
|
166
|
-
map.getBoolean("allowsRemovalOfLastSavedPaymentMethod")
|
|
167
|
-
} else {
|
|
168
|
-
true
|
|
169
|
-
}
|
|
129
|
+
val allowsRemovalOfLastSavedPaymentMethod = map.getBooleanOr("allowsRemovalOfLastSavedPaymentMethod", true)
|
|
170
130
|
val primaryButtonLabel = map.getString("primaryButtonLabel")
|
|
171
|
-
val paymentMethodOrder = map.
|
|
131
|
+
val paymentMethodOrder = map.getStringList("paymentMethodOrder")
|
|
172
132
|
|
|
173
|
-
val formSheetAction =
|
|
174
|
-
map
|
|
175
|
-
.getMap("formSheetAction")
|
|
176
|
-
?.getString("type")
|
|
177
|
-
?.let { type ->
|
|
178
|
-
when (type) {
|
|
179
|
-
"confirm" -> EmbeddedPaymentElement.FormSheetAction.Confirm
|
|
180
|
-
else -> EmbeddedPaymentElement.FormSheetAction.Continue
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
?: EmbeddedPaymentElement.FormSheetAction.Continue
|
|
133
|
+
val formSheetAction = mapToFormSheetAction(map)
|
|
184
134
|
|
|
185
135
|
val configurationBuilder =
|
|
186
136
|
EmbeddedPaymentElement.Configuration
|
|
187
137
|
.Builder(merchantDisplayName)
|
|
188
138
|
.formSheetAction(formSheetAction)
|
|
189
|
-
.allowsDelayedPaymentMethods(allowsDelayedPaymentMethods
|
|
139
|
+
.allowsDelayedPaymentMethods(allowsDelayedPaymentMethods)
|
|
190
140
|
.defaultBillingDetails(defaultBillingDetails)
|
|
191
141
|
.customer(customerConfiguration)
|
|
192
142
|
.googlePay(googlePayConfig)
|
|
@@ -197,28 +147,16 @@ class EmbeddedPaymentElementViewManager :
|
|
|
197
147
|
.preferredNetworks(
|
|
198
148
|
mapToPreferredNetworks(
|
|
199
149
|
map
|
|
200
|
-
.
|
|
150
|
+
.getIntegerList("preferredNetworks")
|
|
201
151
|
?.let { ArrayList(it) },
|
|
202
152
|
),
|
|
203
153
|
).allowsRemovalOfLastSavedPaymentMethod(allowsRemovalOfLastSavedPaymentMethod)
|
|
204
|
-
.cardBrandAcceptance(mapToCardBrandAcceptance(
|
|
154
|
+
.cardBrandAcceptance(mapToCardBrandAcceptance(map))
|
|
205
155
|
.embeddedViewDisplaysMandateText(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
) {
|
|
209
|
-
map.getBoolean("embeddedViewDisplaysMandateText")
|
|
210
|
-
} else {
|
|
211
|
-
true // default value
|
|
212
|
-
},
|
|
213
|
-
)
|
|
214
|
-
// Serialize original ReadableMap because toBundleObject cannot keep arrays of objects
|
|
215
|
-
.customPaymentMethods(
|
|
156
|
+
map.getBooleanOr("embeddedViewDisplaysMandateText", true),
|
|
157
|
+
).customPaymentMethods(
|
|
216
158
|
parseCustomPaymentMethods(
|
|
217
|
-
|
|
218
|
-
map.getMap("customPaymentMethodConfiguration")?.let { readable ->
|
|
219
|
-
putSerializable("customPaymentMethodConfigurationReadableMap", readable.toHashMap())
|
|
220
|
-
}
|
|
221
|
-
},
|
|
159
|
+
map.getMap("customPaymentMethodConfiguration"),
|
|
222
160
|
),
|
|
223
161
|
)
|
|
224
162
|
|
|
@@ -228,23 +166,8 @@ class EmbeddedPaymentElementViewManager :
|
|
|
228
166
|
return configurationBuilder.build()
|
|
229
167
|
}
|
|
230
168
|
|
|
231
|
-
private fun parseRowSelectionBehavior(map: ReadableMap): RowSelectionBehaviorType {
|
|
232
|
-
val rowSelectionBehavior =
|
|
233
|
-
map
|
|
234
|
-
.getMap("rowSelectionBehavior")
|
|
235
|
-
?.getString("type")
|
|
236
|
-
?.let { type ->
|
|
237
|
-
when (type) {
|
|
238
|
-
"immediateAction" -> RowSelectionBehaviorType.ImmediateAction
|
|
239
|
-
else -> RowSelectionBehaviorType.Default
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
?: RowSelectionBehaviorType.Default
|
|
243
|
-
return rowSelectionBehavior
|
|
244
|
-
}
|
|
245
|
-
|
|
246
169
|
private fun parseIntentConfiguration(map: ReadableMap): PaymentSheet.IntentConfiguration {
|
|
247
|
-
val intentConfig =
|
|
170
|
+
val intentConfig = buildIntentConfiguration(map)
|
|
248
171
|
return intentConfig ?: throw IllegalArgumentException("IntentConfiguration is null")
|
|
249
172
|
}
|
|
250
173
|
|
|
@@ -257,35 +180,32 @@ class EmbeddedPaymentElementViewManager :
|
|
|
257
180
|
}
|
|
258
181
|
}
|
|
259
182
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return
|
|
183
|
+
internal fun mapToRowSelectionBehaviorType(map: ReadableMap?): RowSelectionBehaviorType {
|
|
184
|
+
val rowSelectionBehavior =
|
|
185
|
+
map
|
|
186
|
+
?.getMap("rowSelectionBehavior")
|
|
187
|
+
?.getString("type")
|
|
188
|
+
?.let { type ->
|
|
189
|
+
when (type) {
|
|
190
|
+
"immediateAction" -> RowSelectionBehaviorType.ImmediateAction
|
|
191
|
+
else -> RowSelectionBehaviorType.Default
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
?: RowSelectionBehaviorType.Default
|
|
195
|
+
return rowSelectionBehavior
|
|
273
196
|
}
|
|
274
197
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return result
|
|
198
|
+
internal fun mapToFormSheetAction(map: ReadableMap?): EmbeddedPaymentElement.FormSheetAction {
|
|
199
|
+
val formSheetAction =
|
|
200
|
+
map
|
|
201
|
+
?.getMap("formSheetAction")
|
|
202
|
+
?.getString("type")
|
|
203
|
+
?.let { type ->
|
|
204
|
+
when (type) {
|
|
205
|
+
"confirm" -> EmbeddedPaymentElement.FormSheetAction.Confirm
|
|
206
|
+
else -> EmbeddedPaymentElement.FormSheetAction.Continue
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
?: EmbeddedPaymentElement.FormSheetAction.Continue
|
|
210
|
+
return formSheetAction
|
|
291
211
|
}
|
|
@@ -32,10 +32,6 @@ class EventEmitterCompat(
|
|
|
32
32
|
invoke("onFinancialConnectionsEvent", value)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
fun emitOnOrderTrackingCallback() {
|
|
36
|
-
invoke("onOrderTrackingCallback")
|
|
37
|
-
}
|
|
38
|
-
|
|
39
35
|
fun emitOnCustomerAdapterFetchPaymentMethodsCallback() {
|
|
40
36
|
invoke("onCustomerAdapterFetchPaymentMethodsCallback")
|
|
41
37
|
}
|
|
@@ -72,10 +68,6 @@ class EventEmitterCompat(
|
|
|
72
68
|
invoke("embeddedPaymentElementDidUpdateHeight", value)
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
fun emitEmbeddedPaymentElementWillPresent() {
|
|
76
|
-
invoke("embeddedPaymentElementWillPresent")
|
|
77
|
-
}
|
|
78
|
-
|
|
79
71
|
fun emitEmbeddedPaymentElementDidUpdatePaymentOption(value: ReadableMap?) {
|
|
80
72
|
invoke("embeddedPaymentElementDidUpdatePaymentOption", value)
|
|
81
73
|
}
|