@stripe/stripe-react-native 0.44.0 → 0.46.0
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/.clang-format +90 -0
- package/.editorconfig +3 -0
- package/CHANGELOG.md +13 -1
- package/README.md +0 -3
- package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
- package/android/.gradle/8.11.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.11.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.11.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.11.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/config.properties +2 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/.idea/caches/deviceStreaming.xml +619 -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 +90 -18
- package/android/gradle.properties +1 -1
- package/android/local.properties +8 -0
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +15 -6
- package/android/src/main/java/com/reactnativestripesdk/CardChangeEvent.kt +56 -0
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +55 -45
- package/android/src/main/java/com/reactnativestripesdk/{CardFocusEvent.kt → CardFocusChangeEvent.kt} +2 -2
- package/android/src/main/java/com/reactnativestripesdk/CardFormCompleteEvent.kt +17 -16
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +5 -5
- package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +39 -33
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +35 -36
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +224 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +238 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +11 -26
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +14 -6
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +3 -17
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +20 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +63 -44
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +17 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +266 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +25 -33
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +113 -0
- package/android/src/main/java/com/reactnativestripesdk/StripeContainerManager.kt +11 -3
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +180 -65
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +34 -4
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +3 -17
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +33 -27
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +49 -24
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +19 -24
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +11 -29
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +36 -12
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +5 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +21 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeFragment.kt +52 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddToWalletButtonManagerDelegate.java +49 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddToWalletButtonManagerInterface.java +25 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddressSheetViewManagerDelegate.java +64 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddressSheetViewManagerInterface.java +30 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerDelegate.java +41 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerInterface.java +20 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AuBECSDebitFormManagerDelegate.java +36 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AuBECSDebitFormManagerInterface.java +20 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFieldManagerDelegate.java +73 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFieldManagerInterface.java +31 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFormManagerDelegate.java +67 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFormManagerInterface.java +29 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +49 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +21 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/GooglePayButtonManagerDelegate.java +38 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/GooglePayButtonManagerInterface.java +19 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeContainerManagerDelegate.java +32 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeContainerManagerInterface.java +17 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +310 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +21 -19
- package/ios/AddressSheet/AddressSheetView.swift +23 -17
- package/ios/ApplePayButtonManager.m +0 -1
- package/ios/ApplePayButtonManager.swift +1 -3
- package/ios/ApplePayButtonView.swift +25 -20
- package/ios/ApplePayViewController.swift +22 -22
- package/ios/AuBECSDebitFormView.swift +14 -8
- package/ios/CardFieldManager.swift +1 -4
- package/ios/CardFieldView.swift +28 -25
- package/ios/CardFormManager.swift +1 -4
- package/ios/CardFormView.swift +25 -16
- package/ios/CustomerSheet/CustomerSheetUtils.swift +12 -16
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +8 -8
- package/ios/EmbeddedPaymentElementManager.m +6 -0
- package/ios/EmbeddedPaymentElementView.swift +49 -0
- package/ios/NewArch/AddToWalletButtonComponentView.h +10 -0
- package/ios/NewArch/AddToWalletButtonComponentView.mm +93 -0
- package/ios/NewArch/AddressSheetViewComponentView.h +10 -0
- package/ios/NewArch/AddressSheetViewComponentView.mm +109 -0
- package/ios/NewArch/ApplePayButtonComponentView.h +10 -0
- package/ios/NewArch/ApplePayButtonComponentView.mm +124 -0
- package/ios/NewArch/AuBECSDebitFormComponentView.h +10 -0
- package/ios/NewArch/AuBECSDebitFormComponentView.mm +95 -0
- package/ios/NewArch/CardFieldComponentView.h +10 -0
- package/ios/NewArch/CardFieldComponentView.mm +125 -0
- package/ios/NewArch/CardFormComponentView.h +10 -0
- package/ios/NewArch/CardFormComponentView.mm +108 -0
- package/ios/NewArch/EmbeddedPaymentElementViewComponentView.h +10 -0
- package/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm +81 -0
- package/ios/NewArch/StripeContainerComponentView.h +10 -0
- package/ios/NewArch/StripeContainerComponentView.mm +74 -0
- package/ios/NewArch/StripeNewArchConversions.h +20 -0
- package/ios/NewArch/StripeNewArchConversions.mm +47 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +27 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +105 -0
- package/ios/PaymentOptionDisplayData+ReactNative.swift +55 -0
- package/ios/PaymentSheetAppearance.swift +194 -1
- package/ios/PushProvisioning/AddToWalletButtonView.swift +19 -13
- package/ios/StripeContainerView.swift +5 -3
- package/ios/StripeSdk.h +21 -0
- package/ios/StripeSdk.mm +415 -0
- package/ios/StripeSdkEmitter.swift +19 -0
- package/ios/{StripeSdk+CustomerSheet.swift → StripeSdkImpl+CustomerSheet.swift} +24 -25
- package/ios/StripeSdkImpl+Embedded.swift +327 -0
- package/ios/{StripeSdk+PaymentSheet.swift → StripeSdkImpl+PaymentSheet.swift} +18 -29
- package/ios/{StripeSdk.swift → StripeSdkImpl.swift} +50 -72
- package/ios/StripeSwiftInterop.h +25 -0
- package/ios/stripe_react_native.h +2 -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/CustomerSheet.js +1 -1
- package/lib/commonjs/components/CustomerSheet.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/events.js +2 -0
- package/lib/commonjs/events.js.map +1 -0
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +2 -0
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -0
- package/lib/commonjs/specs/NativeAddressSheet.js +2 -0
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -0
- package/lib/commonjs/specs/NativeApplePayButton.js +2 -0
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -0
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +2 -0
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -0
- package/lib/commonjs/specs/NativeCardField.js +2 -0
- package/lib/commonjs/specs/NativeCardField.js.map +1 -0
- package/lib/commonjs/specs/NativeCardForm.js +2 -0
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +2 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -0
- package/lib/commonjs/specs/NativeGooglePayButton.js +2 -0
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +2 -0
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -0
- package/lib/commonjs/specs/utils.js +2 -0
- package/lib/commonjs/specs/utils.js.map +1 -0
- package/lib/commonjs/types/EmbeddedPaymentElement.js +2 -0
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -0
- package/lib/commonjs/types/PaymentSheet.js +1 -1
- package/lib/commonjs/types/PaymentSheet.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/CustomerSheet.js +1 -1
- package/lib/module/components/CustomerSheet.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/events.js +2 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +2 -0
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -0
- package/lib/module/specs/NativeAddressSheet.js +2 -0
- package/lib/module/specs/NativeAddressSheet.js.map +1 -0
- package/lib/module/specs/NativeApplePayButton.js +2 -0
- package/lib/module/specs/NativeApplePayButton.js.map +1 -0
- package/lib/module/specs/NativeAuBECSDebitForm.js +2 -0
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -0
- package/lib/module/specs/NativeCardField.js +2 -0
- package/lib/module/specs/NativeCardField.js.map +1 -0
- package/lib/module/specs/NativeCardForm.js +2 -0
- package/lib/module/specs/NativeCardForm.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +2 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -0
- package/lib/module/specs/NativeGooglePayButton.js +2 -0
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +2 -0
- package/lib/module/specs/NativeStripeContainer.js.map +1 -0
- package/lib/module/specs/NativeStripeSdkModule.js +2 -0
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -0
- package/lib/module/specs/utils.js +2 -0
- package/lib/module/specs/utils.js.map +1 -0
- package/lib/module/types/EmbeddedPaymentElement.js +2 -0
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -0
- package/lib/module/types/PaymentSheet.js +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/typescript/src/components/AddToWalletButton.d.ts.map +1 -1
- package/lib/typescript/src/components/AddressSheet.d.ts.map +1 -1
- package/lib/typescript/src/components/AuBECSDebitForm.d.ts.map +1 -1
- package/lib/typescript/src/components/CardField.d.ts +1 -1
- package/lib/typescript/src/components/CardField.d.ts.map +1 -1
- package/lib/typescript/src/components/CardForm.d.ts +1 -1
- package/lib/typescript/src/components/CardForm.d.ts.map +1 -1
- package/lib/typescript/src/components/CustomerSheet.d.ts +1 -1
- package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -1
- package/lib/typescript/src/components/StripeContainer.d.ts.map +1 -1
- package/lib/typescript/src/events.d.ts +13 -0
- package/lib/typescript/src/events.d.ts.map +1 -0
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +4 -4
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useStripe.d.ts +2 -2
- package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeAddToWalletButton.d.ts +27 -0
- package/lib/typescript/src/specs/NativeAddToWalletButton.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeAddressSheet.d.ts +34 -0
- package/lib/typescript/src/specs/NativeAddressSheet.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeApplePayButton.d.ts +28 -0
- package/lib/typescript/src/specs/NativeApplePayButton.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeAuBECSDebitForm.d.ts +19 -0
- package/lib/typescript/src/specs/NativeAuBECSDebitForm.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeCardField.d.ts +33 -0
- package/lib/typescript/src/specs/NativeCardField.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeCardForm.d.ts +31 -0
- package/lib/typescript/src/specs/NativeCardForm.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +17 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeGooglePayButton.d.ts +11 -0
- package/lib/typescript/src/specs/NativeGooglePayButton.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeContainer.d.ts +8 -0
- package/lib/typescript/src/specs/NativeStripeContainer.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +93 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/utils.d.ts +20 -0
- package/lib/typescript/src/specs/utils.d.ts.map +1 -0
- package/lib/typescript/src/types/CustomerSheet.d.ts +1 -5
- package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +161 -0
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +97 -4
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/components/CardFieldInput.d.ts +3 -2
- package/lib/typescript/src/types/components/CardFieldInput.d.ts.map +1 -1
- package/lib/typescript/src/types/components/CardFormView.d.ts +3 -1
- package/lib/typescript/src/types/components/CardFormView.d.ts.map +1 -1
- package/package.json +22 -2
- package/src/components/AddToWalletButton.tsx +2 -5
- package/src/components/AddressSheet.tsx +5 -16
- package/src/components/AuBECSDebitForm.tsx +3 -12
- package/src/components/CardField.tsx +20 -30
- package/src/components/CardForm.tsx +14 -29
- package/src/components/CustomerSheet.tsx +23 -25
- package/src/components/PlatformPayButton.tsx +6 -6
- package/src/components/StripeContainer.tsx +5 -12
- package/src/components/StripeProvider.tsx +1 -1
- package/src/events.ts +49 -0
- package/src/functions.ts +13 -24
- package/src/hooks/useFinancialConnectionsSheet.tsx +2 -2
- package/src/hooks/useStripe.tsx +2 -2
- package/src/index.tsx +3 -0
- package/src/specs/NativeAddToWalletButton.ts +40 -0
- package/src/specs/NativeAddressSheet.ts +50 -0
- package/src/specs/NativeApplePayButton.ts +40 -0
- package/src/specs/NativeAuBECSDebitForm.ts +24 -0
- package/src/specs/NativeCardField.ts +51 -0
- package/src/specs/NativeCardForm.ts +43 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +28 -0
- package/src/specs/NativeGooglePayButton.ts +20 -0
- package/src/specs/NativeStripeContainer.ts +12 -0
- package/src/specs/NativeStripeSdkModule.ts +219 -0
- package/src/specs/utils.ts +22 -0
- package/src/types/CustomerSheet.ts +1 -5
- package/src/types/EmbeddedPaymentElement.tsx +467 -0
- package/src/types/PaymentSheet.ts +114 -4
- package/src/types/components/CardFieldInput.ts +1 -2
- package/src/types/components/CardFormView.ts +1 -1
- package/stripe-react-native.podspec +27 -2
- package/android/src/main/java/com/reactnativestripesdk/CardChangedEvent.kt +0 -54
- package/ios/StripeSdk.m +0 -244
- package/lib/commonjs/NativeStripeSdk.js +0 -2
- package/lib/commonjs/NativeStripeSdk.js.map +0 -1
- package/lib/commonjs/components/ApplePayButtonNative.js +0 -2
- package/lib/commonjs/components/ApplePayButtonNative.js.map +0 -1
- package/lib/commonjs/components/GooglePayButtonNative.js +0 -2
- package/lib/commonjs/components/GooglePayButtonNative.js.map +0 -1
- package/lib/module/NativeStripeSdk.js +0 -2
- package/lib/module/NativeStripeSdk.js.map +0 -1
- package/lib/module/components/ApplePayButtonNative.js +0 -2
- package/lib/module/components/ApplePayButtonNative.js.map +0 -1
- package/lib/module/components/GooglePayButtonNative.js +0 -2
- package/lib/module/components/GooglePayButtonNative.js.map +0 -1
- package/lib/typescript/src/NativeStripeSdk.d.ts +0 -58
- package/lib/typescript/src/NativeStripeSdk.d.ts.map +0 -1
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts +0 -4
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts.map +0 -1
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts +0 -4
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts.map +0 -1
- package/src/NativeStripeSdk.tsx +0 -159
- package/src/components/ApplePayButtonNative.tsx +0 -5
- package/src/components/GooglePayButtonNative.tsx +0 -7
|
@@ -65,8 +65,8 @@ class CardFormView(
|
|
|
65
65
|
cardFormViewBinding.postalCodeContainer.visibility = visibility
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
fun setDefaultValues(defaults: ReadableMap) {
|
|
69
|
-
setCountry(defaults
|
|
68
|
+
fun setDefaultValues(defaults: ReadableMap?) {
|
|
69
|
+
setCountry(defaults?.getString("countryCode"))
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
fun setDisabled(isDisabled: Boolean) {
|
|
@@ -86,7 +86,7 @@ class CardFormView(
|
|
|
86
86
|
setPostalCodeFilter()
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
fun setPlaceHolders(value: ReadableMap) {
|
|
89
|
+
fun setPlaceHolders(value: ReadableMap?) {
|
|
90
90
|
val numberPlaceholder = getValOr(value, "number", null)
|
|
91
91
|
val expirationPlaceholder = getValOr(value, "expiration", null)
|
|
92
92
|
val cvcPlaceholder = getValOr(value, "cvc", null)
|
|
@@ -136,11 +136,11 @@ class CardFormView(
|
|
|
136
136
|
private fun onChangeFocus() {
|
|
137
137
|
UIManagerHelper
|
|
138
138
|
.getEventDispatcherForReactTag(context, id)
|
|
139
|
-
?.dispatchEvent(
|
|
139
|
+
?.dispatchEvent(CardFocusChangeEvent(context.surfaceId, id, currentFocusedField))
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
@SuppressLint("RestrictedApi")
|
|
143
|
-
fun setCardStyle(value: ReadableMap) {
|
|
143
|
+
fun setCardStyle(value: ReadableMap?) {
|
|
144
144
|
val backgroundColor = getValOr(value, "backgroundColor", null)
|
|
145
145
|
val textColor = getValOr(value, "textColor", null)
|
|
146
146
|
val borderWidth = getIntOrNull(value, "borderWidth")
|
|
@@ -1,86 +1,82 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Dynamic
|
|
3
4
|
import com.facebook.react.bridge.ReadableArray
|
|
4
|
-
import com.facebook.react.bridge.ReadableMap
|
|
5
5
|
import com.facebook.react.module.annotations.ReactModule
|
|
6
6
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
7
7
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
8
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
|
+
import com.facebook.react.viewmanagers.CardFormManagerDelegate
|
|
10
|
+
import com.facebook.react.viewmanagers.CardFormManagerInterface
|
|
11
|
+
import com.reactnativestripesdk.utils.asMapOrNull
|
|
9
12
|
|
|
10
13
|
@ReactModule(name = CardFormViewManager.REACT_CLASS)
|
|
11
|
-
class CardFormViewManager :
|
|
14
|
+
class CardFormViewManager :
|
|
15
|
+
SimpleViewManager<CardFormView>(),
|
|
16
|
+
CardFormManagerInterface<CardFormView> {
|
|
17
|
+
private val delegate = CardFormManagerDelegate(this)
|
|
18
|
+
private var reactContextRef: ThemedReactContext? = null
|
|
19
|
+
|
|
12
20
|
override fun getName() = REACT_CLASS
|
|
13
21
|
|
|
14
|
-
|
|
22
|
+
override fun getDelegate() = delegate
|
|
15
23
|
|
|
16
24
|
override fun getExportedCustomDirectEventTypeConstants() =
|
|
17
25
|
mutableMapOf(
|
|
18
|
-
|
|
26
|
+
CardFocusChangeEvent.EVENT_NAME to mutableMapOf("registrationName" to "onFocusChange"),
|
|
19
27
|
CardFormCompleteEvent.EVENT_NAME to mutableMapOf("registrationName" to "onFormComplete"),
|
|
20
28
|
)
|
|
21
29
|
|
|
22
|
-
override fun receiveCommand(
|
|
23
|
-
root: CardFormView,
|
|
24
|
-
commandId: String?,
|
|
25
|
-
args: ReadableArray?,
|
|
26
|
-
) {
|
|
27
|
-
when (commandId) {
|
|
28
|
-
"focus" -> root.requestFocusFromJS()
|
|
29
|
-
"blur" -> root.requestBlurFromJS()
|
|
30
|
-
"clear" -> root.requestClearFromJS()
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
30
|
@ReactProp(name = "dangerouslyGetFullCardDetails")
|
|
35
|
-
fun setDangerouslyGetFullCardDetails(
|
|
31
|
+
override fun setDangerouslyGetFullCardDetails(
|
|
36
32
|
view: CardFormView,
|
|
37
|
-
dangerouslyGetFullCardDetails: Boolean
|
|
33
|
+
dangerouslyGetFullCardDetails: Boolean,
|
|
38
34
|
) {
|
|
39
35
|
view.setDangerouslyGetFullCardDetails(dangerouslyGetFullCardDetails)
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
@ReactProp(name = "postalCodeEnabled")
|
|
43
|
-
fun setPostalCodeEnabled(
|
|
39
|
+
override fun setPostalCodeEnabled(
|
|
44
40
|
view: CardFormView,
|
|
45
|
-
postalCodeEnabled: Boolean
|
|
41
|
+
postalCodeEnabled: Boolean,
|
|
46
42
|
) {
|
|
47
43
|
view.setPostalCodeEnabled(postalCodeEnabled)
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
@ReactProp(name = "placeholders")
|
|
51
|
-
fun
|
|
47
|
+
override fun setPlaceholders(
|
|
52
48
|
view: CardFormView,
|
|
53
|
-
placeholders:
|
|
49
|
+
placeholders: Dynamic,
|
|
54
50
|
) {
|
|
55
|
-
view.setPlaceHolders(placeholders)
|
|
51
|
+
view.setPlaceHolders(placeholders.asMapOrNull())
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
@ReactProp(name = "autofocus")
|
|
59
|
-
fun setAutofocus(
|
|
55
|
+
override fun setAutofocus(
|
|
60
56
|
view: CardFormView,
|
|
61
|
-
autofocus: Boolean
|
|
57
|
+
autofocus: Boolean,
|
|
62
58
|
) {
|
|
63
59
|
view.setAutofocus(autofocus)
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
@ReactProp(name = "cardStyle")
|
|
67
|
-
fun setCardStyle(
|
|
63
|
+
override fun setCardStyle(
|
|
68
64
|
view: CardFormView,
|
|
69
|
-
cardStyle:
|
|
65
|
+
cardStyle: Dynamic,
|
|
70
66
|
) {
|
|
71
|
-
view.setCardStyle(cardStyle)
|
|
67
|
+
view.setCardStyle(cardStyle.asMapOrNull())
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
@ReactProp(name = "defaultValues")
|
|
75
|
-
fun setDefaultValues(
|
|
71
|
+
override fun setDefaultValues(
|
|
76
72
|
view: CardFormView,
|
|
77
|
-
defaults:
|
|
73
|
+
defaults: Dynamic,
|
|
78
74
|
) {
|
|
79
|
-
view.setDefaultValues(defaults)
|
|
75
|
+
view.setDefaultValues(defaults.asMapOrNull())
|
|
80
76
|
}
|
|
81
77
|
|
|
82
78
|
@ReactProp(name = "disabled")
|
|
83
|
-
fun setDisabled(
|
|
79
|
+
override fun setDisabled(
|
|
84
80
|
view: CardFormView,
|
|
85
81
|
isDisabled: Boolean,
|
|
86
82
|
) {
|
|
@@ -88,7 +84,7 @@ class CardFormViewManager : SimpleViewManager<CardFormView>() {
|
|
|
88
84
|
}
|
|
89
85
|
|
|
90
86
|
@ReactProp(name = "preferredNetworks")
|
|
91
|
-
fun setPreferredNetworks(
|
|
87
|
+
override fun setPreferredNetworks(
|
|
92
88
|
view: CardFormView,
|
|
93
89
|
preferredNetworks: ReadableArray?,
|
|
94
90
|
) {
|
|
@@ -116,6 +112,16 @@ class CardFormViewManager : SimpleViewManager<CardFormView>() {
|
|
|
116
112
|
reactContextRef = null
|
|
117
113
|
}
|
|
118
114
|
|
|
115
|
+
// Native commands
|
|
116
|
+
|
|
117
|
+
override fun blur(view: CardFormView) {
|
|
118
|
+
view.requestBlurFromJS()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
override fun focus(view: CardFormView) {
|
|
122
|
+
view.requestFocusFromJS()
|
|
123
|
+
}
|
|
124
|
+
|
|
119
125
|
companion object {
|
|
120
126
|
const val REACT_CLASS = "CardForm"
|
|
121
127
|
}
|
package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
2
|
|
|
3
|
-
import android.os.Bundle
|
|
4
|
-
import android.view.LayoutInflater
|
|
5
|
-
import android.view.View
|
|
6
|
-
import android.view.ViewGroup
|
|
7
|
-
import android.widget.FrameLayout
|
|
8
|
-
import androidx.fragment.app.Fragment
|
|
9
3
|
import com.facebook.react.bridge.Promise
|
|
10
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
5
|
import com.reactnativestripesdk.utils.ErrorType
|
|
6
|
+
import com.reactnativestripesdk.utils.StripeFragment
|
|
12
7
|
import com.reactnativestripesdk.utils.createError
|
|
13
8
|
import com.reactnativestripesdk.utils.createResult
|
|
14
9
|
import com.reactnativestripesdk.utils.mapFromFinancialConnectionsEvent
|
|
@@ -23,44 +18,26 @@ import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
|
|
|
23
18
|
import com.stripe.android.payments.bankaccount.CollectBankAccountLauncher
|
|
24
19
|
import com.stripe.android.payments.bankaccount.navigation.CollectBankAccountResult
|
|
25
20
|
|
|
26
|
-
class CollectBankAccountLauncherFragment(
|
|
27
|
-
private
|
|
28
|
-
private
|
|
29
|
-
private
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
private
|
|
34
|
-
) : Fragment() {
|
|
21
|
+
class CollectBankAccountLauncherFragment : StripeFragment() {
|
|
22
|
+
private lateinit var context: ReactApplicationContext
|
|
23
|
+
private lateinit var publishableKey: String
|
|
24
|
+
private var stripeAccountId: String? = null
|
|
25
|
+
private lateinit var clientSecret: String
|
|
26
|
+
private var isPaymentIntent: Boolean = false
|
|
27
|
+
private lateinit var collectParams: CollectBankAccountConfiguration.USBankAccount
|
|
28
|
+
private lateinit var promise: Promise
|
|
35
29
|
private lateinit var collectBankAccountLauncher: CollectBankAccountLauncher
|
|
36
30
|
|
|
37
|
-
override fun
|
|
38
|
-
|
|
31
|
+
override fun prepare() {
|
|
32
|
+
collectBankAccountLauncher = createBankAccountLauncher()
|
|
39
33
|
|
|
40
34
|
val stripeSdkModule: StripeSdkModule? = context.getNativeModule(StripeSdkModule::class.java)
|
|
41
|
-
if (stripeSdkModule != null
|
|
35
|
+
if (stripeSdkModule != null) {
|
|
42
36
|
FinancialConnections.setEventListener { event ->
|
|
43
37
|
val params = mapFromFinancialConnectionsEvent(event)
|
|
44
|
-
stripeSdkModule.
|
|
38
|
+
stripeSdkModule.emitOnFinancialConnectionsEvent(params)
|
|
45
39
|
}
|
|
46
40
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
override fun onCreateView(
|
|
50
|
-
inflater: LayoutInflater,
|
|
51
|
-
container: ViewGroup?,
|
|
52
|
-
savedInstanceState: Bundle?,
|
|
53
|
-
): View {
|
|
54
|
-
collectBankAccountLauncher = createBankAccountLauncher()
|
|
55
|
-
|
|
56
|
-
return FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
override fun onViewCreated(
|
|
60
|
-
view: View,
|
|
61
|
-
savedInstanceState: Bundle?,
|
|
62
|
-
) {
|
|
63
|
-
super.onViewCreated(view, savedInstanceState)
|
|
64
41
|
|
|
65
42
|
if (isPaymentIntent) {
|
|
66
43
|
collectBankAccountLauncher.presentWithPaymentIntent(
|
|
@@ -108,11 +85,13 @@ class CollectBankAccountLauncherFragment(
|
|
|
108
85
|
)
|
|
109
86
|
}
|
|
110
87
|
}
|
|
88
|
+
|
|
111
89
|
is CollectBankAccountResult.Cancelled -> {
|
|
112
90
|
promise.resolve(
|
|
113
91
|
createError(ErrorType.Canceled.toString(), "Bank account collection was canceled."),
|
|
114
92
|
)
|
|
115
93
|
}
|
|
94
|
+
|
|
116
95
|
is CollectBankAccountResult.Failed -> {
|
|
117
96
|
promise.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
118
97
|
}
|
|
@@ -122,5 +101,25 @@ class CollectBankAccountLauncherFragment(
|
|
|
122
101
|
|
|
123
102
|
companion object {
|
|
124
103
|
internal const val TAG = "collect_bank_account_launcher_fragment"
|
|
104
|
+
|
|
105
|
+
fun create(
|
|
106
|
+
context: ReactApplicationContext,
|
|
107
|
+
publishableKey: String,
|
|
108
|
+
stripeAccountId: String? = null,
|
|
109
|
+
clientSecret: String,
|
|
110
|
+
isPaymentIntent: Boolean,
|
|
111
|
+
collectParams: CollectBankAccountConfiguration.USBankAccount,
|
|
112
|
+
promise: Promise,
|
|
113
|
+
): CollectBankAccountLauncherFragment {
|
|
114
|
+
val instance = CollectBankAccountLauncherFragment()
|
|
115
|
+
instance.context = context
|
|
116
|
+
instance.publishableKey = publishableKey
|
|
117
|
+
instance.stripeAccountId = stripeAccountId
|
|
118
|
+
instance.clientSecret = clientSecret
|
|
119
|
+
instance.isPaymentIntent = isPaymentIntent
|
|
120
|
+
instance.collectParams = collectParams
|
|
121
|
+
instance.promise = promise
|
|
122
|
+
return instance
|
|
123
|
+
}
|
|
125
124
|
}
|
|
126
125
|
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import androidx.compose.foundation.layout.Box
|
|
5
|
+
import androidx.compose.foundation.layout.requiredHeight
|
|
6
|
+
import androidx.compose.runtime.Composable
|
|
7
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
8
|
+
import androidx.compose.runtime.getValue
|
|
9
|
+
import androidx.compose.runtime.mutableIntStateOf
|
|
10
|
+
import androidx.compose.runtime.remember
|
|
11
|
+
import androidx.compose.runtime.setValue
|
|
12
|
+
import androidx.compose.ui.Modifier
|
|
13
|
+
import androidx.compose.ui.layout.layout
|
|
14
|
+
import androidx.compose.ui.layout.onPlaced
|
|
15
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
16
|
+
import androidx.compose.ui.unit.IntOffset
|
|
17
|
+
import androidx.compose.ui.unit.dp
|
|
18
|
+
import com.facebook.react.bridge.Arguments
|
|
19
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
20
|
+
import com.reactnativestripesdk.utils.KeepJsAwakeTask
|
|
21
|
+
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
22
|
+
import com.stripe.android.paymentelement.EmbeddedPaymentElement
|
|
23
|
+
import com.stripe.android.paymentelement.ExperimentalEmbeddedPaymentElementApi
|
|
24
|
+
import com.stripe.android.paymentelement.rememberEmbeddedPaymentElement
|
|
25
|
+
import com.stripe.android.paymentsheet.CreateIntentResult
|
|
26
|
+
import com.stripe.android.paymentsheet.PaymentSheet
|
|
27
|
+
import kotlinx.coroutines.CompletableDeferred
|
|
28
|
+
import kotlinx.coroutines.channels.Channel
|
|
29
|
+
import kotlinx.coroutines.flow.consumeAsFlow
|
|
30
|
+
import toWritableMap
|
|
31
|
+
|
|
32
|
+
@OptIn(ExperimentalEmbeddedPaymentElementApi::class)
|
|
33
|
+
class EmbeddedPaymentElementView(
|
|
34
|
+
context: Context,
|
|
35
|
+
) : StripeAbstractComposeView(context) {
|
|
36
|
+
private sealed interface Event {
|
|
37
|
+
data class Configure(
|
|
38
|
+
val configuration: EmbeddedPaymentElement.Configuration,
|
|
39
|
+
val intentConfiguration: PaymentSheet.IntentConfiguration,
|
|
40
|
+
) : Event
|
|
41
|
+
|
|
42
|
+
data object Confirm : Event
|
|
43
|
+
|
|
44
|
+
data object ClearPaymentOption : Event
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var latestIntentConfig: PaymentSheet.IntentConfiguration? = null
|
|
48
|
+
var latestElementConfig: EmbeddedPaymentElement.Configuration? = null
|
|
49
|
+
|
|
50
|
+
private val reactContext get() = context as ThemedReactContext
|
|
51
|
+
private val events = Channel<Event>(Channel.UNLIMITED)
|
|
52
|
+
|
|
53
|
+
private val builder by lazy {
|
|
54
|
+
EmbeddedPaymentElement.Builder(
|
|
55
|
+
createIntentCallback = { paymentMethod, shouldSavePaymentMethod ->
|
|
56
|
+
val stripeSdkModule =
|
|
57
|
+
try {
|
|
58
|
+
requireStripeSdkModule()
|
|
59
|
+
} catch (ex: IllegalArgumentException) {
|
|
60
|
+
return@Builder CreateIntentResult.Failure(
|
|
61
|
+
cause =
|
|
62
|
+
Exception(
|
|
63
|
+
"Tried to call confirmHandler, but no callback was found. Please file an issue: https://github.com/stripe/stripe-react-native/issues",
|
|
64
|
+
),
|
|
65
|
+
displayMessage = "An unexpected error occurred",
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Make sure that JS is active since the activity will be paused when stripe ui is presented.
|
|
70
|
+
val keepJsAwakeTask = KeepJsAwakeTask(reactContext.reactApplicationContext).apply { start() }
|
|
71
|
+
|
|
72
|
+
val params =
|
|
73
|
+
Arguments.createMap().apply {
|
|
74
|
+
putMap("paymentMethod", mapFromPaymentMethod(paymentMethod))
|
|
75
|
+
putBoolean("shouldSavePaymentMethod", shouldSavePaymentMethod)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
stripeSdkModule.emitOnConfirmHandlerCallback(params)
|
|
79
|
+
|
|
80
|
+
val resultFromJavascript = stripeSdkModule.embeddedIntentCreationCallback.await()
|
|
81
|
+
// reset the completable
|
|
82
|
+
stripeSdkModule.embeddedIntentCreationCallback = CompletableDeferred()
|
|
83
|
+
|
|
84
|
+
keepJsAwakeTask.stop()
|
|
85
|
+
|
|
86
|
+
resultFromJavascript.getString("clientSecret")?.let {
|
|
87
|
+
CreateIntentResult.Success(clientSecret = it)
|
|
88
|
+
} ?: run {
|
|
89
|
+
val errorMap = resultFromJavascript.getMap("error")
|
|
90
|
+
CreateIntentResult.Failure(
|
|
91
|
+
cause = Exception(errorMap?.getString("message")),
|
|
92
|
+
displayMessage = errorMap?.getString("localizedMessage"),
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
resultCallback = { result ->
|
|
97
|
+
val map =
|
|
98
|
+
Arguments.createMap().apply {
|
|
99
|
+
when (result) {
|
|
100
|
+
is EmbeddedPaymentElement.Result.Completed -> {
|
|
101
|
+
putString("status", "completed")
|
|
102
|
+
}
|
|
103
|
+
is EmbeddedPaymentElement.Result.Canceled -> {
|
|
104
|
+
putString("status", "canceled")
|
|
105
|
+
}
|
|
106
|
+
is EmbeddedPaymentElement.Result.Failed -> {
|
|
107
|
+
putString("status", "failed")
|
|
108
|
+
putString("error", result.error.message ?: "Unknown error")
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
requireStripeSdkModule().emitEmbeddedPaymentElementFormSheetConfirmComplete(map)
|
|
113
|
+
},
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Composable
|
|
118
|
+
override fun Content() {
|
|
119
|
+
val embedded = rememberEmbeddedPaymentElement(builder)
|
|
120
|
+
var height by remember {
|
|
121
|
+
mutableIntStateOf(0)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// collect events: configure, confirm, clear
|
|
125
|
+
LaunchedEffect(Unit) {
|
|
126
|
+
events.consumeAsFlow().collect { ev ->
|
|
127
|
+
when (ev) {
|
|
128
|
+
is Event.Configure -> {
|
|
129
|
+
// call configure and grab the result
|
|
130
|
+
val result =
|
|
131
|
+
embedded.configure(
|
|
132
|
+
intentConfiguration = ev.intentConfiguration,
|
|
133
|
+
configuration = ev.configuration,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
when (result) {
|
|
137
|
+
is EmbeddedPaymentElement.ConfigureResult.Succeeded -> reportHeightChange(1f)
|
|
138
|
+
is EmbeddedPaymentElement.ConfigureResult.Failed -> {
|
|
139
|
+
// send the error back to JS
|
|
140
|
+
val err = result.error
|
|
141
|
+
val msg = err.localizedMessage ?: err.toString()
|
|
142
|
+
// build a RN map
|
|
143
|
+
val payload =
|
|
144
|
+
Arguments.createMap().apply {
|
|
145
|
+
putString("message", msg)
|
|
146
|
+
}
|
|
147
|
+
requireStripeSdkModule().emitEmbeddedPaymentElementLoadingFailed(payload)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
is Event.Confirm -> {
|
|
153
|
+
embedded.confirm()
|
|
154
|
+
}
|
|
155
|
+
is Event.ClearPaymentOption -> {
|
|
156
|
+
embedded.clearPaymentOption()
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
LaunchedEffect(embedded) {
|
|
163
|
+
embedded.paymentOption.collect { opt ->
|
|
164
|
+
val optMap = opt?.toWritableMap()
|
|
165
|
+
val payload =
|
|
166
|
+
Arguments.createMap().apply {
|
|
167
|
+
putMap("paymentOption", optMap)
|
|
168
|
+
}
|
|
169
|
+
requireStripeSdkModule().emitEmbeddedPaymentElementDidUpdatePaymentOption(payload)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
val density = LocalDensity.current
|
|
174
|
+
|
|
175
|
+
Box(
|
|
176
|
+
modifier =
|
|
177
|
+
Modifier
|
|
178
|
+
.requiredHeight(height.dp)
|
|
179
|
+
.layout { measurable, constraints ->
|
|
180
|
+
val minIntrinsicHeight = measurable.minIntrinsicHeight(constraints.maxWidth)
|
|
181
|
+
|
|
182
|
+
height = minIntrinsicHeight
|
|
183
|
+
|
|
184
|
+
layout(constraints.maxWidth, minIntrinsicHeight) {
|
|
185
|
+
measurable.measure(constraints).placeRelative(IntOffset.Zero)
|
|
186
|
+
}
|
|
187
|
+
}.onPlaced {
|
|
188
|
+
reportHeightChange(
|
|
189
|
+
with(density) {
|
|
190
|
+
height.toDp().value
|
|
191
|
+
},
|
|
192
|
+
)
|
|
193
|
+
},
|
|
194
|
+
) {
|
|
195
|
+
embedded.Content()
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private fun reportHeightChange(height: Float) {
|
|
200
|
+
val params =
|
|
201
|
+
Arguments.createMap().apply {
|
|
202
|
+
putDouble("height", height.toDouble())
|
|
203
|
+
}
|
|
204
|
+
requireStripeSdkModule().emitEmbeddedPaymentElementDidUpdateHeight(params)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// APIs
|
|
208
|
+
fun configure(
|
|
209
|
+
config: EmbeddedPaymentElement.Configuration,
|
|
210
|
+
intentConfig: PaymentSheet.IntentConfiguration,
|
|
211
|
+
) {
|
|
212
|
+
events.trySend(Event.Configure(config, intentConfig))
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
fun confirm() {
|
|
216
|
+
events.trySend(Event.Confirm)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
fun clearPaymentOption() {
|
|
220
|
+
events.trySend(Event.ClearPaymentOption)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private fun requireStripeSdkModule() = requireNotNull(reactContext.getNativeModule(StripeSdkModule::class.java))
|
|
224
|
+
}
|