@stripe/stripe-react-native 0.57.0 → 0.57.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -8
- package/android/.idea/AndroidProjectSystem.xml +6 -0
- package/android/.idea/caches/deviceStreaming.xml +1029 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +19 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/runConfigurations.xml +17 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +76 -118
- package/android/gradle.properties +1 -1
- package/android/local.properties +8 -0
- package/android/settings.gradle +2 -0
- package/android/spotless.gradle +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +20 -17
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +13 -11
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +17 -21
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherManager.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +53 -11
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +105 -117
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -8
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetManager.kt +13 -15
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +7 -5
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarManager.kt +31 -0
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +120 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +228 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherManager.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +73 -30
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +19 -245
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +52 -14
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +15 -35
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +5 -10
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +90 -77
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +6 -4
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +13 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +41 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +92 -44
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +3 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +2 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +118 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +922 -0
- package/android/src/test/java/com/facebook/testutils/shadows/ShadowArguments.kt +29 -0
- package/android/src/test/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManagerTest.kt +163 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +976 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetAppearanceTest.kt +801 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +523 -0
- package/android/src/test/java/com/reactnativestripesdk/addresssheet/AddressSheetViewTest.kt +551 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +567 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +456 -0
- package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +43 -0
- package/android/src/test/resources/robolectric.properties +2 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +3 -3
- package/ios/AddressSheet/AddressSheetView.swift +25 -25
- package/ios/AddressSheet/AddressSheetViewManager.swift +2 -2
- package/ios/ApplePayButtonManager.swift +1 -1
- package/ios/ApplePayButtonView.swift +9 -10
- package/ios/ApplePayUtils.swift +51 -51
- package/ios/ApplePayViewController.swift +25 -29
- package/ios/AuBECSDebitFormManager.swift +1 -1
- package/ios/AuBECSDebitFormView.swift +13 -15
- package/ios/CardFieldManager.swift +4 -4
- package/ios/CardFieldView.swift +9 -9
- package/ios/CardFormManager.swift +3 -3
- package/ios/CardFormView.swift +28 -28
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +97 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +133 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.m +16 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.swift +17 -0
- package/ios/CustomerSheet/CustomerSheetUtils.swift +15 -16
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +19 -19
- package/ios/EmbeddedPaymentElementView.swift +2 -2
- package/ios/Errors.swift +22 -23
- package/ios/FinancialConnections.swift +37 -37
- package/ios/Mappers.swift +210 -71
- package/ios/NavigationBarManager.m +13 -0
- package/ios/NavigationBarManager.swift +17 -0
- package/ios/NavigationBarView.swift +65 -0
- package/ios/NewArch/NavigationBarComponentView.h +10 -0
- package/ios/NewArch/NavigationBarComponentView.mm +86 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +7 -1
- package/ios/PaymentMethodFactory.swift +24 -24
- package/ios/PaymentOptionDisplayData+ReactNative.swift +4 -4
- package/ios/PaymentPassFinder.swift +9 -10
- package/ios/PaymentSheetAppearance.swift +137 -138
- package/ios/PushProvisioning/AddToWalletButtonManager.swift +2 -2
- package/ios/PushProvisioning/AddToWalletButtonView.swift +15 -17
- package/ios/PushProvisioning/PushProvisioningUtils.swift +11 -11
- package/ios/StripeContainerManager.swift +1 -1
- package/ios/StripeContainerView.swift +3 -3
- package/ios/StripeOnrampSdk.h +17 -0
- package/ios/StripeOnrampSdk.mm +158 -0
- package/ios/StripeSdk.mm +8 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcuserdata/tianzhao.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/StripeSdk.xcodeproj/xcuserdata/tianzhao.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/ios/StripeSdkEmitter.swift +4 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +30 -25
- package/ios/StripeSdkImpl+Embedded.swift +11 -9
- package/ios/StripeSdkImpl+PaymentSheet.swift +36 -34
- package/ios/StripeSdkImpl.swift +913 -185
- package/ios/UIColorExtension.swift +72 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/connect/Components.js +2 -0
- package/lib/commonjs/connect/Components.js.map +1 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js +2 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/commonjs/connect/EmbeddedComponent.js +19 -0
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -0
- package/lib/commonjs/connect/ModalCloseButton.js +2 -0
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -0
- package/lib/commonjs/connect/NavigationBar.js +2 -0
- package/lib/commonjs/connect/NavigationBar.js.map +1 -0
- package/lib/commonjs/connect/connectTypes.js +2 -0
- package/lib/commonjs/connect/connectTypes.js.map +1 -0
- package/lib/commonjs/events.js +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +2 -0
- package/lib/commonjs/hooks/useOnramp.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +2 -0
- package/lib/commonjs/specs/NativeNavigationBar.js.map +1 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/Onramp.js +2 -0
- package/lib/commonjs/types/Onramp.js.map +1 -0
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/connect/Components.js +2 -0
- package/lib/module/connect/Components.js.map +1 -0
- package/lib/module/connect/ConnectComponentsProvider.js +2 -0
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/module/connect/EmbeddedComponent.js +19 -0
- package/lib/module/connect/EmbeddedComponent.js.map +1 -0
- package/lib/module/connect/ModalCloseButton.js +2 -0
- package/lib/module/connect/ModalCloseButton.js.map +1 -0
- package/lib/module/connect/NavigationBar.js +2 -0
- package/lib/module/connect/NavigationBar.js.map +1 -0
- package/lib/module/connect/connectTypes.js +2 -0
- package/lib/module/connect/connectTypes.js.map +1 -0
- package/lib/module/events.js +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +2 -0
- package/lib/module/hooks/useOnramp.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js.map +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js.map +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/module/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/module/specs/NativeNavigationBar.js +2 -0
- package/lib/module/specs/NativeNavigationBar.js.map +1 -0
- package/lib/module/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/Onramp.js +2 -0
- package/lib/module/types/Onramp.js.map +1 -0
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
- package/lib/typescript/src/connect/Components.d.ts +23 -0
- package/lib/typescript/src/connect/Components.d.ts.map +1 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +22 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts +18 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts +7 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts.map +1 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts +8 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/connect/connectTypes.d.ts +464 -0
- package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +4 -0
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/helpers.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +158 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugin/withStripe.d.ts +15 -0
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts +14 -0
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts +11 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +28 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +5 -0
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +275 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +7 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +25 -14
- package/src/components/StripeProvider.tsx +5 -0
- package/src/connect/Components.tsx +279 -0
- package/src/connect/ConnectComponentsProvider.tsx +93 -0
- package/src/connect/EmbeddedComponent.tsx +407 -0
- package/src/connect/ModalCloseButton.tsx +44 -0
- package/src/connect/NavigationBar.tsx +29 -0
- package/src/connect/connectTypes.ts +626 -0
- package/src/events.ts +23 -0
- package/src/hooks/useOnramp.tsx +334 -0
- package/src/index.tsx +13 -0
- package/src/plugin/withStripe.ts +104 -7
- package/src/specs/NativeConnectAccountOnboardingView.ts +19 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +5 -1
- package/src/specs/NativeNavigationBar.ts +16 -0
- package/src/specs/NativeOnrampSdkModule.ts +47 -0
- package/src/specs/NativeStripeSdkModule.ts +5 -0
- package/src/types/EmbeddedPaymentElement.tsx +24 -3
- package/src/types/Errors.ts +6 -0
- package/src/types/Onramp.ts +317 -0
- package/src/types/PaymentSheet.ts +7 -0
- package/src/types/index.ts +8 -0
- package/stripe-react-native.podspec +20 -7
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
package com.reactnativestripesdk.addresssheet
|
|
2
|
+
|
|
3
|
+
import com.reactnativestripesdk.utils.readableMapOf
|
|
4
|
+
import com.stripe.android.paymentsheet.PaymentSheet
|
|
5
|
+
import com.stripe.android.paymentsheet.addresselement.AddressDetails
|
|
6
|
+
import com.stripe.android.paymentsheet.addresselement.AddressLauncher
|
|
7
|
+
import org.junit.Assert.assertEquals
|
|
8
|
+
import org.junit.Assert.assertFalse
|
|
9
|
+
import org.junit.Assert.assertNotNull
|
|
10
|
+
import org.junit.Assert.assertNull
|
|
11
|
+
import org.junit.Assert.assertTrue
|
|
12
|
+
import org.junit.Test
|
|
13
|
+
import org.junit.runner.RunWith
|
|
14
|
+
import org.robolectric.RobolectricTestRunner
|
|
15
|
+
|
|
16
|
+
@RunWith(RobolectricTestRunner::class)
|
|
17
|
+
class AddressSheetViewTest {
|
|
18
|
+
private val testCity = "testCity"
|
|
19
|
+
private val testCountry = "testCountry"
|
|
20
|
+
private val testLine1 = "testLine1"
|
|
21
|
+
private val testLine2 = "testLine2"
|
|
22
|
+
private val testPostalCode = "testPostalCode"
|
|
23
|
+
private val testState = "testState"
|
|
24
|
+
private val testName = "testName"
|
|
25
|
+
private val testPhone = "testPhone"
|
|
26
|
+
|
|
27
|
+
@Test
|
|
28
|
+
fun buildAddressDetails_Default() {
|
|
29
|
+
val addressDetails =
|
|
30
|
+
AddressSheetView.buildAddressDetails(
|
|
31
|
+
readableMapOf(),
|
|
32
|
+
)
|
|
33
|
+
assertNull(addressDetails.address)
|
|
34
|
+
assertNull(addressDetails.name)
|
|
35
|
+
assertFalse(addressDetails.isCheckboxSelected ?: false)
|
|
36
|
+
assertNull(addressDetails.phoneNumber)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Test
|
|
40
|
+
fun buildAddressDetails_Custom() {
|
|
41
|
+
val addressDetails =
|
|
42
|
+
AddressSheetView.buildAddressDetails(
|
|
43
|
+
readableMapOf(
|
|
44
|
+
"name" to testName,
|
|
45
|
+
"phone" to testPhone,
|
|
46
|
+
"isCheckboxSelected" to true,
|
|
47
|
+
"address" to
|
|
48
|
+
readableMapOf(
|
|
49
|
+
"city" to testCity,
|
|
50
|
+
"line1" to testLine1,
|
|
51
|
+
),
|
|
52
|
+
),
|
|
53
|
+
)
|
|
54
|
+
assertEquals(testCity, addressDetails.address?.city)
|
|
55
|
+
assertEquals(testLine1, addressDetails.address?.line1)
|
|
56
|
+
assertEquals(testName, addressDetails.name)
|
|
57
|
+
assertTrue(addressDetails.isCheckboxSelected ?: false)
|
|
58
|
+
assertEquals(testPhone, addressDetails.phoneNumber)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Test
|
|
62
|
+
fun buildAddressDetails_OnlyName() {
|
|
63
|
+
val addressDetails =
|
|
64
|
+
AddressSheetView.buildAddressDetails(
|
|
65
|
+
readableMapOf(
|
|
66
|
+
"name" to testName,
|
|
67
|
+
),
|
|
68
|
+
)
|
|
69
|
+
assertEquals(testName, addressDetails.name)
|
|
70
|
+
assertNull(addressDetails.phoneNumber)
|
|
71
|
+
assertNull(addressDetails.address)
|
|
72
|
+
assertFalse(addressDetails.isCheckboxSelected ?: false)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Test
|
|
76
|
+
fun buildAddressDetails_OnlyPhone() {
|
|
77
|
+
val addressDetails =
|
|
78
|
+
AddressSheetView.buildAddressDetails(
|
|
79
|
+
readableMapOf(
|
|
80
|
+
"phone" to testPhone,
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
assertNull(addressDetails.name)
|
|
84
|
+
assertEquals(testPhone, addressDetails.phoneNumber)
|
|
85
|
+
assertNull(addressDetails.address)
|
|
86
|
+
assertFalse(addressDetails.isCheckboxSelected ?: false)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@Test
|
|
90
|
+
fun buildAddressDetails_OnlyCheckboxSelected() {
|
|
91
|
+
val addressDetails =
|
|
92
|
+
AddressSheetView.buildAddressDetails(
|
|
93
|
+
readableMapOf(
|
|
94
|
+
"isCheckboxSelected" to true,
|
|
95
|
+
),
|
|
96
|
+
)
|
|
97
|
+
assertNull(addressDetails.name)
|
|
98
|
+
assertNull(addressDetails.phoneNumber)
|
|
99
|
+
assertNull(addressDetails.address)
|
|
100
|
+
assertTrue(addressDetails.isCheckboxSelected ?: false)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@Test
|
|
104
|
+
fun buildAddressDetails_CheckboxSelectedFalse() {
|
|
105
|
+
val addressDetails =
|
|
106
|
+
AddressSheetView.buildAddressDetails(
|
|
107
|
+
readableMapOf(
|
|
108
|
+
"name" to testName,
|
|
109
|
+
"isCheckboxSelected" to false,
|
|
110
|
+
),
|
|
111
|
+
)
|
|
112
|
+
assertEquals(testName, addressDetails.name)
|
|
113
|
+
assertFalse(addressDetails.isCheckboxSelected ?: false)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@Test
|
|
117
|
+
fun buildAddressDetails_PartialAddress() {
|
|
118
|
+
val addressDetails =
|
|
119
|
+
AddressSheetView.buildAddressDetails(
|
|
120
|
+
readableMapOf(
|
|
121
|
+
"name" to testName,
|
|
122
|
+
"address" to
|
|
123
|
+
readableMapOf(
|
|
124
|
+
"country" to testCountry,
|
|
125
|
+
"postalCode" to testPostalCode,
|
|
126
|
+
),
|
|
127
|
+
),
|
|
128
|
+
)
|
|
129
|
+
assertEquals(testName, addressDetails.name)
|
|
130
|
+
assertNotNull(addressDetails.address)
|
|
131
|
+
assertEquals(testCountry, addressDetails.address?.country)
|
|
132
|
+
assertEquals(testPostalCode, addressDetails.address?.postalCode)
|
|
133
|
+
assertNull(addressDetails.address?.city)
|
|
134
|
+
assertNull(addressDetails.address?.line1)
|
|
135
|
+
assertNull(addressDetails.address?.line2)
|
|
136
|
+
assertNull(addressDetails.address?.state)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@Test
|
|
140
|
+
fun buildAddressDetails_FullAddress() {
|
|
141
|
+
val addressDetails =
|
|
142
|
+
AddressSheetView.buildAddressDetails(
|
|
143
|
+
readableMapOf(
|
|
144
|
+
"address" to
|
|
145
|
+
readableMapOf(
|
|
146
|
+
"city" to testCity,
|
|
147
|
+
"country" to testCountry,
|
|
148
|
+
"line1" to testLine1,
|
|
149
|
+
"line2" to testLine2,
|
|
150
|
+
"postalCode" to testPostalCode,
|
|
151
|
+
"state" to testState,
|
|
152
|
+
),
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
assertNotNull(addressDetails.address)
|
|
156
|
+
assertEquals(testCity, addressDetails.address?.city)
|
|
157
|
+
assertEquals(testCountry, addressDetails.address?.country)
|
|
158
|
+
assertEquals(testLine1, addressDetails.address?.line1)
|
|
159
|
+
assertEquals(testLine2, addressDetails.address?.line2)
|
|
160
|
+
assertEquals(testPostalCode, addressDetails.address?.postalCode)
|
|
161
|
+
assertEquals(testState, addressDetails.address?.state)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@Test
|
|
165
|
+
fun buildAddress_NullMap_ReturnsNull() {
|
|
166
|
+
val address = AddressSheetView.buildAddress(null)
|
|
167
|
+
assertNull(address)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@Test
|
|
171
|
+
fun buildAddress_EmptyMap_ReturnsAddressWithNulls() {
|
|
172
|
+
val address =
|
|
173
|
+
AddressSheetView.buildAddress(
|
|
174
|
+
readableMapOf(),
|
|
175
|
+
)
|
|
176
|
+
assertNotNull(address)
|
|
177
|
+
assertNull(address?.city)
|
|
178
|
+
assertNull(address?.country)
|
|
179
|
+
assertNull(address?.state)
|
|
180
|
+
assertNull(address?.postalCode)
|
|
181
|
+
assertNull(address?.line1)
|
|
182
|
+
assertNull(address?.line2)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@Test
|
|
186
|
+
fun buildAddress_FullAddress_ReturnsComplete() {
|
|
187
|
+
val address =
|
|
188
|
+
AddressSheetView.buildAddress(
|
|
189
|
+
readableMapOf(
|
|
190
|
+
"city" to testCity,
|
|
191
|
+
"line1" to testLine1,
|
|
192
|
+
"country" to testCountry,
|
|
193
|
+
"postalCode" to testPostalCode,
|
|
194
|
+
"line2" to testLine2,
|
|
195
|
+
"state" to testState,
|
|
196
|
+
),
|
|
197
|
+
)
|
|
198
|
+
assertEquals(testCity, address?.city)
|
|
199
|
+
assertEquals(testLine1, address?.line1)
|
|
200
|
+
assertEquals(testLine2, address?.line2)
|
|
201
|
+
assertEquals(testState, address?.state)
|
|
202
|
+
assertEquals(testCountry, address?.country)
|
|
203
|
+
assertEquals(testPostalCode, address?.postalCode)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@Test
|
|
207
|
+
fun buildAddress_PartialFields_ReturnsPartial() {
|
|
208
|
+
val address =
|
|
209
|
+
AddressSheetView.buildAddress(
|
|
210
|
+
readableMapOf(
|
|
211
|
+
"city" to testCity,
|
|
212
|
+
"postalCode" to testPostalCode,
|
|
213
|
+
),
|
|
214
|
+
)
|
|
215
|
+
assertNotNull(address)
|
|
216
|
+
assertEquals(testCity, address?.city)
|
|
217
|
+
assertEquals(testPostalCode, address?.postalCode)
|
|
218
|
+
assertNull(address?.country)
|
|
219
|
+
assertNull(address?.line1)
|
|
220
|
+
assertNull(address?.line2)
|
|
221
|
+
assertNull(address?.state)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@Test
|
|
225
|
+
fun buildAddress_OnlyRequiredFields_ReturnsPartial() {
|
|
226
|
+
val address =
|
|
227
|
+
AddressSheetView.buildAddress(
|
|
228
|
+
readableMapOf(
|
|
229
|
+
"country" to testCountry,
|
|
230
|
+
"line1" to testLine1,
|
|
231
|
+
),
|
|
232
|
+
)
|
|
233
|
+
assertNotNull(address)
|
|
234
|
+
assertEquals(testCountry, address?.country)
|
|
235
|
+
assertEquals(testLine1, address?.line1)
|
|
236
|
+
assertNull(address?.city)
|
|
237
|
+
assertNull(address?.line2)
|
|
238
|
+
assertNull(address?.postalCode)
|
|
239
|
+
assertNull(address?.state)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@Test
|
|
243
|
+
fun getFieldConfiguration_Hidden() {
|
|
244
|
+
assertEquals(
|
|
245
|
+
AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.HIDDEN,
|
|
246
|
+
AddressSheetView.getFieldConfiguration("hidden"),
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@Test
|
|
251
|
+
fun getFieldConfiguration_Required() {
|
|
252
|
+
assertEquals(
|
|
253
|
+
AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.REQUIRED,
|
|
254
|
+
AddressSheetView.getFieldConfiguration("required"),
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
@Test
|
|
259
|
+
fun getFieldConfiguration_Optional() {
|
|
260
|
+
assertEquals(
|
|
261
|
+
AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.OPTIONAL,
|
|
262
|
+
AddressSheetView.getFieldConfiguration("optional"),
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@Test
|
|
267
|
+
fun getFieldConfiguration_Invalid_DefaultsToHidden() {
|
|
268
|
+
assertEquals(
|
|
269
|
+
AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.HIDDEN,
|
|
270
|
+
AddressSheetView.getFieldConfiguration("invalid"),
|
|
271
|
+
)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
@Test
|
|
275
|
+
fun getFieldConfiguration_Null_DefaultsToHidden() {
|
|
276
|
+
assertEquals(
|
|
277
|
+
AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.HIDDEN,
|
|
278
|
+
AddressSheetView.getFieldConfiguration(null),
|
|
279
|
+
)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@Test
|
|
283
|
+
fun getFieldConfiguration_EmptyString_DefaultsToHidden() {
|
|
284
|
+
assertEquals(
|
|
285
|
+
AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.HIDDEN,
|
|
286
|
+
AddressSheetView.getFieldConfiguration(""),
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@Test
|
|
291
|
+
fun buildAdditionalFieldsConfiguration_EmptyMap_ReturnsDefaults() {
|
|
292
|
+
val result = AddressSheetView.buildAdditionalFieldsConfiguration(readableMapOf())
|
|
293
|
+
assertNotNull(result)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
@Test
|
|
297
|
+
fun buildAdditionalFieldsConfiguration_PhoneRequired() {
|
|
298
|
+
val params = readableMapOf("phoneNumber" to "required")
|
|
299
|
+
|
|
300
|
+
val result = AddressSheetView.buildAdditionalFieldsConfiguration(params)
|
|
301
|
+
assertNotNull(result)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
@Test
|
|
305
|
+
fun buildAdditionalFieldsConfiguration_PhoneOptional() {
|
|
306
|
+
val params = readableMapOf("phoneNumber" to "optional")
|
|
307
|
+
|
|
308
|
+
val result = AddressSheetView.buildAdditionalFieldsConfiguration(params)
|
|
309
|
+
assertNotNull(result)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
@Test
|
|
313
|
+
fun buildAdditionalFieldsConfiguration_PhoneHidden() {
|
|
314
|
+
val params = readableMapOf("phoneNumber" to "hidden")
|
|
315
|
+
|
|
316
|
+
val result = AddressSheetView.buildAdditionalFieldsConfiguration(params)
|
|
317
|
+
assertNotNull(result)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
@Test
|
|
321
|
+
fun buildAdditionalFieldsConfiguration_WithCheckboxLabel() {
|
|
322
|
+
val label = "custom label"
|
|
323
|
+
val params = readableMapOf("checkboxLabel" to label)
|
|
324
|
+
|
|
325
|
+
val result = AddressSheetView.buildAdditionalFieldsConfiguration(params)
|
|
326
|
+
assertNotNull(result)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
@Test
|
|
330
|
+
fun buildAdditionalFieldsConfiguration_FullConfig() {
|
|
331
|
+
val label = "Accept terms and conditions"
|
|
332
|
+
val params = readableMapOf("phoneNumber" to "required", "checkboxLabel" to label)
|
|
333
|
+
|
|
334
|
+
val result = AddressSheetView.buildAdditionalFieldsConfiguration(params)
|
|
335
|
+
assertNotNull(result)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
@Test
|
|
339
|
+
fun buildAdditionalFieldsConfiguration_InvalidPhoneValue_DefaultsToHidden() {
|
|
340
|
+
val params = readableMapOf("phoneNumber" to "invalid")
|
|
341
|
+
|
|
342
|
+
val result = AddressSheetView.buildAdditionalFieldsConfiguration(params)
|
|
343
|
+
assertNotNull(result)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
@Test
|
|
347
|
+
fun buildResult_FullDetails_ReturnsCompleteMap() {
|
|
348
|
+
val received =
|
|
349
|
+
AddressSheetView.buildResult(
|
|
350
|
+
AddressDetails(
|
|
351
|
+
name = testName,
|
|
352
|
+
address =
|
|
353
|
+
PaymentSheet.Address(
|
|
354
|
+
city = testCity,
|
|
355
|
+
state = testState,
|
|
356
|
+
country = testCountry,
|
|
357
|
+
line2 = testLine2,
|
|
358
|
+
line1 = testLine1,
|
|
359
|
+
postalCode = testPostalCode,
|
|
360
|
+
),
|
|
361
|
+
phoneNumber = testPhone,
|
|
362
|
+
isCheckboxSelected = true,
|
|
363
|
+
),
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
val expected =
|
|
367
|
+
readableMapOf(
|
|
368
|
+
"result" to
|
|
369
|
+
readableMapOf(
|
|
370
|
+
"name" to testName,
|
|
371
|
+
"address" to
|
|
372
|
+
readableMapOf(
|
|
373
|
+
"city" to testCity,
|
|
374
|
+
"country" to testCountry,
|
|
375
|
+
"state" to testState,
|
|
376
|
+
"line1" to testLine1,
|
|
377
|
+
"line2" to testLine2,
|
|
378
|
+
"postalCode" to testPostalCode,
|
|
379
|
+
),
|
|
380
|
+
"phone" to testPhone,
|
|
381
|
+
"isCheckboxSelected" to true,
|
|
382
|
+
),
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
assertEquals(expected, received)
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
@Test
|
|
389
|
+
fun buildResult_NullAddress_ReturnsMapWithAddressContainingNulls() {
|
|
390
|
+
val received =
|
|
391
|
+
AddressSheetView.buildResult(
|
|
392
|
+
AddressDetails(
|
|
393
|
+
name = testName,
|
|
394
|
+
address = null,
|
|
395
|
+
phoneNumber = testPhone,
|
|
396
|
+
isCheckboxSelected = true,
|
|
397
|
+
),
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
val result = received.getMap("result")
|
|
401
|
+
assertNotNull(result)
|
|
402
|
+
assertEquals(testName, result?.getString("name"))
|
|
403
|
+
assertEquals(testPhone, result?.getString("phone"))
|
|
404
|
+
assertTrue(result?.getBoolean("isCheckboxSelected") ?: false)
|
|
405
|
+
// Address map is created but all fields are null
|
|
406
|
+
val address = result?.getMap("address")
|
|
407
|
+
assertNotNull(address)
|
|
408
|
+
assertNull(address?.getString("city"))
|
|
409
|
+
assertNull(address?.getString("country"))
|
|
410
|
+
assertNull(address?.getString("line1"))
|
|
411
|
+
assertNull(address?.getString("line2"))
|
|
412
|
+
assertNull(address?.getString("postalCode"))
|
|
413
|
+
assertNull(address?.getString("state"))
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
@Test
|
|
417
|
+
fun buildResult_NullName_ReturnsMapWithNullName() {
|
|
418
|
+
val received =
|
|
419
|
+
AddressSheetView.buildResult(
|
|
420
|
+
AddressDetails(
|
|
421
|
+
name = null,
|
|
422
|
+
address =
|
|
423
|
+
PaymentSheet.Address(
|
|
424
|
+
city = testCity,
|
|
425
|
+
country = testCountry,
|
|
426
|
+
),
|
|
427
|
+
phoneNumber = testPhone,
|
|
428
|
+
isCheckboxSelected = false,
|
|
429
|
+
),
|
|
430
|
+
)
|
|
431
|
+
|
|
432
|
+
val result = received.getMap("result")
|
|
433
|
+
assertNotNull(result)
|
|
434
|
+
assertNull(result?.getString("name"))
|
|
435
|
+
assertEquals(testPhone, result?.getString("phone"))
|
|
436
|
+
assertFalse(result?.getBoolean("isCheckboxSelected") ?: true)
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
@Test
|
|
440
|
+
fun buildResult_NullPhoneNumber_ReturnsMapWithNullPhone() {
|
|
441
|
+
val received =
|
|
442
|
+
AddressSheetView.buildResult(
|
|
443
|
+
AddressDetails(
|
|
444
|
+
name = testName,
|
|
445
|
+
address =
|
|
446
|
+
PaymentSheet.Address(
|
|
447
|
+
city = testCity,
|
|
448
|
+
country = testCountry,
|
|
449
|
+
),
|
|
450
|
+
phoneNumber = null,
|
|
451
|
+
isCheckboxSelected = true,
|
|
452
|
+
),
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
val result = received.getMap("result")
|
|
456
|
+
assertNotNull(result)
|
|
457
|
+
assertEquals(testName, result?.getString("name"))
|
|
458
|
+
assertNull(result?.getString("phone"))
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
@Test
|
|
462
|
+
fun buildResult_CheckboxSelectedFalse_ReturnsFalse() {
|
|
463
|
+
val received =
|
|
464
|
+
AddressSheetView.buildResult(
|
|
465
|
+
AddressDetails(
|
|
466
|
+
name = testName,
|
|
467
|
+
address = null,
|
|
468
|
+
phoneNumber = null,
|
|
469
|
+
isCheckboxSelected = false,
|
|
470
|
+
),
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
val result = received.getMap("result")
|
|
474
|
+
assertNotNull(result)
|
|
475
|
+
assertFalse(result?.getBoolean("isCheckboxSelected") ?: true)
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
@Test
|
|
479
|
+
fun buildResult_CheckboxSelectedNull_ReturnsFalse() {
|
|
480
|
+
val received =
|
|
481
|
+
AddressSheetView.buildResult(
|
|
482
|
+
AddressDetails(
|
|
483
|
+
name = testName,
|
|
484
|
+
address = null,
|
|
485
|
+
phoneNumber = null,
|
|
486
|
+
isCheckboxSelected = null,
|
|
487
|
+
),
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
val result = received.getMap("result")
|
|
491
|
+
assertNotNull(result)
|
|
492
|
+
// Null checkbox is coerced to false
|
|
493
|
+
assertFalse(result?.getBoolean("isCheckboxSelected") ?: true)
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
@Test
|
|
497
|
+
fun buildResult_PartialAddress_ReturnsPartialAddressMap() {
|
|
498
|
+
val received =
|
|
499
|
+
AddressSheetView.buildResult(
|
|
500
|
+
AddressDetails(
|
|
501
|
+
name = testName,
|
|
502
|
+
address =
|
|
503
|
+
PaymentSheet.Address(
|
|
504
|
+
country = testCountry,
|
|
505
|
+
postalCode = testPostalCode,
|
|
506
|
+
),
|
|
507
|
+
phoneNumber = testPhone,
|
|
508
|
+
isCheckboxSelected = true,
|
|
509
|
+
),
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
val result = received.getMap("result")
|
|
513
|
+
assertNotNull(result)
|
|
514
|
+
val address = result?.getMap("address")
|
|
515
|
+
assertNotNull(address)
|
|
516
|
+
assertNull(address?.getString("city"))
|
|
517
|
+
assertEquals(testCountry, address?.getString("country"))
|
|
518
|
+
assertNull(address?.getString("line1"))
|
|
519
|
+
assertNull(address?.getString("line2"))
|
|
520
|
+
assertEquals(testPostalCode, address?.getString("postalCode"))
|
|
521
|
+
assertNull(address?.getString("state"))
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
@Test
|
|
525
|
+
fun buildResult_MinimalData_ReturnsValidMap() {
|
|
526
|
+
val received =
|
|
527
|
+
AddressSheetView.buildResult(
|
|
528
|
+
AddressDetails(
|
|
529
|
+
name = null,
|
|
530
|
+
address = null,
|
|
531
|
+
phoneNumber = null,
|
|
532
|
+
isCheckboxSelected = null,
|
|
533
|
+
),
|
|
534
|
+
)
|
|
535
|
+
|
|
536
|
+
val result = received.getMap("result")
|
|
537
|
+
assertNotNull(result)
|
|
538
|
+
assertNull(result?.getString("name"))
|
|
539
|
+
assertNull(result?.getString("phone"))
|
|
540
|
+
// Address map is created but all fields are null
|
|
541
|
+
val address = result?.getMap("address")
|
|
542
|
+
assertNotNull(address)
|
|
543
|
+
assertNull(address?.getString("city"))
|
|
544
|
+
assertNull(address?.getString("country"))
|
|
545
|
+
assertNull(address?.getString("line1"))
|
|
546
|
+
assertNull(address?.getString("line2"))
|
|
547
|
+
assertNull(address?.getString("postalCode"))
|
|
548
|
+
assertNull(address?.getString("state"))
|
|
549
|
+
assertFalse(result?.getBoolean("isCheckboxSelected") ?: true)
|
|
550
|
+
}
|
|
551
|
+
}
|