@stripe/stripe-react-native 0.57.0 → 0.57.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -8
- package/android/.idea/AndroidProjectSystem.xml +6 -0
- package/android/.idea/caches/deviceStreaming.xml +1029 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +19 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/runConfigurations.xml +17 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +76 -118
- package/android/gradle.properties +1 -1
- package/android/local.properties +8 -0
- package/android/settings.gradle +2 -0
- package/android/spotless.gradle +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +20 -17
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +13 -11
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +17 -21
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherManager.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +53 -11
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +105 -117
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -8
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetManager.kt +13 -15
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +7 -5
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarManager.kt +31 -0
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +120 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +228 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherManager.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +73 -30
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +19 -245
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +52 -14
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +15 -35
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +5 -10
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +90 -77
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +6 -4
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +13 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +41 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +92 -44
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +3 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +2 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +118 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +922 -0
- package/android/src/test/java/com/facebook/testutils/shadows/ShadowArguments.kt +29 -0
- package/android/src/test/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManagerTest.kt +163 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +976 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetAppearanceTest.kt +801 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +523 -0
- package/android/src/test/java/com/reactnativestripesdk/addresssheet/AddressSheetViewTest.kt +551 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +567 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +456 -0
- package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +43 -0
- package/android/src/test/resources/robolectric.properties +2 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +3 -3
- package/ios/AddressSheet/AddressSheetView.swift +25 -25
- package/ios/AddressSheet/AddressSheetViewManager.swift +2 -2
- package/ios/ApplePayButtonManager.swift +1 -1
- package/ios/ApplePayButtonView.swift +9 -10
- package/ios/ApplePayUtils.swift +51 -51
- package/ios/ApplePayViewController.swift +25 -29
- package/ios/AuBECSDebitFormManager.swift +1 -1
- package/ios/AuBECSDebitFormView.swift +13 -15
- package/ios/CardFieldManager.swift +4 -4
- package/ios/CardFieldView.swift +9 -9
- package/ios/CardFormManager.swift +3 -3
- package/ios/CardFormView.swift +28 -28
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +97 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +133 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.m +16 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.swift +17 -0
- package/ios/CustomerSheet/CustomerSheetUtils.swift +15 -16
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +19 -19
- package/ios/EmbeddedPaymentElementView.swift +2 -2
- package/ios/Errors.swift +22 -23
- package/ios/FinancialConnections.swift +37 -37
- package/ios/Mappers.swift +210 -71
- package/ios/NavigationBarManager.m +13 -0
- package/ios/NavigationBarManager.swift +17 -0
- package/ios/NavigationBarView.swift +65 -0
- package/ios/NewArch/NavigationBarComponentView.h +10 -0
- package/ios/NewArch/NavigationBarComponentView.mm +86 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +7 -1
- package/ios/PaymentMethodFactory.swift +24 -24
- package/ios/PaymentOptionDisplayData+ReactNative.swift +4 -4
- package/ios/PaymentPassFinder.swift +9 -10
- package/ios/PaymentSheetAppearance.swift +137 -138
- package/ios/PushProvisioning/AddToWalletButtonManager.swift +2 -2
- package/ios/PushProvisioning/AddToWalletButtonView.swift +15 -17
- package/ios/PushProvisioning/PushProvisioningUtils.swift +11 -11
- package/ios/StripeContainerManager.swift +1 -1
- package/ios/StripeContainerView.swift +3 -3
- package/ios/StripeOnrampSdk.h +17 -0
- package/ios/StripeOnrampSdk.mm +158 -0
- package/ios/StripeSdk.mm +8 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcuserdata/tianzhao.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/StripeSdk.xcodeproj/xcuserdata/tianzhao.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/ios/StripeSdkEmitter.swift +4 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +30 -25
- package/ios/StripeSdkImpl+Embedded.swift +11 -9
- package/ios/StripeSdkImpl+PaymentSheet.swift +36 -34
- package/ios/StripeSdkImpl.swift +913 -185
- package/ios/UIColorExtension.swift +72 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/connect/Components.js +2 -0
- package/lib/commonjs/connect/Components.js.map +1 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js +2 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/commonjs/connect/EmbeddedComponent.js +19 -0
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -0
- package/lib/commonjs/connect/ModalCloseButton.js +2 -0
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -0
- package/lib/commonjs/connect/NavigationBar.js +2 -0
- package/lib/commonjs/connect/NavigationBar.js.map +1 -0
- package/lib/commonjs/connect/connectTypes.js +2 -0
- package/lib/commonjs/connect/connectTypes.js.map +1 -0
- package/lib/commonjs/events.js +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +2 -0
- package/lib/commonjs/hooks/useOnramp.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +2 -0
- package/lib/commonjs/specs/NativeNavigationBar.js.map +1 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/Onramp.js +2 -0
- package/lib/commonjs/types/Onramp.js.map +1 -0
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/connect/Components.js +2 -0
- package/lib/module/connect/Components.js.map +1 -0
- package/lib/module/connect/ConnectComponentsProvider.js +2 -0
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/module/connect/EmbeddedComponent.js +19 -0
- package/lib/module/connect/EmbeddedComponent.js.map +1 -0
- package/lib/module/connect/ModalCloseButton.js +2 -0
- package/lib/module/connect/ModalCloseButton.js.map +1 -0
- package/lib/module/connect/NavigationBar.js +2 -0
- package/lib/module/connect/NavigationBar.js.map +1 -0
- package/lib/module/connect/connectTypes.js +2 -0
- package/lib/module/connect/connectTypes.js.map +1 -0
- package/lib/module/events.js +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +2 -0
- package/lib/module/hooks/useOnramp.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js.map +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js.map +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/module/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/module/specs/NativeNavigationBar.js +2 -0
- package/lib/module/specs/NativeNavigationBar.js.map +1 -0
- package/lib/module/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/Onramp.js +2 -0
- package/lib/module/types/Onramp.js.map +1 -0
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
- package/lib/typescript/src/connect/Components.d.ts +23 -0
- package/lib/typescript/src/connect/Components.d.ts.map +1 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +22 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts +18 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts +7 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts.map +1 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts +8 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/connect/connectTypes.d.ts +464 -0
- package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +4 -0
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/helpers.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +158 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugin/withStripe.d.ts +15 -0
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts +14 -0
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts +11 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +28 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +5 -0
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +275 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +7 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +25 -14
- package/src/components/StripeProvider.tsx +5 -0
- package/src/connect/Components.tsx +279 -0
- package/src/connect/ConnectComponentsProvider.tsx +93 -0
- package/src/connect/EmbeddedComponent.tsx +407 -0
- package/src/connect/ModalCloseButton.tsx +44 -0
- package/src/connect/NavigationBar.tsx +29 -0
- package/src/connect/connectTypes.ts +626 -0
- package/src/events.ts +23 -0
- package/src/hooks/useOnramp.tsx +334 -0
- package/src/index.tsx +13 -0
- package/src/plugin/withStripe.ts +104 -7
- package/src/specs/NativeConnectAccountOnboardingView.ts +19 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +5 -1
- package/src/specs/NativeNavigationBar.ts +16 -0
- package/src/specs/NativeOnrampSdkModule.ts +47 -0
- package/src/specs/NativeStripeSdkModule.ts +5 -0
- package/src/types/EmbeddedPaymentElement.tsx +24 -3
- package/src/types/Errors.ts +6 -0
- package/src/types/Onramp.ts +317 -0
- package/src/types/PaymentSheet.ts +7 -0
- package/src/types/index.ts +8 -0
- package/stripe-react-native.podspec +20 -7
package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
package com.reactnativestripesdk.mappers
|
|
2
|
+
|
|
3
|
+
import androidx.compose.ui.graphics.Color
|
|
4
|
+
import androidx.compose.ui.text.AnnotatedString
|
|
5
|
+
import androidx.compose.ui.text.LinkAnnotation
|
|
6
|
+
import androidx.compose.ui.text.SpanStyle
|
|
7
|
+
import androidx.compose.ui.text.buildAnnotatedString
|
|
8
|
+
import androidx.compose.ui.text.font.FontStyle
|
|
9
|
+
import androidx.compose.ui.text.font.FontWeight
|
|
10
|
+
import androidx.compose.ui.text.style.TextDecoration
|
|
11
|
+
import androidx.compose.ui.text.withStyle
|
|
12
|
+
import androidx.compose.ui.unit.sp
|
|
13
|
+
import com.reactnativestripesdk.toHtmlString
|
|
14
|
+
import org.junit.Assert
|
|
15
|
+
import org.junit.Test
|
|
16
|
+
import org.junit.runner.RunWith
|
|
17
|
+
import org.robolectric.RobolectricTestRunner
|
|
18
|
+
|
|
19
|
+
@RunWith(RobolectricTestRunner::class)
|
|
20
|
+
class PaymentOptionDisplayDataMapperTest {
|
|
21
|
+
@Test
|
|
22
|
+
fun toHtmlString_PlainText() {
|
|
23
|
+
val annotatedString = AnnotatedString("Simple text")
|
|
24
|
+
val result = annotatedString.toHtmlString()
|
|
25
|
+
|
|
26
|
+
Assert.assertEquals("Simple text", result)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Test
|
|
30
|
+
fun toHtmlString_EmptyString() {
|
|
31
|
+
val annotatedString = AnnotatedString("")
|
|
32
|
+
val result = annotatedString.toHtmlString()
|
|
33
|
+
|
|
34
|
+
Assert.assertEquals("", result)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Test
|
|
38
|
+
fun toHtmlString_PreservesLinks() {
|
|
39
|
+
val annotatedString =
|
|
40
|
+
buildAnnotatedString {
|
|
41
|
+
append("By continuing, you agree to our ")
|
|
42
|
+
pushStringAnnotation("URL", "https://stripe.com/privacy")
|
|
43
|
+
append("Privacy Policy")
|
|
44
|
+
pop()
|
|
45
|
+
append(" and ")
|
|
46
|
+
pushStringAnnotation("URL", "https://stripe.com/terms")
|
|
47
|
+
append("Terms of Service")
|
|
48
|
+
pop()
|
|
49
|
+
append(".")
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
val result = annotatedString.toHtmlString()
|
|
53
|
+
|
|
54
|
+
Assert.assertEquals(
|
|
55
|
+
"By continuing, you agree to our <a href=\"https://stripe.com/privacy\">Privacy Policy</a> and <a href=\"https://stripe.com/terms\">Terms of Service</a>.",
|
|
56
|
+
result,
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Test
|
|
61
|
+
fun toHtmlString_BoldText() {
|
|
62
|
+
val annotatedString =
|
|
63
|
+
buildAnnotatedString {
|
|
64
|
+
append("Normal text ")
|
|
65
|
+
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
|
|
66
|
+
append("bold text")
|
|
67
|
+
}
|
|
68
|
+
append(" normal again")
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
val result = annotatedString.toHtmlString()
|
|
72
|
+
|
|
73
|
+
Assert.assertEquals(
|
|
74
|
+
"Normal text <b>bold text</b> normal again",
|
|
75
|
+
result,
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Test
|
|
80
|
+
fun toHtmlString_BoldTextWithCustomWeight() {
|
|
81
|
+
val annotatedString =
|
|
82
|
+
buildAnnotatedString {
|
|
83
|
+
append("Normal ")
|
|
84
|
+
withStyle(SpanStyle(fontWeight = FontWeight.W700)) {
|
|
85
|
+
append("bold")
|
|
86
|
+
}
|
|
87
|
+
append(" text")
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
val result = annotatedString.toHtmlString()
|
|
91
|
+
|
|
92
|
+
Assert.assertEquals(
|
|
93
|
+
"Normal <b>bold</b> text",
|
|
94
|
+
result,
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@Test
|
|
99
|
+
fun toHtmlString_ItalicText() {
|
|
100
|
+
val annotatedString =
|
|
101
|
+
buildAnnotatedString {
|
|
102
|
+
append("Normal text ")
|
|
103
|
+
withStyle(SpanStyle(fontStyle = FontStyle.Italic)) {
|
|
104
|
+
append("italic text")
|
|
105
|
+
}
|
|
106
|
+
append(" normal again")
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
val result = annotatedString.toHtmlString()
|
|
110
|
+
|
|
111
|
+
Assert.assertEquals(
|
|
112
|
+
"Normal text <i>italic text</i> normal again",
|
|
113
|
+
result,
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Test
|
|
118
|
+
fun toHtmlString_ColoredText() {
|
|
119
|
+
val annotatedString =
|
|
120
|
+
buildAnnotatedString {
|
|
121
|
+
append("Normal text ")
|
|
122
|
+
withStyle(SpanStyle(color = Color.Red)) {
|
|
123
|
+
append("red text")
|
|
124
|
+
}
|
|
125
|
+
append(" normal again")
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
val result = annotatedString.toHtmlString()
|
|
129
|
+
|
|
130
|
+
Assert.assertEquals(
|
|
131
|
+
"Normal text <font color=\"#FF0000\">red text</font> normal again",
|
|
132
|
+
result,
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@Test
|
|
137
|
+
fun toHtmlString_FontSizeText() {
|
|
138
|
+
val annotatedString =
|
|
139
|
+
buildAnnotatedString {
|
|
140
|
+
append("Normal text ")
|
|
141
|
+
withStyle(SpanStyle(fontSize = 24.sp)) {
|
|
142
|
+
append("large text")
|
|
143
|
+
}
|
|
144
|
+
append(" normal again")
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
val result = annotatedString.toHtmlString()
|
|
148
|
+
|
|
149
|
+
Assert.assertEquals(
|
|
150
|
+
"Normal text <span style=\"font-size: 1.5em;\">large text</span> normal again",
|
|
151
|
+
result,
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@Test
|
|
156
|
+
fun toHtmlString_CombinedFormatting() {
|
|
157
|
+
val annotatedString =
|
|
158
|
+
buildAnnotatedString {
|
|
159
|
+
append("Start ")
|
|
160
|
+
withStyle(
|
|
161
|
+
SpanStyle(
|
|
162
|
+
fontWeight = FontWeight.Bold,
|
|
163
|
+
fontStyle = FontStyle.Italic,
|
|
164
|
+
color = Color.Blue,
|
|
165
|
+
),
|
|
166
|
+
) {
|
|
167
|
+
append("bold italic blue")
|
|
168
|
+
}
|
|
169
|
+
append(" end")
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
val result = annotatedString.toHtmlString()
|
|
173
|
+
|
|
174
|
+
Assert.assertEquals(
|
|
175
|
+
"Start <b><i><font color=\"#0000FF\">bold italic blue</font></i></b> end",
|
|
176
|
+
result,
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@Test
|
|
181
|
+
fun toHtmlString_LinksWithFormatting() {
|
|
182
|
+
val annotatedString =
|
|
183
|
+
buildAnnotatedString {
|
|
184
|
+
append("Visit our ")
|
|
185
|
+
pushStringAnnotation("URL", "https://stripe.com/privacy")
|
|
186
|
+
withStyle(SpanStyle(fontWeight = FontWeight.Bold, color = Color.Blue)) {
|
|
187
|
+
append("Privacy Policy")
|
|
188
|
+
}
|
|
189
|
+
pop()
|
|
190
|
+
append(" for details")
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
val result = annotatedString.toHtmlString()
|
|
194
|
+
|
|
195
|
+
Assert.assertEquals(
|
|
196
|
+
"Visit our <b><font color=\"#0000FF\"><a href=\"https://stripe.com/privacy\">Privacy Policy</a></font></b> for details",
|
|
197
|
+
result,
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
@Test
|
|
202
|
+
fun toHtmlString_HtmlEscaping() {
|
|
203
|
+
val annotatedString = AnnotatedString("Text with <tags> & \"quotes\" and 'apostrophes'")
|
|
204
|
+
val result = annotatedString.toHtmlString()
|
|
205
|
+
|
|
206
|
+
Assert.assertEquals(
|
|
207
|
+
"Text with <tags> & "quotes" and 'apostrophes'",
|
|
208
|
+
result,
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
@Test
|
|
213
|
+
fun toHtmlString_HtmlEscapingInLinks() {
|
|
214
|
+
val annotatedString =
|
|
215
|
+
buildAnnotatedString {
|
|
216
|
+
pushStringAnnotation("URL", "https://example.com/search?q=test&foo=bar")
|
|
217
|
+
append("Link with & in URL")
|
|
218
|
+
pop()
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
val result = annotatedString.toHtmlString()
|
|
222
|
+
|
|
223
|
+
Assert.assertEquals(
|
|
224
|
+
"<a href=\"https://example.com/search?q=test&foo=bar\">Link with & in URL</a>",
|
|
225
|
+
result,
|
|
226
|
+
)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@Test
|
|
230
|
+
fun toHtmlString_NestedAnnotations() {
|
|
231
|
+
val annotatedString =
|
|
232
|
+
buildAnnotatedString {
|
|
233
|
+
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
|
|
234
|
+
append("Bold text with ")
|
|
235
|
+
withStyle(SpanStyle(fontStyle = FontStyle.Italic)) {
|
|
236
|
+
append("nested italic")
|
|
237
|
+
}
|
|
238
|
+
append(" continues")
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
val result = annotatedString.toHtmlString()
|
|
243
|
+
|
|
244
|
+
Assert.assertEquals(
|
|
245
|
+
"<b>Bold text with <i>nested italic</i> continues</b>",
|
|
246
|
+
result,
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@Test
|
|
251
|
+
fun toHtmlString_OverlappingAnnotations() {
|
|
252
|
+
val annotatedString =
|
|
253
|
+
buildAnnotatedString {
|
|
254
|
+
append("Start ")
|
|
255
|
+
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
|
|
256
|
+
append("bold ")
|
|
257
|
+
withStyle(SpanStyle(fontStyle = FontStyle.Italic)) {
|
|
258
|
+
append("and italic")
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
withStyle(SpanStyle(fontStyle = FontStyle.Italic)) {
|
|
262
|
+
append(" continues italic")
|
|
263
|
+
}
|
|
264
|
+
append(" end")
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
val result = annotatedString.toHtmlString()
|
|
268
|
+
|
|
269
|
+
Assert.assertEquals(
|
|
270
|
+
"Start <b>bold <i>and italic</i></b><i> continues italic</i> end",
|
|
271
|
+
result,
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
@Test
|
|
276
|
+
fun toHtmlString_MultipleLinksWithFormatting() {
|
|
277
|
+
val annotatedString =
|
|
278
|
+
buildAnnotatedString {
|
|
279
|
+
append("Check ")
|
|
280
|
+
pushLink(LinkAnnotation.Url("https://stripe.com"))
|
|
281
|
+
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
|
|
282
|
+
append("Stripe")
|
|
283
|
+
}
|
|
284
|
+
pop()
|
|
285
|
+
append(" and ")
|
|
286
|
+
pushLink(LinkAnnotation.Url("https://github.com"))
|
|
287
|
+
withStyle(SpanStyle(fontStyle = FontStyle.Italic, color = Color.Green)) {
|
|
288
|
+
append("GitHub")
|
|
289
|
+
}
|
|
290
|
+
pop()
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
val result = annotatedString.toHtmlString()
|
|
294
|
+
|
|
295
|
+
Assert.assertEquals(
|
|
296
|
+
"Check <b><a href=\"https://stripe.com\">Stripe</a></b> and <i><font color=\"#00FF00\"><a href=\"https://github.com\">GitHub</a></font></i>",
|
|
297
|
+
result,
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
@Test
|
|
302
|
+
fun toHtmlString_SpecialCharactersInFormattedText() {
|
|
303
|
+
val annotatedString =
|
|
304
|
+
buildAnnotatedString {
|
|
305
|
+
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
|
|
306
|
+
append("<b>Already bold</b> & \"quoted\"")
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
val result = annotatedString.toHtmlString()
|
|
311
|
+
|
|
312
|
+
Assert.assertEquals(
|
|
313
|
+
"<b><b>Already bold</b> & "quoted"</b>",
|
|
314
|
+
result,
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
@Test
|
|
319
|
+
fun toHtmlString_UnderlineTextDecoration() {
|
|
320
|
+
val annotatedString =
|
|
321
|
+
buildAnnotatedString {
|
|
322
|
+
append("This text is ")
|
|
323
|
+
withStyle(SpanStyle(textDecoration = TextDecoration.Underline)) {
|
|
324
|
+
append("underlined")
|
|
325
|
+
}
|
|
326
|
+
append(".")
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
val result = annotatedString.toHtmlString()
|
|
330
|
+
|
|
331
|
+
Assert.assertEquals(
|
|
332
|
+
"This text is <u>underlined</u>.",
|
|
333
|
+
result,
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
@Test
|
|
338
|
+
fun toHtmlString_StrikethroughTextDecoration() {
|
|
339
|
+
val annotatedString =
|
|
340
|
+
buildAnnotatedString {
|
|
341
|
+
append("This text is ")
|
|
342
|
+
withStyle(SpanStyle(textDecoration = TextDecoration.LineThrough)) {
|
|
343
|
+
append("crossed out")
|
|
344
|
+
}
|
|
345
|
+
append(".")
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
val result = annotatedString.toHtmlString()
|
|
349
|
+
|
|
350
|
+
Assert.assertEquals(
|
|
351
|
+
"This text is <s>crossed out</s>.",
|
|
352
|
+
result,
|
|
353
|
+
)
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
@Test
|
|
357
|
+
fun toHtmlString_CombinedTextDecorations() {
|
|
358
|
+
val annotatedString =
|
|
359
|
+
buildAnnotatedString {
|
|
360
|
+
append("This text is ")
|
|
361
|
+
withStyle(
|
|
362
|
+
SpanStyle(
|
|
363
|
+
textDecoration =
|
|
364
|
+
TextDecoration.combine(
|
|
365
|
+
listOf(TextDecoration.Underline, TextDecoration.LineThrough),
|
|
366
|
+
),
|
|
367
|
+
),
|
|
368
|
+
) {
|
|
369
|
+
append("both underlined and crossed")
|
|
370
|
+
}
|
|
371
|
+
append(".")
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
val result = annotatedString.toHtmlString()
|
|
375
|
+
|
|
376
|
+
Assert.assertEquals(
|
|
377
|
+
"This text is <u><s>both underlined and crossed</s></u>.",
|
|
378
|
+
result,
|
|
379
|
+
)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
@Test
|
|
383
|
+
fun toHtmlString_BackgroundColor() {
|
|
384
|
+
val annotatedString =
|
|
385
|
+
buildAnnotatedString {
|
|
386
|
+
append("This text has ")
|
|
387
|
+
withStyle(SpanStyle(background = Color.Yellow)) {
|
|
388
|
+
append("yellow background")
|
|
389
|
+
}
|
|
390
|
+
append(".")
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
val result = annotatedString.toHtmlString()
|
|
394
|
+
|
|
395
|
+
Assert.assertEquals(
|
|
396
|
+
"This text has <span style=\"background-color: #FFFF00;\">yellow background</span>.",
|
|
397
|
+
result,
|
|
398
|
+
)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
@Test
|
|
402
|
+
fun toHtmlString_LinkTagAnnotation() {
|
|
403
|
+
val annotatedString =
|
|
404
|
+
buildAnnotatedString {
|
|
405
|
+
append("Visit ")
|
|
406
|
+
pushStringAnnotation("LINK_TAG", "https://stripe.com")
|
|
407
|
+
append("Stripe")
|
|
408
|
+
pop()
|
|
409
|
+
append(".")
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
val result = annotatedString.toHtmlString()
|
|
413
|
+
|
|
414
|
+
Assert.assertEquals(
|
|
415
|
+
"Visit <a href=\"https://stripe.com\">Stripe</a>.",
|
|
416
|
+
result,
|
|
417
|
+
)
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
@Test
|
|
421
|
+
fun toHtmlString_ComplexMandateText() {
|
|
422
|
+
val annotatedString =
|
|
423
|
+
buildAnnotatedString {
|
|
424
|
+
append("By continuing, you agree to ")
|
|
425
|
+
pushStringAnnotation("URL", "https://stripe.com/terms")
|
|
426
|
+
withStyle(
|
|
427
|
+
SpanStyle(
|
|
428
|
+
fontWeight = FontWeight.Bold,
|
|
429
|
+
textDecoration = TextDecoration.Underline,
|
|
430
|
+
color = Color.Blue,
|
|
431
|
+
),
|
|
432
|
+
) {
|
|
433
|
+
append("Terms")
|
|
434
|
+
}
|
|
435
|
+
pop()
|
|
436
|
+
append(" and ")
|
|
437
|
+
pushStringAnnotation("URL", "https://stripe.com/privacy")
|
|
438
|
+
withStyle(SpanStyle(fontStyle = FontStyle.Italic, color = Color.Red)) {
|
|
439
|
+
append("Privacy")
|
|
440
|
+
}
|
|
441
|
+
pop()
|
|
442
|
+
append(". Important details are ")
|
|
443
|
+
withStyle(SpanStyle(background = Color.Yellow)) {
|
|
444
|
+
append("highlighted")
|
|
445
|
+
}
|
|
446
|
+
append(".")
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
val result = annotatedString.toHtmlString()
|
|
450
|
+
|
|
451
|
+
Assert.assertEquals(
|
|
452
|
+
"By continuing, you agree to <b><font color=\"#0000FF\"><u><a href=\"https://stripe.com/terms\">Terms</a></u></font></b> and <i><font color=\"#FF0000\"><a href=\"https://stripe.com/privacy\">Privacy</a></font></i>. Important details are <span style=\"background-color: #FFFF00;\">highlighted</span>.",
|
|
453
|
+
result,
|
|
454
|
+
)
|
|
455
|
+
}
|
|
456
|
+
}
|
package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
package com.reactnativestripesdk.pushprovisioning
|
|
2
|
+
|
|
3
|
+
import androidx.test.core.app.ApplicationProvider
|
|
4
|
+
import com.facebook.react.bridge.BridgeReactContext
|
|
5
|
+
import org.junit.Assert
|
|
6
|
+
import org.junit.Test
|
|
7
|
+
import org.junit.runner.RunWith
|
|
8
|
+
import org.robolectric.RobolectricTestRunner
|
|
9
|
+
|
|
10
|
+
@RunWith(RobolectricTestRunner::class)
|
|
11
|
+
class PushProvisioningProxyTest {
|
|
12
|
+
private val reactApplicationContext =
|
|
13
|
+
BridgeReactContext(
|
|
14
|
+
ApplicationProvider.getApplicationContext(),
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
@Test
|
|
18
|
+
fun getApiVersion() {
|
|
19
|
+
/**
|
|
20
|
+
* An empty string is returned because we do not include compileOnly dependencies in our tests.
|
|
21
|
+
* Including the compileOnly dependency causes some linters to complain, and one single test
|
|
22
|
+
* isn't worth it. Once the push provisioning library is split into it's own SDK, we can
|
|
23
|
+
* add back this test. (it should equal "2019-09-09" if the dependency is included).
|
|
24
|
+
*/
|
|
25
|
+
Assert.assertEquals(
|
|
26
|
+
"",
|
|
27
|
+
PushProvisioningProxy.getApiVersion(),
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Test
|
|
32
|
+
fun isNFCEnabled() {
|
|
33
|
+
Assert.assertEquals(
|
|
34
|
+
false,
|
|
35
|
+
PushProvisioningProxy.isNFCEnabled(reactApplicationContext),
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Test
|
|
40
|
+
fun isTokenInWallet() {
|
|
41
|
+
Assert.assertEquals(TapAndPayProxy.isTokenInWallet({}, "4242"), false)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -67,7 +67,7 @@ class AddressSheetUtils {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
internal class func getFieldConfiguration(input: String?, default: AddressViewController.Configuration.AdditionalFields.FieldConfiguration) -> AddressViewController.Configuration.AdditionalFields.FieldConfiguration {
|
|
70
|
-
switch
|
|
70
|
+
switch input {
|
|
71
71
|
case "optional":
|
|
72
72
|
return .optional
|
|
73
73
|
case "required":
|
|
@@ -79,7 +79,7 @@ class AddressSheetUtils {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
internal class func buildResult(address: AddressViewController.AddressDetails) -> [AnyHashable
|
|
82
|
+
internal class func buildResult(address: AddressViewController.AddressDetails) -> [AnyHashable: Any] {
|
|
83
83
|
return [
|
|
84
84
|
"result": [
|
|
85
85
|
"name": address.name ?? NSNull(),
|
|
@@ -93,7 +93,7 @@ class AddressSheetUtils {
|
|
|
93
93
|
],
|
|
94
94
|
"phone": address.phone ?? NSNull(),
|
|
95
95
|
"isCheckboxSelected": address.isCheckboxSelected ?? NSNull(),
|
|
96
|
-
] as [AnyHashable
|
|
96
|
+
] as [AnyHashable: Any],
|
|
97
97
|
]
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -13,20 +13,20 @@ public class AddressSheetView: UIView {
|
|
|
13
13
|
@objc public var visible = false
|
|
14
14
|
@objc public var presentationStyle: String = "popover"
|
|
15
15
|
@objc public var animationStyle: String = ""
|
|
16
|
-
@objc public var appearance: NSDictionary?
|
|
17
|
-
@objc public var defaultValues: NSDictionary?
|
|
18
|
-
@objc public var additionalFields: NSDictionary?
|
|
16
|
+
@objc public var appearance: NSDictionary?
|
|
17
|
+
@objc public var defaultValues: NSDictionary?
|
|
18
|
+
@objc public var additionalFields: NSDictionary?
|
|
19
19
|
@objc public var allowedCountries: [String] = []
|
|
20
20
|
@objc public var autocompleteCountries: [String] = []
|
|
21
|
-
@objc public var primaryButtonTitle: String?
|
|
22
|
-
@objc public var sheetTitle: String?
|
|
21
|
+
@objc public var primaryButtonTitle: String?
|
|
22
|
+
@objc public var sheetTitle: String?
|
|
23
23
|
@objc public var onSubmitAction: RCTDirectEventBlock?
|
|
24
24
|
@objc public var onErrorAction: RCTDirectEventBlock?
|
|
25
25
|
|
|
26
26
|
private var wasVisible = false
|
|
27
|
-
private var addressViewController: AddressViewController?
|
|
28
|
-
internal var addressDetails: AddressViewController.AddressDetails?
|
|
29
|
-
|
|
27
|
+
private var addressViewController: AddressViewController?
|
|
28
|
+
internal var addressDetails: AddressViewController.AddressDetails?
|
|
29
|
+
|
|
30
30
|
override public init(frame: CGRect) {
|
|
31
31
|
super.init(frame: frame)
|
|
32
32
|
}
|
|
@@ -34,12 +34,12 @@ public class AddressSheetView: UIView {
|
|
|
34
34
|
required init?(coder: NSCoder) {
|
|
35
35
|
fatalError("init(coder:) has not been implemented")
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
@objc public func didSetProps() {
|
|
39
|
-
if
|
|
39
|
+
if visible && !wasVisible {
|
|
40
40
|
presentAddressSheet()
|
|
41
41
|
wasVisible = true
|
|
42
|
-
} else if
|
|
42
|
+
} else if !visible && wasVisible {
|
|
43
43
|
addressViewController?.dismiss(animated: true)
|
|
44
44
|
wasVisible = false
|
|
45
45
|
}
|
|
@@ -50,11 +50,11 @@ public class AddressSheetView: UIView {
|
|
|
50
50
|
// by the view component.
|
|
51
51
|
self.didSetProps()
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
private func presentAddressSheet() {
|
|
55
|
-
if
|
|
55
|
+
if STPAPIClient.shared.publishableKey == nil {
|
|
56
56
|
onErrorAction!(
|
|
57
|
-
Errors.createError(ErrorType.Failed, "No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.") as? [AnyHashable
|
|
57
|
+
Errors.createError(ErrorType.Failed, "No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.") as? [AnyHashable: Any]
|
|
58
58
|
)
|
|
59
59
|
return
|
|
60
60
|
}
|
|
@@ -63,26 +63,26 @@ public class AddressSheetView: UIView {
|
|
|
63
63
|
config = try buildAddressSheetConfiguration()
|
|
64
64
|
} catch {
|
|
65
65
|
onErrorAction!(
|
|
66
|
-
Errors.createError(ErrorType.Failed, error.localizedDescription) as? [AnyHashable
|
|
66
|
+
Errors.createError(ErrorType.Failed, error.localizedDescription) as? [AnyHashable: Any]
|
|
67
67
|
)
|
|
68
68
|
return
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
self.addressViewController = AddressViewController(
|
|
72
72
|
configuration: config,
|
|
73
73
|
delegate: self
|
|
74
74
|
)
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
let navigationController = UINavigationController(rootViewController: addressViewController!)
|
|
77
77
|
navigationController.modalPresentationStyle = getModalPresentationStyle()
|
|
78
78
|
navigationController.modalTransitionStyle = getModalTransitionStyle()
|
|
79
79
|
let vc = findViewControllerPresenter(from: RCTKeyWindow()?.rootViewController ?? UIViewController())
|
|
80
80
|
vc.present(navigationController, animated: true)
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
private func buildAddressSheetConfiguration() throws -> AddressViewController.Configuration {
|
|
84
84
|
let appearanceConfiguration = try PaymentSheetAppearance.buildAppearanceFromParams(userParams: appearance)
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
return AddressViewController.Configuration(
|
|
87
87
|
defaultValues: AddressSheetUtils.buildDefaultValues(params: defaultValues),
|
|
88
88
|
additionalFields: AddressSheetUtils.buildAdditionalFieldsConfiguration(params: additionalFields),
|
|
@@ -90,11 +90,11 @@ public class AddressSheetView: UIView {
|
|
|
90
90
|
appearance: appearanceConfiguration,
|
|
91
91
|
buttonTitle: primaryButtonTitle,
|
|
92
92
|
title: sheetTitle
|
|
93
|
-
|
|
93
|
+
)
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
private func getModalPresentationStyle() -> UIModalPresentationStyle {
|
|
97
|
-
switch
|
|
97
|
+
switch presentationStyle {
|
|
98
98
|
case "fullscreen":
|
|
99
99
|
return .fullScreen
|
|
100
100
|
case "pageSheet":
|
|
@@ -111,9 +111,9 @@ public class AddressSheetView: UIView {
|
|
|
111
111
|
return .popover
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
|
|
115
115
|
private func getModalTransitionStyle() -> UIModalTransitionStyle {
|
|
116
|
-
switch
|
|
116
|
+
switch animationStyle {
|
|
117
117
|
case "flip":
|
|
118
118
|
return .flipHorizontal
|
|
119
119
|
case "curl":
|
|
@@ -135,7 +135,7 @@ extension AddressSheetView: AddressViewControllerDelegate {
|
|
|
135
135
|
Errors.createError(
|
|
136
136
|
ErrorType.Canceled,
|
|
137
137
|
"The flow has been canceled."
|
|
138
|
-
) as? [AnyHashable
|
|
138
|
+
) as? [AnyHashable: Any]
|
|
139
139
|
)
|
|
140
140
|
return
|
|
141
141
|
}
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
import Foundation
|
|
9
9
|
|
|
10
10
|
@objc(AddressSheetViewManager)
|
|
11
|
-
class AddressSheetViewManager
|
|
11
|
+
class AddressSheetViewManager: RCTViewManager {
|
|
12
12
|
override func view() -> UIView! {
|
|
13
13
|
return AddressSheetView()
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
override class func requiresMainQueueSetup() -> Bool {
|
|
17
17
|
return true
|
|
18
18
|
}
|