@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,12 @@ package com.reactnativestripesdk.pushprovisioning
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.util.Log
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
5
6
|
import com.facebook.react.bridge.ReadableMap
|
|
6
7
|
import com.facebook.react.bridge.WritableMap
|
|
7
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
8
8
|
import com.google.android.gms.tasks.Task
|
|
9
9
|
import com.reactnativestripesdk.utils.createError
|
|
10
|
+
import com.reactnativestripesdk.utils.getIntOr
|
|
10
11
|
|
|
11
12
|
typealias TokenCheckHandler =
|
|
12
13
|
(isCardInWallet: Boolean, token: WritableMap?, error: WritableMap?) -> Unit
|
|
@@ -25,6 +26,7 @@ object TapAndPayProxy {
|
|
|
25
26
|
val tapAndPayClientClass = Class.forName("com.google.android.gms.tapandpay.TapAndPayClient")
|
|
26
27
|
val listTokensMethod = tapAndPayClientClass.getMethod("listTokens")
|
|
27
28
|
|
|
29
|
+
@Suppress("UNCHECKED_CAST")
|
|
28
30
|
listTokensMethod.invoke(client) as Task<List<Any>>
|
|
29
31
|
} catch (e: Exception) {
|
|
30
32
|
Log.e(TAG, "There was a problem listing tokens with Google TapAndPay: " + e.message)
|
|
@@ -97,9 +99,9 @@ object TapAndPayProxy {
|
|
|
97
99
|
tapAndPayClient,
|
|
98
100
|
activity,
|
|
99
101
|
tokenReferenceId,
|
|
100
|
-
token.
|
|
102
|
+
token.getIntOr("serviceProvider", 0),
|
|
101
103
|
cardDescription,
|
|
102
|
-
token.
|
|
104
|
+
token.getIntOr("network", 0),
|
|
103
105
|
REQUEST_CODE_TOKENIZE,
|
|
104
106
|
)
|
|
105
107
|
} catch (e: Exception) {
|
|
@@ -108,7 +110,7 @@ object TapAndPayProxy {
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
private fun mapFromTokenInfo(token: Any?): WritableMap {
|
|
111
|
-
val result =
|
|
113
|
+
val result = Arguments.createMap()
|
|
112
114
|
token?.let {
|
|
113
115
|
try {
|
|
114
116
|
val tokenInfoClass = Class.forName("com.google.android.gms.tapandpay.issuer.TokenInfo")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
package com.reactnativestripesdk.utils
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
3
4
|
import com.facebook.react.bridge.WritableMap
|
|
4
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
5
5
|
import com.stripe.android.core.exception.APIException
|
|
6
6
|
import com.stripe.android.core.exception.AuthenticationException
|
|
7
7
|
import com.stripe.android.core.exception.InvalidRequestException
|
|
@@ -66,8 +66,8 @@ internal fun mapError(
|
|
|
66
66
|
type: String?,
|
|
67
67
|
stripeErrorCode: String?,
|
|
68
68
|
): WritableMap {
|
|
69
|
-
val map: WritableMap =
|
|
70
|
-
val details: WritableMap =
|
|
69
|
+
val map: WritableMap = Arguments.createMap()
|
|
70
|
+
val details: WritableMap = Arguments.createMap()
|
|
71
71
|
details.putString("code", code)
|
|
72
72
|
details.putString("message", message)
|
|
73
73
|
details.putString("localizedMessage", localizedMessage)
|
|
@@ -178,8 +178,18 @@ internal fun createError(
|
|
|
178
178
|
return mapError(code, error.message, error.localizedMessage, null, null, null)
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
internal fun createCanceledError(message: String? = null): WritableMap = createError(ErrorType.Canceled.toString(), message)
|
|
182
|
+
|
|
183
|
+
internal fun createFailedError(error: Throwable): WritableMap = createError(ErrorType.Failed.toString(), error)
|
|
184
|
+
|
|
181
185
|
internal fun createMissingInitError(): WritableMap =
|
|
182
186
|
createError(
|
|
183
187
|
ErrorType.Failed.toString(),
|
|
184
188
|
"Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.",
|
|
185
189
|
)
|
|
190
|
+
|
|
191
|
+
internal fun createOnrampNotConfiguredError(): WritableMap =
|
|
192
|
+
createError(
|
|
193
|
+
ErrorType.Failed.toString(),
|
|
194
|
+
"Onramp is not configured.",
|
|
195
|
+
)
|
|
@@ -45,6 +45,14 @@ fun ReadableMap?.getDoubleOr(
|
|
|
45
45
|
default: Double,
|
|
46
46
|
): Double = getDoubleOrNull(key) ?: default
|
|
47
47
|
|
|
48
|
+
fun ReadableMap?.getLongOrNull(key: String): Long? =
|
|
49
|
+
if (this?.hasKey(key) == true && this.getType(key) == ReadableType.Number) this.getDouble(key).toLong() else null
|
|
50
|
+
|
|
51
|
+
fun ReadableMap?.getLongOr(
|
|
52
|
+
key: String,
|
|
53
|
+
default: Long,
|
|
54
|
+
): Long = getLongOrNull(key) ?: default
|
|
55
|
+
|
|
48
56
|
fun ReadableMap?.getFloatOrNull(key: String): Float? =
|
|
49
57
|
if (this?.hasKey(key) == true && this.getType(key) == ReadableType.Number) this.getDouble(key).toFloat() else null
|
|
50
58
|
|
|
@@ -74,4 +82,37 @@ fun ReadableArray.forEachMap(callback: (map: ReadableMap) -> Unit) {
|
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Returns a List of Strings if the key exists and points to an array of strings, or null otherwise.
|
|
87
|
+
*/
|
|
88
|
+
fun ReadableMap.getStringList(key: String): List<String>? {
|
|
89
|
+
if (!hasKey(key) || getType(key) != ReadableType.Array) return null
|
|
90
|
+
val array: ReadableArray = getArray(key) ?: return null
|
|
91
|
+
|
|
92
|
+
val result = mutableListOf<String>()
|
|
93
|
+
for (i in 0 until array.size()) {
|
|
94
|
+
// getString returns null if the element isn't actually a string
|
|
95
|
+
array.getString(i)?.let { result.add(it) }
|
|
96
|
+
}
|
|
97
|
+
return result
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Returns a List of Ints if the key exists and points to an array of numbers, or null otherwise.
|
|
102
|
+
*/
|
|
103
|
+
fun ReadableMap.getIntegerList(key: String): List<Int>? {
|
|
104
|
+
if (!hasKey(key) || getType(key) != ReadableType.Array) return null
|
|
105
|
+
val array: ReadableArray = getArray(key) ?: return null
|
|
106
|
+
|
|
107
|
+
val result = mutableListOf<Int>()
|
|
108
|
+
for (i in 0 until array.size()) {
|
|
109
|
+
// getType check to skip non-number entries
|
|
110
|
+
if (array.getType(i) == ReadableType.Number) {
|
|
111
|
+
// if it's actually a float/double, this will truncate; adjust as needed
|
|
112
|
+
result.add(array.getInt(i))
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result
|
|
116
|
+
}
|
|
117
|
+
|
|
77
118
|
fun Dynamic.asMapOrNull(): ReadableMap? = if (this.type == ReadableType.Map) this.asMap() else null
|
|
@@ -37,7 +37,7 @@ internal class KeepJsAwakeTask(
|
|
|
37
37
|
|
|
38
38
|
try {
|
|
39
39
|
headlessJsTaskContext.finishTask(taskId)
|
|
40
|
-
} catch (
|
|
40
|
+
} catch (_: AssertionError) {
|
|
41
41
|
// Ignore if task already finished
|
|
42
42
|
Log.w("KeepJsAwakeTask", "Tried to stop a non-existent task (id=$taskId)")
|
|
43
43
|
} finally {
|
|
@@ -29,12 +29,14 @@ import com.stripe.android.paymentelement.ExperimentalCustomPaymentMethodsApi
|
|
|
29
29
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
30
30
|
import java.lang.IllegalArgumentException
|
|
31
31
|
|
|
32
|
+
internal fun createEmptyResult(): WritableMap = WritableNativeMap()
|
|
33
|
+
|
|
32
34
|
internal fun createResult(
|
|
33
35
|
key: String,
|
|
34
36
|
value: WritableMap,
|
|
35
37
|
additionalFields: Map<String, Any>? = null,
|
|
36
38
|
): WritableMap {
|
|
37
|
-
val map =
|
|
39
|
+
val map = Arguments.createMap()
|
|
38
40
|
map.putMap(key, value)
|
|
39
41
|
additionalFields?.let { map.merge(it.toReadableMap()) }
|
|
40
42
|
return map
|
|
@@ -44,9 +46,9 @@ internal fun createCanAddCardResult(
|
|
|
44
46
|
canAddCard: Boolean,
|
|
45
47
|
status: String? = null,
|
|
46
48
|
token: WritableMap? = null,
|
|
47
|
-
):
|
|
48
|
-
val result =
|
|
49
|
-
val details =
|
|
49
|
+
): WritableMap {
|
|
50
|
+
val result = Arguments.createMap()
|
|
51
|
+
val details = Arguments.createMap()
|
|
50
52
|
result.putBoolean("canAddCard", canAddCard)
|
|
51
53
|
if (status != null) {
|
|
52
54
|
details.putString("status", status)
|
|
@@ -92,8 +94,8 @@ internal fun mapToReturnURL(urlScheme: String?): String? {
|
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
internal fun mapIntentShipping(shipping: PaymentIntent.Shipping): WritableMap {
|
|
95
|
-
val map: WritableMap =
|
|
96
|
-
val address: WritableMap =
|
|
97
|
+
val map: WritableMap = Arguments.createMap()
|
|
98
|
+
val address: WritableMap = Arguments.createMap()
|
|
97
99
|
|
|
98
100
|
address.putString("city", shipping.address.city)
|
|
99
101
|
address.putString("country", shipping.address.country)
|
|
@@ -186,8 +188,8 @@ internal fun mapToPaymentMethodType(type: String?): PaymentMethod.Type? =
|
|
|
186
188
|
}
|
|
187
189
|
|
|
188
190
|
internal fun mapFromBillingDetails(billingDatails: PaymentMethod.BillingDetails?): WritableMap {
|
|
189
|
-
val details: WritableMap =
|
|
190
|
-
val address: WritableMap =
|
|
191
|
+
val details: WritableMap = Arguments.createMap()
|
|
192
|
+
val address: WritableMap = Arguments.createMap()
|
|
191
193
|
|
|
192
194
|
address.putString("country", billingDatails?.address?.country)
|
|
193
195
|
address.putString("city", billingDatails?.address?.city)
|
|
@@ -233,7 +235,6 @@ internal fun mapTokenType(type: Token.Type): String =
|
|
|
233
235
|
Token.Type.CvcUpdate -> "CvcUpdate"
|
|
234
236
|
Token.Type.Person -> "Person"
|
|
235
237
|
Token.Type.Pii -> "Pii"
|
|
236
|
-
else -> "Unknown"
|
|
237
238
|
}
|
|
238
239
|
|
|
239
240
|
internal fun mapFromBankAccountType(type: BankAccount.Type?): String =
|
|
@@ -265,7 +266,7 @@ internal fun mapFromBankAccount(bankAccount: BankAccount?): WritableMap? {
|
|
|
265
266
|
return null
|
|
266
267
|
}
|
|
267
268
|
|
|
268
|
-
val bankAccountMap: WritableMap =
|
|
269
|
+
val bankAccountMap: WritableMap = Arguments.createMap()
|
|
269
270
|
bankAccountMap.putString("id", bankAccount.id)
|
|
270
271
|
bankAccountMap.putString("bankName", bankAccount.bankName)
|
|
271
272
|
bankAccountMap.putString("accountHolderName", bankAccount.accountHolderName)
|
|
@@ -312,13 +313,13 @@ internal fun mapFromUSBankAccountType(type: PaymentMethod.USBankAccount.USBankAc
|
|
|
312
313
|
}
|
|
313
314
|
|
|
314
315
|
internal fun mapFromCard(card: Card?): WritableMap? {
|
|
315
|
-
val cardMap: WritableMap =
|
|
316
|
+
val cardMap: WritableMap = Arguments.createMap()
|
|
316
317
|
|
|
317
318
|
if (card == null) {
|
|
318
319
|
return null
|
|
319
320
|
}
|
|
320
321
|
|
|
321
|
-
val address: WritableMap =
|
|
322
|
+
val address: WritableMap = Arguments.createMap()
|
|
322
323
|
|
|
323
324
|
cardMap.putString("country", card.country)
|
|
324
325
|
cardMap.putString("brand", mapCardBrand(card.brand))
|
|
@@ -346,7 +347,7 @@ internal fun mapFromCard(card: Card?): WritableMap? {
|
|
|
346
347
|
}
|
|
347
348
|
|
|
348
349
|
internal fun mapFromToken(token: Token): WritableMap {
|
|
349
|
-
val tokenMap: WritableMap =
|
|
350
|
+
val tokenMap: WritableMap = Arguments.createMap()
|
|
350
351
|
tokenMap.putString("id", token.id)
|
|
351
352
|
tokenMap.putString("created", token.created.time.toString())
|
|
352
353
|
tokenMap.putString("type", mapTokenType(token.type))
|
|
@@ -359,7 +360,7 @@ internal fun mapFromToken(token: Token): WritableMap {
|
|
|
359
360
|
}
|
|
360
361
|
|
|
361
362
|
internal fun mapFromPaymentMethod(paymentMethod: PaymentMethod): WritableMap {
|
|
362
|
-
val pm: WritableMap =
|
|
363
|
+
val pm: WritableMap = Arguments.createMap()
|
|
363
364
|
|
|
364
365
|
pm.putString("id", paymentMethod.id)
|
|
365
366
|
pm.putString("paymentMethodType", mapPaymentMethodType(paymentMethod.type))
|
|
@@ -368,7 +369,7 @@ internal fun mapFromPaymentMethod(paymentMethod: PaymentMethod): WritableMap {
|
|
|
368
369
|
pm.putMap("billingDetails", mapFromBillingDetails(paymentMethod.billingDetails))
|
|
369
370
|
pm.putMap(
|
|
370
371
|
"Card",
|
|
371
|
-
|
|
372
|
+
Arguments.createMap().also {
|
|
372
373
|
it.putString("brand", mapCardBrand(paymentMethod.card?.brand))
|
|
373
374
|
it.putString("country", paymentMethod.card?.country)
|
|
374
375
|
paymentMethod.card?.expiryYear?.let { year -> it.putInt("expYear", year) }
|
|
@@ -386,7 +387,7 @@ internal fun mapFromPaymentMethod(paymentMethod: PaymentMethod): WritableMap {
|
|
|
386
387
|
)
|
|
387
388
|
it.putMap(
|
|
388
389
|
"threeDSecureUsage",
|
|
389
|
-
|
|
390
|
+
Arguments.createMap().also { threeDSecureUsageMap ->
|
|
390
391
|
threeDSecureUsageMap.putBoolean(
|
|
391
392
|
"isSupported",
|
|
392
393
|
paymentMethod.card?.threeDSecureUsage?.isSupported ?: false,
|
|
@@ -397,7 +398,7 @@ internal fun mapFromPaymentMethod(paymentMethod: PaymentMethod): WritableMap {
|
|
|
397
398
|
)
|
|
398
399
|
pm.putMap(
|
|
399
400
|
"SepaDebit",
|
|
400
|
-
|
|
401
|
+
Arguments.createMap().also {
|
|
401
402
|
it.putString("bankCode", paymentMethod.sepaDebit?.bankCode)
|
|
402
403
|
it.putString("country", paymentMethod.sepaDebit?.country)
|
|
403
404
|
it.putString("fingerprint", paymentMethod.sepaDebit?.fingerprint)
|
|
@@ -406,7 +407,7 @@ internal fun mapFromPaymentMethod(paymentMethod: PaymentMethod): WritableMap {
|
|
|
406
407
|
)
|
|
407
408
|
pm.putMap(
|
|
408
409
|
"BacsDebit",
|
|
409
|
-
|
|
410
|
+
Arguments.createMap().also {
|
|
410
411
|
it.putString("fingerprint", paymentMethod.bacsDebit?.fingerprint)
|
|
411
412
|
it.putString("last4", paymentMethod.bacsDebit?.last4)
|
|
412
413
|
it.putString("sortCode", paymentMethod.bacsDebit?.sortCode)
|
|
@@ -414,7 +415,7 @@ internal fun mapFromPaymentMethod(paymentMethod: PaymentMethod): WritableMap {
|
|
|
414
415
|
)
|
|
415
416
|
pm.putMap(
|
|
416
417
|
"AuBecsDebit",
|
|
417
|
-
|
|
418
|
+
Arguments.createMap().also {
|
|
418
419
|
it.putString("bsbNumber", paymentMethod.bacsDebit?.sortCode)
|
|
419
420
|
it.putString("fingerprint", paymentMethod.bacsDebit?.fingerprint)
|
|
420
421
|
it.putString("last4", paymentMethod.bacsDebit?.last4)
|
|
@@ -422,22 +423,22 @@ internal fun mapFromPaymentMethod(paymentMethod: PaymentMethod): WritableMap {
|
|
|
422
423
|
)
|
|
423
424
|
pm.putMap(
|
|
424
425
|
"Ideal",
|
|
425
|
-
|
|
426
|
+
Arguments.createMap().also {
|
|
426
427
|
it.putString("bankName", paymentMethod.ideal?.bank)
|
|
427
428
|
it.putString("bankIdentifierCode", paymentMethod.ideal?.bankIdentifierCode)
|
|
428
429
|
},
|
|
429
430
|
)
|
|
430
431
|
pm.putMap(
|
|
431
432
|
"Fpx",
|
|
432
|
-
|
|
433
|
+
Arguments.createMap().also {
|
|
433
434
|
it.putString("accountHolderType", paymentMethod.fpx?.accountHolderType)
|
|
434
435
|
it.putString("bank", paymentMethod.fpx?.bank)
|
|
435
436
|
},
|
|
436
437
|
)
|
|
437
|
-
pm.putMap("Upi",
|
|
438
|
+
pm.putMap("Upi", Arguments.createMap().also { it.putString("vpa", paymentMethod.upi?.vpa) })
|
|
438
439
|
pm.putMap(
|
|
439
440
|
"USBankAccount",
|
|
440
|
-
|
|
441
|
+
Arguments.createMap().also {
|
|
441
442
|
it.putString("routingNumber", paymentMethod.usBankAccount?.routingNumber)
|
|
442
443
|
it.putString(
|
|
443
444
|
"accountType",
|
|
@@ -463,7 +464,7 @@ internal fun mapFromPaymentMethod(paymentMethod: PaymentMethod): WritableMap {
|
|
|
463
464
|
}
|
|
464
465
|
|
|
465
466
|
internal fun mapFromPaymentIntentResult(paymentIntent: PaymentIntent): WritableMap {
|
|
466
|
-
val map: WritableMap =
|
|
467
|
+
val map: WritableMap = Arguments.createMap()
|
|
467
468
|
map.putString("id", paymentIntent.id)
|
|
468
469
|
map.putString("clientSecret", paymentIntent.clientSecret)
|
|
469
470
|
map.putBoolean("livemode", paymentIntent.isLiveMode)
|
|
@@ -490,7 +491,7 @@ internal fun mapFromPaymentIntentResult(paymentIntent: PaymentIntent): WritableM
|
|
|
490
491
|
map.putNull("canceledAt")
|
|
491
492
|
|
|
492
493
|
paymentIntent.lastPaymentError?.let {
|
|
493
|
-
val paymentError: WritableMap =
|
|
494
|
+
val paymentError: WritableMap = Arguments.createMap()
|
|
494
495
|
paymentError.putString("code", it.code)
|
|
495
496
|
paymentError.putString("message", it.message)
|
|
496
497
|
paymentError.putString("type", mapFromPaymentIntentLastErrorType(it.type))
|
|
@@ -521,8 +522,8 @@ internal fun mapFromMicrodepositType(type: MicrodepositType): String =
|
|
|
521
522
|
internal fun mapNextAction(
|
|
522
523
|
type: NextActionType?,
|
|
523
524
|
data: NextActionData?,
|
|
524
|
-
):
|
|
525
|
-
val nextActionMap =
|
|
525
|
+
): WritableMap? {
|
|
526
|
+
val nextActionMap = Arguments.createMap()
|
|
526
527
|
when (type) {
|
|
527
528
|
NextActionType.RedirectToUrl -> {
|
|
528
529
|
(data as? NextActionData.RedirectToUrl)?.let {
|
|
@@ -589,6 +590,12 @@ internal fun mapNextAction(
|
|
|
589
590
|
nextActionMap.putString("voucherURL", it.hostedVoucherUrl)
|
|
590
591
|
}
|
|
591
592
|
}
|
|
593
|
+
NextActionType.DisplayPayNowDetails -> {
|
|
594
|
+
(data as? NextActionData.DisplayPayNowDetails)?.let {
|
|
595
|
+
nextActionMap.putString("type", "paynow")
|
|
596
|
+
nextActionMap.putString("qrCodeUrl", it.qrCodeUrl)
|
|
597
|
+
}
|
|
598
|
+
}
|
|
592
599
|
}
|
|
593
600
|
return nextActionMap
|
|
594
601
|
}
|
|
@@ -654,6 +661,21 @@ internal fun mapToAddress(
|
|
|
654
661
|
return address.build()
|
|
655
662
|
}
|
|
656
663
|
|
|
664
|
+
internal fun mapToPaymentSheetAddress(addressMap: ReadableMap?): PaymentSheet.Address? {
|
|
665
|
+
if (addressMap == null) {
|
|
666
|
+
return null
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
return PaymentSheet.Address(
|
|
670
|
+
city = addressMap.getString("city"),
|
|
671
|
+
country = addressMap.getString("country"),
|
|
672
|
+
line1 = addressMap.getString("line1"),
|
|
673
|
+
line2 = addressMap.getString("line2"),
|
|
674
|
+
postalCode = addressMap.getString("postalCode"),
|
|
675
|
+
state = addressMap.getString("state"),
|
|
676
|
+
)
|
|
677
|
+
}
|
|
678
|
+
|
|
657
679
|
internal fun mapToBillingDetails(
|
|
658
680
|
billingDetails: ReadableMap?,
|
|
659
681
|
cardAddress: Address?,
|
|
@@ -675,14 +697,17 @@ internal fun mapToBillingDetails(
|
|
|
675
697
|
return paymentMethodBillingDetailsBuilder.build()
|
|
676
698
|
}
|
|
677
699
|
|
|
678
|
-
internal fun mapToMetadata(metadata: ReadableMap?): Map<String, String>? =
|
|
700
|
+
internal fun mapToMetadata(metadata: ReadableMap?): Map<String, String>? =
|
|
701
|
+
metadata?.toHashMap()?.mapValues {
|
|
702
|
+
it.value.toString()
|
|
703
|
+
}
|
|
679
704
|
|
|
680
705
|
internal fun mapToShippingDetails(shippingDetails: ReadableMap?): ConfirmPaymentIntentParams.Shipping? {
|
|
681
706
|
if (shippingDetails == null) {
|
|
682
707
|
return null
|
|
683
708
|
}
|
|
684
709
|
|
|
685
|
-
val address = mapToAddress(shippingDetails
|
|
710
|
+
val address = mapToAddress(shippingDetails.getMap("address"), null)
|
|
686
711
|
|
|
687
712
|
return ConfirmPaymentIntentParams.Shipping(
|
|
688
713
|
name = getValOr(shippingDetails, "name") ?: "",
|
|
@@ -858,7 +883,7 @@ fun mapToUICustomization(params: ReadableMap): PaymentAuthConfig.Stripe3ds2UiCus
|
|
|
858
883
|
}
|
|
859
884
|
|
|
860
885
|
internal fun mapFromSetupIntentResult(setupIntent: SetupIntent): WritableMap {
|
|
861
|
-
val map: WritableMap =
|
|
886
|
+
val map: WritableMap = Arguments.createMap()
|
|
862
887
|
val paymentMethodTypes: WritableArray = Arguments.createArray()
|
|
863
888
|
map.putString("id", setupIntent.id)
|
|
864
889
|
map.putString("status", mapIntentStatus(setupIntent.status))
|
|
@@ -875,7 +900,7 @@ internal fun mapFromSetupIntentResult(setupIntent: SetupIntent): WritableMap {
|
|
|
875
900
|
map.putMap("nextAction", mapNextAction(setupIntent.nextActionType, setupIntent.nextActionData))
|
|
876
901
|
|
|
877
902
|
setupIntent.lastSetupError?.let {
|
|
878
|
-
val setupError: WritableMap =
|
|
903
|
+
val setupError: WritableMap = Arguments.createMap()
|
|
879
904
|
setupError.putString("code", it.code)
|
|
880
905
|
setupError.putString("message", it.message)
|
|
881
906
|
setupError.putString("type", mapFromSetupIntentLastErrorType(it.type))
|
|
@@ -913,22 +938,22 @@ fun mapToPaymentIntentFutureUsage(type: String?): ConfirmPaymentIntentParams.Set
|
|
|
913
938
|
}
|
|
914
939
|
|
|
915
940
|
internal fun mapFromShippingContact(googlePayResult: GooglePayResult): WritableMap {
|
|
916
|
-
val map =
|
|
941
|
+
val map = Arguments.createMap()
|
|
917
942
|
map.putString("emailAddress", googlePayResult.email)
|
|
918
|
-
val name =
|
|
943
|
+
val name = Arguments.createMap()
|
|
919
944
|
googlePayResult.name
|
|
920
945
|
name.putString("givenName", googlePayResult.shippingInformation?.name)
|
|
921
946
|
map.putMap("name", name)
|
|
922
947
|
googlePayResult.shippingInformation?.phone?.let { map.putString("phoneNumber", it) }
|
|
923
948
|
?: run { map.putString("phoneNumber", googlePayResult.phoneNumber) }
|
|
924
|
-
val postalAddress =
|
|
949
|
+
val postalAddress = Arguments.createMap()
|
|
925
950
|
postalAddress.putString("city", googlePayResult.shippingInformation?.address?.city)
|
|
926
951
|
postalAddress.putString("country", googlePayResult.shippingInformation?.address?.country)
|
|
927
952
|
postalAddress.putString("postalCode", googlePayResult.shippingInformation?.address?.postalCode)
|
|
928
953
|
postalAddress.putString("state", googlePayResult.shippingInformation?.address?.state)
|
|
929
954
|
val line1: String? = googlePayResult.shippingInformation?.address?.line1
|
|
930
955
|
val line2: String? = googlePayResult.shippingInformation?.address?.line2
|
|
931
|
-
val street = (
|
|
956
|
+
val street = (line1 ?: "") + (if (line2 != null) "\n$line2" else "")
|
|
932
957
|
postalAddress.putString("street", street)
|
|
933
958
|
postalAddress.putString("isoCountryCode", googlePayResult.shippingInformation?.address?.country)
|
|
934
959
|
map.putMap("postalAddress", postalAddress)
|
|
@@ -975,6 +1000,7 @@ private fun List<Any?>.toWritableArray(): WritableArray {
|
|
|
975
1000
|
val writableArray = Arguments.createArray()
|
|
976
1001
|
|
|
977
1002
|
forEach { value ->
|
|
1003
|
+
@Suppress("UNCHECKED_CAST")
|
|
978
1004
|
when (value) {
|
|
979
1005
|
null -> writableArray.pushNull()
|
|
980
1006
|
is Boolean -> writableArray.pushBoolean(value)
|
|
@@ -982,7 +1008,7 @@ private fun List<Any?>.toWritableArray(): WritableArray {
|
|
|
982
1008
|
is Double -> writableArray.pushDouble(value)
|
|
983
1009
|
is String -> writableArray.pushString(value)
|
|
984
1010
|
is Map<*, *> -> writableArray.pushMap((value as Map<String, Any?>).toReadableMap())
|
|
985
|
-
is List<*> -> writableArray.pushArray(
|
|
1011
|
+
is List<*> -> writableArray.pushArray(value.toWritableArray())
|
|
986
1012
|
else -> writableArray.pushString(value.toString())
|
|
987
1013
|
}
|
|
988
1014
|
}
|
|
@@ -994,6 +1020,7 @@ private fun Map<String, Any?>.toReadableMap(): ReadableMap {
|
|
|
994
1020
|
val writableMap = Arguments.createMap()
|
|
995
1021
|
|
|
996
1022
|
forEach { (key, value) ->
|
|
1023
|
+
@Suppress("UNCHECKED_CAST")
|
|
997
1024
|
when (value) {
|
|
998
1025
|
null -> writableMap.putNull(key)
|
|
999
1026
|
is Boolean -> writableMap.putBoolean(key, value)
|
|
@@ -1001,7 +1028,7 @@ private fun Map<String, Any?>.toReadableMap(): ReadableMap {
|
|
|
1001
1028
|
is Double -> writableMap.putDouble(key, value)
|
|
1002
1029
|
is String -> writableMap.putString(key, value)
|
|
1003
1030
|
is Map<*, *> -> writableMap.putMap(key, (value as Map<String, Any?>).toReadableMap())
|
|
1004
|
-
is List<*> -> writableMap.putArray(key,
|
|
1031
|
+
is List<*> -> writableMap.putArray(key, value.toWritableArray())
|
|
1005
1032
|
else -> writableMap.putString(key, value.toString())
|
|
1006
1033
|
}
|
|
1007
1034
|
}
|
|
@@ -1046,10 +1073,10 @@ internal fun mapFromCustomPaymentMethod(
|
|
|
1046
1073
|
customPaymentMethod: PaymentSheet.CustomPaymentMethod,
|
|
1047
1074
|
billingDetails: PaymentMethod.BillingDetails,
|
|
1048
1075
|
): WritableMap =
|
|
1049
|
-
|
|
1076
|
+
Arguments.createMap().apply {
|
|
1050
1077
|
putMap(
|
|
1051
1078
|
"customPaymentMethod",
|
|
1052
|
-
|
|
1079
|
+
Arguments.createMap().apply {
|
|
1053
1080
|
putString("id", customPaymentMethod.id)
|
|
1054
1081
|
},
|
|
1055
1082
|
)
|
|
@@ -1058,7 +1085,7 @@ internal fun mapFromCustomPaymentMethod(
|
|
|
1058
1085
|
|
|
1059
1086
|
@SuppressLint("RestrictedApi")
|
|
1060
1087
|
internal fun mapFromConfirmationToken(confirmationToken: ConfirmationToken): WritableMap {
|
|
1061
|
-
val token: WritableMap =
|
|
1088
|
+
val token: WritableMap = Arguments.createMap()
|
|
1062
1089
|
|
|
1063
1090
|
token.putString("id", confirmationToken.id)
|
|
1064
1091
|
token.putDouble("created", confirmationToken.created.toDouble())
|
|
@@ -1071,7 +1098,7 @@ internal fun mapFromConfirmationToken(confirmationToken: ConfirmationToken): Wri
|
|
|
1071
1098
|
|
|
1072
1099
|
// PaymentMethodPreview
|
|
1073
1100
|
confirmationToken.paymentMethodPreview?.let { preview ->
|
|
1074
|
-
val paymentMethodPreview =
|
|
1101
|
+
val paymentMethodPreview = Arguments.createMap()
|
|
1075
1102
|
paymentMethodPreview.putString("type", mapPaymentMethodType(preview.type))
|
|
1076
1103
|
paymentMethodPreview.putMap("billingDetails", mapFromBillingDetails(preview.billingDetails))
|
|
1077
1104
|
paymentMethodPreview.putString("allowRedisplay", mapFromAllowRedisplay(preview.allowRedisplay))
|
|
@@ -1083,12 +1110,12 @@ internal fun mapFromConfirmationToken(confirmationToken: ConfirmationToken): Wri
|
|
|
1083
1110
|
|
|
1084
1111
|
// Shipping details
|
|
1085
1112
|
confirmationToken.shipping?.let { shippingDetails ->
|
|
1086
|
-
val shipping =
|
|
1113
|
+
val shipping = Arguments.createMap()
|
|
1087
1114
|
shipping.putString("name", shippingDetails.name)
|
|
1088
1115
|
shipping.putString("phone", shippingDetails.phone)
|
|
1089
1116
|
|
|
1090
1117
|
shippingDetails.address?.let { address ->
|
|
1091
|
-
val addressMap =
|
|
1118
|
+
val addressMap = Arguments.createMap()
|
|
1092
1119
|
addressMap.putString("city", address.city)
|
|
1093
1120
|
addressMap.putString("country", address.country)
|
|
1094
1121
|
addressMap.putString("line1", address.line1)
|
|
@@ -1097,7 +1124,7 @@ internal fun mapFromConfirmationToken(confirmationToken: ConfirmationToken): Wri
|
|
|
1097
1124
|
addressMap.putString("state", address.state)
|
|
1098
1125
|
shipping.putMap("address", addressMap)
|
|
1099
1126
|
} ?: run {
|
|
1100
|
-
shipping.putMap("address",
|
|
1127
|
+
shipping.putMap("address", Arguments.createMap())
|
|
1101
1128
|
}
|
|
1102
1129
|
|
|
1103
1130
|
token.putMap("shipping", shipping)
|
|
@@ -1146,3 +1173,24 @@ fun readableMapOf(vararg pairs: Pair<String, Any?>): ReadableMap =
|
|
|
1146
1173
|
}
|
|
1147
1174
|
}
|
|
1148
1175
|
}
|
|
1176
|
+
|
|
1177
|
+
fun readableArrayOf(vararg elements: Any?): ReadableArray =
|
|
1178
|
+
Arguments.createArray().apply {
|
|
1179
|
+
for (element in elements) {
|
|
1180
|
+
when (element) {
|
|
1181
|
+
null -> pushNull()
|
|
1182
|
+
is String -> pushString(element)
|
|
1183
|
+
is Boolean -> pushBoolean(element)
|
|
1184
|
+
is Double -> pushDouble(element)
|
|
1185
|
+
is Float -> pushDouble(element.toDouble())
|
|
1186
|
+
is Int -> pushInt(element)
|
|
1187
|
+
is Long -> pushInt(element.toInt())
|
|
1188
|
+
is ReadableMap -> pushMap(element)
|
|
1189
|
+
is ReadableArray -> pushArray(element)
|
|
1190
|
+
else -> {
|
|
1191
|
+
val valueType = element.javaClass.canonicalName
|
|
1192
|
+
throw IllegalArgumentException("Illegal value type $valueType for array element")
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
@@ -44,6 +44,9 @@ public class EmbeddedPaymentElementViewManagerDelegate<T extends View, U extends
|
|
|
44
44
|
case "clearPaymentOption":
|
|
45
45
|
mViewManager.clearPaymentOption(view);
|
|
46
46
|
break;
|
|
47
|
+
case "update":
|
|
48
|
+
mViewManager.update(view, args != null ? args.getString(0) : null);
|
|
49
|
+
break;
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
package com.facebook.react.viewmanagers;
|
|
11
11
|
|
|
12
12
|
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
13
14
|
import com.facebook.react.bridge.Dynamic;
|
|
14
15
|
|
|
15
16
|
public interface EmbeddedPaymentElementViewManagerInterface<T extends View> {
|
|
@@ -17,4 +18,5 @@ public interface EmbeddedPaymentElementViewManagerInterface<T extends View> {
|
|
|
17
18
|
void setIntentConfiguration(T view, Dynamic value);
|
|
18
19
|
void confirm(T view);
|
|
19
20
|
void clearPaymentOption(T view);
|
|
21
|
+
void update(T view, @Nullable String intentConfigurationJson);
|
|
20
22
|
}
|