@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
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import com.facebook.react.bridge.Dynamic
|
|
6
|
+
import com.facebook.react.bridge.ReadableArray
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap
|
|
8
|
+
import com.facebook.react.bridge.ReadableType
|
|
9
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
10
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
11
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
12
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
13
|
+
import com.facebook.react.viewmanagers.EmbeddedPaymentElementViewManagerDelegate
|
|
14
|
+
import com.facebook.react.viewmanagers.EmbeddedPaymentElementViewManagerInterface
|
|
15
|
+
import com.reactnativestripesdk.PaymentSheetFragment.Companion.buildCustomerConfiguration
|
|
16
|
+
import com.reactnativestripesdk.PaymentSheetFragment.Companion.buildGooglePayConfig
|
|
17
|
+
import com.reactnativestripesdk.addresssheet.AddressSheetView
|
|
18
|
+
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
19
|
+
import com.reactnativestripesdk.utils.PaymentSheetException
|
|
20
|
+
import com.reactnativestripesdk.utils.mapToPreferredNetworks
|
|
21
|
+
import com.reactnativestripesdk.utils.toBundleObject
|
|
22
|
+
import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi
|
|
23
|
+
import com.stripe.android.paymentelement.EmbeddedPaymentElement
|
|
24
|
+
import com.stripe.android.paymentelement.ExperimentalEmbeddedPaymentElementApi
|
|
25
|
+
import com.stripe.android.paymentsheet.PaymentSheet
|
|
26
|
+
|
|
27
|
+
@OptIn(ExperimentalEmbeddedPaymentElementApi::class)
|
|
28
|
+
@ReactModule(name = EmbeddedPaymentElementViewManager.NAME)
|
|
29
|
+
class EmbeddedPaymentElementViewManager :
|
|
30
|
+
ViewGroupManager<EmbeddedPaymentElementView>(),
|
|
31
|
+
EmbeddedPaymentElementViewManagerInterface<EmbeddedPaymentElementView> {
|
|
32
|
+
companion object {
|
|
33
|
+
const val NAME = "EmbeddedPaymentElementView"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private val delegate = EmbeddedPaymentElementViewManagerDelegate(this)
|
|
37
|
+
|
|
38
|
+
override fun getName() = NAME
|
|
39
|
+
|
|
40
|
+
override fun getDelegate() = delegate
|
|
41
|
+
|
|
42
|
+
override fun createViewInstance(ctx: ThemedReactContext): EmbeddedPaymentElementView = EmbeddedPaymentElementView(ctx)
|
|
43
|
+
|
|
44
|
+
override fun onDropViewInstance(view: EmbeddedPaymentElementView) {
|
|
45
|
+
super.onDropViewInstance(view)
|
|
46
|
+
|
|
47
|
+
view.handleOnDropViewInstance()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override fun needsCustomLayoutForChildren(): Boolean = true
|
|
51
|
+
|
|
52
|
+
@ReactProp(name = "configuration")
|
|
53
|
+
override fun setConfiguration(
|
|
54
|
+
view: EmbeddedPaymentElementView,
|
|
55
|
+
cfg: Dynamic,
|
|
56
|
+
) {
|
|
57
|
+
val elementConfig = parseElementConfiguration(cfg.asMap(), view.context)
|
|
58
|
+
view.latestElementConfig = elementConfig
|
|
59
|
+
// if intentConfig is already set, configure immediately:
|
|
60
|
+
view.latestIntentConfig?.let { intentCfg ->
|
|
61
|
+
view.configure(elementConfig, intentCfg)
|
|
62
|
+
view.post {
|
|
63
|
+
view.requestLayout()
|
|
64
|
+
view.invalidate()
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@ReactProp(name = "intentConfiguration")
|
|
70
|
+
override fun setIntentConfiguration(
|
|
71
|
+
view: EmbeddedPaymentElementView,
|
|
72
|
+
cfg: Dynamic,
|
|
73
|
+
) {
|
|
74
|
+
val intentConfig = parseIntentConfiguration(cfg.asMap())
|
|
75
|
+
view.latestIntentConfig = intentConfig
|
|
76
|
+
view.latestElementConfig?.let { elemCfg ->
|
|
77
|
+
view.configure(elemCfg, intentConfig)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@SuppressLint("RestrictedApi")
|
|
82
|
+
@OptIn(ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi::class)
|
|
83
|
+
private fun parseElementConfiguration(
|
|
84
|
+
map: ReadableMap,
|
|
85
|
+
context: Context,
|
|
86
|
+
): EmbeddedPaymentElement.Configuration {
|
|
87
|
+
val merchantDisplayName = map.getString("merchantDisplayName").orEmpty()
|
|
88
|
+
val allowsDelayedPaymentMethods: Boolean =
|
|
89
|
+
if (map.hasKey("allowsDelayedPaymentMethods") &&
|
|
90
|
+
map.getType("allowsDelayedPaymentMethods") == ReadableType.Boolean
|
|
91
|
+
) {
|
|
92
|
+
map.getBoolean("allowsDelayedPaymentMethods")
|
|
93
|
+
} else {
|
|
94
|
+
false // default
|
|
95
|
+
}
|
|
96
|
+
var defaultBillingDetails: PaymentSheet.BillingDetails? = null
|
|
97
|
+
val billingDetailsMap = map.getMap("defaultBillingDetails")
|
|
98
|
+
if (billingDetailsMap != null) {
|
|
99
|
+
val addressBundle = billingDetailsMap.getMap("address")
|
|
100
|
+
val address =
|
|
101
|
+
PaymentSheet.Address(
|
|
102
|
+
addressBundle?.getString("city"),
|
|
103
|
+
addressBundle?.getString("country"),
|
|
104
|
+
addressBundle?.getString("line1"),
|
|
105
|
+
addressBundle?.getString("line2"),
|
|
106
|
+
addressBundle?.getString("postalCode"),
|
|
107
|
+
addressBundle?.getString("state"),
|
|
108
|
+
)
|
|
109
|
+
defaultBillingDetails =
|
|
110
|
+
PaymentSheet.BillingDetails(
|
|
111
|
+
address,
|
|
112
|
+
billingDetailsMap.getString("email"),
|
|
113
|
+
billingDetailsMap.getString("name"),
|
|
114
|
+
billingDetailsMap.getString("phone"),
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
val customerConfiguration =
|
|
119
|
+
try {
|
|
120
|
+
buildCustomerConfiguration(toBundleObject(map))
|
|
121
|
+
} catch (error: PaymentSheetException) {
|
|
122
|
+
throw Error() // TODO handle error
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
val googlePayConfig = buildGooglePayConfig(toBundleObject(map.getMap("googlePay")))
|
|
126
|
+
val shippingDetails =
|
|
127
|
+
map.getMap("defaultShippingDetails")?.let {
|
|
128
|
+
AddressSheetView.buildAddressDetails(it)
|
|
129
|
+
}
|
|
130
|
+
val appearance =
|
|
131
|
+
try {
|
|
132
|
+
buildPaymentSheetAppearance(toBundleObject(map.getMap("appearance")), context)
|
|
133
|
+
} catch (error: PaymentSheetAppearanceException) {
|
|
134
|
+
throw Error() // TODO handle error
|
|
135
|
+
}
|
|
136
|
+
val billingConfigParams = map.getMap("billingDetailsCollectionConfiguration")
|
|
137
|
+
val billingDetailsConfig =
|
|
138
|
+
PaymentSheet.BillingDetailsCollectionConfiguration(
|
|
139
|
+
name = mapToCollectionMode(billingConfigParams?.getString("name")),
|
|
140
|
+
phone = mapToCollectionMode(billingConfigParams?.getString("phone")),
|
|
141
|
+
email = mapToCollectionMode(billingConfigParams?.getString("email")),
|
|
142
|
+
address = mapToAddressCollectionMode(billingConfigParams?.getString("address")),
|
|
143
|
+
attachDefaultsToPaymentMethod =
|
|
144
|
+
billingConfigParams?.getBoolean("attachDefaultsToPaymentMethod") ?: false,
|
|
145
|
+
)
|
|
146
|
+
val allowsRemovalOfLastSavedPaymentMethod =
|
|
147
|
+
if (map.hasKey("allowsRemovalOfLastSavedPaymentMethod")) {
|
|
148
|
+
map.getBoolean("allowsRemovalOfLastSavedPaymentMethod")
|
|
149
|
+
} else {
|
|
150
|
+
true
|
|
151
|
+
}
|
|
152
|
+
val primaryButtonLabel = map.getString("primaryButtonLabel")
|
|
153
|
+
val paymentMethodOrder = map.getStringArrayList("paymentMethodOrder")
|
|
154
|
+
|
|
155
|
+
val formSheetAction =
|
|
156
|
+
map
|
|
157
|
+
.getMap("formSheetAction")
|
|
158
|
+
?.getString("type")
|
|
159
|
+
?.let { type ->
|
|
160
|
+
when (type) {
|
|
161
|
+
"confirm" -> EmbeddedPaymentElement.FormSheetAction.Confirm
|
|
162
|
+
else -> EmbeddedPaymentElement.FormSheetAction.Continue
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
?: EmbeddedPaymentElement.FormSheetAction.Continue
|
|
166
|
+
|
|
167
|
+
val configurationBuilder =
|
|
168
|
+
EmbeddedPaymentElement.Configuration
|
|
169
|
+
.Builder(merchantDisplayName)
|
|
170
|
+
.formSheetAction(formSheetAction)
|
|
171
|
+
.allowsDelayedPaymentMethods(allowsDelayedPaymentMethods ?: false)
|
|
172
|
+
.defaultBillingDetails(defaultBillingDetails)
|
|
173
|
+
.customer(customerConfiguration)
|
|
174
|
+
.googlePay(googlePayConfig)
|
|
175
|
+
.appearance(appearance)
|
|
176
|
+
.shippingDetails(shippingDetails)
|
|
177
|
+
.billingDetailsCollectionConfiguration(billingDetailsConfig)
|
|
178
|
+
.preferredNetworks(
|
|
179
|
+
mapToPreferredNetworks(
|
|
180
|
+
map
|
|
181
|
+
.getIntegerArrayList("preferredNetworks")
|
|
182
|
+
?.let { ArrayList(it) },
|
|
183
|
+
),
|
|
184
|
+
).allowsRemovalOfLastSavedPaymentMethod(allowsRemovalOfLastSavedPaymentMethod)
|
|
185
|
+
.cardBrandAcceptance(mapToCardBrandAcceptance(toBundleObject(map)))
|
|
186
|
+
|
|
187
|
+
primaryButtonLabel?.let { configurationBuilder.primaryButtonLabel(it) }
|
|
188
|
+
paymentMethodOrder?.let { configurationBuilder.paymentMethodOrder(it) }
|
|
189
|
+
|
|
190
|
+
return configurationBuilder.build()
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private fun parseIntentConfiguration(map: ReadableMap): PaymentSheet.IntentConfiguration {
|
|
194
|
+
val intentConfig = PaymentSheetFragment.buildIntentConfiguration(toBundleObject(map))
|
|
195
|
+
return intentConfig ?: throw IllegalArgumentException("IntentConfiguration is null")
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
override fun confirm(view: EmbeddedPaymentElementView) {
|
|
199
|
+
view.confirm()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
override fun clearPaymentOption(view: EmbeddedPaymentElementView) {
|
|
203
|
+
view.clearPaymentOption()
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Returns a List of Strings if the key exists and points to an array of strings, or null otherwise.
|
|
209
|
+
*/
|
|
210
|
+
fun ReadableMap.getStringArrayList(key: String): List<String>? {
|
|
211
|
+
if (!hasKey(key) || getType(key) != ReadableType.Array) return null
|
|
212
|
+
val array: ReadableArray = getArray(key) ?: return null
|
|
213
|
+
|
|
214
|
+
val result = mutableListOf<String>()
|
|
215
|
+
for (i in 0 until array.size()) {
|
|
216
|
+
// getString returns null if the element isn't actually a string
|
|
217
|
+
array.getString(i)?.let { result.add(it) }
|
|
218
|
+
}
|
|
219
|
+
return result
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Returns a List of Ints if the key exists and points to an array of numbers, or null otherwise.
|
|
224
|
+
*/
|
|
225
|
+
fun ReadableMap.getIntegerArrayList(key: String): List<Int>? {
|
|
226
|
+
if (!hasKey(key) || getType(key) != ReadableType.Array) return null
|
|
227
|
+
val array: ReadableArray = getArray(key) ?: return null
|
|
228
|
+
|
|
229
|
+
val result = mutableListOf<Int>()
|
|
230
|
+
for (i in 0 until array.size()) {
|
|
231
|
+
// getType check to skip non-number entries
|
|
232
|
+
if (array.getType(i) == ReadableType.Number) {
|
|
233
|
+
// if it's actually a float/double, this will truncate; adjust as needed
|
|
234
|
+
result.add(array.getInt(i))
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return result
|
|
238
|
+
}
|
|
@@ -1,11 +1,5 @@
|
|
|
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 androidx.fragment.app.FragmentActivity
|
|
10
4
|
import com.facebook.react.bridge.Arguments
|
|
11
5
|
import com.facebook.react.bridge.Promise
|
|
@@ -15,6 +9,7 @@ import com.facebook.react.bridge.WritableArray
|
|
|
15
9
|
import com.facebook.react.bridge.WritableMap
|
|
16
10
|
import com.facebook.react.bridge.WritableNativeMap
|
|
17
11
|
import com.reactnativestripesdk.utils.ErrorType
|
|
12
|
+
import com.reactnativestripesdk.utils.StripeFragment
|
|
18
13
|
import com.reactnativestripesdk.utils.createError
|
|
19
14
|
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
20
15
|
import com.reactnativestripesdk.utils.mapFromFinancialConnectionsEvent
|
|
@@ -29,7 +24,7 @@ import com.stripe.android.financialconnections.model.FinancialConnectionsAccount
|
|
|
29
24
|
import com.stripe.android.financialconnections.model.FinancialConnectionsAccountList
|
|
30
25
|
import com.stripe.android.financialconnections.model.FinancialConnectionsSession
|
|
31
26
|
|
|
32
|
-
class FinancialConnectionsSheetFragment :
|
|
27
|
+
class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
33
28
|
enum class Mode {
|
|
34
29
|
ForToken,
|
|
35
30
|
ForSession,
|
|
@@ -40,28 +35,13 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
40
35
|
private lateinit var configuration: FinancialConnectionsSheet.Configuration
|
|
41
36
|
private lateinit var mode: Mode
|
|
42
37
|
|
|
43
|
-
override fun
|
|
44
|
-
super.onCreate(savedInstanceState)
|
|
45
|
-
|
|
38
|
+
override fun prepare() {
|
|
46
39
|
val stripeSdkModule: StripeSdkModule? = context.getNativeModule(StripeSdkModule::class.java)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
stripeSdkModule.sendEvent(context, "onFinancialConnectionsEvent", params)
|
|
51
|
-
}
|
|
40
|
+
FinancialConnections.setEventListener { event ->
|
|
41
|
+
val params = mapFromFinancialConnectionsEvent(event)
|
|
42
|
+
stripeSdkModule?.emitOnFinancialConnectionsEvent(params)
|
|
52
43
|
}
|
|
53
|
-
}
|
|
54
44
|
|
|
55
|
-
override fun onCreateView(
|
|
56
|
-
inflater: LayoutInflater,
|
|
57
|
-
container: ViewGroup?,
|
|
58
|
-
savedInstanceState: Bundle?,
|
|
59
|
-
): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
60
|
-
|
|
61
|
-
override fun onViewCreated(
|
|
62
|
-
view: View,
|
|
63
|
-
savedInstanceState: Bundle?,
|
|
64
|
-
) {
|
|
65
45
|
when (mode) {
|
|
66
46
|
Mode.ForToken -> {
|
|
67
47
|
FinancialConnectionsSheet
|
|
@@ -70,6 +50,7 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
70
50
|
::onFinancialConnectionsSheetForTokenResult,
|
|
71
51
|
).present(configuration = configuration)
|
|
72
52
|
}
|
|
53
|
+
|
|
73
54
|
Mode.ForSession -> {
|
|
74
55
|
FinancialConnectionsSheet
|
|
75
56
|
.create(this, ::onFinancialConnectionsSheetForDataResult)
|
|
@@ -90,9 +71,11 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
90
71
|
is FinancialConnectionsSheetForTokenResult.Canceled -> {
|
|
91
72
|
promise.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
|
|
92
73
|
}
|
|
74
|
+
|
|
93
75
|
is FinancialConnectionsSheetForTokenResult.Failed -> {
|
|
94
76
|
promise.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
95
77
|
}
|
|
78
|
+
|
|
96
79
|
is FinancialConnectionsSheetForTokenResult.Completed -> {
|
|
97
80
|
promise.resolve(createTokenResult(result))
|
|
98
81
|
(context.currentActivity as? FragmentActivity)
|
|
@@ -109,9 +92,11 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
109
92
|
is FinancialConnectionsSheetResult.Canceled -> {
|
|
110
93
|
promise.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
|
|
111
94
|
}
|
|
95
|
+
|
|
112
96
|
is FinancialConnectionsSheetResult.Failed -> {
|
|
113
97
|
promise.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
114
98
|
}
|
|
99
|
+
|
|
115
100
|
is FinancialConnectionsSheetResult.Completed -> {
|
|
116
101
|
promise.resolve(
|
|
117
102
|
WritableNativeMap().also {
|
|
@@ -4,11 +4,21 @@ import com.facebook.react.module.annotations.ReactModule
|
|
|
4
4
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
5
5
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
6
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
7
|
+
import com.facebook.react.viewmanagers.GooglePayButtonManagerDelegate
|
|
8
|
+
import com.facebook.react.viewmanagers.GooglePayButtonManagerInterface
|
|
7
9
|
|
|
8
10
|
@ReactModule(name = GooglePayButtonManager.REACT_CLASS)
|
|
9
|
-
class GooglePayButtonManager :
|
|
11
|
+
class GooglePayButtonManager :
|
|
12
|
+
SimpleViewManager<GooglePayButtonView>(),
|
|
13
|
+
GooglePayButtonManagerInterface<GooglePayButtonView> {
|
|
14
|
+
private val delegate = GooglePayButtonManagerDelegate(this)
|
|
15
|
+
|
|
10
16
|
override fun getName() = REACT_CLASS
|
|
11
17
|
|
|
18
|
+
override fun getDelegate() = delegate
|
|
19
|
+
|
|
20
|
+
override fun createViewInstance(reactContext: ThemedReactContext): GooglePayButtonView = GooglePayButtonView(reactContext)
|
|
21
|
+
|
|
12
22
|
override fun onAfterUpdateTransaction(view: GooglePayButtonView) {
|
|
13
23
|
super.onAfterUpdateTransaction(view)
|
|
14
24
|
|
|
@@ -16,7 +26,7 @@ class GooglePayButtonManager : SimpleViewManager<GooglePayButtonView>() {
|
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
@ReactProp(name = "type")
|
|
19
|
-
fun
|
|
29
|
+
override fun setType(
|
|
20
30
|
view: GooglePayButtonView,
|
|
21
31
|
buttonType: Int,
|
|
22
32
|
) {
|
|
@@ -24,7 +34,7 @@ class GooglePayButtonManager : SimpleViewManager<GooglePayButtonView>() {
|
|
|
24
34
|
}
|
|
25
35
|
|
|
26
36
|
@ReactProp(name = "appearance")
|
|
27
|
-
fun
|
|
37
|
+
override fun setAppearance(
|
|
28
38
|
view: GooglePayButtonView,
|
|
29
39
|
appearance: Int,
|
|
30
40
|
) {
|
|
@@ -32,15 +42,13 @@ class GooglePayButtonManager : SimpleViewManager<GooglePayButtonView>() {
|
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
@ReactProp(name = "borderRadius")
|
|
35
|
-
fun
|
|
45
|
+
override fun setBorderRadius(
|
|
36
46
|
view: GooglePayButtonView,
|
|
37
47
|
borderRadius: Int,
|
|
38
48
|
) {
|
|
39
49
|
view.setBorderRadius(borderRadius)
|
|
40
50
|
}
|
|
41
51
|
|
|
42
|
-
override fun createViewInstance(reactContext: ThemedReactContext): GooglePayButtonView = GooglePayButtonView(reactContext)
|
|
43
|
-
|
|
44
52
|
companion object {
|
|
45
53
|
const val REACT_CLASS = "GooglePayButton"
|
|
46
54
|
}
|
|
@@ -1,17 +1,12 @@
|
|
|
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 androidx.fragment.app.FragmentActivity
|
|
10
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
5
|
import com.facebook.react.bridge.ReadableMap
|
|
12
6
|
import com.facebook.react.bridge.WritableMap
|
|
13
7
|
import com.reactnativestripesdk.utils.ErrorType
|
|
14
8
|
import com.reactnativestripesdk.utils.GooglePayErrorType
|
|
9
|
+
import com.reactnativestripesdk.utils.StripeFragment
|
|
15
10
|
import com.reactnativestripesdk.utils.createError
|
|
16
11
|
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
17
12
|
import com.reactnativestripesdk.utils.getBooleanOr
|
|
@@ -19,7 +14,7 @@ import com.reactnativestripesdk.utils.getIntOrNull
|
|
|
19
14
|
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
20
15
|
import com.stripe.android.googlepaylauncher.GooglePayLauncher
|
|
21
16
|
|
|
22
|
-
class GooglePayLauncherFragment :
|
|
17
|
+
class GooglePayLauncherFragment : StripeFragment() {
|
|
23
18
|
enum class Mode {
|
|
24
19
|
ForSetup,
|
|
25
20
|
ForPayment,
|
|
@@ -34,16 +29,7 @@ class GooglePayLauncherFragment : Fragment() {
|
|
|
34
29
|
private var label: String? = null
|
|
35
30
|
private lateinit var callback: (result: GooglePayLauncher.Result?, error: WritableMap?) -> Unit
|
|
36
31
|
|
|
37
|
-
override fun
|
|
38
|
-
inflater: LayoutInflater,
|
|
39
|
-
container: ViewGroup?,
|
|
40
|
-
savedInstanceState: Bundle?,
|
|
41
|
-
): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
42
|
-
|
|
43
|
-
override fun onViewCreated(
|
|
44
|
-
view: View,
|
|
45
|
-
savedInstanceState: Bundle?,
|
|
46
|
-
) {
|
|
32
|
+
override fun prepare() {
|
|
47
33
|
launcher =
|
|
48
34
|
GooglePayLauncher(
|
|
49
35
|
fragment = this,
|
package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt
CHANGED
|
@@ -12,12 +12,12 @@ import com.reactnativestripesdk.utils.removeFragment
|
|
|
12
12
|
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
13
13
|
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher
|
|
14
14
|
|
|
15
|
-
class GooglePayPaymentMethodLauncherFragment(
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
|
|
15
|
+
class GooglePayPaymentMethodLauncherFragment : Fragment() {
|
|
16
|
+
private lateinit var context: ReactApplicationContext
|
|
17
|
+
private var isTestEnv = false
|
|
18
|
+
private var paymentMethodRequired = false
|
|
19
|
+
private lateinit var promise: Promise
|
|
20
|
+
|
|
21
21
|
override fun onCreateView(
|
|
22
22
|
inflater: LayoutInflater,
|
|
23
23
|
container: ViewGroup?,
|
|
@@ -50,5 +50,19 @@ class GooglePayPaymentMethodLauncherFragment(
|
|
|
50
50
|
|
|
51
51
|
companion object {
|
|
52
52
|
const val TAG = "google_pay_support_fragment"
|
|
53
|
+
|
|
54
|
+
fun create(
|
|
55
|
+
context: ReactApplicationContext,
|
|
56
|
+
isTestEnv: Boolean,
|
|
57
|
+
paymentMethodRequired: Boolean,
|
|
58
|
+
promise: Promise,
|
|
59
|
+
): GooglePayPaymentMethodLauncherFragment {
|
|
60
|
+
val instance = GooglePayPaymentMethodLauncherFragment()
|
|
61
|
+
instance.context = context
|
|
62
|
+
instance.isTestEnv = isTestEnv
|
|
63
|
+
instance.paymentMethodRequired = paymentMethodRequired
|
|
64
|
+
instance.promise = promise
|
|
65
|
+
return instance
|
|
66
|
+
}
|
|
53
67
|
}
|
|
54
68
|
}
|
|
@@ -1,17 +1,12 @@
|
|
|
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 androidx.fragment.app.FragmentActivity
|
|
10
4
|
import com.facebook.react.bridge.Promise
|
|
11
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
6
|
import com.reactnativestripesdk.utils.ConfirmPaymentErrorType
|
|
13
7
|
import com.reactnativestripesdk.utils.ConfirmSetupIntentErrorType
|
|
14
8
|
import com.reactnativestripesdk.utils.ErrorType
|
|
9
|
+
import com.reactnativestripesdk.utils.StripeFragment
|
|
15
10
|
import com.reactnativestripesdk.utils.createError
|
|
16
11
|
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
17
12
|
import com.reactnativestripesdk.utils.createResult
|
|
@@ -29,26 +24,57 @@ import com.stripe.android.payments.paymentlauncher.PaymentLauncher
|
|
|
29
24
|
import com.stripe.android.payments.paymentlauncher.PaymentResult
|
|
30
25
|
|
|
31
26
|
/** Instances of this class should only be initialized with the companion's helper methods. */
|
|
32
|
-
class PaymentLauncherFragment(
|
|
33
|
-
private
|
|
34
|
-
private
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
private
|
|
27
|
+
class PaymentLauncherFragment : StripeFragment() {
|
|
28
|
+
private lateinit var context: ReactApplicationContext
|
|
29
|
+
private lateinit var stripe: Stripe
|
|
30
|
+
private lateinit var publishableKey: String
|
|
31
|
+
private var stripeAccountId: String? = null
|
|
32
|
+
private lateinit var promise: Promise
|
|
33
|
+
|
|
38
34
|
// Used when confirming a payment intent
|
|
39
|
-
private
|
|
40
|
-
private
|
|
35
|
+
private var paymentIntentClientSecret: String? = null
|
|
36
|
+
private var confirmPaymentParams: ConfirmPaymentIntentParams? = null
|
|
37
|
+
|
|
41
38
|
// Used when confirming a setup intent
|
|
42
|
-
private
|
|
43
|
-
private
|
|
39
|
+
private var setupIntentClientSecret: String? = null
|
|
40
|
+
private var confirmSetupParams: ConfirmSetupIntentParams? = null
|
|
41
|
+
|
|
44
42
|
// Used when handling the next action on a payment intent
|
|
45
|
-
private
|
|
43
|
+
private var handleNextActionPaymentIntentClientSecret: String? = null
|
|
44
|
+
|
|
46
45
|
// Used when handling the next action on a setup intent
|
|
47
|
-
private
|
|
48
|
-
) : Fragment() {
|
|
46
|
+
private var handleNextActionSetupIntentClientSecret: String? = null
|
|
49
47
|
private lateinit var paymentLauncher: PaymentLauncher
|
|
50
48
|
|
|
51
49
|
companion object {
|
|
50
|
+
private fun create(
|
|
51
|
+
context: ReactApplicationContext,
|
|
52
|
+
stripe: Stripe,
|
|
53
|
+
publishableKey: String,
|
|
54
|
+
stripeAccountId: String?,
|
|
55
|
+
promise: Promise,
|
|
56
|
+
paymentIntentClientSecret: String? = null,
|
|
57
|
+
confirmPaymentParams: ConfirmPaymentIntentParams? = null,
|
|
58
|
+
setupIntentClientSecret: String? = null,
|
|
59
|
+
confirmSetupParams: ConfirmSetupIntentParams? = null,
|
|
60
|
+
handleNextActionPaymentIntentClientSecret: String? = null,
|
|
61
|
+
handleNextActionSetupIntentClientSecret: String? = null,
|
|
62
|
+
): PaymentLauncherFragment {
|
|
63
|
+
val instance = PaymentLauncherFragment()
|
|
64
|
+
instance.context = context
|
|
65
|
+
instance.stripe = stripe
|
|
66
|
+
instance.publishableKey = publishableKey
|
|
67
|
+
instance.stripeAccountId = stripeAccountId
|
|
68
|
+
instance.promise = promise
|
|
69
|
+
instance.paymentIntentClientSecret = paymentIntentClientSecret
|
|
70
|
+
instance.confirmPaymentParams = confirmPaymentParams
|
|
71
|
+
instance.setupIntentClientSecret = setupIntentClientSecret
|
|
72
|
+
instance.confirmSetupParams = confirmSetupParams
|
|
73
|
+
instance.handleNextActionPaymentIntentClientSecret = handleNextActionPaymentIntentClientSecret
|
|
74
|
+
instance.handleNextActionSetupIntentClientSecret = handleNextActionSetupIntentClientSecret
|
|
75
|
+
return instance
|
|
76
|
+
}
|
|
77
|
+
|
|
52
78
|
/** Helper-constructor used for confirming payment intents */
|
|
53
79
|
fun forPayment(
|
|
54
80
|
context: ReactApplicationContext,
|
|
@@ -60,7 +86,7 @@ class PaymentLauncherFragment(
|
|
|
60
86
|
confirmPaymentParams: ConfirmPaymentIntentParams,
|
|
61
87
|
): PaymentLauncherFragment {
|
|
62
88
|
val paymentLauncherFragment =
|
|
63
|
-
|
|
89
|
+
create(
|
|
64
90
|
context,
|
|
65
91
|
stripe,
|
|
66
92
|
publishableKey,
|
|
@@ -84,7 +110,7 @@ class PaymentLauncherFragment(
|
|
|
84
110
|
confirmSetupParams: ConfirmSetupIntentParams,
|
|
85
111
|
): PaymentLauncherFragment {
|
|
86
112
|
val paymentLauncherFragment =
|
|
87
|
-
|
|
113
|
+
create(
|
|
88
114
|
context,
|
|
89
115
|
stripe,
|
|
90
116
|
publishableKey,
|
|
@@ -107,7 +133,7 @@ class PaymentLauncherFragment(
|
|
|
107
133
|
handleNextActionPaymentIntentClientSecret: String,
|
|
108
134
|
): PaymentLauncherFragment {
|
|
109
135
|
val paymentLauncherFragment =
|
|
110
|
-
|
|
136
|
+
create(
|
|
111
137
|
context,
|
|
112
138
|
stripe,
|
|
113
139
|
publishableKey,
|
|
@@ -129,7 +155,7 @@ class PaymentLauncherFragment(
|
|
|
129
155
|
handleNextActionSetupIntentClientSecret: String,
|
|
130
156
|
): PaymentLauncherFragment {
|
|
131
157
|
val paymentLauncherFragment =
|
|
132
|
-
|
|
158
|
+
create(
|
|
133
159
|
context,
|
|
134
160
|
stripe,
|
|
135
161
|
publishableKey,
|
|
@@ -161,43 +187,36 @@ class PaymentLauncherFragment(
|
|
|
161
187
|
internal const val TAG = "payment_launcher_fragment"
|
|
162
188
|
}
|
|
163
189
|
|
|
164
|
-
override fun
|
|
165
|
-
inflater: LayoutInflater,
|
|
166
|
-
container: ViewGroup?,
|
|
167
|
-
savedInstanceState: Bundle?,
|
|
168
|
-
): View {
|
|
190
|
+
override fun prepare() {
|
|
169
191
|
paymentLauncher = createPaymentLauncher()
|
|
170
192
|
if (paymentIntentClientSecret != null && confirmPaymentParams != null) {
|
|
171
|
-
paymentLauncher.confirm(confirmPaymentParams)
|
|
193
|
+
paymentLauncher.confirm(confirmPaymentParams!!)
|
|
172
194
|
} else if (setupIntentClientSecret != null && confirmSetupParams != null) {
|
|
173
|
-
paymentLauncher.confirm(confirmSetupParams)
|
|
195
|
+
paymentLauncher.confirm(confirmSetupParams!!)
|
|
174
196
|
} else if (handleNextActionPaymentIntentClientSecret != null) {
|
|
175
|
-
paymentLauncher.handleNextActionForPaymentIntent(handleNextActionPaymentIntentClientSecret)
|
|
197
|
+
paymentLauncher.handleNextActionForPaymentIntent(handleNextActionPaymentIntentClientSecret!!)
|
|
176
198
|
} else if (handleNextActionSetupIntentClientSecret != null) {
|
|
177
|
-
paymentLauncher.handleNextActionForSetupIntent(handleNextActionSetupIntentClientSecret)
|
|
199
|
+
paymentLauncher.handleNextActionForSetupIntent(handleNextActionSetupIntentClientSecret!!)
|
|
178
200
|
} else {
|
|
179
201
|
throw Exception(
|
|
180
202
|
"Invalid parameters provided to PaymentLauncher. Ensure that you are providing the correct client secret and setup params (if necessary).",
|
|
181
203
|
)
|
|
182
204
|
}
|
|
183
|
-
return FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
184
205
|
}
|
|
185
206
|
|
|
186
207
|
private fun createPaymentLauncher(): PaymentLauncher =
|
|
187
208
|
PaymentLauncher.create(this, publishableKey, stripeAccountId) { paymentResult ->
|
|
188
209
|
when (paymentResult) {
|
|
189
210
|
is PaymentResult.Completed -> {
|
|
190
|
-
|
|
191
|
-
retrievePaymentIntent(
|
|
192
|
-
}
|
|
193
|
-
retrievePaymentIntent(
|
|
194
|
-
}
|
|
195
|
-
retrieveSetupIntent(
|
|
196
|
-
}
|
|
197
|
-
retrieveSetupIntent(
|
|
198
|
-
}
|
|
199
|
-
throw Exception("Failed to create Payment Launcher. No client secret provided.")
|
|
200
|
-
}
|
|
211
|
+
paymentIntentClientSecret?.let {
|
|
212
|
+
retrievePaymentIntent(it, stripeAccountId)
|
|
213
|
+
} ?: handleNextActionPaymentIntentClientSecret?.let {
|
|
214
|
+
retrievePaymentIntent(it, stripeAccountId)
|
|
215
|
+
} ?: setupIntentClientSecret?.let {
|
|
216
|
+
retrieveSetupIntent(it, stripeAccountId)
|
|
217
|
+
} ?: handleNextActionSetupIntentClientSecret?.let {
|
|
218
|
+
retrieveSetupIntent(it, stripeAccountId)
|
|
219
|
+
} ?: throw Exception("Failed to create Payment Launcher. No client secret provided.")
|
|
201
220
|
}
|
|
202
221
|
is PaymentResult.Canceled -> {
|
|
203
222
|
promise.resolve(createError(ConfirmPaymentErrorType.Canceled.toString(), message = null))
|
|
@@ -19,7 +19,7 @@ import com.stripe.android.model.PaymentMethodOptionsParams
|
|
|
19
19
|
|
|
20
20
|
class PaymentMethodCreateParamsFactory(
|
|
21
21
|
private val paymentMethodData: ReadableMap?,
|
|
22
|
-
private val options: ReadableMap
|
|
22
|
+
private val options: ReadableMap?,
|
|
23
23
|
private val cardFieldView: CardFieldView?,
|
|
24
24
|
private val cardFormView: CardFormView?,
|
|
25
25
|
) {
|
|
@@ -267,6 +267,7 @@ class PaymentMethodCreateParamsFactory(
|
|
|
267
267
|
PaymentMethod.Type.Card -> createCardStripeIntentParams(clientSecret, isPaymentIntent)
|
|
268
268
|
PaymentMethod.Type.USBankAccount ->
|
|
269
269
|
createUSBankAccountStripeIntentParams(clientSecret, isPaymentIntent)
|
|
270
|
+
|
|
270
271
|
PaymentMethod.Type.Affirm -> createAffirmStripeIntentParams(clientSecret, isPaymentIntent)
|
|
271
272
|
PaymentMethod.Type.Ideal,
|
|
272
273
|
PaymentMethod.Type.Alipay,
|
|
@@ -304,6 +305,7 @@ class PaymentMethodCreateParamsFactory(
|
|
|
304
305
|
)
|
|
305
306
|
}
|
|
306
307
|
}
|
|
308
|
+
|
|
307
309
|
null -> ConfirmPaymentIntentParams.create(clientSecret)
|
|
308
310
|
else -> {
|
|
309
311
|
throw Exception("This paymentMethodType is not supported yet")
|