@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,228 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.reactnativestripesdk.utils.PaymentSheetException
|
|
5
|
+
import com.reactnativestripesdk.utils.getBooleanOr
|
|
6
|
+
import com.reactnativestripesdk.utils.getIntOr
|
|
7
|
+
import com.reactnativestripesdk.utils.getLongOr
|
|
8
|
+
import com.reactnativestripesdk.utils.getStringList
|
|
9
|
+
import com.reactnativestripesdk.utils.isEmpty
|
|
10
|
+
import com.stripe.android.paymentelement.PaymentMethodOptionsSetupFutureUsagePreview
|
|
11
|
+
import com.stripe.android.paymentsheet.PaymentSheet
|
|
12
|
+
|
|
13
|
+
@Throws(PaymentSheetException::class)
|
|
14
|
+
internal fun buildIntentConfiguration(intentConfigurationParams: ReadableMap?): PaymentSheet.IntentConfiguration? {
|
|
15
|
+
if (intentConfigurationParams == null) {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
val modeParams =
|
|
19
|
+
intentConfigurationParams.getMap("mode")
|
|
20
|
+
?: throw PaymentSheetException(
|
|
21
|
+
"If `intentConfiguration` is provided, `intentConfiguration.mode` is required",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
return PaymentSheet.IntentConfiguration(
|
|
25
|
+
mode = buildIntentConfigurationMode(modeParams),
|
|
26
|
+
paymentMethodTypes =
|
|
27
|
+
intentConfigurationParams.getStringList("paymentMethodTypes")?.toList()
|
|
28
|
+
?: emptyList(),
|
|
29
|
+
onBehalfOf = intentConfigurationParams.getString("onBehalfOf"),
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@OptIn(PaymentMethodOptionsSetupFutureUsagePreview::class)
|
|
34
|
+
private fun buildIntentConfigurationMode(modeParams: ReadableMap): PaymentSheet.IntentConfiguration.Mode =
|
|
35
|
+
if (modeParams.hasKey("amount")) {
|
|
36
|
+
val currencyCode =
|
|
37
|
+
modeParams.getString("currencyCode")
|
|
38
|
+
?: throw PaymentSheetException(
|
|
39
|
+
"You must provide a value to intentConfiguration.mode.currencyCode",
|
|
40
|
+
)
|
|
41
|
+
PaymentSheet.IntentConfiguration.Mode.Payment(
|
|
42
|
+
amount = modeParams.getLongOr("amount", 0),
|
|
43
|
+
currency = currencyCode,
|
|
44
|
+
setupFutureUse = mapToSetupFutureUse(modeParams.getString("setupFutureUsage")),
|
|
45
|
+
captureMethod = mapToCaptureMethod(modeParams.getString("captureMethod")),
|
|
46
|
+
paymentMethodOptions = mapToPaymentMethodOptions(modeParams.getMap("paymentMethodOptions")),
|
|
47
|
+
)
|
|
48
|
+
} else {
|
|
49
|
+
val setupFutureUsage =
|
|
50
|
+
mapToSetupFutureUse(modeParams.getString("setupFutureUsage"))
|
|
51
|
+
?: throw PaymentSheetException(
|
|
52
|
+
"You must provide a value to intentConfiguration.mode.setupFutureUsage",
|
|
53
|
+
)
|
|
54
|
+
PaymentSheet.IntentConfiguration.Mode.Setup(
|
|
55
|
+
currency = modeParams.getString("currencyCode"),
|
|
56
|
+
setupFutureUse = setupFutureUsage,
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
internal fun buildLinkConfig(params: ReadableMap?): PaymentSheet.LinkConfiguration {
|
|
61
|
+
if (params == null) {
|
|
62
|
+
return PaymentSheet.LinkConfiguration()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
val display = mapStringToLinkDisplay(params.getString("display"))
|
|
66
|
+
|
|
67
|
+
return PaymentSheet.LinkConfiguration(
|
|
68
|
+
display = display,
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private fun mapStringToLinkDisplay(value: String?): PaymentSheet.LinkConfiguration.Display =
|
|
73
|
+
when (value) {
|
|
74
|
+
"automatic" -> PaymentSheet.LinkConfiguration.Display.Automatic
|
|
75
|
+
"never" -> PaymentSheet.LinkConfiguration.Display.Never
|
|
76
|
+
else -> PaymentSheet.LinkConfiguration.Display.Automatic
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private val mapIntToButtonType =
|
|
80
|
+
mapOf(
|
|
81
|
+
1 to PaymentSheet.GooglePayConfiguration.ButtonType.Buy,
|
|
82
|
+
6 to PaymentSheet.GooglePayConfiguration.ButtonType.Book,
|
|
83
|
+
5 to PaymentSheet.GooglePayConfiguration.ButtonType.Checkout,
|
|
84
|
+
4 to PaymentSheet.GooglePayConfiguration.ButtonType.Donate,
|
|
85
|
+
11 to PaymentSheet.GooglePayConfiguration.ButtonType.Order,
|
|
86
|
+
1000 to PaymentSheet.GooglePayConfiguration.ButtonType.Pay,
|
|
87
|
+
7 to PaymentSheet.GooglePayConfiguration.ButtonType.Subscribe,
|
|
88
|
+
1001 to PaymentSheet.GooglePayConfiguration.ButtonType.Plain,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
internal fun buildGooglePayConfig(params: ReadableMap?): PaymentSheet.GooglePayConfiguration? {
|
|
92
|
+
if (params == null || params.isEmpty()) {
|
|
93
|
+
return null
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
val countryCode = params.getString("merchantCountryCode").orEmpty()
|
|
97
|
+
val currencyCode = params.getString("currencyCode").orEmpty()
|
|
98
|
+
val testEnv = params.getBooleanOr("testEnv", false)
|
|
99
|
+
val amount = params.getString("amount")?.toLongOrNull()
|
|
100
|
+
val label = params.getString("label")
|
|
101
|
+
val buttonType =
|
|
102
|
+
mapIntToButtonType[params.getIntOr("buttonType", 0)]
|
|
103
|
+
?: PaymentSheet.GooglePayConfiguration.ButtonType.Pay
|
|
104
|
+
|
|
105
|
+
return PaymentSheet.GooglePayConfiguration(
|
|
106
|
+
environment =
|
|
107
|
+
if (testEnv) {
|
|
108
|
+
PaymentSheet.GooglePayConfiguration.Environment.Test
|
|
109
|
+
} else {
|
|
110
|
+
PaymentSheet.GooglePayConfiguration.Environment.Production
|
|
111
|
+
},
|
|
112
|
+
countryCode = countryCode,
|
|
113
|
+
currencyCode = currencyCode,
|
|
114
|
+
amount = amount,
|
|
115
|
+
label = label,
|
|
116
|
+
buttonType = buttonType,
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@Throws(PaymentSheetException::class)
|
|
121
|
+
internal fun buildCustomerConfiguration(map: ReadableMap?): PaymentSheet.CustomerConfiguration? {
|
|
122
|
+
val customerId = map?.getString("customerId").orEmpty()
|
|
123
|
+
val customerEphemeralKeySecret = map?.getString("customerEphemeralKeySecret").orEmpty()
|
|
124
|
+
val customerSessionClientSecret = map?.getString("customerSessionClientSecret").orEmpty()
|
|
125
|
+
return if (customerSessionClientSecret.isNotEmpty() &&
|
|
126
|
+
customerEphemeralKeySecret.isNotEmpty()
|
|
127
|
+
) {
|
|
128
|
+
throw PaymentSheetException(
|
|
129
|
+
"`customerEphemeralKeySecret` and `customerSessionClientSecret` cannot both be set",
|
|
130
|
+
)
|
|
131
|
+
} else if (customerId.isNotEmpty() && customerSessionClientSecret.isNotEmpty()) {
|
|
132
|
+
PaymentSheet.CustomerConfiguration.createWithCustomerSession(
|
|
133
|
+
id = customerId,
|
|
134
|
+
clientSecret = customerSessionClientSecret,
|
|
135
|
+
)
|
|
136
|
+
} else if (customerId.isNotEmpty() && customerEphemeralKeySecret.isNotEmpty()) {
|
|
137
|
+
PaymentSheet.CustomerConfiguration(
|
|
138
|
+
id = customerId,
|
|
139
|
+
ephemeralKeySecret = customerEphemeralKeySecret,
|
|
140
|
+
)
|
|
141
|
+
} else {
|
|
142
|
+
null
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
internal fun buildBillingDetails(map: ReadableMap?): PaymentSheet.BillingDetails? {
|
|
147
|
+
if (map == null) {
|
|
148
|
+
return null
|
|
149
|
+
}
|
|
150
|
+
val addressMap = map.getMap("address")
|
|
151
|
+
val address =
|
|
152
|
+
PaymentSheet.Address(
|
|
153
|
+
addressMap?.getString("city"),
|
|
154
|
+
addressMap?.getString("country"),
|
|
155
|
+
addressMap?.getString("line1"),
|
|
156
|
+
addressMap?.getString("line2"),
|
|
157
|
+
addressMap?.getString("postalCode"),
|
|
158
|
+
addressMap?.getString("state"),
|
|
159
|
+
)
|
|
160
|
+
return PaymentSheet.BillingDetails(
|
|
161
|
+
address,
|
|
162
|
+
map.getString("email"),
|
|
163
|
+
map.getString("name"),
|
|
164
|
+
map.getString("phone"),
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
internal fun buildBillingDetailsCollectionConfiguration(map: ReadableMap?): PaymentSheet.BillingDetailsCollectionConfiguration =
|
|
169
|
+
PaymentSheet.BillingDetailsCollectionConfiguration(
|
|
170
|
+
name = mapToCollectionMode(map?.getString("name")),
|
|
171
|
+
phone = mapToCollectionMode(map?.getString("phone")),
|
|
172
|
+
email = mapToCollectionMode(map?.getString("email")),
|
|
173
|
+
address = mapToAddressCollectionMode(map?.getString("address")),
|
|
174
|
+
attachDefaultsToPaymentMethod = map.getBooleanOr("attachDefaultsToPaymentMethod", false),
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
internal fun mapToCollectionMode(str: String?): PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode =
|
|
178
|
+
when (str) {
|
|
179
|
+
"automatic" -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Automatic
|
|
180
|
+
"never" -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Never
|
|
181
|
+
"always" -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Always
|
|
182
|
+
else -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Automatic
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
internal fun mapToAddressCollectionMode(str: String?): PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode =
|
|
186
|
+
when (str) {
|
|
187
|
+
"automatic" ->
|
|
188
|
+
PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic
|
|
189
|
+
|
|
190
|
+
"never" -> PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Never
|
|
191
|
+
"full" -> PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Full
|
|
192
|
+
else -> PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
internal fun mapToCardBrandAcceptance(params: ReadableMap?): PaymentSheet.CardBrandAcceptance {
|
|
196
|
+
val cardBrandAcceptanceParams = params?.getMap("cardBrandAcceptance") ?: return PaymentSheet.CardBrandAcceptance.all()
|
|
197
|
+
val filter = cardBrandAcceptanceParams.getString("filter") ?: return PaymentSheet.CardBrandAcceptance.all()
|
|
198
|
+
|
|
199
|
+
return when (filter) {
|
|
200
|
+
"all" -> PaymentSheet.CardBrandAcceptance.all()
|
|
201
|
+
"allowed" -> {
|
|
202
|
+
val brands = cardBrandAcceptanceParams.getStringList("brands") ?: return PaymentSheet.CardBrandAcceptance.all()
|
|
203
|
+
val brandCategories = brands.mapNotNull { mapToCardBrandCategory(it) }
|
|
204
|
+
if (brandCategories.isEmpty()) {
|
|
205
|
+
return PaymentSheet.CardBrandAcceptance.all()
|
|
206
|
+
}
|
|
207
|
+
PaymentSheet.CardBrandAcceptance.allowed(brandCategories)
|
|
208
|
+
}
|
|
209
|
+
"disallowed" -> {
|
|
210
|
+
val brands = cardBrandAcceptanceParams.getStringList("brands") ?: return PaymentSheet.CardBrandAcceptance.all()
|
|
211
|
+
val brandCategories = brands.mapNotNull { mapToCardBrandCategory(it) }
|
|
212
|
+
if (brandCategories.isEmpty()) {
|
|
213
|
+
return PaymentSheet.CardBrandAcceptance.all()
|
|
214
|
+
}
|
|
215
|
+
PaymentSheet.CardBrandAcceptance.disallowed(brandCategories)
|
|
216
|
+
}
|
|
217
|
+
else -> PaymentSheet.CardBrandAcceptance.all()
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
internal fun mapToCardBrandCategory(brand: String): PaymentSheet.CardBrandAcceptance.BrandCategory? =
|
|
222
|
+
when (brand) {
|
|
223
|
+
"visa" -> PaymentSheet.CardBrandAcceptance.BrandCategory.Visa
|
|
224
|
+
"mastercard" -> PaymentSheet.CardBrandAcceptance.BrandCategory.Mastercard
|
|
225
|
+
"amex" -> PaymentSheet.CardBrandAcceptance.BrandCategory.Amex
|
|
226
|
+
"discover" -> PaymentSheet.CardBrandAcceptance.BrandCategory.Discover
|
|
227
|
+
else -> null
|
|
228
|
+
}
|
|
@@ -342,6 +342,7 @@ class PaymentLauncherManager(
|
|
|
342
342
|
StripeIntent.NextActionType.DisplayOxxoDetails,
|
|
343
343
|
StripeIntent.NextActionType.DisplayBoletoDetails,
|
|
344
344
|
StripeIntent.NextActionType.DisplayKonbiniDetails,
|
|
345
|
+
StripeIntent.NextActionType.DisplayPayNowDetails,
|
|
345
346
|
StripeIntent.NextActionType.VerifyWithMicrodeposits,
|
|
346
347
|
StripeIntent.NextActionType.DisplayMultibancoDetails,
|
|
347
348
|
StripeIntent.NextActionType.DisplayPayNowDetails,
|
|
@@ -6,6 +6,7 @@ import com.reactnativestripesdk.utils.getValOr
|
|
|
6
6
|
import com.reactnativestripesdk.utils.mapToBillingDetails
|
|
7
7
|
import com.reactnativestripesdk.utils.mapToMetadata
|
|
8
8
|
import com.reactnativestripesdk.utils.mapToPaymentIntentFutureUsage
|
|
9
|
+
import com.reactnativestripesdk.utils.mapToShippingDetails
|
|
9
10
|
import com.reactnativestripesdk.utils.mapToUSBankAccountHolderType
|
|
10
11
|
import com.reactnativestripesdk.utils.mapToUSBankAccountType
|
|
11
12
|
import com.stripe.android.model.ConfirmPaymentIntentParams
|
|
@@ -403,10 +404,12 @@ class PaymentMethodCreateParamsFactory(
|
|
|
403
404
|
}
|
|
404
405
|
|
|
405
406
|
val params = createAffirmParams()
|
|
407
|
+
val shippingDetails = mapToShippingDetails(paymentMethodData?.getMap("shippingDetails"))
|
|
406
408
|
|
|
407
409
|
return ConfirmPaymentIntentParams.createWithPaymentMethodCreateParams(
|
|
408
410
|
paymentMethodCreateParams = params,
|
|
409
411
|
clientSecret = clientSecret,
|
|
412
|
+
shipping = shippingDetails,
|
|
410
413
|
setupFutureUsage = mapToPaymentIntentFutureUsage(getValOr(options, "setupFutureUsage")),
|
|
411
414
|
mandateData = buildMandateDataParams(),
|
|
412
415
|
)
|
|
@@ -11,8 +11,6 @@ import androidx.compose.ui.text.style.TextDecoration
|
|
|
11
11
|
import androidx.compose.ui.unit.TextUnit
|
|
12
12
|
import com.facebook.react.bridge.Arguments
|
|
13
13
|
import com.facebook.react.bridge.WritableMap
|
|
14
|
-
import com.reactnativestripesdk.getBase64FromBitmap
|
|
15
|
-
import com.reactnativestripesdk.getBitmapFromDrawable
|
|
16
14
|
import com.reactnativestripesdk.utils.mapFromPaymentSheetBillingDetails
|
|
17
15
|
import com.stripe.android.paymentelement.EmbeddedPaymentElement
|
|
18
16
|
import kotlinx.coroutines.Dispatchers
|
|
@@ -50,7 +48,7 @@ suspend fun EmbeddedPaymentElement.PaymentOptionDisplayData.toWritableMap(): Wri
|
|
|
50
48
|
getBase64FromBitmap(bitmap)
|
|
51
49
|
} ?: ""
|
|
52
50
|
}
|
|
53
|
-
} catch (
|
|
51
|
+
} catch (_: Exception) {
|
|
54
52
|
// If imageLoader fails or times out, return empty string
|
|
55
53
|
""
|
|
56
54
|
}
|
|
@@ -120,17 +118,17 @@ fun AnnotatedString.toHtmlString(): String {
|
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
AnnotationType.STRING_ANNOTATION -> {
|
|
123
|
-
val stringAnnotation = annotation.data as AnnotatedString.Range
|
|
121
|
+
val stringAnnotation = annotation.data as AnnotatedString.Range<*>
|
|
124
122
|
when (stringAnnotation.tag) {
|
|
125
123
|
"URL", "LINK_TAG" -> {
|
|
126
124
|
val url = stringAnnotation.item
|
|
127
|
-
htmlBuilder.append("<a href=\"${escapeHtml(url)}\">")
|
|
125
|
+
htmlBuilder.append("<a href=\"${escapeHtml(url as String)}\">")
|
|
128
126
|
openTags.add(TagInfo(annotation.end, "</a>"))
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
130
|
AnnotationType.LINK_ANNOTATION -> {
|
|
133
|
-
val linkAnnotation = annotation.data as AnnotatedString.Range
|
|
131
|
+
val linkAnnotation = annotation.data as AnnotatedString.Range<*>
|
|
134
132
|
when (val linkItem = linkAnnotation.item) {
|
|
135
133
|
is LinkAnnotation.Url -> {
|
|
136
134
|
htmlBuilder.append("<a href=\"${escapeHtml(linkItem.url)}\">")
|
|
@@ -3,7 +3,7 @@ package com.reactnativestripesdk
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
5
|
import android.content.res.Configuration
|
|
6
|
-
import
|
|
6
|
+
import androidx.core.graphics.toColorInt
|
|
7
7
|
import com.facebook.react.bridge.Arguments
|
|
8
8
|
import com.facebook.react.bridge.ReadableMap
|
|
9
9
|
import com.facebook.react.bridge.ReadableType
|
|
@@ -34,8 +34,8 @@ fun buildPaymentSheetAppearance(
|
|
|
34
34
|
|
|
35
35
|
val builder = PaymentSheet.Appearance.Builder()
|
|
36
36
|
builder.typography(buildTypography(userParams?.getMap(PaymentSheetAppearanceKeys.FONT), context))
|
|
37
|
-
builder.colorsLight(buildColorsBuilder(lightColorParams).
|
|
38
|
-
builder.colorsDark(buildColorsBuilder(darkColorParams).
|
|
37
|
+
builder.colorsLight(buildColorsBuilder(isLightMode = true, lightColorParams).build())
|
|
38
|
+
builder.colorsDark(buildColorsBuilder(isLightMode = false, darkColorParams).build())
|
|
39
39
|
builder.shapes(buildShapes(userParams?.getMap(PaymentSheetAppearanceKeys.SHAPES)))
|
|
40
40
|
builder.primaryButton(
|
|
41
41
|
buildPrimaryButton(
|
|
@@ -48,6 +48,7 @@ fun buildPaymentSheetAppearance(
|
|
|
48
48
|
return builder.build()
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
@SuppressLint("RestrictedApi")
|
|
51
52
|
@OptIn(AppearanceAPIAdditionsPreview::class)
|
|
52
53
|
private fun buildTypography(
|
|
53
54
|
fontParams: ReadableMap?,
|
|
@@ -74,7 +75,7 @@ private fun buildTypography(
|
|
|
74
75
|
private fun colorFromHex(hexString: String?): Int? =
|
|
75
76
|
hexString?.trim()?.replace("#", "")?.let {
|
|
76
77
|
if (it.length == 6 || it.length == 8) {
|
|
77
|
-
|
|
78
|
+
"#$it".toColorInt()
|
|
78
79
|
} else {
|
|
79
80
|
throw PaymentSheetAppearanceException(
|
|
80
81
|
"Failed to set Payment Sheet appearance. Expected hex string of length 6 or 8, but received: $it",
|
|
@@ -82,8 +83,17 @@ private fun colorFromHex(hexString: String?): Int? =
|
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
@SuppressLint("RestrictedApi")
|
|
87
|
+
private fun buildColorsBuilder(
|
|
88
|
+
isLightMode: Boolean,
|
|
89
|
+
colorParams: ReadableMap?,
|
|
90
|
+
): PaymentSheet.Colors.Builder {
|
|
91
|
+
val builder =
|
|
92
|
+
if (isLightMode) {
|
|
93
|
+
PaymentSheet.Colors.Builder.light()
|
|
94
|
+
} else {
|
|
95
|
+
PaymentSheet.Colors.Builder.dark()
|
|
96
|
+
}
|
|
87
97
|
|
|
88
98
|
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.PRIMARY))?.let {
|
|
89
99
|
builder.primary(it)
|
|
@@ -132,6 +142,7 @@ private fun buildColorsBuilder(colorParams: ReadableMap?): PaymentSheet.Colors.B
|
|
|
132
142
|
return builder
|
|
133
143
|
}
|
|
134
144
|
|
|
145
|
+
@SuppressLint("RestrictedApi")
|
|
135
146
|
private fun buildShapes(shapeParams: ReadableMap?): PaymentSheet.Shapes {
|
|
136
147
|
val builder = PaymentSheet.Shapes.Builder()
|
|
137
148
|
|
|
@@ -146,6 +157,7 @@ private fun buildShapes(shapeParams: ReadableMap?): PaymentSheet.Shapes {
|
|
|
146
157
|
return builder.build()
|
|
147
158
|
}
|
|
148
159
|
|
|
160
|
+
@SuppressLint("RestrictedApi")
|
|
149
161
|
private fun buildPrimaryButton(
|
|
150
162
|
params: ReadableMap?,
|
|
151
163
|
context: Context,
|
|
@@ -162,9 +174,9 @@ private fun buildPrimaryButton(
|
|
|
162
174
|
|
|
163
175
|
return PaymentSheet.PrimaryButton(
|
|
164
176
|
colorsLight =
|
|
165
|
-
buildPrimaryButtonColors(lightColorParams, context).
|
|
177
|
+
buildPrimaryButtonColors(true, lightColorParams, context).build(),
|
|
166
178
|
colorsDark =
|
|
167
|
-
buildPrimaryButtonColors(darkColorParams, context).
|
|
179
|
+
buildPrimaryButtonColors(false, darkColorParams, context).build(),
|
|
168
180
|
shape =
|
|
169
181
|
PaymentSheet.PrimaryButtonShape(
|
|
170
182
|
cornerRadiusDp =
|
|
@@ -181,12 +193,19 @@ private fun buildPrimaryButton(
|
|
|
181
193
|
)
|
|
182
194
|
}
|
|
183
195
|
|
|
196
|
+
@SuppressLint("RestrictedApi")
|
|
184
197
|
@Throws(PaymentSheetAppearanceException::class)
|
|
185
198
|
private fun buildPrimaryButtonColors(
|
|
199
|
+
isLightMode: Boolean,
|
|
186
200
|
colorParams: ReadableMap,
|
|
187
201
|
context: Context,
|
|
188
202
|
): PaymentSheet.PrimaryButtonColors.Builder {
|
|
189
|
-
val builder =
|
|
203
|
+
val builder =
|
|
204
|
+
if (isLightMode) {
|
|
205
|
+
PaymentSheet.PrimaryButtonColors.Builder.light()
|
|
206
|
+
} else {
|
|
207
|
+
PaymentSheet.PrimaryButtonColors.Builder.dark()
|
|
208
|
+
}
|
|
190
209
|
|
|
191
210
|
// TODO: Why is background a string but successBackgroundColor a "dynamic" color?
|
|
192
211
|
// https://stripe.dev/stripe-react-native/api-reference/types/PaymentSheet.PrimaryButtonColorConfig.html
|
|
@@ -236,16 +255,23 @@ private fun buildEmbeddedAppearance(
|
|
|
236
255
|
val separatorInsetsParams =
|
|
237
256
|
flatParams?.getMap(PaymentSheetAppearanceKeys.SEPARATOR_INSETS)
|
|
238
257
|
|
|
239
|
-
val
|
|
258
|
+
val flatRadioLightColorsBuilder =
|
|
240
259
|
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithRadio.Colors
|
|
241
|
-
.Builder
|
|
260
|
+
.Builder
|
|
261
|
+
.light()
|
|
262
|
+
|
|
263
|
+
val flatRadioDarkColorsBuilder =
|
|
264
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithRadio.Colors
|
|
265
|
+
.Builder
|
|
266
|
+
.dark()
|
|
242
267
|
|
|
243
268
|
dynamicColorFromParams(
|
|
244
269
|
context,
|
|
245
270
|
flatParams,
|
|
246
271
|
PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
247
272
|
)?.let {
|
|
248
|
-
|
|
273
|
+
flatRadioLightColorsBuilder.separatorColor(it)
|
|
274
|
+
flatRadioDarkColorsBuilder.separatorColor(it)
|
|
249
275
|
}
|
|
250
276
|
|
|
251
277
|
dynamicColorFromParams(
|
|
@@ -253,7 +279,8 @@ private fun buildEmbeddedAppearance(
|
|
|
253
279
|
radioParams,
|
|
254
280
|
PaymentSheetAppearanceKeys.SELECTED_COLOR,
|
|
255
281
|
)?.let {
|
|
256
|
-
|
|
282
|
+
flatRadioLightColorsBuilder.selectedColor(it)
|
|
283
|
+
flatRadioDarkColorsBuilder.selectedColor(it)
|
|
257
284
|
}
|
|
258
285
|
|
|
259
286
|
dynamicColorFromParams(
|
|
@@ -261,7 +288,8 @@ private fun buildEmbeddedAppearance(
|
|
|
261
288
|
radioParams,
|
|
262
289
|
PaymentSheetAppearanceKeys.UNSELECTED_COLOR,
|
|
263
290
|
)?.let {
|
|
264
|
-
|
|
291
|
+
flatRadioLightColorsBuilder.unselectedColor(it)
|
|
292
|
+
flatRadioDarkColorsBuilder.unselectedColor(it)
|
|
265
293
|
}
|
|
266
294
|
|
|
267
295
|
val rowStyleBuilder =
|
|
@@ -292,32 +320,39 @@ private fun buildEmbeddedAppearance(
|
|
|
292
320
|
rowStyleBuilder.additionalVerticalInsetsDp(it)
|
|
293
321
|
}
|
|
294
322
|
|
|
295
|
-
rowStyleBuilder.colorsLight(
|
|
296
|
-
rowStyleBuilder.colorsDark(
|
|
323
|
+
rowStyleBuilder.colorsLight(flatRadioLightColorsBuilder.build())
|
|
324
|
+
rowStyleBuilder.colorsDark(flatRadioDarkColorsBuilder.build())
|
|
297
325
|
|
|
298
326
|
embeddedBuilder.rowStyle(rowStyleBuilder.build())
|
|
299
327
|
}
|
|
300
328
|
|
|
301
329
|
"flatWithCheckmark" -> {
|
|
302
|
-
val flatParams = rowParams
|
|
330
|
+
val flatParams = rowParams.getMap(PaymentSheetAppearanceKeys.FLAT)
|
|
303
331
|
val checkmarkParams = flatParams?.getMap(PaymentSheetAppearanceKeys.CHECKMARK)
|
|
304
332
|
val separatorInsetsParams =
|
|
305
333
|
flatParams?.getMap(PaymentSheetAppearanceKeys.SEPARATOR_INSETS)
|
|
306
334
|
|
|
307
|
-
val
|
|
335
|
+
val flatCheckmarkLightColorsBuilder =
|
|
308
336
|
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithCheckmark.Colors
|
|
309
|
-
.Builder
|
|
337
|
+
.Builder
|
|
338
|
+
.light()
|
|
339
|
+
val flatCheckmarkDarkColorsBuilder =
|
|
340
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithCheckmark.Colors
|
|
341
|
+
.Builder
|
|
342
|
+
.dark()
|
|
310
343
|
|
|
311
344
|
dynamicColorFromParams(
|
|
312
345
|
context,
|
|
313
346
|
flatParams,
|
|
314
347
|
PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
315
348
|
)?.let {
|
|
316
|
-
|
|
349
|
+
flatCheckmarkLightColorsBuilder.separatorColor(it)
|
|
350
|
+
flatCheckmarkDarkColorsBuilder.separatorColor(it)
|
|
317
351
|
}
|
|
318
352
|
|
|
319
353
|
dynamicColorFromParams(context, checkmarkParams, PaymentSheetAppearanceKeys.COLOR)?.let {
|
|
320
|
-
|
|
354
|
+
flatCheckmarkLightColorsBuilder.checkmarkColor(it)
|
|
355
|
+
flatCheckmarkDarkColorsBuilder.checkmarkColor(it)
|
|
321
356
|
}
|
|
322
357
|
|
|
323
358
|
val rowStyleBuilder =
|
|
@@ -353,31 +388,38 @@ private fun buildEmbeddedAppearance(
|
|
|
353
388
|
}
|
|
354
389
|
|
|
355
390
|
// TODO: The theme is so crazy long, why does each Color thing has the same redundant Theme...
|
|
356
|
-
rowStyleBuilder.colorsLight(
|
|
357
|
-
rowStyleBuilder.colorsDark(
|
|
391
|
+
rowStyleBuilder.colorsLight(flatCheckmarkLightColorsBuilder.build())
|
|
392
|
+
rowStyleBuilder.colorsDark(flatCheckmarkDarkColorsBuilder.build())
|
|
358
393
|
embeddedBuilder.rowStyle(rowStyleBuilder.build())
|
|
359
394
|
}
|
|
360
395
|
|
|
361
396
|
"flatWithDisclosure" -> {
|
|
362
|
-
val flatParams = rowParams
|
|
397
|
+
val flatParams = rowParams.getMap(PaymentSheetAppearanceKeys.FLAT)
|
|
363
398
|
val disclosureParams = flatParams?.getMap(PaymentSheetAppearanceKeys.DISCLOSURE)
|
|
364
399
|
val separatorInsetsParams =
|
|
365
400
|
flatParams?.getMap(PaymentSheetAppearanceKeys.SEPARATOR_INSETS)
|
|
366
401
|
|
|
367
|
-
val
|
|
402
|
+
val flatDisclosureLightColorsBuilder =
|
|
368
403
|
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithDisclosure.Colors
|
|
369
|
-
.Builder
|
|
404
|
+
.Builder
|
|
405
|
+
.light()
|
|
406
|
+
val flatDisclosureDarkColorsBuilder =
|
|
407
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithDisclosure.Colors
|
|
408
|
+
.Builder
|
|
409
|
+
.dark()
|
|
370
410
|
|
|
371
411
|
dynamicColorFromParams(
|
|
372
412
|
context,
|
|
373
413
|
flatParams,
|
|
374
414
|
PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
375
415
|
)?.let {
|
|
376
|
-
|
|
416
|
+
flatDisclosureLightColorsBuilder.separatorColor(it)
|
|
417
|
+
flatDisclosureDarkColorsBuilder.separatorColor(it)
|
|
377
418
|
}
|
|
378
419
|
|
|
379
420
|
dynamicColorFromParams(context, disclosureParams, PaymentSheetAppearanceKeys.COLOR)?.let {
|
|
380
|
-
|
|
421
|
+
flatDisclosureLightColorsBuilder.disclosureColor(it)
|
|
422
|
+
flatDisclosureDarkColorsBuilder.disclosureColor(it)
|
|
381
423
|
}
|
|
382
424
|
|
|
383
425
|
val rowStyleBuilder =
|
|
@@ -408,8 +450,8 @@ private fun buildEmbeddedAppearance(
|
|
|
408
450
|
rowStyleBuilder.additionalVerticalInsetsDp(it)
|
|
409
451
|
}
|
|
410
452
|
|
|
411
|
-
rowStyleBuilder.colorsLight(
|
|
412
|
-
rowStyleBuilder.colorsDark(
|
|
453
|
+
rowStyleBuilder.colorsLight(flatDisclosureLightColorsBuilder.build())
|
|
454
|
+
rowStyleBuilder.colorsDark(flatDisclosureDarkColorsBuilder.build())
|
|
413
455
|
|
|
414
456
|
embeddedBuilder.rowStyle(rowStyleBuilder.build())
|
|
415
457
|
}
|
|
@@ -516,6 +558,7 @@ private fun getFontResId(
|
|
|
516
558
|
)
|
|
517
559
|
}
|
|
518
560
|
|
|
561
|
+
@SuppressLint("DiscouragedApi")
|
|
519
562
|
val id = context.resources.getIdentifier(fontFileName, "font", context.packageName)
|
|
520
563
|
if (id == 0) {
|
|
521
564
|
throw PaymentSheetAppearanceException("$fontErrorPrefix Failed to find font: $fontFileName")
|