@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
|
@@ -2,11 +2,11 @@ package com.reactnativestripesdk
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.res.ColorStateList
|
|
5
|
-
import android.graphics.Color
|
|
6
5
|
import android.os.Build
|
|
7
6
|
import android.text.InputFilter
|
|
8
7
|
import android.view.View
|
|
9
8
|
import android.widget.FrameLayout
|
|
9
|
+
import androidx.core.graphics.toColorInt
|
|
10
10
|
import androidx.core.view.setMargins
|
|
11
11
|
import com.facebook.react.bridge.ReadableMap
|
|
12
12
|
import com.facebook.react.uimanager.PixelUtil
|
|
@@ -36,6 +36,7 @@ import com.stripe.android.view.CardInputListener
|
|
|
36
36
|
class CardFormView(
|
|
37
37
|
private val context: ThemedReactContext,
|
|
38
38
|
) : FrameLayout(context) {
|
|
39
|
+
@SuppressLint("PrivateResource")
|
|
39
40
|
private var cardForm: CardFormView =
|
|
40
41
|
CardFormView(context, null, com.stripe.android.R.style.StripeCardFormView_Borderless)
|
|
41
42
|
private var dangerouslyGetFullCardDetails: Boolean = false
|
|
@@ -77,7 +78,7 @@ class CardFormView(
|
|
|
77
78
|
cardForm.setPreferredNetworks(mapToPreferredNetworks(preferredNetworks))
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
@SuppressLint("RestrictedApi")
|
|
81
|
+
@SuppressLint("RestrictedApi", "VisibleForTests")
|
|
81
82
|
private fun setCountry(countryString: String?) {
|
|
82
83
|
if (countryString != null) {
|
|
83
84
|
cardFormViewBinding.countryLayout.setSelectedCountryCode(CountryCode(countryString))
|
|
@@ -126,20 +127,13 @@ class CardFormView(
|
|
|
126
127
|
cardNumberEditText.clearFocus()
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
fun requestClearFromJS() {
|
|
130
|
-
multilineWidgetBinding.etCardNumber.setText("")
|
|
131
|
-
multilineWidgetBinding.etCvc.setText("")
|
|
132
|
-
multilineWidgetBinding.etExpiry.setText("")
|
|
133
|
-
cardFormViewBinding.postalCode.setText("")
|
|
134
|
-
}
|
|
135
|
-
|
|
136
130
|
private fun onChangeFocus() {
|
|
137
131
|
UIManagerHelper
|
|
138
132
|
.getEventDispatcherForReactTag(context, id)
|
|
139
133
|
?.dispatchEvent(CardFocusChangeEvent(context.surfaceId, id, currentFocusedField))
|
|
140
134
|
}
|
|
141
135
|
|
|
142
|
-
@SuppressLint("RestrictedApi")
|
|
136
|
+
@SuppressLint("RestrictedApi", "VisibleForTests")
|
|
143
137
|
fun setCardStyle(value: ReadableMap?) {
|
|
144
138
|
val backgroundColor = getValOr(value, "backgroundColor", null)
|
|
145
139
|
val textColor = getValOr(value, "textColor", null)
|
|
@@ -169,19 +163,19 @@ class CardFormView(
|
|
|
169
163
|
|
|
170
164
|
textColor?.let {
|
|
171
165
|
for (binding in editTextBindings) {
|
|
172
|
-
binding.setTextColor(
|
|
166
|
+
binding.setTextColor(it.toColorInt())
|
|
173
167
|
}
|
|
174
|
-
cardFormViewBinding.countryLayout.countryAutocomplete.setTextColor(
|
|
168
|
+
cardFormViewBinding.countryLayout.countryAutocomplete.setTextColor(it.toColorInt())
|
|
175
169
|
}
|
|
176
170
|
textErrorColor?.let {
|
|
177
171
|
for (binding in editTextBindings) {
|
|
178
|
-
binding.setErrorColor(
|
|
179
|
-
cardFormViewBinding.postalCode.setErrorColor(
|
|
172
|
+
binding.setErrorColor(it.toColorInt())
|
|
173
|
+
cardFormViewBinding.postalCode.setErrorColor(it.toColorInt())
|
|
180
174
|
}
|
|
181
175
|
}
|
|
182
176
|
placeholderColor?.let {
|
|
183
177
|
for (binding in placeholderTextBindings) {
|
|
184
|
-
binding.defaultHintTextColor = ColorStateList.valueOf(
|
|
178
|
+
binding.defaultHintTextColor = ColorStateList.valueOf(it.toColorInt())
|
|
185
179
|
}
|
|
186
180
|
}
|
|
187
181
|
fontSize?.let {
|
|
@@ -205,7 +199,7 @@ class CardFormView(
|
|
|
205
199
|
}
|
|
206
200
|
cursorColor?.let {
|
|
207
201
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
208
|
-
val color =
|
|
202
|
+
val color = it.toColorInt()
|
|
209
203
|
for (binding in editTextBindings) {
|
|
210
204
|
binding.textCursorDrawable?.setTint(color)
|
|
211
205
|
binding.textSelectHandle?.setTint(color)
|
|
@@ -224,16 +218,16 @@ class CardFormView(
|
|
|
224
218
|
.build(),
|
|
225
219
|
).also { shape ->
|
|
226
220
|
shape.strokeWidth = 0.0f
|
|
227
|
-
shape.strokeColor = ColorStateList.valueOf(
|
|
228
|
-
shape.fillColor = ColorStateList.valueOf(
|
|
221
|
+
shape.strokeColor = ColorStateList.valueOf("#000000".toColorInt())
|
|
222
|
+
shape.fillColor = ColorStateList.valueOf("#FFFFFF".toColorInt())
|
|
229
223
|
borderWidth?.let {
|
|
230
224
|
shape.strokeWidth = PixelUtil.toPixelFromDIP(it.toDouble())
|
|
231
225
|
}
|
|
232
226
|
borderColor?.let {
|
|
233
|
-
shape.strokeColor = ColorStateList.valueOf(
|
|
227
|
+
shape.strokeColor = ColorStateList.valueOf(it.toColorInt())
|
|
234
228
|
}
|
|
235
229
|
backgroundColor?.let {
|
|
236
|
-
shape.fillColor = ColorStateList.valueOf(
|
|
230
|
+
shape.fillColor = ColorStateList.valueOf(it.toColorInt())
|
|
237
231
|
}
|
|
238
232
|
}
|
|
239
233
|
}
|
|
@@ -247,6 +241,8 @@ class CardFormView(
|
|
|
247
241
|
if (isValid) {
|
|
248
242
|
cardForm.paymentMethodCreateParams?.let {
|
|
249
243
|
val cardParamsMap = it.toParamMap()["card"] as HashMap<*, *>
|
|
244
|
+
|
|
245
|
+
@SuppressLint("RestrictedApi")
|
|
250
246
|
val cardDetails: MutableMap<String, Any> =
|
|
251
247
|
mutableMapOf(
|
|
252
248
|
"expiryMonth" to cardParamsMap["exp_month"] as Int,
|
|
@@ -340,7 +336,7 @@ class CardFormView(
|
|
|
340
336
|
)
|
|
341
337
|
}
|
|
342
338
|
|
|
343
|
-
@SuppressLint("RestrictedApi")
|
|
339
|
+
@SuppressLint("RestrictedApi", "VisibleForTests")
|
|
344
340
|
private fun createPostalCodeInputFilter(): InputFilter {
|
|
345
341
|
return InputFilter { charSequence, start, end, _, _, _ ->
|
|
346
342
|
if (cardFormViewBinding.countryLayout.getSelectedCountryCode() == CountryCode.US) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
2
|
|
|
3
|
+
import android.annotation.SuppressLint
|
|
3
4
|
import androidx.activity.ComponentActivity
|
|
4
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
6
|
import com.reactnativestripesdk.utils.ErrorType
|
|
@@ -66,6 +67,7 @@ class CollectBankAccountLauncherManager(
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
private fun createBankAccountLauncher(activity: ComponentActivity): CollectBankAccountLauncher =
|
|
70
|
+
@SuppressLint("RestrictedApi")
|
|
69
71
|
CollectBankAccountLauncher.create(activity, signal) { result ->
|
|
70
72
|
when (result) {
|
|
71
73
|
is CollectBankAccountResult.Completed -> {
|
|
@@ -22,6 +22,7 @@ import java.lang.ref.WeakReference
|
|
|
22
22
|
class CustomPaymentMethodActivity : ReactActivity() {
|
|
23
23
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
24
24
|
// Disable the transition animation to make it truly invisible
|
|
25
|
+
@Suppress("DEPRECATION")
|
|
25
26
|
overridePendingTransition(0, 0)
|
|
26
27
|
super.onCreate(savedInstanceState)
|
|
27
28
|
}
|
|
@@ -53,6 +54,7 @@ class CustomPaymentMethodActivity : ReactActivity() {
|
|
|
53
54
|
override fun finish() {
|
|
54
55
|
super.finish()
|
|
55
56
|
// Disable the exit animation as well
|
|
57
|
+
@Suppress("DEPRECATION")
|
|
56
58
|
overridePendingTransition(0, 0)
|
|
57
59
|
|
|
58
60
|
// Clear the weak reference when finished
|
|
@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.requiredHeight
|
|
|
9
9
|
import androidx.compose.runtime.Composable
|
|
10
10
|
import androidx.compose.runtime.LaunchedEffect
|
|
11
11
|
import androidx.compose.runtime.getValue
|
|
12
|
-
import androidx.compose.runtime.mutableIntStateOf
|
|
13
12
|
import androidx.compose.runtime.mutableStateOf
|
|
14
13
|
import androidx.compose.runtime.remember
|
|
15
14
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
@@ -22,7 +21,6 @@ import androidx.compose.ui.unit.IntOffset
|
|
|
22
21
|
import androidx.compose.ui.unit.dp
|
|
23
22
|
import com.facebook.react.bridge.Arguments
|
|
24
23
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
25
|
-
import com.reactnativestripesdk.toWritableMap
|
|
26
24
|
import com.reactnativestripesdk.utils.KeepJsAwakeTask
|
|
27
25
|
import com.reactnativestripesdk.utils.mapFromConfirmationToken
|
|
28
26
|
import com.reactnativestripesdk.utils.mapFromCustomPaymentMethod
|
|
@@ -56,6 +54,10 @@ class EmbeddedPaymentElementView(
|
|
|
56
54
|
val intentConfiguration: PaymentSheet.IntentConfiguration,
|
|
57
55
|
) : Event
|
|
58
56
|
|
|
57
|
+
data class Update(
|
|
58
|
+
val intentConfiguration: PaymentSheet.IntentConfiguration,
|
|
59
|
+
) : Event
|
|
60
|
+
|
|
59
61
|
data object Confirm : Event
|
|
60
62
|
|
|
61
63
|
data object ClearPaymentOption : Event
|
|
@@ -196,7 +198,7 @@ class EmbeddedPaymentElementView(
|
|
|
196
198
|
val stripeSdkModule =
|
|
197
199
|
try {
|
|
198
200
|
requireStripeSdkModule()
|
|
199
|
-
} catch (
|
|
201
|
+
} catch (_: IllegalArgumentException) {
|
|
200
202
|
return@Builder CreateIntentResult.Failure(
|
|
201
203
|
cause =
|
|
202
204
|
Exception(
|
|
@@ -242,7 +244,7 @@ class EmbeddedPaymentElementView(
|
|
|
242
244
|
val stripeSdkModule =
|
|
243
245
|
try {
|
|
244
246
|
requireStripeSdkModule()
|
|
245
|
-
} catch (
|
|
247
|
+
} catch (_: IllegalArgumentException) {
|
|
246
248
|
return@Builder CreateIntentResult.Failure(
|
|
247
249
|
cause =
|
|
248
250
|
Exception(
|
|
@@ -295,9 +297,6 @@ class EmbeddedPaymentElementView(
|
|
|
295
297
|
}
|
|
296
298
|
|
|
297
299
|
val embedded = rememberEmbeddedPaymentElement(builder)
|
|
298
|
-
var height by remember {
|
|
299
|
-
mutableIntStateOf(0)
|
|
300
|
-
}
|
|
301
300
|
|
|
302
301
|
// collect events: configure, confirm, clear
|
|
303
302
|
LaunchedEffect(Unit) {
|
|
@@ -327,6 +326,47 @@ class EmbeddedPaymentElementView(
|
|
|
327
326
|
}
|
|
328
327
|
}
|
|
329
328
|
|
|
329
|
+
is Event.Update -> {
|
|
330
|
+
val elemConfig = latestElementConfig
|
|
331
|
+
if (elemConfig == null) {
|
|
332
|
+
val payload =
|
|
333
|
+
Arguments.createMap().apply {
|
|
334
|
+
putString("message", "Cannot update: no element configuration exists")
|
|
335
|
+
}
|
|
336
|
+
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementLoadingFailed(payload)
|
|
337
|
+
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementUpdateComplete(null)
|
|
338
|
+
return@collect
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
val result =
|
|
342
|
+
embedded.configure(
|
|
343
|
+
intentConfiguration = ev.intentConfiguration,
|
|
344
|
+
configuration = elemConfig,
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
when (result) {
|
|
348
|
+
is EmbeddedPaymentElement.ConfigureResult.Succeeded -> {
|
|
349
|
+
val payload =
|
|
350
|
+
Arguments.createMap().apply {
|
|
351
|
+
putString("status", "succeeded")
|
|
352
|
+
}
|
|
353
|
+
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementUpdateComplete(payload)
|
|
354
|
+
}
|
|
355
|
+
is EmbeddedPaymentElement.ConfigureResult.Failed -> {
|
|
356
|
+
val err = result.error
|
|
357
|
+
val msg = err.localizedMessage ?: err.toString()
|
|
358
|
+
val failPayload =
|
|
359
|
+
Arguments.createMap().apply {
|
|
360
|
+
putString("message", msg)
|
|
361
|
+
}
|
|
362
|
+
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementLoadingFailed(failPayload)
|
|
363
|
+
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementUpdateComplete(null)
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
latestIntentConfig = ev.intentConfiguration
|
|
368
|
+
}
|
|
369
|
+
|
|
330
370
|
is Event.Confirm -> {
|
|
331
371
|
embedded.confirm()
|
|
332
372
|
}
|
|
@@ -348,10 +388,8 @@ class EmbeddedPaymentElementView(
|
|
|
348
388
|
}
|
|
349
389
|
}
|
|
350
390
|
|
|
351
|
-
val density = LocalDensity.current
|
|
352
|
-
|
|
353
391
|
Box {
|
|
354
|
-
|
|
392
|
+
MeasuredEmbeddedElement(
|
|
355
393
|
reportHeightChange = { h -> reportHeightChange(h) },
|
|
356
394
|
) {
|
|
357
395
|
embedded.Content()
|
|
@@ -360,7 +398,7 @@ class EmbeddedPaymentElementView(
|
|
|
360
398
|
}
|
|
361
399
|
|
|
362
400
|
@Composable
|
|
363
|
-
private fun
|
|
401
|
+
private fun MeasuredEmbeddedElement(
|
|
364
402
|
reportHeightChange: (Float) -> Unit,
|
|
365
403
|
content: @Composable () -> Unit,
|
|
366
404
|
) {
|
|
@@ -419,6 +457,10 @@ class EmbeddedPaymentElementView(
|
|
|
419
457
|
events.trySend(Event.Configure(config, intentConfig))
|
|
420
458
|
}
|
|
421
459
|
|
|
460
|
+
fun update(intentConfig: PaymentSheet.IntentConfiguration) {
|
|
461
|
+
events.trySend(Event.Update(intentConfig))
|
|
462
|
+
}
|
|
463
|
+
|
|
422
464
|
fun confirm() {
|
|
423
465
|
events.trySend(Event.Confirm)
|
|
424
466
|
}
|
|
@@ -2,28 +2,32 @@ package com.reactnativestripesdk
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
5
6
|
import com.facebook.react.bridge.Dynamic
|
|
6
|
-
import com.facebook.react.bridge.ReadableArray
|
|
7
7
|
import com.facebook.react.bridge.ReadableMap
|
|
8
|
-
import com.facebook.react.bridge.
|
|
8
|
+
import com.facebook.react.bridge.WritableArray
|
|
9
|
+
import com.facebook.react.bridge.WritableMap
|
|
9
10
|
import com.facebook.react.module.annotations.ReactModule
|
|
10
11
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
11
12
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
12
13
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
13
14
|
import com.facebook.react.viewmanagers.EmbeddedPaymentElementViewManagerDelegate
|
|
14
15
|
import com.facebook.react.viewmanagers.EmbeddedPaymentElementViewManagerInterface
|
|
15
|
-
import com.reactnativestripesdk.PaymentSheetManager.Companion.buildCustomerConfiguration
|
|
16
|
-
import com.reactnativestripesdk.PaymentSheetManager.Companion.buildGooglePayConfig
|
|
17
16
|
import com.reactnativestripesdk.addresssheet.AddressSheetView
|
|
18
17
|
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
19
18
|
import com.reactnativestripesdk.utils.PaymentSheetException
|
|
19
|
+
import com.reactnativestripesdk.utils.asMapOrNull
|
|
20
20
|
import com.reactnativestripesdk.utils.getBooleanOr
|
|
21
|
+
import com.reactnativestripesdk.utils.getIntegerList
|
|
22
|
+
import com.reactnativestripesdk.utils.getStringList
|
|
21
23
|
import com.reactnativestripesdk.utils.mapToPreferredNetworks
|
|
22
24
|
import com.reactnativestripesdk.utils.parseCustomPaymentMethods
|
|
23
25
|
import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi
|
|
24
26
|
import com.stripe.android.paymentelement.EmbeddedPaymentElement
|
|
25
27
|
import com.stripe.android.paymentelement.ExperimentalCustomPaymentMethodsApi
|
|
26
28
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
29
|
+
import org.json.JSONArray
|
|
30
|
+
import org.json.JSONObject
|
|
27
31
|
|
|
28
32
|
@ReactModule(name = EmbeddedPaymentElementViewManager.NAME)
|
|
29
33
|
class EmbeddedPaymentElementViewManager :
|
|
@@ -54,10 +58,10 @@ class EmbeddedPaymentElementViewManager :
|
|
|
54
58
|
view: EmbeddedPaymentElementView,
|
|
55
59
|
cfg: Dynamic,
|
|
56
60
|
) {
|
|
57
|
-
val readableMap = cfg.
|
|
61
|
+
val readableMap = cfg.asMapOrNull()
|
|
58
62
|
if (readableMap == null) return
|
|
59
63
|
|
|
60
|
-
val rowSelectionBehaviorType =
|
|
64
|
+
val rowSelectionBehaviorType = mapToRowSelectionBehaviorType(readableMap)
|
|
61
65
|
view.rowSelectionBehaviorType.value = rowSelectionBehaviorType
|
|
62
66
|
|
|
63
67
|
val elementConfig = parseElementConfiguration(readableMap, view.context)
|
|
@@ -77,7 +81,7 @@ class EmbeddedPaymentElementViewManager :
|
|
|
77
81
|
view: EmbeddedPaymentElementView,
|
|
78
82
|
cfg: Dynamic,
|
|
79
83
|
) {
|
|
80
|
-
val readableMap = cfg.
|
|
84
|
+
val readableMap = cfg.asMapOrNull()
|
|
81
85
|
if (readableMap == null) return
|
|
82
86
|
|
|
83
87
|
// Detect which callback type to use based on the presence of the confirmation token handler
|
|
@@ -101,45 +105,18 @@ class EmbeddedPaymentElementViewManager :
|
|
|
101
105
|
context: Context,
|
|
102
106
|
): EmbeddedPaymentElement.Configuration {
|
|
103
107
|
val merchantDisplayName = map.getString("merchantDisplayName").orEmpty()
|
|
104
|
-
val allowsDelayedPaymentMethods
|
|
105
|
-
|
|
106
|
-
map.getType("allowsDelayedPaymentMethods") == ReadableType.Boolean
|
|
107
|
-
) {
|
|
108
|
-
map.getBoolean("allowsDelayedPaymentMethods")
|
|
109
|
-
} else {
|
|
110
|
-
false // default
|
|
111
|
-
}
|
|
112
|
-
var defaultBillingDetails: PaymentSheet.BillingDetails? = null
|
|
113
|
-
val billingDetailsMap = map.getMap("defaultBillingDetails")
|
|
114
|
-
if (billingDetailsMap != null) {
|
|
115
|
-
val addressMap = billingDetailsMap.getMap("address")
|
|
116
|
-
val address =
|
|
117
|
-
PaymentSheet.Address(
|
|
118
|
-
addressMap?.getString("city"),
|
|
119
|
-
addressMap?.getString("country"),
|
|
120
|
-
addressMap?.getString("line1"),
|
|
121
|
-
addressMap?.getString("line2"),
|
|
122
|
-
addressMap?.getString("postalCode"),
|
|
123
|
-
addressMap?.getString("state"),
|
|
124
|
-
)
|
|
125
|
-
defaultBillingDetails =
|
|
126
|
-
PaymentSheet.BillingDetails(
|
|
127
|
-
address,
|
|
128
|
-
billingDetailsMap.getString("email"),
|
|
129
|
-
billingDetailsMap.getString("name"),
|
|
130
|
-
billingDetailsMap.getString("phone"),
|
|
131
|
-
)
|
|
132
|
-
}
|
|
108
|
+
val allowsDelayedPaymentMethods = map.getBooleanOr("allowsDelayedPaymentMethods", false)
|
|
109
|
+
val defaultBillingDetails = buildBillingDetails(map.getMap("defaultBillingDetails"))
|
|
133
110
|
|
|
134
111
|
val customerConfiguration =
|
|
135
112
|
try {
|
|
136
113
|
buildCustomerConfiguration(map)
|
|
137
|
-
} catch (
|
|
114
|
+
} catch (_: PaymentSheetException) {
|
|
138
115
|
throw Error() // TODO handle error
|
|
139
116
|
}
|
|
140
117
|
|
|
141
118
|
val googlePayConfig = buildGooglePayConfig(map.getMap("googlePay"))
|
|
142
|
-
val linkConfig =
|
|
119
|
+
val linkConfig = buildLinkConfig(map.getMap("link"))
|
|
143
120
|
val shippingDetails =
|
|
144
121
|
map.getMap("defaultShippingDetails")?.let {
|
|
145
122
|
AddressSheetView.buildAddressDetails(it)
|
|
@@ -147,45 +124,24 @@ class EmbeddedPaymentElementViewManager :
|
|
|
147
124
|
val appearance =
|
|
148
125
|
try {
|
|
149
126
|
buildPaymentSheetAppearance(map.getMap("appearance"), context)
|
|
150
|
-
} catch (
|
|
127
|
+
} catch (_: PaymentSheetAppearanceException) {
|
|
151
128
|
throw Error() // TODO handle error
|
|
152
129
|
}
|
|
153
|
-
val billingConfigParams = map.getMap("billingDetailsCollectionConfiguration")
|
|
154
130
|
val billingDetailsConfig =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
phone = mapToCollectionMode(billingConfigParams?.getString("phone")),
|
|
158
|
-
email = mapToCollectionMode(billingConfigParams?.getString("email")),
|
|
159
|
-
address = mapToAddressCollectionMode(billingConfigParams?.getString("address")),
|
|
160
|
-
attachDefaultsToPaymentMethod =
|
|
161
|
-
billingConfigParams?.getBooleanOr("attachDefaultsToPaymentMethod", false) ?: false,
|
|
131
|
+
buildBillingDetailsCollectionConfiguration(
|
|
132
|
+
map.getMap("billingDetailsCollectionConfiguration"),
|
|
162
133
|
)
|
|
163
|
-
val allowsRemovalOfLastSavedPaymentMethod =
|
|
164
|
-
if (map.hasKey("allowsRemovalOfLastSavedPaymentMethod")) {
|
|
165
|
-
map.getBoolean("allowsRemovalOfLastSavedPaymentMethod")
|
|
166
|
-
} else {
|
|
167
|
-
true
|
|
168
|
-
}
|
|
134
|
+
val allowsRemovalOfLastSavedPaymentMethod = map.getBooleanOr("allowsRemovalOfLastSavedPaymentMethod", true)
|
|
169
135
|
val primaryButtonLabel = map.getString("primaryButtonLabel")
|
|
170
|
-
val paymentMethodOrder = map.
|
|
136
|
+
val paymentMethodOrder = map.getStringList("paymentMethodOrder")
|
|
171
137
|
|
|
172
|
-
val formSheetAction =
|
|
173
|
-
map
|
|
174
|
-
.getMap("formSheetAction")
|
|
175
|
-
?.getString("type")
|
|
176
|
-
?.let { type ->
|
|
177
|
-
when (type) {
|
|
178
|
-
"confirm" -> EmbeddedPaymentElement.FormSheetAction.Confirm
|
|
179
|
-
else -> EmbeddedPaymentElement.FormSheetAction.Continue
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
?: EmbeddedPaymentElement.FormSheetAction.Continue
|
|
138
|
+
val formSheetAction = mapToFormSheetAction(map)
|
|
183
139
|
|
|
184
140
|
val configurationBuilder =
|
|
185
141
|
EmbeddedPaymentElement.Configuration
|
|
186
142
|
.Builder(merchantDisplayName)
|
|
187
143
|
.formSheetAction(formSheetAction)
|
|
188
|
-
.allowsDelayedPaymentMethods(allowsDelayedPaymentMethods
|
|
144
|
+
.allowsDelayedPaymentMethods(allowsDelayedPaymentMethods)
|
|
189
145
|
.defaultBillingDetails(defaultBillingDetails)
|
|
190
146
|
.customer(customerConfiguration)
|
|
191
147
|
.googlePay(googlePayConfig)
|
|
@@ -196,19 +152,13 @@ class EmbeddedPaymentElementViewManager :
|
|
|
196
152
|
.preferredNetworks(
|
|
197
153
|
mapToPreferredNetworks(
|
|
198
154
|
map
|
|
199
|
-
.
|
|
155
|
+
.getIntegerList("preferredNetworks")
|
|
200
156
|
?.let { ArrayList(it) },
|
|
201
157
|
),
|
|
202
158
|
).allowsRemovalOfLastSavedPaymentMethod(allowsRemovalOfLastSavedPaymentMethod)
|
|
203
159
|
.cardBrandAcceptance(mapToCardBrandAcceptance(map))
|
|
204
160
|
.embeddedViewDisplaysMandateText(
|
|
205
|
-
|
|
206
|
-
map.getType("embeddedViewDisplaysMandateText") == ReadableType.Boolean
|
|
207
|
-
) {
|
|
208
|
-
map.getBoolean("embeddedViewDisplaysMandateText")
|
|
209
|
-
} else {
|
|
210
|
-
true // default value
|
|
211
|
-
},
|
|
161
|
+
map.getBooleanOr("embeddedViewDisplaysMandateText", true),
|
|
212
162
|
).customPaymentMethods(
|
|
213
163
|
parseCustomPaymentMethods(
|
|
214
164
|
map.getMap("customPaymentMethodConfiguration"),
|
|
@@ -221,23 +171,8 @@ class EmbeddedPaymentElementViewManager :
|
|
|
221
171
|
return configurationBuilder.build()
|
|
222
172
|
}
|
|
223
173
|
|
|
224
|
-
private fun parseRowSelectionBehavior(map: ReadableMap): RowSelectionBehaviorType {
|
|
225
|
-
val rowSelectionBehavior =
|
|
226
|
-
map
|
|
227
|
-
.getMap("rowSelectionBehavior")
|
|
228
|
-
?.getString("type")
|
|
229
|
-
?.let { type ->
|
|
230
|
-
when (type) {
|
|
231
|
-
"immediateAction" -> RowSelectionBehaviorType.ImmediateAction
|
|
232
|
-
else -> RowSelectionBehaviorType.Default
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
?: RowSelectionBehaviorType.Default
|
|
236
|
-
return rowSelectionBehavior
|
|
237
|
-
}
|
|
238
|
-
|
|
239
174
|
private fun parseIntentConfiguration(map: ReadableMap): PaymentSheet.IntentConfiguration {
|
|
240
|
-
val intentConfig =
|
|
175
|
+
val intentConfig = buildIntentConfiguration(map)
|
|
241
176
|
return intentConfig ?: throw IllegalArgumentException("IntentConfiguration is null")
|
|
242
177
|
}
|
|
243
178
|
|
|
@@ -248,37 +183,90 @@ class EmbeddedPaymentElementViewManager :
|
|
|
248
183
|
override fun clearPaymentOption(view: EmbeddedPaymentElementView) {
|
|
249
184
|
view.clearPaymentOption()
|
|
250
185
|
}
|
|
251
|
-
}
|
|
252
186
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
187
|
+
override fun update(
|
|
188
|
+
view: EmbeddedPaymentElementView,
|
|
189
|
+
intentConfigurationJson: String?,
|
|
190
|
+
) {
|
|
191
|
+
intentConfigurationJson?.let { json ->
|
|
192
|
+
try {
|
|
193
|
+
val jsonObject = JSONObject(json)
|
|
194
|
+
val cfg = jsonToWritableMap(jsonObject)
|
|
195
|
+
val intentConfig = buildIntentConfiguration(cfg)
|
|
196
|
+
if (intentConfig != null) {
|
|
197
|
+
view.update(intentConfig)
|
|
198
|
+
}
|
|
199
|
+
} catch (e: Exception) {
|
|
200
|
+
android.util.Log.e("EmbeddedPaymentElement", "Failed to parse intent config JSON", e)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
264
203
|
}
|
|
265
|
-
return result
|
|
266
|
-
}
|
|
267
204
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
205
|
+
private fun jsonToWritableMap(json: JSONObject): WritableMap {
|
|
206
|
+
val map = Arguments.createMap()
|
|
207
|
+
val keys = json.keys()
|
|
208
|
+
while (keys.hasNext()) {
|
|
209
|
+
val key = keys.next()
|
|
210
|
+
when (val value = json.get(key)) {
|
|
211
|
+
is Boolean -> map.putBoolean(key, value)
|
|
212
|
+
is Int -> map.putInt(key, value)
|
|
213
|
+
is Double -> map.putDouble(key, value)
|
|
214
|
+
is Long -> map.putDouble(key, value.toDouble())
|
|
215
|
+
is String -> map.putString(key, value)
|
|
216
|
+
is JSONObject -> map.putMap(key, jsonToWritableMap(value))
|
|
217
|
+
is JSONArray -> map.putArray(key, jsonToWritableArray(value))
|
|
218
|
+
JSONObject.NULL -> map.putNull(key)
|
|
219
|
+
else -> map.putString(key, value.toString())
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return map
|
|
223
|
+
}
|
|
274
224
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
225
|
+
private fun jsonToWritableArray(json: JSONArray): WritableArray {
|
|
226
|
+
val array = Arguments.createArray()
|
|
227
|
+
for (i in 0 until json.length()) {
|
|
228
|
+
when (val value = json.get(i)) {
|
|
229
|
+
is Boolean -> array.pushBoolean(value)
|
|
230
|
+
is Int -> array.pushInt(value)
|
|
231
|
+
is Double -> array.pushDouble(value)
|
|
232
|
+
is Long -> array.pushDouble(value.toDouble())
|
|
233
|
+
is String -> array.pushString(value)
|
|
234
|
+
is JSONObject -> array.pushMap(jsonToWritableMap(value))
|
|
235
|
+
is JSONArray -> array.pushArray(jsonToWritableArray(value))
|
|
236
|
+
JSONObject.NULL -> array.pushNull()
|
|
237
|
+
else -> array.pushString(value.toString())
|
|
238
|
+
}
|
|
281
239
|
}
|
|
240
|
+
return array
|
|
282
241
|
}
|
|
283
|
-
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
internal fun mapToRowSelectionBehaviorType(map: ReadableMap?): RowSelectionBehaviorType {
|
|
245
|
+
val rowSelectionBehavior =
|
|
246
|
+
map
|
|
247
|
+
?.getMap("rowSelectionBehavior")
|
|
248
|
+
?.getString("type")
|
|
249
|
+
?.let { type ->
|
|
250
|
+
when (type) {
|
|
251
|
+
"immediateAction" -> RowSelectionBehaviorType.ImmediateAction
|
|
252
|
+
else -> RowSelectionBehaviorType.Default
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
?: RowSelectionBehaviorType.Default
|
|
256
|
+
return rowSelectionBehavior
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
internal fun mapToFormSheetAction(map: ReadableMap?): EmbeddedPaymentElement.FormSheetAction {
|
|
260
|
+
val formSheetAction =
|
|
261
|
+
map
|
|
262
|
+
?.getMap("formSheetAction")
|
|
263
|
+
?.getString("type")
|
|
264
|
+
?.let { type ->
|
|
265
|
+
when (type) {
|
|
266
|
+
"confirm" -> EmbeddedPaymentElement.FormSheetAction.Confirm
|
|
267
|
+
else -> EmbeddedPaymentElement.FormSheetAction.Continue
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
?: EmbeddedPaymentElement.FormSheetAction.Continue
|
|
271
|
+
return formSheetAction
|
|
284
272
|
}
|
|
@@ -32,10 +32,6 @@ class EventEmitterCompat(
|
|
|
32
32
|
invoke("onFinancialConnectionsEvent", value)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
fun emitOnOrderTrackingCallback() {
|
|
36
|
-
invoke("onOrderTrackingCallback")
|
|
37
|
-
}
|
|
38
|
-
|
|
39
35
|
fun emitOnCustomerAdapterFetchPaymentMethodsCallback() {
|
|
40
36
|
invoke("onCustomerAdapterFetchPaymentMethodsCallback")
|
|
41
37
|
}
|
|
@@ -72,10 +68,6 @@ class EventEmitterCompat(
|
|
|
72
68
|
invoke("embeddedPaymentElementDidUpdateHeight", value)
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
fun emitEmbeddedPaymentElementWillPresent() {
|
|
76
|
-
invoke("embeddedPaymentElementWillPresent")
|
|
77
|
-
}
|
|
78
|
-
|
|
79
71
|
fun emitEmbeddedPaymentElementDidUpdatePaymentOption(value: ReadableMap?) {
|
|
80
72
|
invoke("embeddedPaymentElementDidUpdatePaymentOption", value)
|
|
81
73
|
}
|
|
@@ -92,6 +84,10 @@ class EventEmitterCompat(
|
|
|
92
84
|
invoke("embeddedPaymentElementLoadingFailed", value)
|
|
93
85
|
}
|
|
94
86
|
|
|
87
|
+
fun emitEmbeddedPaymentElementUpdateComplete(value: ReadableMap?) {
|
|
88
|
+
invoke("embeddedPaymentElementUpdateComplete", value)
|
|
89
|
+
}
|
|
90
|
+
|
|
95
91
|
fun emitOnCustomPaymentMethodConfirmHandlerCallback(value: ReadableMap?) {
|
|
96
92
|
invoke("onCustomPaymentMethodConfirmHandlerCallback", value)
|
|
97
93
|
}
|