@stripe/stripe-react-native 0.14.0 → 0.17.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/.editorconfig +15 -0
- package/.husky/pre-commit +4 -0
- package/CHANGELOG.md +55 -0
- package/android/build.gradle +1 -6
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +27 -6
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +34 -3
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +10 -1
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +284 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +17 -7
- package/android/src/main/java/com/reactnativestripesdk/GooglePayFragment.kt +8 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +6 -2
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +12 -11
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +213 -367
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +45 -28
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +85 -46
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/{Errors.kt → utils/Errors.kt} +5 -1
- package/android/src/main/java/com/reactnativestripesdk/{Extensions.kt → utils/Extensions.kt} +12 -1
- package/android/src/main/java/com/reactnativestripesdk/{Mappers.kt → utils/Mappers.kt} +8 -5
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +18 -0
- package/android/src/main/res/{drawable-night/googlepay_button_background.xml → drawable/googlepay_button_background_dark.xml} +1 -1
- package/android/src/main/res/{drawable-night/googlepay_button_content.xml → drawable/googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-night/googlepay_button_overlay.xml → drawable/googlepay_button_overlay_dark.xml} +0 -0
- package/android/src/main/res/{drawable-night/pay_with_googlepay_button_content.xml → drawable/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-ar-night/pay_with_googlepay_button_content.xml → drawable-ar/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-bg-night/pay_with_googlepay_button_content.xml → drawable-bg/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-ca-night/pay_with_googlepay_button_content.xml → drawable-ca/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-cs-night/pay_with_googlepay_button_content.xml → drawable-cs/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-da-night/pay_with_googlepay_button_content.xml → drawable-da/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-de-night/pay_with_googlepay_button_content.xml → drawable-de/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-el-night/pay_with_googlepay_button_content.xml → drawable-el/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-es-night/pay_with_googlepay_button_content.xml → drawable-es/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-et-night/pay_with_googlepay_button_content.xml → drawable-et/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-fi-night/pay_with_googlepay_button_content.xml → drawable-fi/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-fr-night/pay_with_googlepay_button_content.xml → drawable-fr/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-night-hdpi/googlepay_button_background_image.9.png → drawable-hdpi/googlepay_button_background_image_dark.9.png} +0 -0
- package/android/src/main/res/{drawable-hr-night/pay_with_googlepay_button_content.xml → drawable-hr/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-id-night/pay_with_googlepay_button_content.xml → drawable-id/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-it-night/pay_with_googlepay_button_content.xml → drawable-it/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-ja-night/pay_with_googlepay_button_content.xml → drawable-ja/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-ko-night/pay_with_googlepay_button_content.xml → drawable-ko/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-night-mdpi/googlepay_button_background_image.9.png → drawable-mdpi/googlepay_button_background_image_dark.9.png} +0 -0
- package/android/src/main/res/{drawable-ms-night/pay_with_googlepay_button_content.xml → drawable-ms/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-nl-night/pay_with_googlepay_button_content.xml → drawable-nl/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-no-night/pay_with_googlepay_button_content.xml → drawable-no/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-pl-night/pay_with_googlepay_button_content.xml → drawable-pl/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-pt-night/pay_with_googlepay_button_content.xml → drawable-pt/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-ru-night/pay_with_googlepay_button_content.xml → drawable-ru/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-sk-night/pay_with_googlepay_button_content.xml → drawable-sk/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-sl-night/pay_with_googlepay_button_content.xml → drawable-sl/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-sr-night/pay_with_googlepay_button_content.xml → drawable-sr/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-sv-night/pay_with_googlepay_button_content.xml → drawable-sv/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-th-night/pay_with_googlepay_button_content.xml → drawable-th/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-tr-night/pay_with_googlepay_button_content.xml → drawable-tr/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-uk-night/pay_with_googlepay_button_content.xml → drawable-uk/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-night-v21/googlepay_button_background.xml → drawable-v21/googlepay_button_background_dark.xml} +1 -1
- package/android/src/main/res/{drawable-night-xhdpi/googlepay_button_background_image.9.png → drawable-xhdpi/googlepay_button_background_image_dark.9.png} +0 -0
- package/android/src/main/res/{drawable-night-xxhdpi/googlepay_button_background_image.9.png → drawable-xxhdpi/googlepay_button_background_image_dark.9.png} +0 -0
- package/android/src/main/res/{drawable-night-xxxhdpi/googlepay_button_background_image.9.png → drawable-xxxhdpi/googlepay_button_background_image_dark.9.png} +0 -0
- package/android/src/main/res/{layout-night/googlepay_button.xml → layout/googlepay_button_dark.xml} +4 -4
- package/android/src/main/res/{layout-night/pay_with_googlepay_button.xml → layout/pay_with_googlepay_button_dark.xml} +4 -4
- package/ios/ApplePayUtils.swift +159 -0
- package/ios/CardFormView.swift +20 -0
- package/ios/Errors.swift +11 -0
- package/ios/FinancialConnections.swift +258 -0
- package/ios/Mappers.swift +20 -22
- package/ios/PaymentMethodFactory.swift +9 -0
- package/ios/StripeSdk.m +10 -1
- package/ios/StripeSdk.swift +67 -44
- package/ios/Tests/ApplePayUtilsTests.swift +214 -0
- package/lib/commonjs/NativeStripeSdk.js.map +1 -1
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/ApplePayButton.js +1 -1
- package/lib/commonjs/components/ApplePayButton.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/GooglePayButton.js +1 -1
- package/lib/commonjs/components/GooglePayButton.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/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/hooks/useApplePay.js +1 -1
- package/lib/commonjs/hooks/useApplePay.js.map +1 -1
- package/lib/commonjs/hooks/useConfirmPayment.js +1 -1
- package/lib/commonjs/hooks/useConfirmPayment.js.map +1 -1
- package/lib/commonjs/hooks/useConfirmSetupIntent.js +1 -1
- package/lib/commonjs/hooks/useConfirmSetupIntent.js.map +1 -1
- package/lib/commonjs/hooks/useFinancialConnectionsSheet.js +2 -0
- package/lib/commonjs/hooks/useFinancialConnectionsSheet.js.map +1 -0
- package/lib/commonjs/hooks/useGooglePay.js +1 -1
- package/lib/commonjs/hooks/useGooglePay.js.map +1 -1
- package/lib/commonjs/hooks/usePaymentSheet.js +1 -1
- package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
- package/lib/commonjs/hooks/useStripe.js +1 -1
- package/lib/commonjs/hooks/useStripe.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/types/FinancialConnections.js +2 -0
- package/lib/commonjs/types/FinancialConnections.js.map +1 -0
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/commonjs/types/SetupIntent.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/NativeStripeSdk.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/ApplePayButton.js +1 -1
- package/lib/module/components/ApplePayButton.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/GooglePayButton.js +1 -1
- package/lib/module/components/GooglePayButton.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/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/hooks/useApplePay.js +1 -1
- package/lib/module/hooks/useApplePay.js.map +1 -1
- package/lib/module/hooks/useConfirmPayment.js +1 -1
- package/lib/module/hooks/useConfirmPayment.js.map +1 -1
- package/lib/module/hooks/useConfirmSetupIntent.js +1 -1
- package/lib/module/hooks/useConfirmSetupIntent.js.map +1 -1
- package/lib/module/hooks/useFinancialConnectionsSheet.js +2 -0
- package/lib/module/hooks/useFinancialConnectionsSheet.js.map +1 -0
- package/lib/module/hooks/useGooglePay.js +1 -1
- package/lib/module/hooks/useGooglePay.js.map +1 -1
- package/lib/module/hooks/usePaymentSheet.js +1 -1
- package/lib/module/hooks/usePaymentSheet.js.map +1 -1
- package/lib/module/hooks/useStripe.js +1 -1
- package/lib/module/hooks/useStripe.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/types/FinancialConnections.js +2 -0
- package/lib/module/types/FinancialConnections.js.map +1 -0
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/module/types/SetupIntent.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/NativeStripeSdk.d.ts +3 -1
- package/lib/typescript/src/components/CardForm.d.ts +1 -1
- package/lib/typescript/src/components/GooglePayButton.d.ts +2 -2
- package/lib/typescript/src/functions.d.ts +15 -1
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +11 -0
- package/lib/typescript/src/hooks/useStripe.d.ts +3 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/types/ApplePay.d.ts +31 -5
- package/lib/typescript/src/types/FinancialConnections.d.ts +100 -0
- package/lib/typescript/src/types/PaymentIntent.d.ts +1 -0
- package/lib/typescript/src/types/PaymentMethod.d.ts +9 -1
- package/lib/typescript/src/types/PaymentSheet.d.ts +17 -15
- package/lib/typescript/src/types/SetupIntent.d.ts +1 -0
- package/lib/typescript/src/types/Token.d.ts +18 -7
- package/lib/typescript/src/types/index.d.ts +2 -1
- package/package.json +11 -23
- package/src/NativeStripeSdk.tsx +7 -0
- package/src/components/CardForm.tsx +2 -2
- package/src/components/GooglePayButton.tsx +8 -2
- package/src/functions.ts +58 -0
- package/src/hooks/useFinancialConnectionsSheet.tsx +34 -0
- package/src/hooks/useStripe.tsx +21 -0
- package/src/index.tsx +1 -0
- package/src/types/ApplePay.ts +39 -6
- package/src/types/FinancialConnections.ts +126 -0
- package/src/types/PaymentIntent.ts +1 -0
- package/src/types/PaymentMethod.ts +11 -1
- package/src/types/PaymentSheet.ts +34 -36
- package/src/types/SetupIntent.ts +1 -0
- package/src/types/Token.ts +24 -7
- package/src/types/index.ts +2 -0
- package/android/.DS_Store +0 -0
- package/android/.gradle/7.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/.gitignore +0 -3
- package/android/.idea/gradle.xml +0 -13
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/modules/android.iml +0 -18
- package/android/.idea/modules.xml +0 -8
- package/android/.idea/vcs.xml +0 -6
- package/android/.idea/workspace.xml +0 -52
- package/android/local.properties +0 -8
- package/android/src/.DS_Store +0 -0
- package/android/src/androidTest/.DS_Store +0 -0
- package/android/src/androidTest/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +0 -35
- package/android/src/main/res/drawable-night/googlepay_button_no_shadow_background.xml +0 -6
- package/android/src/main/res/drawable-night-hdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable-night-mdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable-night-v21/googlepay_button_no_shadow_background.xml +0 -7
- package/android/src/main/res/drawable-night-xhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable-night-xxhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable-night-xxxhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/values-night/googlepay_strings.xml +0 -12
- package/ios/.DS_Store +0 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcuserdata/charliecruzan.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/StripeSdk.xcodeproj/xcuserdata/charliecruzan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -22
- package/ios/StripeSdk.xcodeproj/xcuserdata/charliecruzan.xcuserdatad/xcschemes/xcschememanagement.plist +0 -27
- package/lib/typescript/e2e/buyNowPayLater.test.d.ts +0 -1
- package/lib/typescript/e2e/helpers.d.ts +0 -5
- package/lib/typescript/e2e/payments.test.d.ts +0 -1
- package/lib/typescript/e2e/paymentsWithRedirects.test.d.ts +0 -1
- package/lib/typescript/e2e/screenObject/BasicPaymentScreen.d.ts +0 -16
- package/lib/typescript/e2e/screenObject/HomeScreen.d.ts +0 -6
- package/lib/typescript/e2e/screenObject/components/BECSForm.d.ts +0 -8
- package/lib/typescript/e2e/screenObject/components/CardField.d.ts +0 -10
- package/lib/typescript/example/server/index.d.ts +0 -1
- package/lib/typescript/example/server/utils.d.ts +0 -11
- package/lib/typescript/example/src/App.d.ts +0 -45
- package/lib/typescript/example/src/Config.d.ts +0 -2
- package/lib/typescript/example/src/colors.d.ts +0 -8
- package/lib/typescript/example/src/components/Button.d.ts +0 -11
- package/lib/typescript/example/src/components/Collapse.d.ts +0 -6
- package/lib/typescript/example/src/components/PaymentScreen.d.ts +0 -7
- package/lib/typescript/example/src/helpers.d.ts +0 -1
- package/lib/typescript/example/src/screens/ACHPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/ACHSetupScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/AfterpayClearpayPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/AlipayPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/ApplePayScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/AuBECSDebitPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/AuBECSDebitSetupPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/BancontactPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/BancontactSetupFuturePaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/CVCReCollectionScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/CreateTokenScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/EPSPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/FPXPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/GiropayPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/GooglePayScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/GrabPayPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/HomeScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/IdealPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/IdealSetupFuturePaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/KlarnaPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/MultilineWebhookPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/NoWebhookPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/OxxoPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/P24PaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/PayPalScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/PaymentResultScreen.d.ts +0 -8
- package/lib/typescript/example/src/screens/PaymentSheetAppearance.d.ts +0 -3
- package/lib/typescript/example/src/screens/PaymentsUICompleteScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/PaymentsUICustomScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/SepaPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/SepaSetupFuturePaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/SetupFuturePaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/SofortPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/SofortSetupFuturePaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/WebhookPaymentScreen.d.ts +0 -1
- package/lib/typescript/src/plugin/__tests__/withStripe-test.d.ts +0 -1
- package/src/plugin/__tests__/fixtures/sample-AndroidManifest.xml +0 -24
- package/src/plugin/__tests__/withStripe-test.ts +0 -111
|
@@ -2,6 +2,7 @@ package com.reactnativestripesdk
|
|
|
2
2
|
|
|
3
3
|
import android.graphics.Color
|
|
4
4
|
import android.os.Bundle
|
|
5
|
+
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
5
6
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
6
7
|
|
|
7
8
|
fun PaymentSheetFragment.buildPaymentSheetAppearance(userParams: Bundle?): PaymentSheet.Appearance {
|
|
@@ -18,6 +18,9 @@ import com.facebook.react.bridge.Promise
|
|
|
18
18
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
19
19
|
import com.facebook.react.bridge.WritableMap
|
|
20
20
|
import com.facebook.react.bridge.WritableNativeMap
|
|
21
|
+
import com.reactnativestripesdk.utils.*
|
|
22
|
+
import com.reactnativestripesdk.utils.createError
|
|
23
|
+
import com.reactnativestripesdk.utils.createResult
|
|
21
24
|
import com.stripe.android.paymentsheet.PaymentOptionCallback
|
|
22
25
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
23
26
|
import com.stripe.android.paymentsheet.PaymentSheetResult
|
|
@@ -55,10 +58,7 @@ class PaymentSheetFragment(
|
|
|
55
58
|
}
|
|
56
59
|
val customerId = arguments?.getString("customerId").orEmpty()
|
|
57
60
|
val customerEphemeralKeySecret = arguments?.getString("customerEphemeralKeySecret").orEmpty()
|
|
58
|
-
val
|
|
59
|
-
val currencyCode = arguments?.getString("currencyCode").orEmpty()
|
|
60
|
-
val googlePayEnabled = arguments?.getBoolean("googlePay")
|
|
61
|
-
val testEnv = arguments?.getBoolean("testEnv")
|
|
61
|
+
val googlePayConfig = buildGooglePayConfig(arguments?.getBundle("googlePay"))
|
|
62
62
|
val allowsDelayedPaymentMethods = arguments?.getBoolean("allowsDelayedPaymentMethods")
|
|
63
63
|
val billingDetailsBundle = arguments?.getBundle("defaultBillingDetails")
|
|
64
64
|
paymentIntentClientSecret = arguments?.getString("paymentIntentClientSecret").orEmpty()
|
|
@@ -71,39 +71,31 @@ class PaymentSheetFragment(
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
val paymentOptionCallback = PaymentOptionCallback { paymentOption ->
|
|
74
|
-
|
|
75
|
-
val bitmap = getBitmapFromVectorDrawable(context,
|
|
74
|
+
val result = paymentOption?.let {
|
|
75
|
+
val bitmap = getBitmapFromVectorDrawable(context, it.drawableResourceId)
|
|
76
76
|
val imageString = getBase64FromBitmap(bitmap)
|
|
77
77
|
val option: WritableMap = WritableNativeMap()
|
|
78
|
-
option.putString("label",
|
|
78
|
+
option.putString("label", it.label)
|
|
79
79
|
option.putString("image", imageString)
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
80
|
+
createResult("paymentOption", option)
|
|
81
|
+
} ?: run {
|
|
82
|
+
createError(PaymentSheetErrorType.Canceled.toString(), "The payment option selection flow has been canceled")
|
|
83
83
|
}
|
|
84
|
+
presentPromise?.resolve(result)
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
val paymentResultCallback = PaymentSheetResultCallback { paymentResult ->
|
|
87
88
|
when (paymentResult) {
|
|
88
89
|
is PaymentSheetResult.Canceled -> {
|
|
89
|
-
|
|
90
|
-
confirmPromise?.resolve(createError(PaymentSheetErrorType.Canceled.toString(), message))
|
|
91
|
-
?: run {
|
|
92
|
-
presentPromise?.resolve(createError(PaymentSheetErrorType.Canceled.toString(), message))
|
|
93
|
-
}
|
|
90
|
+
resolvePaymentResult(createError(PaymentSheetErrorType.Canceled.toString(), "The payment flow has been canceled"))
|
|
94
91
|
}
|
|
95
92
|
is PaymentSheetResult.Failed -> {
|
|
96
|
-
|
|
97
|
-
?: run {
|
|
98
|
-
presentPromise?.resolve(createError(PaymentSheetErrorType.Failed.toString(), paymentResult.error))
|
|
99
|
-
}
|
|
93
|
+
resolvePaymentResult(createError(PaymentSheetErrorType.Failed.toString(), paymentResult.error))
|
|
100
94
|
}
|
|
101
95
|
is PaymentSheetResult.Completed -> {
|
|
102
|
-
|
|
103
|
-
presentPromise?.resolve(WritableNativeMap())
|
|
104
|
-
}
|
|
96
|
+
resolvePaymentResult(WritableNativeMap())
|
|
105
97
|
// Remove the fragment now, we can be sure it won't be needed again if an intent is successful
|
|
106
|
-
(context
|
|
98
|
+
removeFragment(context)
|
|
107
99
|
}
|
|
108
100
|
}
|
|
109
101
|
}
|
|
@@ -133,11 +125,7 @@ class PaymentSheetFragment(
|
|
|
133
125
|
id = customerId,
|
|
134
126
|
ephemeralKeySecret = customerEphemeralKeySecret
|
|
135
127
|
) else null,
|
|
136
|
-
googlePay =
|
|
137
|
-
environment = if (testEnv == true) PaymentSheet.GooglePayConfiguration.Environment.Test else PaymentSheet.GooglePayConfiguration.Environment.Production,
|
|
138
|
-
countryCode = countryCode,
|
|
139
|
-
currencyCode = currencyCode
|
|
140
|
-
) else null,
|
|
128
|
+
googlePay = googlePayConfig,
|
|
141
129
|
appearance = appearance
|
|
142
130
|
)
|
|
143
131
|
|
|
@@ -197,6 +185,35 @@ class PaymentSheetFragment(
|
|
|
197
185
|
)
|
|
198
186
|
}
|
|
199
187
|
}
|
|
188
|
+
|
|
189
|
+
private fun resolvePaymentResult(map: WritableMap) {
|
|
190
|
+
confirmPromise?.let {
|
|
191
|
+
it.resolve(map)
|
|
192
|
+
confirmPromise = null
|
|
193
|
+
} ?: run {
|
|
194
|
+
presentPromise?.resolve(map)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
companion object {
|
|
199
|
+
const val TAG = "payment_sheet_launch_fragment"
|
|
200
|
+
|
|
201
|
+
internal fun buildGooglePayConfig(params: Bundle?): PaymentSheet.GooglePayConfiguration? {
|
|
202
|
+
if (params == null) {
|
|
203
|
+
return null
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
val countryCode = params.getString("merchantCountryCode").orEmpty()
|
|
207
|
+
val currencyCode = params.getString("currencyCode").orEmpty()
|
|
208
|
+
val testEnv = params.getBoolean("testEnv")
|
|
209
|
+
|
|
210
|
+
return PaymentSheet.GooglePayConfiguration(
|
|
211
|
+
environment = if (testEnv) PaymentSheet.GooglePayConfiguration.Environment.Test else PaymentSheet.GooglePayConfiguration.Environment.Production,
|
|
212
|
+
countryCode = countryCode,
|
|
213
|
+
currencyCode = currencyCode
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
200
217
|
}
|
|
201
218
|
|
|
202
219
|
fun getBitmapFromVectorDrawable(context: Context?, drawableId: Int): Bitmap? {
|
|
@@ -5,9 +5,13 @@ import android.content.Intent
|
|
|
5
5
|
import android.os.Parcelable
|
|
6
6
|
import android.util.Log
|
|
7
7
|
import androidx.appcompat.app.AppCompatActivity
|
|
8
|
+
import androidx.fragment.app.Fragment
|
|
8
9
|
import com.facebook.react.bridge.*
|
|
9
10
|
import com.facebook.react.module.annotations.ReactModule
|
|
10
11
|
import com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy
|
|
12
|
+
import com.reactnativestripesdk.utils.*
|
|
13
|
+
import com.reactnativestripesdk.utils.createError
|
|
14
|
+
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
11
15
|
import com.stripe.android.*
|
|
12
16
|
import com.stripe.android.core.ApiVersion
|
|
13
17
|
import com.stripe.android.core.AppInfo
|
|
@@ -36,6 +40,15 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
36
40
|
private var paymentSheetFragment: PaymentSheetFragment? = null
|
|
37
41
|
private var googlePayFragment: GooglePayFragment? = null
|
|
38
42
|
private var paymentLauncherFragment: PaymentLauncherFragment? = null
|
|
43
|
+
private var collectBankAccountLauncherFragment: CollectBankAccountLauncherFragment? = null
|
|
44
|
+
private var financialConnectionsSheetFragment: FinancialConnectionsSheetFragment? = null
|
|
45
|
+
private var allFragments : Array<Fragment?> = arrayOf(
|
|
46
|
+
paymentSheetFragment,
|
|
47
|
+
googlePayFragment,
|
|
48
|
+
paymentLauncherFragment,
|
|
49
|
+
collectBankAccountLauncherFragment,
|
|
50
|
+
financialConnectionsSheetFragment
|
|
51
|
+
)
|
|
39
52
|
|
|
40
53
|
private var confirmPromise: Promise? = null
|
|
41
54
|
private var confirmPaymentClientSecret: String? = null
|
|
@@ -43,11 +56,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
43
56
|
private val mActivityEventListener = object : BaseActivityEventListener() {
|
|
44
57
|
override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
|
|
45
58
|
if (::stripe.isInitialized) {
|
|
46
|
-
|
|
47
|
-
paymentSheetFragment?.activity?.activityResultRegistry?.dispatchResult(requestCode, resultCode, data)
|
|
48
|
-
googlePayFragment?.activity?.activityResultRegistry?.dispatchResult(requestCode, resultCode, data)
|
|
49
|
-
paymentLauncherFragment?.activity?.activityResultRegistry?.dispatchResult(requestCode, resultCode, data)
|
|
50
|
-
// END
|
|
59
|
+
dispatchActivityResultsToFragments(requestCode, resultCode, data)
|
|
51
60
|
try {
|
|
52
61
|
val result = AddPaymentMethodActivityStarter.Result.fromIntent(data)
|
|
53
62
|
if (data?.getParcelableExtra<Parcelable>("extra_activity_result") != null) {
|
|
@@ -64,6 +73,13 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
64
73
|
reactContext.addActivityEventListener(mActivityEventListener)
|
|
65
74
|
}
|
|
66
75
|
|
|
76
|
+
// Necessary on older versions of React Native (~0.65 and below)
|
|
77
|
+
private fun dispatchActivityResultsToFragments(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
78
|
+
for (fragment in allFragments) {
|
|
79
|
+
fragment?.activity?.activityResultRegistry?.dispatchResult(requestCode, resultCode, data)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
67
83
|
private fun configure3dSecure(params: ReadableMap) {
|
|
68
84
|
val stripe3dsConfigBuilder = PaymentAuthConfig.Stripe3ds2Config.Builder()
|
|
69
85
|
if (params.hasKey("timeout")) stripe3dsConfigBuilder.setTimeout(params.getInt("timeout"))
|
|
@@ -118,17 +134,14 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
118
134
|
@ReactMethod
|
|
119
135
|
fun initPaymentSheet(params: ReadableMap, promise: Promise) {
|
|
120
136
|
getCurrentActivityOrResolveWithError(promise)?.let { activity ->
|
|
121
|
-
paymentSheetFragment?.
|
|
122
|
-
// If a payment sheet was already initialized, we want to remove its fragment first
|
|
123
|
-
activity.supportFragmentManager.beginTransaction().remove(it).commitAllowingStateLoss()
|
|
124
|
-
}
|
|
137
|
+
paymentSheetFragment?.removeFragment(reactApplicationContext)
|
|
125
138
|
paymentSheetFragment = PaymentSheetFragment(reactApplicationContext, promise).also {
|
|
126
139
|
val bundle = toBundleObject(params)
|
|
127
140
|
it.arguments = bundle
|
|
128
141
|
}
|
|
129
142
|
try {
|
|
130
143
|
activity.supportFragmentManager.beginTransaction()
|
|
131
|
-
.add(paymentSheetFragment!!,
|
|
144
|
+
.add(paymentSheetFragment!!, PaymentSheetFragment.TAG)
|
|
132
145
|
.commit()
|
|
133
146
|
} catch (error: IllegalStateException) {
|
|
134
147
|
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
@@ -174,7 +187,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
174
187
|
)
|
|
175
188
|
} else {
|
|
176
189
|
Log.e("StripeReactNative", "FPX payment failed. Promise and/or client secret is not set.")
|
|
177
|
-
confirmPromise?.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), "FPX payment failed."))
|
|
190
|
+
confirmPromise?.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), "FPX payment failed. Client secret is not set."))
|
|
178
191
|
}
|
|
179
192
|
}
|
|
180
193
|
is AddPaymentMethodActivityStarter.Result.Failure -> {
|
|
@@ -190,27 +203,30 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
190
203
|
|
|
191
204
|
@ReactMethod
|
|
192
205
|
fun createPaymentMethod(data: ReadableMap, options: ReadableMap, promise: Promise) {
|
|
193
|
-
val
|
|
194
|
-
promise.resolve(createError(
|
|
206
|
+
val paymentMethodType = getValOr(data, "paymentMethodType")?.let { mapToPaymentMethodType(it) } ?: run {
|
|
207
|
+
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), "You must provide paymentMethodType"))
|
|
195
208
|
return
|
|
196
209
|
}
|
|
197
|
-
val cardAddress = cardFieldView?.cardAddress ?: cardFormView?.cardAddress
|
|
198
210
|
val paymentMethodData = getMapOrNull(data, "paymentMethodData")
|
|
199
|
-
val
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
211
|
+
val factory = PaymentMethodCreateParamsFactory(paymentMethodData, options, cardFieldView, cardFormView)
|
|
212
|
+
try {
|
|
213
|
+
val paymentMethodCreateParams = factory.createPaymentMethodParams(paymentMethodType)
|
|
214
|
+
stripe.createPaymentMethod(
|
|
215
|
+
paymentMethodCreateParams,
|
|
216
|
+
callback = object : ApiResultCallback<PaymentMethod> {
|
|
217
|
+
override fun onError(e: Exception) {
|
|
218
|
+
promise.resolve(createError("Failed", e))
|
|
219
|
+
}
|
|
208
220
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
221
|
+
override fun onSuccess(result: PaymentMethod) {
|
|
222
|
+
val paymentMethodMap: WritableMap = mapFromPaymentMethod(result)
|
|
223
|
+
promise.resolve(createResult("paymentMethod", paymentMethodMap))
|
|
224
|
+
}
|
|
212
225
|
}
|
|
213
|
-
|
|
226
|
+
)
|
|
227
|
+
} catch (error: PaymentMethodCreateParamsException) {
|
|
228
|
+
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), error))
|
|
229
|
+
}
|
|
214
230
|
}
|
|
215
231
|
|
|
216
232
|
@ReactMethod
|
|
@@ -388,10 +404,10 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
388
404
|
// return
|
|
389
405
|
// }
|
|
390
406
|
|
|
391
|
-
val factory = PaymentMethodCreateParamsFactory(
|
|
407
|
+
val factory = PaymentMethodCreateParamsFactory(paymentMethodData, options, cardFieldView, cardFormView)
|
|
392
408
|
|
|
393
409
|
try {
|
|
394
|
-
val confirmParams = factory.
|
|
410
|
+
val confirmParams = factory.createParams(paymentIntentClientSecret, paymentMethodType, isPaymentIntent = true) as ConfirmPaymentIntentParams
|
|
395
411
|
urlScheme?.let {
|
|
396
412
|
confirmParams.returnUrl = mapToReturnURL(urlScheme)
|
|
397
413
|
}
|
|
@@ -441,10 +457,10 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
441
457
|
return
|
|
442
458
|
}
|
|
443
459
|
|
|
444
|
-
val factory = PaymentMethodCreateParamsFactory(
|
|
460
|
+
val factory = PaymentMethodCreateParamsFactory(getMapOrNull(params, "paymentMethodData"), options, cardFieldView, cardFormView)
|
|
445
461
|
|
|
446
462
|
try {
|
|
447
|
-
val confirmParams = factory.
|
|
463
|
+
val confirmParams = factory.createParams(setupIntentClientSecret, paymentMethodType, isPaymentIntent = false) as ConfirmSetupIntentParams
|
|
448
464
|
urlScheme?.let {
|
|
449
465
|
confirmParams.returnUrl = mapToReturnURL(urlScheme)
|
|
450
466
|
}
|
|
@@ -474,7 +490,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
474
490
|
getCurrentActivityOrResolveWithError(promise)?.let {
|
|
475
491
|
try {
|
|
476
492
|
it.supportFragmentManager.beginTransaction()
|
|
477
|
-
.add(fragment,
|
|
493
|
+
.add(fragment, GooglePayPaymentMethodLauncherFragment.TAG)
|
|
478
494
|
.commit()
|
|
479
495
|
} catch (error: IllegalStateException) {
|
|
480
496
|
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
@@ -492,7 +508,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
492
508
|
getCurrentActivityOrResolveWithError(promise)?.let {
|
|
493
509
|
try {
|
|
494
510
|
it.supportFragmentManager.beginTransaction()
|
|
495
|
-
.add(googlePayFragment!!,
|
|
511
|
+
.add(googlePayFragment!!, GooglePayFragment.TAG)
|
|
496
512
|
.commit()
|
|
497
513
|
} catch (error: IllegalStateException) {
|
|
498
514
|
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
@@ -545,12 +561,13 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
545
561
|
|
|
546
562
|
getCurrentActivityOrResolveWithError(promise)?.let {
|
|
547
563
|
PushProvisioningProxy.isCardInWallet(it, last4) { isCardInWallet, token, error ->
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
564
|
+
val result = error?.let {
|
|
565
|
+
createCanAddCardResult(false, "MISSING_CONFIGURATION", null)
|
|
566
|
+
} ?: run {
|
|
551
567
|
val status = if (isCardInWallet) "CARD_ALREADY_EXISTS" else null
|
|
552
|
-
|
|
568
|
+
createCanAddCardResult(!isCardInWallet, status, token)
|
|
553
569
|
}
|
|
570
|
+
promise.resolve(result)
|
|
554
571
|
}
|
|
555
572
|
}
|
|
556
573
|
}
|
|
@@ -563,14 +580,13 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
563
580
|
}
|
|
564
581
|
getCurrentActivityOrResolveWithError(promise)?.let {
|
|
565
582
|
PushProvisioningProxy.isCardInWallet(it, last4) { isCardInWallet, token, error ->
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
result.putMap("token", token)
|
|
572
|
-
promise.resolve(result)
|
|
583
|
+
val result: WritableMap = error ?: run {
|
|
584
|
+
val map = WritableNativeMap()
|
|
585
|
+
map.putBoolean("isInWallet", isCardInWallet)
|
|
586
|
+
map.putMap("token", token)
|
|
587
|
+
map
|
|
573
588
|
}
|
|
589
|
+
promise.resolve(result)
|
|
574
590
|
}
|
|
575
591
|
}
|
|
576
592
|
}
|
|
@@ -597,7 +613,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
597
613
|
billingDetails.getString("email")
|
|
598
614
|
)
|
|
599
615
|
|
|
600
|
-
|
|
616
|
+
collectBankAccountLauncherFragment = CollectBankAccountLauncherFragment(
|
|
601
617
|
reactApplicationContext,
|
|
602
618
|
publishableKey,
|
|
603
619
|
clientSecret,
|
|
@@ -608,7 +624,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
608
624
|
getCurrentActivityOrResolveWithError(promise)?.let {
|
|
609
625
|
try {
|
|
610
626
|
it.supportFragmentManager.beginTransaction()
|
|
611
|
-
.add(
|
|
627
|
+
.add(collectBankAccountLauncherFragment!!, "collect_bank_account_launcher_fragment")
|
|
612
628
|
.commit()
|
|
613
629
|
} catch (error: IllegalStateException) {
|
|
614
630
|
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
@@ -635,6 +651,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
635
651
|
promise.resolve(createResult("paymentIntent", mapFromPaymentIntentResult(result)))
|
|
636
652
|
}
|
|
637
653
|
}
|
|
654
|
+
|
|
638
655
|
val setupCallback = object : ApiResultCallback<SetupIntent> {
|
|
639
656
|
override fun onError(e: Exception) {
|
|
640
657
|
promise.resolve(createError(ErrorType.Failed.toString(), e))
|
|
@@ -683,6 +700,28 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
683
700
|
}
|
|
684
701
|
}
|
|
685
702
|
|
|
703
|
+
@ReactMethod
|
|
704
|
+
fun collectBankAccountToken(clientSecret: String, promise: Promise) {
|
|
705
|
+
if (!::stripe.isInitialized) {
|
|
706
|
+
promise.resolve(createMissingInitError())
|
|
707
|
+
return
|
|
708
|
+
}
|
|
709
|
+
financialConnectionsSheetFragment = FinancialConnectionsSheetFragment().also {
|
|
710
|
+
it.presentFinancialConnectionsSheet(clientSecret, FinancialConnectionsSheetFragment.Mode.ForToken, publishableKey, promise, reactApplicationContext)
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
@ReactMethod
|
|
715
|
+
fun collectFinancialConnectionsAccounts(clientSecret: String, promise: Promise) {
|
|
716
|
+
if (!::stripe.isInitialized) {
|
|
717
|
+
promise.resolve(createMissingInitError())
|
|
718
|
+
return
|
|
719
|
+
}
|
|
720
|
+
financialConnectionsSheetFragment = FinancialConnectionsSheetFragment().also {
|
|
721
|
+
it.presentFinancialConnectionsSheet(clientSecret, FinancialConnectionsSheetFragment.Mode.ForSession, publishableKey, promise, reactApplicationContext)
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
686
725
|
/**
|
|
687
726
|
* Safely get and cast the current activity as an AppCompatActivity. If that fails, the promise
|
|
688
727
|
* provided will be resolved with an error message instructing the user to retry the method.
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt
CHANGED
|
@@ -17,7 +17,7 @@ import com.facebook.react.bridge.WritableMap
|
|
|
17
17
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
18
18
|
import com.facebook.react.uimanager.UIManagerModule
|
|
19
19
|
import com.facebook.react.uimanager.events.EventDispatcher
|
|
20
|
-
import com.reactnativestripesdk.createError
|
|
20
|
+
import com.reactnativestripesdk.utils.createError
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class AddToWalletButtonView(private val context: ThemedReactContext, private val requestManager: RequestManager) : AppCompatImageView(context) {
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt
CHANGED
|
@@ -9,8 +9,8 @@ import android.util.Log
|
|
|
9
9
|
import com.facebook.react.bridge.BaseActivityEventListener
|
|
10
10
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
11
|
import com.facebook.react.bridge.ReadableMap
|
|
12
|
-
import com.reactnativestripesdk.createError
|
|
13
|
-
import com.reactnativestripesdk.mapError
|
|
12
|
+
import com.reactnativestripesdk.utils.createError
|
|
13
|
+
import com.reactnativestripesdk.utils.mapError
|
|
14
14
|
import com.stripe.android.pushProvisioning.PushProvisioningActivity
|
|
15
15
|
import com.stripe.android.pushProvisioning.PushProvisioningActivityStarter
|
|
16
16
|
|
|
@@ -5,7 +5,7 @@ import android.util.Log
|
|
|
5
5
|
import com.facebook.react.bridge.ReadableMap
|
|
6
6
|
import com.facebook.react.bridge.WritableMap
|
|
7
7
|
import com.facebook.react.bridge.WritableNativeMap
|
|
8
|
-
import com.reactnativestripesdk.createError
|
|
8
|
+
import com.reactnativestripesdk.utils.createError
|
|
9
9
|
import com.google.android.gms.tasks.Task
|
|
10
10
|
|
|
11
11
|
typealias TokenCheckHandler = (isCardInWallet: Boolean, token: WritableMap?, error: WritableMap?) -> Unit
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.reactnativestripesdk
|
|
1
|
+
package com.reactnativestripesdk.utils
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.WritableMap
|
|
4
4
|
import com.facebook.react.bridge.WritableNativeMap
|
|
@@ -111,3 +111,7 @@ internal fun createError(code: String, error: Throwable): WritableMap {
|
|
|
111
111
|
null,
|
|
112
112
|
null)
|
|
113
113
|
}
|
|
114
|
+
|
|
115
|
+
internal fun createMissingInitError(): WritableMap {
|
|
116
|
+
return createError(ErrorType.Failed.toString(), "Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.")
|
|
117
|
+
}
|
package/android/src/main/java/com/reactnativestripesdk/{Extensions.kt → utils/Extensions.kt}
RENAMED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
package com.reactnativestripesdk
|
|
1
|
+
package com.reactnativestripesdk.utils
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.view.View
|
|
5
5
|
import android.view.inputmethod.InputMethodManager
|
|
6
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
7
|
+
import androidx.fragment.app.Fragment
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
9
|
|
|
7
10
|
fun View.showSoftKeyboard() {
|
|
8
11
|
post {
|
|
@@ -19,3 +22,11 @@ fun View.hideSoftKeyboard() {
|
|
|
19
22
|
imm?.hideSoftInputFromWindow(windowToken, 0)
|
|
20
23
|
}
|
|
21
24
|
}
|
|
25
|
+
|
|
26
|
+
fun Fragment.removeFragment(context: ReactApplicationContext) {
|
|
27
|
+
(context.currentActivity as? AppCompatActivity)?.supportFragmentManager?.let {
|
|
28
|
+
if (it.findFragmentByTag(this.tag) != null) {
|
|
29
|
+
it.beginTransaction().remove(this).commitAllowingStateLoss()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.reactnativestripesdk
|
|
1
|
+
package com.reactnativestripesdk.utils
|
|
2
2
|
|
|
3
3
|
import android.os.Bundle
|
|
4
4
|
import android.util.Log
|
|
@@ -124,6 +124,7 @@ internal fun mapPaymentMethodType(type: PaymentMethod.Type?): String {
|
|
|
124
124
|
PaymentMethod.Type.Klarna -> "Klarna"
|
|
125
125
|
PaymentMethod.Type.USBankAccount -> "USBankAccount"
|
|
126
126
|
PaymentMethod.Type.PayPal -> "PayPal"
|
|
127
|
+
PaymentMethod.Type.Affirm -> "Affirm"
|
|
127
128
|
else -> "Unknown"
|
|
128
129
|
}
|
|
129
130
|
}
|
|
@@ -152,6 +153,7 @@ internal fun mapToPaymentMethodType(type: String?): PaymentMethod.Type? {
|
|
|
152
153
|
"Klarna" -> PaymentMethod.Type.Klarna
|
|
153
154
|
"USBankAccount" -> PaymentMethod.Type.USBankAccount
|
|
154
155
|
"PayPal" -> PaymentMethod.Type.PayPal
|
|
156
|
+
"Affirm" -> PaymentMethod.Type.Affirm
|
|
155
157
|
else -> null
|
|
156
158
|
}
|
|
157
159
|
}
|
|
@@ -215,12 +217,11 @@ internal fun mapFromBankAccountStatus(status: BankAccount.Status?): String {
|
|
|
215
217
|
}
|
|
216
218
|
|
|
217
219
|
internal fun mapFromBankAccount(bankAccount: BankAccount?): WritableMap? {
|
|
218
|
-
val bankAccountMap: WritableMap = WritableNativeMap()
|
|
219
|
-
|
|
220
220
|
if (bankAccount == null) {
|
|
221
221
|
return null
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
val bankAccountMap: WritableMap = WritableNativeMap()
|
|
224
225
|
bankAccountMap.putString("id", bankAccount.id)
|
|
225
226
|
bankAccountMap.putString("bankName", bankAccount.bankName)
|
|
226
227
|
bankAccountMap.putString("accountHolderName", bankAccount.accountHolderName)
|
|
@@ -229,6 +230,8 @@ internal fun mapFromBankAccount(bankAccount: BankAccount?): WritableMap? {
|
|
|
229
230
|
bankAccountMap.putString("country", bankAccount.countryCode)
|
|
230
231
|
bankAccountMap.putString("routingNumber", bankAccount.routingNumber)
|
|
231
232
|
bankAccountMap.putString("status", mapFromBankAccountStatus(bankAccount.status))
|
|
233
|
+
bankAccountMap.putString("fingerprint", bankAccount.fingerprint)
|
|
234
|
+
bankAccountMap.putString("last4", bankAccount.last4)
|
|
232
235
|
|
|
233
236
|
return bankAccountMap
|
|
234
237
|
}
|
|
@@ -310,13 +313,13 @@ internal fun mapFromCard(card: Card?): WritableMap? {
|
|
|
310
313
|
|
|
311
314
|
internal fun mapFromToken(token: Token): WritableMap {
|
|
312
315
|
val tokenMap: WritableMap = WritableNativeMap()
|
|
313
|
-
|
|
314
316
|
tokenMap.putString("id", token.id)
|
|
315
|
-
tokenMap.
|
|
317
|
+
tokenMap.putDouble("created", token.created.time.toDouble())
|
|
316
318
|
tokenMap.putString("type", mapTokenType(token.type))
|
|
317
319
|
tokenMap.putBoolean("livemode", token.livemode)
|
|
318
320
|
tokenMap.putMap("bankAccount", mapFromBankAccount(token.bankAccount))
|
|
319
321
|
tokenMap.putMap("card", mapFromCard(token.card))
|
|
322
|
+
tokenMap.putBoolean("used", token.used)
|
|
320
323
|
|
|
321
324
|
return tokenMap
|
|
322
325
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package com.reactnativestripesdk.utils
|
|
2
|
+
|
|
3
|
+
class PostalCodeUtilities {
|
|
4
|
+
|
|
5
|
+
companion object {
|
|
6
|
+
internal fun isValidGlobalPostalCodeCharacter(c: Char): Boolean {
|
|
7
|
+
return Character.isLetterOrDigit(c)
|
|
8
|
+
|| c.isWhitespace()
|
|
9
|
+
|| c == '-'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
internal fun isValidUsPostalCodeCharacter(c: Char): Boolean {
|
|
13
|
+
return Character.isDigit(c)
|
|
14
|
+
|| c.isWhitespace()
|
|
15
|
+
|| c == '-'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
|
3
3
|
<item
|
|
4
|
-
android:drawable="@drawable/
|
|
4
|
+
android:drawable="@drawable/googlepay_button_background_image_dark" />
|
|
5
5
|
</selector>
|
|
6
6
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|