@stripe/stripe-react-native 0.41.0 → 0.43.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/.husky/pre-commit +0 -3
- package/CHANGELOG.md +27 -0
- package/README.md +3 -0
- 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.lock +0 -0
- package/android/.gradle/8.11.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.11.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +7 -1
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/android/gradle.properties +4 -1
- package/android/gradlew +249 -0
- package/android/gradlew.bat +92 -0
- package/android/spotless.gradle +19 -0
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +30 -34
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +20 -10
- package/android/src/main/java/com/reactnativestripesdk/CardChangedEvent.kt +12 -13
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +242 -105
- package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +58 -20
- package/android/src/main/java/com/reactnativestripesdk/CardFocusEvent.kt +8 -11
- package/android/src/main/java/com/reactnativestripesdk/CardFormCompleteEvent.kt +10 -12
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +135 -87
- package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +57 -22
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +53 -23
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +125 -83
- package/android/src/main/java/com/reactnativestripesdk/FormCompleteEvent.kt +9 -11
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +16 -9
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +36 -28
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +67 -43
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +21 -16
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +101 -56
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +244 -166
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +183 -123
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +181 -57
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +402 -258
- package/android/src/main/java/com/reactnativestripesdk/StripeContainerManager.kt +11 -4
- package/android/src/main/java/com/reactnativestripesdk/StripeContainerView.kt +5 -1
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +654 -299
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +12 -14
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +42 -37
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetEvent.kt +12 -11
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +29 -29
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +50 -18
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +227 -147
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +15 -18
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +33 -15
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +63 -37
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletCompleteEvent.kt +9 -13
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/EphemeralKeyProvider.kt +15 -17
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt +76 -60
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +71 -47
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +117 -51
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +4 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +39 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +337 -250
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -11
- package/ios/CustomerSheet/CustomerSheetUtils.swift +3 -1
- package/ios/FinancialConnections.swift +18 -2
- package/ios/Mappers.swift +23 -0
- package/ios/PaymentMethodFactory.swift +31 -29
- package/ios/StripeSdk+CustomerSheet.swift +2 -1
- package/ios/StripeSdk+PaymentSheet.swift +42 -0
- package/ios/StripeSdk.m +2 -0
- package/ios/StripeSdk.swift +116 -24
- package/lib/commonjs/NativeStripeSdk.js +1 -1
- 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/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/ApplePayButtonNative.js +1 -1
- package/lib/commonjs/components/ApplePayButtonNative.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/GooglePayButtonNative.js +1 -1
- package/lib/commonjs/components/GooglePayButtonNative.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/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useConfirmPayment.js.map +1 -1
- package/lib/commonjs/hooks/useConfirmSetupIntent.js.map +1 -1
- package/lib/commonjs/hooks/useFinancialConnectionsSheet.js +1 -1
- package/lib/commonjs/hooks/useFinancialConnectionsSheet.js.map +1 -1
- package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
- package/lib/commonjs/hooks/usePlatformPay.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.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/types/ApplePay.js.map +1 -1
- package/lib/commonjs/types/Common.js +1 -1
- package/lib/commonjs/types/Common.js.map +1 -1
- package/lib/commonjs/types/CustomerSheet.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/FinancialConnections.js +1 -1
- package/lib/commonjs/types/FinancialConnections.js.map +1 -1
- package/lib/commonjs/types/NextAction.js.map +1 -1
- package/lib/commonjs/types/PaymentIntent.js +1 -1
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/commonjs/types/PaymentMethod.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.js +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/PlatformPay.js +1 -1
- package/lib/commonjs/types/PlatformPay.js.map +1 -1
- package/lib/commonjs/types/PushProvisioning.js +1 -1
- package/lib/commonjs/types/PushProvisioning.js.map +1 -1
- package/lib/commonjs/types/SetupIntent.js +1 -1
- package/lib/commonjs/types/SetupIntent.js.map +1 -1
- package/lib/commonjs/types/ThreeDSecure.js +1 -1
- package/lib/commonjs/types/ThreeDSecure.js.map +1 -1
- package/lib/commonjs/types/Token.js.map +1 -1
- package/lib/commonjs/types/components/ApplePayButtonComponent.js.map +1 -1
- package/lib/commonjs/types/components/AuBECSDebitFormComponent.js.map +1 -1
- package/lib/commonjs/types/components/CardFieldInput.js +1 -1
- package/lib/commonjs/types/components/CardFieldInput.js.map +1 -1
- package/lib/commonjs/types/components/CardFormView.js.map +1 -1
- package/lib/commonjs/types/components/GooglePayButtonComponent.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 +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/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/ApplePayButtonNative.js +1 -1
- package/lib/module/components/ApplePayButtonNative.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/GooglePayButtonNative.js +1 -1
- package/lib/module/components/GooglePayButtonNative.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/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useConfirmPayment.js.map +1 -1
- package/lib/module/hooks/useConfirmSetupIntent.js.map +1 -1
- package/lib/module/hooks/useFinancialConnectionsSheet.js +1 -1
- package/lib/module/hooks/useFinancialConnectionsSheet.js.map +1 -1
- package/lib/module/hooks/usePaymentSheet.js.map +1 -1
- package/lib/module/hooks/usePlatformPay.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.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/types/ApplePay.js.map +1 -1
- package/lib/module/types/Common.js +1 -1
- package/lib/module/types/Common.js.map +1 -1
- package/lib/module/types/CustomerSheet.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/FinancialConnections.js +1 -1
- package/lib/module/types/FinancialConnections.js.map +1 -1
- package/lib/module/types/NextAction.js.map +1 -1
- package/lib/module/types/PaymentIntent.js +1 -1
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/module/types/PaymentMethod.js.map +1 -1
- package/lib/module/types/PaymentSheet.js +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/PlatformPay.js +1 -1
- package/lib/module/types/PlatformPay.js.map +1 -1
- package/lib/module/types/PushProvisioning.js +1 -1
- package/lib/module/types/PushProvisioning.js.map +1 -1
- package/lib/module/types/SetupIntent.js +1 -1
- package/lib/module/types/SetupIntent.js.map +1 -1
- package/lib/module/types/ThreeDSecure.js +1 -1
- package/lib/module/types/ThreeDSecure.js.map +1 -1
- package/lib/module/types/Token.js.map +1 -1
- package/lib/module/types/components/ApplePayButtonComponent.js.map +1 -1
- package/lib/module/types/components/AuBECSDebitFormComponent.js.map +1 -1
- package/lib/module/types/components/CardFieldInput.js +1 -1
- package/lib/module/types/components/CardFieldInput.js.map +1 -1
- package/lib/module/types/components/CardFormView.js.map +1 -1
- package/lib/module/types/components/GooglePayButtonComponent.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 +5 -4
- package/lib/typescript/src/NativeStripeSdk.d.ts.map +1 -0
- package/lib/typescript/src/components/AddToWalletButton.d.ts +3 -1
- package/lib/typescript/src/components/AddToWalletButton.d.ts.map +1 -0
- package/lib/typescript/src/components/AddressSheet.d.ts +4 -2
- package/lib/typescript/src/components/AddressSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts +1 -0
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts.map +1 -0
- package/lib/typescript/src/components/AuBECSDebitForm.d.ts +3 -1
- package/lib/typescript/src/components/AuBECSDebitForm.d.ts.map +1 -0
- package/lib/typescript/src/components/CardField.d.ts +1 -0
- package/lib/typescript/src/components/CardField.d.ts.map +1 -0
- package/lib/typescript/src/components/CardForm.d.ts +1 -0
- package/lib/typescript/src/components/CardForm.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomerSheet.d.ts +2 -1
- package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts +1 -0
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts.map +1 -0
- package/lib/typescript/src/components/PlatformPayButton.d.ts +3 -1
- package/lib/typescript/src/components/PlatformPayButton.d.ts.map +1 -0
- package/lib/typescript/src/components/StripeContainer.d.ts +2 -1
- package/lib/typescript/src/components/StripeContainer.d.ts.map +1 -0
- package/lib/typescript/src/components/StripeProvider.d.ts +3 -2
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -0
- package/lib/typescript/src/functions.d.ts +12 -7
- package/lib/typescript/src/functions.d.ts.map +1 -0
- package/lib/typescript/src/helpers.d.ts +1 -0
- package/lib/typescript/src/helpers.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useConfirmPayment.d.ts +2 -1
- package/lib/typescript/src/hooks/useConfirmPayment.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts +1 -0
- package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +5 -2
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePaymentSheet.d.ts +2 -1
- package/lib/typescript/src/hooks/usePaymentSheet.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePlatformPay.d.ts +4 -3
- package/lib/typescript/src/hooks/usePlatformPay.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useStripe.d.ts +11 -8
- package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/plugin/withStripe.d.ts +2 -1
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -0
- package/lib/typescript/src/types/ApplePay.d.ts +6 -5
- package/lib/typescript/src/types/ApplePay.d.ts.map +1 -0
- package/lib/typescript/src/types/Common.d.ts +4 -1
- package/lib/typescript/src/types/Common.d.ts.map +1 -0
- package/lib/typescript/src/types/CustomerSheet.d.ts +12 -4
- package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -0
- package/lib/typescript/src/types/Errors.d.ts +2 -1
- package/lib/typescript/src/types/Errors.d.ts.map +1 -0
- package/lib/typescript/src/types/FinancialConnections.d.ts +82 -14
- package/lib/typescript/src/types/FinancialConnections.d.ts.map +1 -0
- package/lib/typescript/src/types/NextAction.d.ts +9 -8
- package/lib/typescript/src/types/NextAction.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentIntent.d.ts +41 -14
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentMethod.d.ts +27 -15
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +72 -22
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -0
- package/lib/typescript/src/types/PlatformPay.d.ts +22 -21
- package/lib/typescript/src/types/PlatformPay.d.ts.map +1 -0
- package/lib/typescript/src/types/PushProvisioning.d.ts +5 -4
- package/lib/typescript/src/types/PushProvisioning.d.ts.map +1 -0
- package/lib/typescript/src/types/SetupIntent.d.ts +4 -3
- package/lib/typescript/src/types/SetupIntent.d.ts.map +1 -0
- package/lib/typescript/src/types/ThreeDSecure.d.ts +1 -0
- package/lib/typescript/src/types/ThreeDSecure.d.ts.map +1 -0
- package/lib/typescript/src/types/Token.d.ts +10 -9
- package/lib/typescript/src/types/Token.d.ts.map +1 -0
- package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts +3 -2
- package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts +1 -0
- package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/components/CardFieldInput.d.ts +8 -5
- package/lib/typescript/src/types/components/CardFieldInput.d.ts.map +1 -0
- package/lib/typescript/src/types/components/CardFormView.d.ts +9 -6
- package/lib/typescript/src/types/components/CardFormView.d.ts.map +1 -0
- package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts +1 -0
- package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +24 -23
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/package.json +33 -42
- package/src/NativeStripeSdk.tsx +5 -3
- package/src/components/CardField.tsx +1 -1
- package/src/components/CardForm.tsx +12 -9
- package/src/components/CustomerSheet.tsx +4 -6
- package/src/components/StripeProvider.tsx +17 -0
- package/src/functions.ts +70 -16
- package/src/hooks/useFinancialConnectionsSheet.tsx +12 -4
- package/src/hooks/useStripe.tsx +10 -4
- package/src/types/Common.ts +3 -0
- package/src/types/CustomerSheet.ts +7 -0
- package/src/types/FinancialConnections.ts +72 -0
- package/src/types/PaymentIntent.ts +30 -1
- package/src/types/PaymentMethod.ts +13 -1
- package/src/types/PaymentSheet.ts +65 -5
- package/src/types/components/CardFieldInput.ts +8 -4
- package/src/types/components/CardFormView.ts +8 -4
- package/stripe-react-native.podspec +2 -1
|
@@ -8,19 +8,17 @@ import com.reactnativestripesdk.addresssheet.AddressSheetViewManager
|
|
|
8
8
|
import com.reactnativestripesdk.pushprovisioning.AddToWalletButtonManager
|
|
9
9
|
|
|
10
10
|
class StripeSdkPackage : ReactPackage {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
11
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
|
|
12
|
+
listOf<NativeModule>(StripeSdkModule(reactContext))
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
|
|
15
|
+
listOf<ViewManager<*, *>>(
|
|
16
|
+
CardFieldViewManager(),
|
|
17
|
+
AuBECSDebitFormViewManager(),
|
|
18
|
+
StripeContainerManager(),
|
|
19
|
+
CardFormViewManager(),
|
|
20
|
+
GooglePayButtonManager(),
|
|
21
|
+
AddToWalletButtonManager(reactContext),
|
|
22
|
+
AddressSheetViewManager(),
|
|
23
|
+
)
|
|
26
24
|
}
|
package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt
CHANGED
|
@@ -26,28 +26,31 @@ class AddressLauncherFragment : Fragment() {
|
|
|
26
26
|
private var configuration = AddressLauncher.Configuration()
|
|
27
27
|
private var callback: ((error: WritableMap?, address: AddressDetails?) -> Unit)? = null
|
|
28
28
|
|
|
29
|
-
override fun onCreateView(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
29
|
+
override fun onCreateView(
|
|
30
|
+
inflater: LayoutInflater,
|
|
31
|
+
container: ViewGroup?,
|
|
32
|
+
savedInstanceState: Bundle?,
|
|
33
|
+
): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
35
34
|
|
|
36
|
-
override fun onViewCreated(
|
|
35
|
+
override fun onViewCreated(
|
|
36
|
+
view: View,
|
|
37
|
+
savedInstanceState: Bundle?,
|
|
38
|
+
) {
|
|
37
39
|
publishableKey?.let { publishableKey ->
|
|
38
|
-
addressLauncher =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
addressLauncher =
|
|
41
|
+
AddressLauncher(this, ::onAddressLauncherResult).also {
|
|
42
|
+
it.present(publishableKey = publishableKey, configuration = configuration)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
?: run {
|
|
46
|
+
callback?.invoke(
|
|
47
|
+
createError(
|
|
48
|
+
ErrorType.Failed.toString(),
|
|
49
|
+
"No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.",
|
|
50
|
+
),
|
|
51
|
+
null,
|
|
43
52
|
)
|
|
44
53
|
}
|
|
45
|
-
} ?: run {
|
|
46
|
-
callback?.invoke(
|
|
47
|
-
createError(ErrorType.Failed.toString(), "No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method."),
|
|
48
|
-
null
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
private fun onAddressLauncherResult(result: AddressLauncherResult) {
|
|
@@ -55,14 +58,11 @@ class AddressLauncherFragment : Fragment() {
|
|
|
55
58
|
is AddressLauncherResult.Canceled -> {
|
|
56
59
|
callback?.invoke(
|
|
57
60
|
createError(ErrorType.Canceled.toString(), "The flow has been canceled."),
|
|
58
|
-
null
|
|
61
|
+
null,
|
|
59
62
|
)
|
|
60
63
|
}
|
|
61
64
|
is AddressLauncherResult.Succeeded -> {
|
|
62
|
-
callback?.invoke(
|
|
63
|
-
null,
|
|
64
|
-
result.address
|
|
65
|
-
)
|
|
65
|
+
callback?.invoke(null, result.address)
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -77,17 +77,19 @@ class AddressLauncherFragment : Fragment() {
|
|
|
77
77
|
googlePlacesApiKey: String?,
|
|
78
78
|
autocompleteCountries: Set<String>,
|
|
79
79
|
additionalFields: AddressLauncher.AdditionalFieldsConfiguration?,
|
|
80
|
-
callback: ((error: WritableMap?, address: AddressDetails?) -> Unit)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
callback: ((error: WritableMap?, address: AddressDetails?) -> Unit),
|
|
81
|
+
) {
|
|
82
|
+
configuration =
|
|
83
|
+
AddressLauncher.Configuration(
|
|
84
|
+
appearance = appearance,
|
|
85
|
+
address = defaultAddress,
|
|
86
|
+
allowedCountries = allowedCountries,
|
|
87
|
+
buttonTitle = buttonTitle,
|
|
88
|
+
additionalFields = additionalFields,
|
|
89
|
+
title = title,
|
|
90
|
+
googlePlacesApiKey = googlePlacesApiKey,
|
|
91
|
+
autocompleteCountries = autocompleteCountries,
|
|
92
|
+
)
|
|
91
93
|
this.callback = callback
|
|
92
94
|
(context.currentActivity as? FragmentActivity)?.let {
|
|
93
95
|
attemptToCleanupPreviousFragment(it)
|
|
@@ -96,16 +98,19 @@ class AddressLauncherFragment : Fragment() {
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
private fun attemptToCleanupPreviousFragment(currentActivity: FragmentActivity) {
|
|
99
|
-
currentActivity.supportFragmentManager
|
|
101
|
+
currentActivity.supportFragmentManager
|
|
102
|
+
.beginTransaction()
|
|
100
103
|
.remove(this)
|
|
101
104
|
.commitAllowingStateLoss()
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
private fun commitFragmentAndStartFlow(currentActivity: FragmentActivity) {
|
|
105
108
|
try {
|
|
106
|
-
currentActivity.supportFragmentManager
|
|
109
|
+
currentActivity.supportFragmentManager
|
|
110
|
+
.beginTransaction()
|
|
107
111
|
.add(this, TAG)
|
|
108
112
|
.commit()
|
|
109
|
-
} catch (_: IllegalStateException) {
|
|
113
|
+
} catch (_: IllegalStateException) {
|
|
114
|
+
}
|
|
110
115
|
}
|
|
111
116
|
}
|
|
@@ -2,27 +2,28 @@ package com.reactnativestripesdk.addresssheet
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.WritableMap
|
|
4
4
|
import com.facebook.react.uimanager.events.Event
|
|
5
|
-
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
5
|
|
|
7
|
-
internal class AddressSheetEvent
|
|
6
|
+
internal class AddressSheetEvent(
|
|
7
|
+
surfaceId: Int,
|
|
8
|
+
viewTag: Int,
|
|
9
|
+
private val eventType: EventType,
|
|
10
|
+
private val eventMap: WritableMap?,
|
|
11
|
+
) : Event<AddressSheetEvent>(surfaceId, viewTag) {
|
|
8
12
|
enum class EventType {
|
|
9
13
|
OnSubmit,
|
|
10
|
-
OnError
|
|
14
|
+
OnError,
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
override fun
|
|
14
|
-
rctEventEmitter.receiveEvent(viewTag, eventName, eventMap)
|
|
15
|
-
}
|
|
17
|
+
override fun getEventData() = eventMap
|
|
16
18
|
|
|
17
19
|
companion object {
|
|
18
|
-
const val ON_SUBMIT = "
|
|
19
|
-
const val ON_ERROR = "
|
|
20
|
+
const val ON_SUBMIT = "topSubmitAction"
|
|
21
|
+
const val ON_ERROR = "topErrorAction"
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
override fun getEventName(): String
|
|
23
|
-
|
|
24
|
+
override fun getEventName(): String =
|
|
25
|
+
when (eventType) {
|
|
24
26
|
EventType.OnSubmit -> ON_SUBMIT
|
|
25
27
|
EventType.OnError -> ON_ERROR
|
|
26
28
|
}
|
|
27
|
-
}
|
|
28
29
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
package com.reactnativestripesdk.addresssheet
|
|
2
2
|
|
|
3
|
+
import android.annotation.SuppressLint
|
|
3
4
|
import android.os.Bundle
|
|
4
5
|
import android.util.Log
|
|
5
6
|
import android.widget.FrameLayout
|
|
6
|
-
import com.facebook.react.bridge.Arguments
|
|
7
7
|
import com.facebook.react.bridge.ReadableMap
|
|
8
8
|
import com.facebook.react.bridge.WritableMap
|
|
9
9
|
import com.facebook.react.bridge.WritableNativeMap
|
|
10
10
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
11
|
-
import com.facebook.react.uimanager.
|
|
12
|
-
import com.facebook.react.uimanager.events.EventDispatcher
|
|
11
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
13
12
|
import com.reactnativestripesdk.buildPaymentSheetAppearance
|
|
14
13
|
import com.reactnativestripesdk.utils.ErrorType
|
|
15
14
|
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
@@ -18,10 +17,11 @@ import com.reactnativestripesdk.utils.toBundleObject
|
|
|
18
17
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
19
18
|
import com.stripe.android.paymentsheet.addresselement.AddressDetails
|
|
20
19
|
import com.stripe.android.paymentsheet.addresselement.AddressLauncher
|
|
21
|
-
import com.stripe.android.paymentsheet.addresselement.AddressLauncherResult
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
@SuppressLint("ViewConstructor")
|
|
22
|
+
class AddressSheetView(
|
|
23
|
+
private val context: ThemedReactContext,
|
|
24
|
+
) : FrameLayout(context) {
|
|
25
25
|
private var isVisible = false
|
|
26
26
|
private var appearanceParams: ReadableMap? = null
|
|
27
27
|
private var defaultAddress: AddressDetails? = null
|
|
@@ -33,14 +33,14 @@ class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(co
|
|
|
33
33
|
private var additionalFields: AddressLauncher.AdditionalFieldsConfiguration? = null
|
|
34
34
|
|
|
35
35
|
private fun onSubmit(params: WritableMap) {
|
|
36
|
-
|
|
37
|
-
AddressSheetEvent(id, AddressSheetEvent.EventType.OnSubmit, params)
|
|
36
|
+
UIManagerHelper.getEventDispatcherForReactTag(context, id)?.dispatchEvent(
|
|
37
|
+
AddressSheetEvent(context.surfaceId, id, AddressSheetEvent.EventType.OnSubmit, params),
|
|
38
38
|
)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
private fun onError(params: WritableMap?) {
|
|
42
|
-
|
|
43
|
-
AddressSheetEvent(id, AddressSheetEvent.EventType.OnError, params)
|
|
42
|
+
UIManagerHelper.getEventDispatcherForReactTag(context, id)?.dispatchEvent(
|
|
43
|
+
AddressSheetEvent(context.surfaceId, id, AddressSheetEvent.EventType.OnError, params),
|
|
44
44
|
)
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -48,18 +48,22 @@ class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(co
|
|
|
48
48
|
if (newVisibility && !isVisible) {
|
|
49
49
|
launchAddressSheet()
|
|
50
50
|
} else if (!newVisibility && isVisible) {
|
|
51
|
-
Log.w(
|
|
51
|
+
Log.w(
|
|
52
|
+
"StripeReactNative",
|
|
53
|
+
"Programmatically dismissing the Address Sheet is not supported on Android.",
|
|
54
|
+
)
|
|
52
55
|
}
|
|
53
56
|
isVisible = newVisibility
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
private fun launchAddressSheet() {
|
|
57
|
-
val appearance =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
val appearance =
|
|
61
|
+
try {
|
|
62
|
+
buildPaymentSheetAppearance(toBundleObject(appearanceParams), context)
|
|
63
|
+
} catch (error: PaymentSheetAppearanceException) {
|
|
64
|
+
onError(createError(ErrorType.Failed.toString(), error))
|
|
65
|
+
return
|
|
66
|
+
}
|
|
63
67
|
AddressLauncherFragment().presentAddressSheet(
|
|
64
68
|
context,
|
|
65
69
|
appearance,
|
|
@@ -69,7 +73,7 @@ class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(co
|
|
|
69
73
|
sheetTitle,
|
|
70
74
|
googlePlacesApiKey,
|
|
71
75
|
autocompleteCountries,
|
|
72
|
-
additionalFields
|
|
76
|
+
additionalFields,
|
|
73
77
|
) { error, address ->
|
|
74
78
|
if (address != null) {
|
|
75
79
|
onSubmit(buildResult(address))
|
|
@@ -113,18 +117,15 @@ class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(co
|
|
|
113
117
|
}
|
|
114
118
|
|
|
115
119
|
companion object {
|
|
116
|
-
internal fun buildAddressDetails(bundle: Bundle): AddressDetails
|
|
117
|
-
|
|
120
|
+
internal fun buildAddressDetails(bundle: Bundle): AddressDetails =
|
|
121
|
+
AddressDetails(
|
|
118
122
|
name = bundle.getString("name"),
|
|
119
123
|
address = buildAddress(bundle.getBundle("address")),
|
|
120
124
|
phoneNumber = bundle.getString("phone"),
|
|
121
125
|
isCheckboxSelected = bundle.getBoolean("isCheckboxSelected"),
|
|
122
126
|
)
|
|
123
|
-
}
|
|
124
127
|
|
|
125
|
-
internal fun buildAddressDetails(map: ReadableMap): AddressDetails
|
|
126
|
-
return buildAddressDetails(toBundleObject(map))
|
|
127
|
-
}
|
|
128
|
+
internal fun buildAddressDetails(map: ReadableMap): AddressDetails = buildAddressDetails(toBundleObject(map))
|
|
128
129
|
|
|
129
130
|
internal fun buildAddress(bundle: Bundle?): PaymentSheet.Address? {
|
|
130
131
|
if (bundle == null) {
|
|
@@ -136,25 +137,24 @@ class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(co
|
|
|
136
137
|
line1 = bundle.getString("line1"),
|
|
137
138
|
line2 = bundle.getString("line2"),
|
|
138
139
|
state = bundle.getString("state"),
|
|
139
|
-
postalCode = bundle.getString("postalCode")
|
|
140
|
+
postalCode = bundle.getString("postalCode"),
|
|
140
141
|
)
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
internal fun getFieldConfiguration(key: String?): AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration
|
|
144
|
-
|
|
144
|
+
internal fun getFieldConfiguration(key: String?): AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration =
|
|
145
|
+
when (key) {
|
|
145
146
|
"hidden" -> AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.HIDDEN
|
|
146
147
|
"optional" -> AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.OPTIONAL
|
|
147
148
|
"required" -> AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.REQUIRED
|
|
148
149
|
else -> AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.HIDDEN
|
|
149
150
|
}
|
|
150
|
-
}
|
|
151
151
|
|
|
152
152
|
internal fun buildAdditionalFieldsConfiguration(params: ReadableMap): AddressLauncher.AdditionalFieldsConfiguration {
|
|
153
153
|
val phoneConfiguration = getFieldConfiguration(params.getString("phoneNumber"))
|
|
154
154
|
|
|
155
155
|
return AddressLauncher.AdditionalFieldsConfiguration(
|
|
156
156
|
phone = phoneConfiguration,
|
|
157
|
-
checkboxLabel = params.getString("checkboxLabel")
|
|
157
|
+
checkboxLabel = params.getString("checkboxLabel"),
|
|
158
158
|
)
|
|
159
159
|
}
|
|
160
160
|
|
package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt
CHANGED
|
@@ -2,66 +2,98 @@ package com.reactnativestripesdk.addresssheet
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReadableArray
|
|
4
4
|
import com.facebook.react.bridge.ReadableMap
|
|
5
|
-
import com.facebook.react.
|
|
5
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
6
6
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
7
7
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
8
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
9
|
|
|
10
|
+
@ReactModule(name = AddressSheetViewManager.REACT_CLASS)
|
|
10
11
|
class AddressSheetViewManager : SimpleViewManager<AddressSheetView>() {
|
|
11
|
-
override fun getName() =
|
|
12
|
+
override fun getName() = REACT_CLASS
|
|
12
13
|
|
|
13
|
-
override fun getExportedCustomDirectEventTypeConstants()
|
|
14
|
-
|
|
15
|
-
AddressSheetEvent.ON_SUBMIT
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
override fun getExportedCustomDirectEventTypeConstants() =
|
|
15
|
+
mutableMapOf(
|
|
16
|
+
AddressSheetEvent.ON_SUBMIT to
|
|
17
|
+
mutableMapOf("registrationName" to "onSubmitAction"),
|
|
18
|
+
AddressSheetEvent.ON_ERROR to
|
|
19
|
+
mutableMapOf("registrationName" to "onErrorAction"),
|
|
20
|
+
)
|
|
18
21
|
|
|
19
22
|
@ReactProp(name = "visible")
|
|
20
|
-
fun setVisible(
|
|
23
|
+
fun setVisible(
|
|
24
|
+
view: AddressSheetView,
|
|
25
|
+
visibility: Boolean,
|
|
26
|
+
) {
|
|
21
27
|
view.setVisible(visibility)
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
@ReactProp(name = "appearance")
|
|
25
|
-
fun setAppearance(
|
|
31
|
+
fun setAppearance(
|
|
32
|
+
view: AddressSheetView,
|
|
33
|
+
appearance: ReadableMap,
|
|
34
|
+
) {
|
|
26
35
|
view.setAppearance(appearance)
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
@ReactProp(name = "defaultValues")
|
|
30
|
-
fun setDefaultValues(
|
|
39
|
+
fun setDefaultValues(
|
|
40
|
+
view: AddressSheetView,
|
|
41
|
+
defaults: ReadableMap,
|
|
42
|
+
) {
|
|
31
43
|
view.setDefaultValues(defaults)
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
@ReactProp(name = "additionalFields")
|
|
35
|
-
fun setAdditionalFields(
|
|
47
|
+
fun setAdditionalFields(
|
|
48
|
+
view: AddressSheetView,
|
|
49
|
+
fields: ReadableMap,
|
|
50
|
+
) {
|
|
36
51
|
view.setAdditionalFields(fields)
|
|
37
52
|
}
|
|
38
53
|
|
|
39
54
|
@ReactProp(name = "allowedCountries")
|
|
40
|
-
fun setAllowedCountries(
|
|
55
|
+
fun setAllowedCountries(
|
|
56
|
+
view: AddressSheetView,
|
|
57
|
+
countries: ReadableArray,
|
|
58
|
+
) {
|
|
41
59
|
view.setAllowedCountries(countries.toArrayList().filterIsInstance<String>())
|
|
42
60
|
}
|
|
43
61
|
|
|
44
62
|
@ReactProp(name = "autocompleteCountries")
|
|
45
|
-
fun setAutocompleteCountries(
|
|
63
|
+
fun setAutocompleteCountries(
|
|
64
|
+
view: AddressSheetView,
|
|
65
|
+
countries: ReadableArray,
|
|
66
|
+
) {
|
|
46
67
|
view.setAutocompleteCountries(countries.toArrayList().filterIsInstance<String>())
|
|
47
68
|
}
|
|
48
69
|
|
|
49
70
|
@ReactProp(name = "primaryButtonTitle")
|
|
50
|
-
fun setPrimaryButtonTitle(
|
|
71
|
+
fun setPrimaryButtonTitle(
|
|
72
|
+
view: AddressSheetView,
|
|
73
|
+
title: String,
|
|
74
|
+
) {
|
|
51
75
|
view.setPrimaryButtonTitle(title)
|
|
52
76
|
}
|
|
53
77
|
|
|
54
78
|
@ReactProp(name = "sheetTitle")
|
|
55
|
-
fun setSheetTitle(
|
|
79
|
+
fun setSheetTitle(
|
|
80
|
+
view: AddressSheetView,
|
|
81
|
+
title: String,
|
|
82
|
+
) {
|
|
56
83
|
view.setSheetTitle(title)
|
|
57
84
|
}
|
|
58
85
|
|
|
59
86
|
@ReactProp(name = "googlePlacesApiKey")
|
|
60
|
-
fun setGooglePlacesApiKey(
|
|
87
|
+
fun setGooglePlacesApiKey(
|
|
88
|
+
view: AddressSheetView,
|
|
89
|
+
key: String,
|
|
90
|
+
) {
|
|
61
91
|
view.setGooglePlacesApiKey(key)
|
|
62
92
|
}
|
|
63
93
|
|
|
64
|
-
override fun createViewInstance(reactContext: ThemedReactContext): AddressSheetView
|
|
65
|
-
|
|
94
|
+
override fun createViewInstance(reactContext: ThemedReactContext): AddressSheetView = AddressSheetView(reactContext)
|
|
95
|
+
|
|
96
|
+
companion object {
|
|
97
|
+
const val REACT_CLASS = "AddressSheetView"
|
|
66
98
|
}
|
|
67
99
|
}
|