@stripe/stripe-react-native 0.56.0 → 0.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +76 -118
- package/android/gradle.properties +1 -1
- package/android/settings.gradle +2 -0
- package/android/spotless.gradle +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +24 -20
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +20 -17
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +28 -32
- package/android/src/main/java/com/reactnativestripesdk/{CollectBankAccountLauncherFragment.kt → CollectBankAccountLauncherManager.kt} +23 -44
- package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +4 -11
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +52 -132
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +0 -8
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
- package/android/src/main/java/com/reactnativestripesdk/{FinancialConnectionsSheetFragment.kt → FinancialConnectionsSheetManager.kt} +43 -92
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +107 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherManager.kt +37 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +7 -5
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarManager.kt +31 -0
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +120 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +228 -0
- package/android/src/main/java/com/reactnativestripesdk/{PaymentLauncherFragment.kt → PaymentLauncherManager.kt} +40 -77
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +11 -20
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +409 -483
- package/android/src/main/java/com/reactnativestripesdk/{PaymentSheetFragment.kt → PaymentSheetManager.kt} +65 -300
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +227 -232
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +78 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +52 -39
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/{CustomerSheetFragment.kt → CustomerSheetManager.kt} +64 -99
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -3
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +5 -10
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +90 -77
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +6 -4
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +13 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +87 -11
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +178 -185
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeUIManager.kt +62 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +118 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +922 -0
- package/android/src/test/java/com/facebook/testutils/shadows/ShadowArguments.kt +29 -0
- package/android/src/test/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManagerTest.kt +163 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +976 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetAppearanceTest.kt +801 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +523 -0
- package/android/src/test/java/com/reactnativestripesdk/addresssheet/AddressSheetViewTest.kt +551 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +567 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +456 -0
- package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +43 -0
- package/android/src/test/resources/robolectric.properties +2 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +3 -3
- package/ios/AddressSheet/AddressSheetView.swift +26 -26
- package/ios/AddressSheet/AddressSheetViewManager.swift +2 -2
- package/ios/ApplePayButtonManager.swift +1 -1
- package/ios/ApplePayButtonView.swift +9 -10
- package/ios/ApplePayUtils.swift +51 -51
- package/ios/ApplePayViewController.swift +25 -29
- package/ios/AuBECSDebitFormManager.swift +1 -1
- package/ios/AuBECSDebitFormView.swift +13 -15
- package/ios/CardFieldManager.swift +4 -4
- package/ios/CardFieldView.swift +9 -9
- package/ios/CardFormManager.swift +3 -3
- package/ios/CardFormView.swift +28 -28
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +97 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +133 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.m +16 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.swift +17 -0
- package/ios/CustomerSheet/CustomerSheetUtils.swift +15 -16
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +19 -19
- package/ios/EmbeddedPaymentElementView.swift +2 -2
- package/ios/Errors.swift +22 -23
- package/ios/FinancialConnections.swift +37 -37
- package/ios/Mappers.swift +212 -75
- package/ios/NavigationBarManager.m +13 -0
- package/ios/NavigationBarManager.swift +17 -0
- package/ios/NavigationBarView.swift +65 -0
- package/ios/NewArch/NavigationBarComponentView.h +10 -0
- package/ios/NewArch/NavigationBarComponentView.mm +86 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +7 -1
- package/ios/PaymentMethodFactory.swift +24 -41
- package/ios/PaymentOptionDisplayData+ReactNative.swift +4 -4
- package/ios/PaymentPassFinder.swift +9 -10
- package/ios/PaymentSheetAppearance.swift +137 -138
- package/ios/PushProvisioning/AddToWalletButtonManager.swift +2 -2
- package/ios/PushProvisioning/AddToWalletButtonView.swift +16 -18
- package/ios/PushProvisioning/PushProvisioningUtils.swift +11 -11
- package/ios/StripeContainerManager.swift +1 -1
- package/ios/StripeContainerView.swift +3 -3
- package/ios/StripeOnrampSdk.h +17 -0
- package/ios/StripeOnrampSdk.mm +158 -0
- package/ios/StripeSdk.mm +8 -0
- package/ios/StripeSdkEmitter.swift +4 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +31 -26
- package/ios/StripeSdkImpl+Embedded.swift +11 -9
- package/ios/StripeSdkImpl+PaymentSheet.swift +51 -42
- package/ios/StripeSdkImpl.swift +919 -191
- package/ios/UIColorExtension.swift +72 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/connect/Components.js +2 -0
- package/lib/commonjs/connect/Components.js.map +1 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js +2 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/commonjs/connect/EmbeddedComponent.js +19 -0
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -0
- package/lib/commonjs/connect/ModalCloseButton.js +2 -0
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -0
- package/lib/commonjs/connect/NavigationBar.js +2 -0
- package/lib/commonjs/connect/NavigationBar.js.map +1 -0
- package/lib/commonjs/connect/connectTypes.js +2 -0
- package/lib/commonjs/connect/connectTypes.js.map +1 -0
- package/lib/commonjs/events.js +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +2 -0
- package/lib/commonjs/hooks/useOnramp.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +2 -0
- package/lib/commonjs/specs/NativeNavigationBar.js.map +1 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/Onramp.js +2 -0
- package/lib/commonjs/types/Onramp.js.map +1 -0
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/connect/Components.js +2 -0
- package/lib/module/connect/Components.js.map +1 -0
- package/lib/module/connect/ConnectComponentsProvider.js +2 -0
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/module/connect/EmbeddedComponent.js +19 -0
- package/lib/module/connect/EmbeddedComponent.js.map +1 -0
- package/lib/module/connect/ModalCloseButton.js +2 -0
- package/lib/module/connect/ModalCloseButton.js.map +1 -0
- package/lib/module/connect/NavigationBar.js +2 -0
- package/lib/module/connect/NavigationBar.js.map +1 -0
- package/lib/module/connect/connectTypes.js +2 -0
- package/lib/module/connect/connectTypes.js.map +1 -0
- package/lib/module/events.js +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +2 -0
- package/lib/module/hooks/useOnramp.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js.map +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js.map +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/module/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/module/specs/NativeNavigationBar.js +2 -0
- package/lib/module/specs/NativeNavigationBar.js.map +1 -0
- package/lib/module/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/Onramp.js +2 -0
- package/lib/module/types/Onramp.js.map +1 -0
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
- package/lib/typescript/src/connect/Components.d.ts +23 -0
- package/lib/typescript/src/connect/Components.d.ts.map +1 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +22 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts +18 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts +7 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts.map +1 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts +8 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/connect/connectTypes.d.ts +464 -0
- package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +3 -0
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/helpers.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +158 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugin/withStripe.d.ts +15 -0
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts +14 -0
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts +11 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +28 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +5 -0
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +275 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentIntent.d.ts +1 -9
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentMethod.d.ts +2 -8
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentSheet.d.ts +7 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +24 -12
- package/src/components/StripeProvider.tsx +5 -0
- package/src/connect/Components.tsx +279 -0
- package/src/connect/ConnectComponentsProvider.tsx +93 -0
- package/src/connect/EmbeddedComponent.tsx +407 -0
- package/src/connect/ModalCloseButton.tsx +44 -0
- package/src/connect/NavigationBar.tsx +29 -0
- package/src/connect/connectTypes.ts +626 -0
- package/src/events.ts +22 -0
- package/src/hooks/useOnramp.tsx +334 -0
- package/src/index.tsx +13 -0
- package/src/plugin/withStripe.ts +104 -7
- package/src/specs/NativeConnectAccountOnboardingView.ts +19 -0
- package/src/specs/NativeNavigationBar.ts +16 -0
- package/src/specs/NativeOnrampSdkModule.ts +47 -0
- package/src/specs/NativeStripeSdkModule.ts +5 -0
- package/src/types/Errors.ts +6 -0
- package/src/types/Onramp.ts +317 -0
- package/src/types/PaymentIntent.ts +0 -10
- package/src/types/PaymentMethod.ts +0 -9
- package/src/types/PaymentSheet.ts +7 -0
- package/src/types/index.ts +8 -0
- package/stripe-react-native.podspec +21 -8
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -703
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -18
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +0 -146
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +0 -68
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +0 -102
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeFragment.kt +0 -52
package/ios/Mappers.swift
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import Contacts
|
|
1
2
|
import Stripe
|
|
2
|
-
import StripePaymentSheet
|
|
3
3
|
@_spi(ConfirmationTokensPublicPreview) import StripePayments
|
|
4
|
-
|
|
4
|
+
#if canImport(StripeCryptoOnramp)
|
|
5
|
+
@_spi(STP) import StripeCryptoOnramp
|
|
6
|
+
@_spi(STP) import StripePaymentSheet
|
|
7
|
+
#else
|
|
8
|
+
import StripePaymentSheet
|
|
9
|
+
#endif
|
|
5
10
|
|
|
6
11
|
class Mappers {
|
|
7
12
|
class func createResult(_ key: String, _ value: NSDictionary?, additionalFields: [String: Any]? = nil) -> NSDictionary {
|
|
@@ -70,13 +75,13 @@ class Mappers {
|
|
|
70
75
|
"routingNumber": bankAccount.routingNumber ?? NSNull(),
|
|
71
76
|
"status": mapFromBankAccountStatus(bankAccount.status) ?? NSNull(),
|
|
72
77
|
"fingerprint": bankAccount.fingerprint ?? NSNull(),
|
|
73
|
-
"last4": bankAccount.last4 ?? NSNull()
|
|
78
|
+
"last4": bankAccount.last4 ?? NSNull(),
|
|
74
79
|
]
|
|
75
80
|
return result
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
class func mapFromCard(_ card: STPCard?) -> NSDictionary? {
|
|
79
|
-
if
|
|
84
|
+
if card == nil {
|
|
80
85
|
return nil
|
|
81
86
|
}
|
|
82
87
|
let cardMap: NSDictionary = [
|
|
@@ -163,7 +168,7 @@ class Mappers {
|
|
|
163
168
|
class func mapToShippingMethods(shippingMethods: NSArray?) -> [PKShippingMethod] {
|
|
164
169
|
var shippingMethodsList: [PKShippingMethod] = []
|
|
165
170
|
|
|
166
|
-
if let methods = shippingMethods as? [[String
|
|
171
|
+
if let methods = shippingMethods as? [[String: Any]] {
|
|
167
172
|
for method in methods {
|
|
168
173
|
let label = method["label"] as? String ?? ""
|
|
169
174
|
let amount = NSDecimalNumber(string: method["amount"] as? String ?? "")
|
|
@@ -190,7 +195,7 @@ class Mappers {
|
|
|
190
195
|
"identifier": shippingMethod.identifier ?? "",
|
|
191
196
|
"amount": shippingMethod.amount.stringValue,
|
|
192
197
|
"isPending": shippingMethod.type == .pending,
|
|
193
|
-
"label": shippingMethod.label
|
|
198
|
+
"label": shippingMethod.label,
|
|
194
199
|
]
|
|
195
200
|
|
|
196
201
|
if #available(iOS 15.0, *) {
|
|
@@ -237,21 +242,21 @@ class Mappers {
|
|
|
237
242
|
|
|
238
243
|
class func mapAddressFields(_ addressFields: [String]) -> [String] {
|
|
239
244
|
return addressFields.map {
|
|
240
|
-
if
|
|
245
|
+
if $0 == "street" {
|
|
241
246
|
return CNPostalAddressStreetKey
|
|
242
|
-
} else if
|
|
247
|
+
} else if $0 == "city" {
|
|
243
248
|
return CNPostalAddressCityKey
|
|
244
|
-
} else if
|
|
249
|
+
} else if $0 == "subAdministrativeArea" {
|
|
245
250
|
return CNPostalAddressSubAdministrativeAreaKey
|
|
246
|
-
} else if
|
|
251
|
+
} else if $0 == "state" {
|
|
247
252
|
return CNPostalAddressStateKey
|
|
248
|
-
} else if
|
|
253
|
+
} else if $0 == "postalCode" {
|
|
249
254
|
return CNPostalAddressPostalCodeKey
|
|
250
|
-
} else if
|
|
255
|
+
} else if $0 == "country" {
|
|
251
256
|
return CNPostalAddressCountryKey
|
|
252
|
-
} else if
|
|
257
|
+
} else if $0 == "countryCode" {
|
|
253
258
|
return CNPostalAddressISOCountryCodeKey
|
|
254
|
-
} else if
|
|
259
|
+
} else if $0 == "subLocality" {
|
|
255
260
|
return CNPostalAddressSubLocalityKey
|
|
256
261
|
}
|
|
257
262
|
return ""
|
|
@@ -286,7 +291,6 @@ class Mappers {
|
|
|
286
291
|
case STPPaymentMethodType.SEPADebit: return "SepaDebit"
|
|
287
292
|
case STPPaymentMethodType.AUBECSDebit: return "AuBecsDebit"
|
|
288
293
|
case STPPaymentMethodType.bacsDebit: return "BacsDebit"
|
|
289
|
-
case STPPaymentMethodType.giropay: return "Giropay"
|
|
290
294
|
case STPPaymentMethodType.przelewy24: return "P24"
|
|
291
295
|
case STPPaymentMethodType.EPS: return "Eps"
|
|
292
296
|
case STPPaymentMethodType.bancontact: return "Bancontact"
|
|
@@ -319,7 +323,6 @@ class Mappers {
|
|
|
319
323
|
case "SepaDebit": return STPPaymentMethodType.SEPADebit
|
|
320
324
|
case "AuBecsDebit": return STPPaymentMethodType.AUBECSDebit
|
|
321
325
|
case "BacsDebit": return STPPaymentMethodType.bacsDebit
|
|
322
|
-
case "Giropay": return STPPaymentMethodType.giropay
|
|
323
326
|
case "P24": return STPPaymentMethodType.przelewy24
|
|
324
327
|
case "Eps": return STPPaymentMethodType.EPS
|
|
325
328
|
case "Bancontact": return STPPaymentMethodType.bancontact
|
|
@@ -371,7 +374,7 @@ class Mappers {
|
|
|
371
374
|
"state": address.state ?? NSNull(),
|
|
372
375
|
"country": address.country ?? NSNull(),
|
|
373
376
|
"line1": address.line1 ?? NSNull(),
|
|
374
|
-
"line2":address.line2 ?? NSNull(),
|
|
377
|
+
"line2": address.line2 ?? NSNull(),
|
|
375
378
|
"postalCode": address.postalCode ?? NSNull(),
|
|
376
379
|
]
|
|
377
380
|
}
|
|
@@ -412,7 +415,7 @@ class Mappers {
|
|
|
412
415
|
"message": lastPaymentError.message ?? NSNull(),
|
|
413
416
|
"type": mapFromPaymentIntentLastPaymentErrorType(lastPaymentError.type) ?? NSNull(),
|
|
414
417
|
"declineCode": lastPaymentError.declineCode ?? NSNull(),
|
|
415
|
-
"paymentMethod": mapFromPaymentMethod(lastPaymentError.paymentMethod) ?? NSNull()
|
|
418
|
+
"paymentMethod": mapFromPaymentMethod(lastPaymentError.paymentMethod) ?? NSNull(),
|
|
416
419
|
]
|
|
417
420
|
|
|
418
421
|
intent.setValue(paymentError, forKey: "lastPaymentError")
|
|
@@ -426,7 +429,7 @@ class Mappers {
|
|
|
426
429
|
intent.setValue(convertDateToUnixTimestampMilliseconds(date: canceledAt), forKey: "canceledAt")
|
|
427
430
|
}
|
|
428
431
|
|
|
429
|
-
return intent
|
|
432
|
+
return intent
|
|
430
433
|
}
|
|
431
434
|
|
|
432
435
|
class func mapNextAction(nextAction: STPIntentAction?) -> NSDictionary? {
|
|
@@ -442,12 +445,12 @@ class Mappers {
|
|
|
442
445
|
case .redirectToURL:
|
|
443
446
|
return [
|
|
444
447
|
"type": "urlRedirect",
|
|
445
|
-
"redirectUrl": it.redirectToURL?.url.absoluteString ?? NSNull()
|
|
448
|
+
"redirectUrl": it.redirectToURL?.url.absoluteString ?? NSNull(),
|
|
446
449
|
]
|
|
447
450
|
case .weChatPayRedirectToApp:
|
|
448
451
|
return [
|
|
449
452
|
"type": "weChatRedirect",
|
|
450
|
-
"redirectUrl": it.weChatPayRedirectToApp?.nativeURL?.absoluteString ?? NSNull()
|
|
453
|
+
"redirectUrl": it.weChatPayRedirectToApp?.nativeURL?.absoluteString ?? NSNull(),
|
|
451
454
|
]
|
|
452
455
|
case .alipayHandleRedirect:
|
|
453
456
|
return [
|
|
@@ -612,7 +615,7 @@ class Mappers {
|
|
|
612
615
|
if let brand = brand {
|
|
613
616
|
switch brand {
|
|
614
617
|
case "Visa": return STPCardBrand.visa
|
|
615
|
-
case "AmericanExpress"
|
|
618
|
+
case "AmericanExpress": return STPCardBrand.amex
|
|
616
619
|
case "MasterCard": return STPCardBrand.mastercard
|
|
617
620
|
case "Discover": return STPCardBrand.discover
|
|
618
621
|
case "JCB": return STPCardBrand.JCB
|
|
@@ -640,7 +643,7 @@ class Mappers {
|
|
|
640
643
|
"preferredNetwork": paymentMethod.card?.networks?.preferred ?? NSNull(),
|
|
641
644
|
"availableNetworks": paymentMethod.card?.networks?.available ?? NSNull(),
|
|
642
645
|
"threeDSecureUsage": [
|
|
643
|
-
|
|
646
|
+
"isSupported": paymentMethod.card?.threeDSecureUsage?.supported ?? false
|
|
644
647
|
],
|
|
645
648
|
]
|
|
646
649
|
|
|
@@ -653,12 +656,12 @@ class Mappers {
|
|
|
653
656
|
let bacsDebit: NSDictionary = [
|
|
654
657
|
"fingerprint": paymentMethod.bacsDebit?.fingerprint ?? NSNull(),
|
|
655
658
|
"last4": paymentMethod.bacsDebit?.last4 ?? NSNull(),
|
|
656
|
-
"sortCode": paymentMethod.bacsDebit?.sortCode ?? NSNull()
|
|
659
|
+
"sortCode": paymentMethod.bacsDebit?.sortCode ?? NSNull(),
|
|
657
660
|
]
|
|
658
661
|
let auBECSDebit: NSDictionary = [
|
|
659
662
|
"bsbNumber": paymentMethod.auBECSDebit?.bsbNumber ?? NSNull(),
|
|
660
663
|
"fingerprint": paymentMethod.auBECSDebit?.fingerprint ?? NSNull(),
|
|
661
|
-
"last4": paymentMethod.auBECSDebit?.last4 ?? NSNull()
|
|
664
|
+
"last4": paymentMethod.auBECSDebit?.last4 ?? NSNull(),
|
|
662
665
|
]
|
|
663
666
|
let USBankAccount: NSDictionary = [
|
|
664
667
|
"routingNumber": paymentMethod.usBankAccount?.routingNumber ?? NSNull(),
|
|
@@ -666,7 +669,7 @@ class Mappers {
|
|
|
666
669
|
"accountType": mapFromUSBankAccountType(type: paymentMethod.usBankAccount?.accountType),
|
|
667
670
|
"last4": paymentMethod.usBankAccount?.last4 ?? NSNull(),
|
|
668
671
|
"bankName": paymentMethod.usBankAccount?.bankName ?? NSNull(),
|
|
669
|
-
"linkedAccount": paymentMethod.usBankAccount?.
|
|
672
|
+
"linkedAccount": paymentMethod.usBankAccount?.financialConnectionsAccount ?? NSNull(),
|
|
670
673
|
"fingerprint": paymentMethod.usBankAccount?.fingerprint ?? NSNull(),
|
|
671
674
|
"preferredNetworks": paymentMethod.usBankAccount?.networks?.preferred ?? NSNull(),
|
|
672
675
|
"supportedNetworks": paymentMethod.usBankAccount?.networks?.supported ?? NSNull(),
|
|
@@ -680,7 +683,7 @@ class Mappers {
|
|
|
680
683
|
"Card": card,
|
|
681
684
|
"Ideal": [
|
|
682
685
|
"bankIdentifierCode": paymentMethod.iDEAL?.bankIdentifierCode ?? "",
|
|
683
|
-
"bankName": paymentMethod.iDEAL?.bankName ?? ""
|
|
686
|
+
"bankName": paymentMethod.iDEAL?.bankName ?? "",
|
|
684
687
|
],
|
|
685
688
|
"Fpx": [
|
|
686
689
|
"bank": paymentMethod.fpx?.bankIdentifierCode ?? "",
|
|
@@ -691,7 +694,7 @@ class Mappers {
|
|
|
691
694
|
"Upi": [
|
|
692
695
|
"vpa": paymentMethod.upi?.vpa
|
|
693
696
|
],
|
|
694
|
-
"USBankAccount": USBankAccount
|
|
697
|
+
"USBankAccount": USBankAccount,
|
|
695
698
|
]
|
|
696
699
|
return method
|
|
697
700
|
}
|
|
@@ -701,18 +704,18 @@ class Mappers {
|
|
|
701
704
|
return nil
|
|
702
705
|
}
|
|
703
706
|
|
|
704
|
-
var paymentMethodPreview: NSDictionary?
|
|
707
|
+
var paymentMethodPreview: NSDictionary?
|
|
705
708
|
if let preview = confirmationToken.paymentMethodPreview {
|
|
706
709
|
paymentMethodPreview = [
|
|
707
710
|
"type": Mappers.mapPaymentMethodType(type: preview.type),
|
|
708
711
|
"billingDetails": Mappers.mapFromBillingDetails(billingDetails: preview.billingDetails),
|
|
709
712
|
"allowRedisplay": mapFromAllowRedisplay(allowRedisplay: preview.allowRedisplay) ?? NSNull(),
|
|
710
713
|
"customerId": preview.customerId ?? NSNull(),
|
|
711
|
-
"allResponseFields": preview.allResponseFields
|
|
714
|
+
"allResponseFields": preview.allResponseFields,
|
|
712
715
|
]
|
|
713
716
|
}
|
|
714
717
|
|
|
715
|
-
var shipping: NSDictionary?
|
|
718
|
+
var shipping: NSDictionary?
|
|
716
719
|
if let shippingDetails = confirmationToken.shipping {
|
|
717
720
|
var addressDetails: NSDictionary = [:]
|
|
718
721
|
if let address = shippingDetails.address {
|
|
@@ -728,7 +731,7 @@ class Mappers {
|
|
|
728
731
|
shipping = [
|
|
729
732
|
"address": addressDetails,
|
|
730
733
|
"name": shippingDetails.name ?? NSNull(),
|
|
731
|
-
"phone": shippingDetails.phone ?? NSNull()
|
|
734
|
+
"phone": shippingDetails.phone ?? NSNull(),
|
|
732
735
|
]
|
|
733
736
|
}
|
|
734
737
|
|
|
@@ -743,7 +746,7 @@ class Mappers {
|
|
|
743
746
|
"setupFutureUsage": mapFromSetupFutureUsage(setupFutureUsage: confirmationToken.setupFutureUsage) ?? NSNull(),
|
|
744
747
|
"paymentMethodPreview": paymentMethodPreview ?? NSNull(),
|
|
745
748
|
"shipping": shipping ?? NSNull(),
|
|
746
|
-
"allResponseFields": confirmationToken.allResponseFields
|
|
749
|
+
"allResponseFields": confirmationToken.allResponseFields,
|
|
747
750
|
]
|
|
748
751
|
return token
|
|
749
752
|
}
|
|
@@ -837,9 +840,8 @@ class Mappers {
|
|
|
837
840
|
"nextAction": mapNextAction(nextAction: setupIntent.nextAction) ?? NSNull(),
|
|
838
841
|
]
|
|
839
842
|
|
|
840
|
-
|
|
841
843
|
let types = setupIntent.paymentMethodTypes.map {
|
|
842
|
-
mapPaymentMethodType(type:
|
|
844
|
+
mapPaymentMethodType(type: $0)
|
|
843
845
|
}
|
|
844
846
|
|
|
845
847
|
intent.setValue(types, forKey: "paymentMethodTypes")
|
|
@@ -851,7 +853,7 @@ class Mappers {
|
|
|
851
853
|
"message": lastSetupError.message ?? NSNull(),
|
|
852
854
|
"type": mapFromSetupIntentLastPaymentErrorType(lastSetupError.type) ?? NSNull(),
|
|
853
855
|
"declineCode": lastSetupError.declineCode ?? NSNull(),
|
|
854
|
-
"paymentMethod": mapFromPaymentMethod(lastSetupError.paymentMethod) ?? NSNull()
|
|
856
|
+
"paymentMethod": mapFromPaymentMethod(lastSetupError.paymentMethod) ?? NSNull(),
|
|
855
857
|
]
|
|
856
858
|
intent.setValue(setupError, forKey: "lastSetupError")
|
|
857
859
|
}
|
|
@@ -878,7 +880,7 @@ class Mappers {
|
|
|
878
880
|
|
|
879
881
|
class func mapUICustomization(_ params: NSDictionary) -> STPThreeDSUICustomization {
|
|
880
882
|
let uiCustomization = STPThreeDSUICustomization()
|
|
881
|
-
if let labelSettings = params["label"] as?
|
|
883
|
+
if let labelSettings = params["label"] as? [String: Any?] {
|
|
882
884
|
if let headingTextColor = labelSettings["headingTextColor"] as? String {
|
|
883
885
|
uiCustomization.labelCustomization.headingTextColor = UIColor(hexString: headingTextColor)
|
|
884
886
|
}
|
|
@@ -893,7 +895,7 @@ class Mappers {
|
|
|
893
895
|
}
|
|
894
896
|
}
|
|
895
897
|
|
|
896
|
-
if let navigationBarSettings = params["navigationBar"] as?
|
|
898
|
+
if let navigationBarSettings = params["navigationBar"] as? [String: Any?] {
|
|
897
899
|
if let barTintColor = navigationBarSettings["barTintColor"] as? String {
|
|
898
900
|
uiCustomization.navigationBarCustomization.barTintColor = UIColor(hexString: barTintColor)
|
|
899
901
|
}
|
|
@@ -917,7 +919,7 @@ class Mappers {
|
|
|
917
919
|
}
|
|
918
920
|
}
|
|
919
921
|
|
|
920
|
-
if let textFieldSettings = params["textField"] as?
|
|
922
|
+
if let textFieldSettings = params["textField"] as? [String: Any?] {
|
|
921
923
|
if let borderColor = textFieldSettings["borderColor"] as? String {
|
|
922
924
|
uiCustomization.textFieldCustomization.borderColor = UIColor(hexString: borderColor)
|
|
923
925
|
}
|
|
@@ -935,7 +937,7 @@ class Mappers {
|
|
|
935
937
|
}
|
|
936
938
|
}
|
|
937
939
|
|
|
938
|
-
if let footerSettings = params["footer"] as?
|
|
940
|
+
if let footerSettings = params["footer"] as? [String: Any?] {
|
|
939
941
|
if let backgroundColor = footerSettings["backgroundColor"] as? String {
|
|
940
942
|
uiCustomization.footerCustomization.backgroundColor = UIColor(hexString: backgroundColor)
|
|
941
943
|
}
|
|
@@ -950,7 +952,7 @@ class Mappers {
|
|
|
950
952
|
}
|
|
951
953
|
}
|
|
952
954
|
|
|
953
|
-
if let submitButtonSettings = params["submitButton"] as?
|
|
955
|
+
if let submitButtonSettings = params["submitButton"] as? [String: Any?] {
|
|
954
956
|
let buttonCustomization = uiCustomization.buttonCustomization(for: STPThreeDSCustomizationButtonType.submit)
|
|
955
957
|
|
|
956
958
|
if let backgroundColor = submitButtonSettings["backgroundColor"] as? String {
|
|
@@ -969,7 +971,7 @@ class Mappers {
|
|
|
969
971
|
uiCustomization.setButtonCustomization(buttonCustomization, for: STPThreeDSCustomizationButtonType.submit)
|
|
970
972
|
}
|
|
971
973
|
|
|
972
|
-
if let submitButtonSettings = params["cancelButton"] as?
|
|
974
|
+
if let submitButtonSettings = params["cancelButton"] as? [String: Any?] {
|
|
973
975
|
let buttonCustomization = uiCustomization.buttonCustomization(for: STPThreeDSCustomizationButtonType.cancel)
|
|
974
976
|
|
|
975
977
|
if let backgroundColor = submitButtonSettings["backgroundColor"] as? String {
|
|
@@ -988,7 +990,7 @@ class Mappers {
|
|
|
988
990
|
uiCustomization.setButtonCustomization(buttonCustomization, for: STPThreeDSCustomizationButtonType.cancel)
|
|
989
991
|
}
|
|
990
992
|
|
|
991
|
-
if let submitButtonSettings = params["continueButton"] as?
|
|
993
|
+
if let submitButtonSettings = params["continueButton"] as? [String: Any?] {
|
|
992
994
|
let buttonCustomization = uiCustomization.buttonCustomization(for: STPThreeDSCustomizationButtonType.continue)
|
|
993
995
|
|
|
994
996
|
if let backgroundColor = submitButtonSettings["backgroundColor"] as? String {
|
|
@@ -1007,7 +1009,7 @@ class Mappers {
|
|
|
1007
1009
|
uiCustomization.setButtonCustomization(buttonCustomization, for: STPThreeDSCustomizationButtonType.continue)
|
|
1008
1010
|
}
|
|
1009
1011
|
|
|
1010
|
-
if let submitButtonSettings = params["nextButton"] as?
|
|
1012
|
+
if let submitButtonSettings = params["nextButton"] as? [String: Any?] {
|
|
1011
1013
|
let buttonCustomization = uiCustomization.buttonCustomization(for: STPThreeDSCustomizationButtonType.next)
|
|
1012
1014
|
|
|
1013
1015
|
if let backgroundColor = submitButtonSettings["backgroundColor"] as? String {
|
|
@@ -1026,7 +1028,7 @@ class Mappers {
|
|
|
1026
1028
|
uiCustomization.setButtonCustomization(buttonCustomization, for: STPThreeDSCustomizationButtonType.next)
|
|
1027
1029
|
}
|
|
1028
1030
|
|
|
1029
|
-
if let submitButtonSettings = params["resendButton"] as?
|
|
1031
|
+
if let submitButtonSettings = params["resendButton"] as? [String: Any?] {
|
|
1030
1032
|
let buttonCustomization = uiCustomization.buttonCustomization(for: STPThreeDSCustomizationButtonType.resend)
|
|
1031
1033
|
|
|
1032
1034
|
if let backgroundColor = submitButtonSettings["backgroundColor"] as? String {
|
|
@@ -1049,7 +1051,6 @@ class Mappers {
|
|
|
1049
1051
|
uiCustomization.backgroundColor = UIColor(hexString: backgroundColor)
|
|
1050
1052
|
}
|
|
1051
1053
|
|
|
1052
|
-
|
|
1053
1054
|
return uiCustomization
|
|
1054
1055
|
}
|
|
1055
1056
|
|
|
@@ -1061,7 +1062,6 @@ class Mappers {
|
|
|
1061
1062
|
return nil
|
|
1062
1063
|
}
|
|
1063
1064
|
|
|
1064
|
-
|
|
1065
1065
|
class func mapFromCardValidationState(state: STPCardValidationState?) -> String {
|
|
1066
1066
|
if let state = state {
|
|
1067
1067
|
switch state {
|
|
@@ -1076,7 +1076,7 @@ class Mappers {
|
|
|
1076
1076
|
|
|
1077
1077
|
class func mapToPKAddPassButtonStyle(style: String?) -> PKAddPassButtonStyle {
|
|
1078
1078
|
if let style = style {
|
|
1079
|
-
if
|
|
1079
|
+
if style == "onDarkBackground" {
|
|
1080
1080
|
return .blackOutline
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
@@ -1086,9 +1086,9 @@ class Mappers {
|
|
|
1086
1086
|
class func mapFromUSBankAccountHolderType(type: STPPaymentMethodUSBankAccountHolderType?) -> String {
|
|
1087
1087
|
if let type = type {
|
|
1088
1088
|
switch type {
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1089
|
+
case STPPaymentMethodUSBankAccountHolderType.company: return "Company"
|
|
1090
|
+
case STPPaymentMethodUSBankAccountHolderType.individual: return "Individual"
|
|
1091
|
+
case STPPaymentMethodUSBankAccountHolderType.unknown: return "Unknown"
|
|
1092
1092
|
}
|
|
1093
1093
|
}
|
|
1094
1094
|
return "Unknown"
|
|
@@ -1096,18 +1096,18 @@ class Mappers {
|
|
|
1096
1096
|
|
|
1097
1097
|
class func mapToUSBankAccountHolderType(type: String?) -> STPPaymentMethodUSBankAccountHolderType {
|
|
1098
1098
|
switch type {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1099
|
+
case "Company": return STPPaymentMethodUSBankAccountHolderType.company
|
|
1100
|
+
case "Individual": return STPPaymentMethodUSBankAccountHolderType.individual
|
|
1101
|
+
default: return STPPaymentMethodUSBankAccountHolderType.individual
|
|
1102
1102
|
}
|
|
1103
1103
|
}
|
|
1104
1104
|
|
|
1105
1105
|
class func mapFromUSBankAccountType(type: STPPaymentMethodUSBankAccountType?) -> String {
|
|
1106
1106
|
if let type = type {
|
|
1107
1107
|
switch type {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1108
|
+
case STPPaymentMethodUSBankAccountType.savings: return "Savings"
|
|
1109
|
+
case STPPaymentMethodUSBankAccountType.checking: return "Checking"
|
|
1110
|
+
case STPPaymentMethodUSBankAccountType.unknown: return "Unknown"
|
|
1111
1111
|
}
|
|
1112
1112
|
}
|
|
1113
1113
|
return "Unknown"
|
|
@@ -1115,9 +1115,9 @@ class Mappers {
|
|
|
1115
1115
|
|
|
1116
1116
|
class func mapToUSBankAccountType(type: String?) -> STPPaymentMethodUSBankAccountType {
|
|
1117
1117
|
switch type {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1118
|
+
case "Savings": return STPPaymentMethodUSBankAccountType.savings
|
|
1119
|
+
case "Checking": return STPPaymentMethodUSBankAccountType.checking
|
|
1120
|
+
default: return STPPaymentMethodUSBankAccountType.checking
|
|
1121
1121
|
}
|
|
1122
1122
|
}
|
|
1123
1123
|
|
|
@@ -1147,25 +1147,162 @@ class Mappers {
|
|
|
1147
1147
|
}
|
|
1148
1148
|
|
|
1149
1149
|
class func financialConnectionsEventToMap(_ event: FinancialConnectionsEvent) -> [String: Any] {
|
|
1150
|
-
|
|
1150
|
+
var metadata: [String: Any] = [:]
|
|
1151
1151
|
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1152
|
+
if let manualEntry = event.metadata.manualEntry {
|
|
1153
|
+
metadata["manualEntry"] = manualEntry
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
if let institutionName = event.metadata.institutionName {
|
|
1157
|
+
metadata["institutionName"] = institutionName
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
if let errorCode = event.metadata.errorCode {
|
|
1161
|
+
metadata["errorCode"] = errorCode.rawValue
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
let mappedEvent: [String: Any] = [
|
|
1165
|
+
"name": event.name.rawValue,
|
|
1166
|
+
"metadata": metadata,
|
|
1167
|
+
]
|
|
1168
|
+
|
|
1169
|
+
return mappedEvent
|
|
1170
|
+
}
|
|
1155
1171
|
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1172
|
+
#if canImport(StripeCryptoOnramp)
|
|
1173
|
+
class func mapToLinkAppearance(_ params: [String: Any?]) -> LinkAppearance {
|
|
1174
|
+
let darkColors = params["darkColors"] as? [String: Any?]
|
|
1175
|
+
let lightColors = params["lightColors"] as? [String: Any?]
|
|
1159
1176
|
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1177
|
+
let darkPrimaryHex = darkColors?["primary"] as? String
|
|
1178
|
+
let lightPrimaryHex = lightColors?["primary"] as? String
|
|
1179
|
+
let darkSelectedBorderHex = darkColors?["borderSelected"] as? String
|
|
1180
|
+
let lightSelectedBorderHex = lightColors?["borderSelected"] as? String
|
|
1181
|
+
|
|
1182
|
+
let darkPrimary = darkPrimaryHex.flatMap { UIColor(hexString: $0) }
|
|
1183
|
+
let lightPrimary = lightPrimaryHex.flatMap { UIColor(hexString: $0) }
|
|
1184
|
+
|
|
1185
|
+
let darkSelectedBorder = darkSelectedBorderHex.flatMap { UIColor(hexString: $0) }
|
|
1186
|
+
let lightSelectedBorder = lightSelectedBorderHex.flatMap { UIColor(hexString: $0) }
|
|
1187
|
+
|
|
1188
|
+
let primary: UIColor? = if let darkPrimary, let lightPrimary {
|
|
1189
|
+
UIColor { trait in
|
|
1190
|
+
trait.userInterfaceStyle == .dark ? darkPrimary : lightPrimary
|
|
1191
|
+
}
|
|
1192
|
+
} else {
|
|
1193
|
+
darkPrimary ?? lightPrimary
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
let selectedBorder: UIColor? = if let darkSelectedBorder, let lightSelectedBorder {
|
|
1197
|
+
UIColor { trait in
|
|
1198
|
+
trait.userInterfaceStyle == .dark ? darkSelectedBorder : lightSelectedBorder
|
|
1199
|
+
}
|
|
1200
|
+
} else {
|
|
1201
|
+
darkSelectedBorder ?? lightSelectedBorder
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
let colors: LinkAppearance.Colors? = if primary != nil || selectedBorder != nil {
|
|
1205
|
+
.init(primary: primary, selectedBorder: selectedBorder)
|
|
1206
|
+
} else {
|
|
1207
|
+
nil
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
let primaryButtonConfiguration: LinkAppearance.PrimaryButtonConfiguration? =
|
|
1211
|
+
if let primaryButton = params["primaryButton"] as? [String: CGFloat],
|
|
1212
|
+
let cornerRadius = primaryButton["cornerRadius"],
|
|
1213
|
+
let height = primaryButton["height"] {
|
|
1214
|
+
.init(cornerRadius: cornerRadius, height: height)
|
|
1215
|
+
} else {
|
|
1216
|
+
nil
|
|
1217
|
+
}
|
|
1163
1218
|
|
|
1164
|
-
|
|
1165
|
-
"
|
|
1166
|
-
"
|
|
1167
|
-
|
|
1219
|
+
let style: PaymentSheet.UserInterfaceStyle = switch params["style"] as? String ?? "" {
|
|
1220
|
+
case "ALWAYS_LIGHT": .alwaysLight
|
|
1221
|
+
case "ALWAYS_DARK": .alwaysDark
|
|
1222
|
+
default: .automatic
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
return LinkAppearance(
|
|
1226
|
+
colors: colors,
|
|
1227
|
+
primaryButton: primaryButtonConfiguration,
|
|
1228
|
+
style: style,
|
|
1229
|
+
reduceLinkBranding: true
|
|
1230
|
+
)
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
class func mapToKycAddress(_ params: [String: String]) -> Address {
|
|
1234
|
+
return Address(
|
|
1235
|
+
city: params["city"],
|
|
1236
|
+
country: params["country"],
|
|
1237
|
+
line1: params["line1"],
|
|
1238
|
+
line2: params["line2"],
|
|
1239
|
+
postalCode: params["postalCode"],
|
|
1240
|
+
state: params["state"]
|
|
1241
|
+
)
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
class func mapToKycInfo(_ params: [String: Any?]) throws -> KycInfo {
|
|
1245
|
+
guard let firstName = params["firstName"] as? String, !firstName.isEmpty else {
|
|
1246
|
+
throw KycInfoError.missingRequiredField("firstName")
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
guard let lastName = params["lastName"] as? String, !lastName.isEmpty else {
|
|
1250
|
+
throw KycInfoError.missingRequiredField("lastName")
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
guard let idNumber = params["idNumber"] as? String, !idNumber.isEmpty else {
|
|
1254
|
+
throw KycInfoError.missingRequiredField("idNumber")
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
guard let dateOfBirthParams = params["dateOfBirth"] as? [String: Int] else {
|
|
1258
|
+
throw KycInfoError.missingRequiredField("dateOfBirth")
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
guard let day = dateOfBirthParams["day"] else {
|
|
1262
|
+
throw KycInfoError.missingRequiredField("dateOfBirth.day")
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
guard let month = dateOfBirthParams["month"] else {
|
|
1266
|
+
throw KycInfoError.missingRequiredField("dateOfBirth.month")
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
guard let year = dateOfBirthParams["year"] else {
|
|
1270
|
+
throw KycInfoError.missingRequiredField("dateOfBirth.year")
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
let dateOfBirth = KycInfo.DateOfBirth(day: day, month: month, year: year)
|
|
1274
|
+
|
|
1275
|
+
// All address parameters are optional, so we don’t guard.
|
|
1276
|
+
let address = if let addressParams = params["address"] as? [String: String] {
|
|
1277
|
+
mapToKycAddress(addressParams)
|
|
1278
|
+
} else {
|
|
1279
|
+
Address()
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
return KycInfo(
|
|
1283
|
+
firstName: firstName,
|
|
1284
|
+
lastName: lastName,
|
|
1285
|
+
idNumber: idNumber,
|
|
1286
|
+
address: address,
|
|
1287
|
+
dateOfBirth: dateOfBirth
|
|
1288
|
+
)
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
class func paymentMethodDisplayDataToMap(_ paymentMethodDisplayData: PaymentMethodDisplayData) -> [String: String] {
|
|
1292
|
+
var result = [
|
|
1293
|
+
"icon": "data:image/png;base64," + (paymentMethodDisplayData.icon.pngData()?.base64EncodedString(options: []) ?? ""),
|
|
1294
|
+
"label": paymentMethodDisplayData.label,
|
|
1295
|
+
]
|
|
1296
|
+
|
|
1297
|
+
if let sublabel = paymentMethodDisplayData.sublabel {
|
|
1298
|
+
result["sublabel"] = sublabel
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
return result
|
|
1302
|
+
}
|
|
1168
1303
|
|
|
1169
|
-
|
|
1304
|
+
enum KycInfoError: Swift.Error {
|
|
1305
|
+
case missingRequiredField(String)
|
|
1170
1306
|
}
|
|
1307
|
+
#endif
|
|
1171
1308
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NavigationBarManager.m
|
|
3
|
+
// stripe-react-native
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
#import <Foundation/Foundation.h>
|
|
7
|
+
#import <React/RCTBridgeModule.h>
|
|
8
|
+
#import <React/RCTViewManager.h>
|
|
9
|
+
|
|
10
|
+
@interface RCT_EXTERN_MODULE(NavigationBarManager, RCTViewManager)
|
|
11
|
+
RCT_EXPORT_VIEW_PROPERTY(title, NSString)
|
|
12
|
+
RCT_EXPORT_VIEW_PROPERTY(onCloseButtonPress, RCTDirectEventBlock)
|
|
13
|
+
@end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NavigationBarManager.swift
|
|
3
|
+
// stripe-react-native
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
import Foundation
|
|
7
|
+
|
|
8
|
+
@objc(NavigationBarManager)
|
|
9
|
+
class NavigationBarManager: RCTViewManager {
|
|
10
|
+
override func view() -> UIView! {
|
|
11
|
+
return NavigationBarView()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override class func requiresMainQueueSetup() -> Bool {
|
|
15
|
+
return true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NavigationBarView.swift
|
|
3
|
+
// stripe-react-native
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
import Foundation
|
|
7
|
+
import UIKit
|
|
8
|
+
|
|
9
|
+
@objc(NavigationBarView)
|
|
10
|
+
public class NavigationBarView: UIView {
|
|
11
|
+
@objc public var onCloseButtonPress: RCTDirectEventBlock?
|
|
12
|
+
|
|
13
|
+
private var navigationBar: UINavigationBar!
|
|
14
|
+
private var navigationItem: UINavigationItem!
|
|
15
|
+
|
|
16
|
+
@objc public var title: NSString? {
|
|
17
|
+
didSet {
|
|
18
|
+
navigationItem.title = title as String?
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override public init(frame: CGRect) {
|
|
23
|
+
super.init(frame: frame)
|
|
24
|
+
setupNavigationBar()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
required init?(coder: NSCoder) {
|
|
28
|
+
fatalError("init(coder:) has not been implemented")
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private func setupNavigationBar() {
|
|
32
|
+
// Create navigation bar
|
|
33
|
+
navigationBar = UINavigationBar(frame: .zero)
|
|
34
|
+
navigationBar.translatesAutoresizingMaskIntoConstraints = false
|
|
35
|
+
|
|
36
|
+
// Create navigation item
|
|
37
|
+
navigationItem = UINavigationItem()
|
|
38
|
+
navigationBar.items = [navigationItem]
|
|
39
|
+
|
|
40
|
+
// Add close button on the right
|
|
41
|
+
let closeButton = UIBarButtonItem(
|
|
42
|
+
barButtonSystemItem: .close,
|
|
43
|
+
target: self,
|
|
44
|
+
action: #selector(closeButtonTapped)
|
|
45
|
+
)
|
|
46
|
+
navigationItem.rightBarButtonItem = closeButton
|
|
47
|
+
|
|
48
|
+
// Add to view
|
|
49
|
+
addSubview(navigationBar)
|
|
50
|
+
|
|
51
|
+
// Setup constraints
|
|
52
|
+
NSLayoutConstraint.activate([
|
|
53
|
+
navigationBar.topAnchor.constraint(equalTo: topAnchor),
|
|
54
|
+
navigationBar.leadingAnchor.constraint(equalTo: leadingAnchor),
|
|
55
|
+
navigationBar.trailingAnchor.constraint(equalTo: trailingAnchor),
|
|
56
|
+
navigationBar.bottomAnchor.constraint(equalTo: bottomAnchor),
|
|
57
|
+
])
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@objc private func closeButtonTapped() {
|
|
61
|
+
if let onCloseButtonPress = onCloseButtonPress {
|
|
62
|
+
onCloseButtonPress([:])
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|