@stripe/stripe-react-native 0.42.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 +14 -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/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
- package/android/.project +0 -11
- package/android/.settings/org.eclipse.buildship.core.prefs +3 -3
- 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 +33 -24
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +107 -85
- 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 +137 -156
- 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 +295 -258
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -11
- package/ios/CustomerSheet/CustomerSheetUtils.swift +3 -1
- package/ios/FinancialConnections.swift +6 -2
- package/ios/StripeSdk+CustomerSheet.swift +2 -1
- package/ios/StripeSdk+PaymentSheet.swift +42 -0
- package/ios/StripeSdk.m +2 -0
- package/ios/StripeSdk.swift +72 -11
- 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.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.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.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.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 +4 -3
- 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 +6 -5
- 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 +3 -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 +21 -17
- 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 +16 -15
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentMethod.d.ts +21 -16
- 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 +32 -40
- package/src/NativeStripeSdk.tsx +4 -2
- 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 +13 -14
- package/src/types/Common.ts +3 -0
- package/src/types/CustomerSheet.ts +7 -0
- package/src/types/FinancialConnections.ts +3 -0
- package/src/types/PaymentMethod.ts +5 -1
- package/src/types/PaymentSheet.ts +64 -4
- package/src/types/components/CardFieldInput.ts +8 -4
- package/src/types/components/CardFormView.ts +8 -4
- package/stripe-react-native.podspec +2 -1
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- /package/android/.gradle/{8.9 → 8.11.1}/fileChanges/last-build.bin +0 -0
- /package/android/.gradle/{8.9/dependencies-accessors → 8.11.1}/gc.properties +0 -0
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
|
+
|
|
2
3
|
import com.facebook.react.bridge.Arguments
|
|
3
4
|
import com.facebook.react.bridge.WritableMap
|
|
4
5
|
import com.facebook.react.uimanager.events.Event
|
|
5
|
-
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
6
|
|
|
7
|
-
internal class CardFocusEvent
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
internal class CardFocusEvent(
|
|
8
|
+
surfaceId: Int,
|
|
9
|
+
viewTag: Int,
|
|
10
|
+
private val focusField: String?,
|
|
11
|
+
) : Event<CardFocusEvent>(surfaceId, viewTag) {
|
|
12
|
+
override fun getEventName() = EVENT_NAME
|
|
11
13
|
|
|
12
|
-
override fun
|
|
13
|
-
rctEventEmitter.receiveEvent(viewTag, eventName, serializeEventData())
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
private fun serializeEventData(): WritableMap {
|
|
14
|
+
override fun getEventData(): WritableMap? {
|
|
17
15
|
val eventData = Arguments.createMap()
|
|
18
16
|
eventData.putString("focusedField", focusField)
|
|
19
17
|
|
|
@@ -23,5 +21,4 @@ internal class CardFocusEvent constructor(viewTag: Int, private val focusField:
|
|
|
23
21
|
companion object {
|
|
24
22
|
const val EVENT_NAME = "topFocusChange"
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
}
|
|
@@ -3,18 +3,17 @@ package com.reactnativestripesdk
|
|
|
3
3
|
import com.facebook.react.bridge.Arguments
|
|
4
4
|
import com.facebook.react.bridge.WritableMap
|
|
5
5
|
import com.facebook.react.uimanager.events.Event
|
|
6
|
-
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
7
6
|
|
|
8
|
-
internal class CardFormCompleteEvent
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
internal class CardFormCompleteEvent(
|
|
8
|
+
surfaceId: Int,
|
|
9
|
+
viewTag: Int,
|
|
10
|
+
private val cardDetails: MutableMap<String, Any>?,
|
|
11
|
+
private val complete: Boolean,
|
|
12
|
+
private val dangerouslyGetFullCardDetails: Boolean,
|
|
13
|
+
) : Event<CardChangedEvent>(surfaceId, viewTag) {
|
|
14
|
+
override fun getEventName() = EVENT_NAME
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
override fun getEventData(): WritableMap? {
|
|
18
17
|
val eventData = Arguments.createMap()
|
|
19
18
|
|
|
20
19
|
if (cardDetails == null) {
|
|
@@ -37,7 +36,6 @@ internal class CardFormCompleteEvent constructor(viewTag: Int, private val cardD
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
companion object {
|
|
40
|
-
const val EVENT_NAME = "
|
|
39
|
+
const val EVENT_NAME = "topFormComplete"
|
|
41
40
|
}
|
|
42
|
-
|
|
43
41
|
}
|
|
@@ -12,36 +12,46 @@ import androidx.core.view.setMargins
|
|
|
12
12
|
import com.facebook.react.bridge.ReadableMap
|
|
13
13
|
import com.facebook.react.uimanager.PixelUtil
|
|
14
14
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
15
|
-
import com.facebook.react.uimanager.
|
|
16
|
-
import com.facebook.react.uimanager.events.EventDispatcher
|
|
15
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
17
16
|
import com.facebook.react.views.text.ReactTypefaceUtils
|
|
18
17
|
import com.google.android.material.shape.CornerFamily
|
|
19
18
|
import com.google.android.material.shape.MaterialShapeDrawable
|
|
20
19
|
import com.google.android.material.shape.ShapeAppearanceModel
|
|
21
|
-
import com.reactnativestripesdk.utils
|
|
20
|
+
import com.reactnativestripesdk.utils.PostalCodeUtilities
|
|
21
|
+
import com.reactnativestripesdk.utils.getIntOrNull
|
|
22
|
+
import com.reactnativestripesdk.utils.getValOr
|
|
23
|
+
import com.reactnativestripesdk.utils.hideSoftKeyboard
|
|
22
24
|
import com.reactnativestripesdk.utils.mapCardBrand
|
|
25
|
+
import com.reactnativestripesdk.utils.mapToPreferredNetworks
|
|
26
|
+
import com.reactnativestripesdk.utils.showSoftKeyboard
|
|
23
27
|
import com.stripe.android.core.model.CountryCode
|
|
24
|
-
import com.stripe.android.databinding.StripeCardMultilineWidgetBinding
|
|
25
28
|
import com.stripe.android.databinding.StripeCardFormViewBinding
|
|
29
|
+
import com.stripe.android.databinding.StripeCardMultilineWidgetBinding
|
|
26
30
|
import com.stripe.android.model.Address
|
|
27
31
|
import com.stripe.android.model.PaymentMethodCreateParams
|
|
28
32
|
import com.stripe.android.view.CardFormView
|
|
29
33
|
import com.stripe.android.view.CardInputListener
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
private
|
|
35
|
+
@SuppressLint("ViewConstructor")
|
|
36
|
+
class CardFormView(
|
|
37
|
+
private val context: ThemedReactContext,
|
|
38
|
+
) : FrameLayout(context) {
|
|
39
|
+
private var cardForm: CardFormView =
|
|
40
|
+
CardFormView(context, null, com.stripe.android.R.style.StripeCardFormView_Borderless)
|
|
34
41
|
private var dangerouslyGetFullCardDetails: Boolean = false
|
|
35
42
|
private var currentFocusedField: String? = null
|
|
36
43
|
var cardParams: PaymentMethodCreateParams.Card? = null
|
|
37
44
|
var cardAddress: Address? = null
|
|
38
45
|
private val cardFormViewBinding = StripeCardFormViewBinding.bind(cardForm)
|
|
39
|
-
private val multilineWidgetBinding =
|
|
46
|
+
private val multilineWidgetBinding =
|
|
47
|
+
StripeCardMultilineWidgetBinding.bind(cardFormViewBinding.cardMultilineWidget)
|
|
40
48
|
|
|
41
49
|
init {
|
|
42
50
|
cardFormViewBinding.cardMultilineWidgetContainer.isFocusable = true
|
|
43
51
|
cardFormViewBinding.cardMultilineWidgetContainer.isFocusableInTouchMode = true
|
|
44
|
-
(cardFormViewBinding.cardMultilineWidgetContainer.layoutParams as MarginLayoutParams).setMargins(
|
|
52
|
+
(cardFormViewBinding.cardMultilineWidgetContainer.layoutParams as MarginLayoutParams).setMargins(
|
|
53
|
+
0,
|
|
54
|
+
)
|
|
45
55
|
addView(cardForm)
|
|
46
56
|
setListeners()
|
|
47
57
|
|
|
@@ -124,8 +134,9 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
private fun onChangeFocus() {
|
|
127
|
-
|
|
128
|
-
|
|
137
|
+
UIManagerHelper
|
|
138
|
+
.getEventDispatcherForReactTag(context, id)
|
|
139
|
+
?.dispatchEvent(CardFocusEvent(context.surfaceId, id, currentFocusedField))
|
|
129
140
|
}
|
|
130
141
|
|
|
131
142
|
@SuppressLint("RestrictedApi")
|
|
@@ -141,18 +152,20 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
141
152
|
val textErrorColor = getValOr(value, "textErrorColor", null)
|
|
142
153
|
val cursorColor = getValOr(value, "cursorColor", null)
|
|
143
154
|
|
|
144
|
-
val editTextBindings =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
val editTextBindings =
|
|
156
|
+
setOf(
|
|
157
|
+
cardFormViewBinding.cardMultilineWidget.cardNumberEditText,
|
|
158
|
+
cardFormViewBinding.cardMultilineWidget.cvcEditText,
|
|
159
|
+
cardFormViewBinding.cardMultilineWidget.expiryDateEditText,
|
|
160
|
+
cardFormViewBinding.postalCode,
|
|
161
|
+
)
|
|
162
|
+
val placeholderTextBindings =
|
|
163
|
+
setOf(
|
|
164
|
+
multilineWidgetBinding.tlExpiry,
|
|
165
|
+
multilineWidgetBinding.tlCardNumber,
|
|
166
|
+
multilineWidgetBinding.tlCvc,
|
|
167
|
+
cardFormViewBinding.postalCodeContainer,
|
|
168
|
+
)
|
|
156
169
|
|
|
157
170
|
textColor?.let {
|
|
158
171
|
for (binding in editTextBindings) {
|
|
@@ -178,7 +191,8 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
178
191
|
}
|
|
179
192
|
fontFamily?.let {
|
|
180
193
|
// Load custom font from assets, and fallback to default system font
|
|
181
|
-
val typeface =
|
|
194
|
+
val typeface =
|
|
195
|
+
ReactTypefaceUtils.applyStyles(null, -1, -1, it.takeIf { it.isNotEmpty() }, context.assets)
|
|
182
196
|
for (binding in editTextBindings) {
|
|
183
197
|
binding.typeface = typeface
|
|
184
198
|
}
|
|
@@ -202,25 +216,26 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
202
216
|
}
|
|
203
217
|
}
|
|
204
218
|
|
|
205
|
-
cardFormViewBinding.cardMultilineWidgetContainer.background =
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
cardFormViewBinding.cardMultilineWidgetContainer.background =
|
|
220
|
+
MaterialShapeDrawable(
|
|
221
|
+
ShapeAppearanceModel()
|
|
222
|
+
.toBuilder()
|
|
223
|
+
.setAllCorners(CornerFamily.ROUNDED, PixelUtil.toPixelFromDIP(borderRadius.toDouble()))
|
|
224
|
+
.build(),
|
|
225
|
+
).also { shape ->
|
|
226
|
+
shape.strokeWidth = 0.0f
|
|
227
|
+
shape.strokeColor = ColorStateList.valueOf(Color.parseColor("#000000"))
|
|
228
|
+
shape.fillColor = ColorStateList.valueOf(Color.parseColor("#FFFFFF"))
|
|
229
|
+
borderWidth?.let {
|
|
230
|
+
shape.strokeWidth = PixelUtil.toPixelFromDIP(it.toDouble())
|
|
231
|
+
}
|
|
232
|
+
borderColor?.let {
|
|
233
|
+
shape.strokeColor = ColorStateList.valueOf(Color.parseColor(it))
|
|
234
|
+
}
|
|
235
|
+
backgroundColor?.let {
|
|
236
|
+
shape.fillColor = ColorStateList.valueOf(Color.parseColor(it))
|
|
237
|
+
}
|
|
222
238
|
}
|
|
223
|
-
}
|
|
224
239
|
}
|
|
225
240
|
|
|
226
241
|
fun setDangerouslyGetFullCardDetails(isEnabled: Boolean) {
|
|
@@ -232,35 +247,58 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
232
247
|
if (isValid) {
|
|
233
248
|
cardForm.cardParams?.let {
|
|
234
249
|
val cardParamsMap = it.toParamMap()["card"] as HashMap<*, *>
|
|
235
|
-
val cardDetails: MutableMap<String, Any> =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
250
|
+
val cardDetails: MutableMap<String, Any> =
|
|
251
|
+
mutableMapOf(
|
|
252
|
+
"expiryMonth" to cardParamsMap["exp_month"] as Int,
|
|
253
|
+
"expiryYear" to cardParamsMap["exp_year"] as Int,
|
|
254
|
+
"last4" to it.last4,
|
|
255
|
+
"brand" to mapCardBrand(it.brand),
|
|
256
|
+
"postalCode" to (it.address?.postalCode ?: ""),
|
|
257
|
+
"country" to (it.address?.country ?: ""),
|
|
258
|
+
)
|
|
243
259
|
|
|
244
260
|
if (dangerouslyGetFullCardDetails) {
|
|
245
261
|
cardDetails["number"] = cardParamsMap["number"] as String
|
|
246
262
|
cardDetails["cvc"] = cardParamsMap["cvc"] as String
|
|
247
263
|
}
|
|
248
264
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
265
|
+
UIManagerHelper
|
|
266
|
+
.getEventDispatcherForReactTag(context, id)
|
|
267
|
+
?.dispatchEvent(
|
|
268
|
+
CardFormCompleteEvent(
|
|
269
|
+
context.surfaceId,
|
|
270
|
+
id,
|
|
271
|
+
cardDetails,
|
|
272
|
+
isValid,
|
|
273
|
+
dangerouslyGetFullCardDetails,
|
|
274
|
+
),
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
cardAddress =
|
|
278
|
+
Address
|
|
279
|
+
.Builder()
|
|
280
|
+
.setPostalCode(it.address?.postalCode)
|
|
281
|
+
.setCountry(it.address?.country)
|
|
282
|
+
.build()
|
|
283
|
+
|
|
284
|
+
cardFormViewBinding.cardMultilineWidget.paymentMethodCard?.let { params ->
|
|
285
|
+
cardParams = params
|
|
286
|
+
}
|
|
258
287
|
}
|
|
259
288
|
} else {
|
|
260
289
|
cardParams = null
|
|
261
290
|
cardAddress = null
|
|
262
|
-
|
|
263
|
-
|
|
291
|
+
UIManagerHelper
|
|
292
|
+
.getEventDispatcherForReactTag(context, id)
|
|
293
|
+
?.dispatchEvent(
|
|
294
|
+
CardFormCompleteEvent(
|
|
295
|
+
context.surfaceId,
|
|
296
|
+
id,
|
|
297
|
+
null,
|
|
298
|
+
isValid,
|
|
299
|
+
dangerouslyGetFullCardDetails,
|
|
300
|
+
),
|
|
301
|
+
)
|
|
264
302
|
}
|
|
265
303
|
}
|
|
266
304
|
|
|
@@ -269,29 +307,37 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
269
307
|
val expiryEditText = multilineWidgetBinding.etExpiry
|
|
270
308
|
val postalCodeEditText = cardFormViewBinding.postalCode
|
|
271
309
|
|
|
272
|
-
cardNumberEditText.onFocusChangeListener =
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
310
|
+
cardNumberEditText.onFocusChangeListener =
|
|
311
|
+
OnFocusChangeListener { _, hasFocus ->
|
|
312
|
+
currentFocusedField =
|
|
313
|
+
if (hasFocus) CardInputListener.FocusField.CardNumber.toString() else null
|
|
314
|
+
onChangeFocus()
|
|
315
|
+
}
|
|
316
|
+
cvcEditText.onFocusChangeListener =
|
|
317
|
+
OnFocusChangeListener { _, hasFocus ->
|
|
318
|
+
currentFocusedField = if (hasFocus) CardInputListener.FocusField.Cvc.toString() else null
|
|
319
|
+
onChangeFocus()
|
|
320
|
+
}
|
|
321
|
+
expiryEditText.onFocusChangeListener =
|
|
322
|
+
OnFocusChangeListener { _, hasFocus ->
|
|
323
|
+
currentFocusedField =
|
|
324
|
+
if (hasFocus) CardInputListener.FocusField.ExpiryDate.toString() else null
|
|
325
|
+
onChangeFocus()
|
|
326
|
+
}
|
|
327
|
+
postalCodeEditText.onFocusChangeListener =
|
|
328
|
+
OnFocusChangeListener { _, hasFocus ->
|
|
329
|
+
currentFocusedField =
|
|
330
|
+
if (hasFocus) CardInputListener.FocusField.PostalCode.toString() else null
|
|
331
|
+
onChangeFocus()
|
|
332
|
+
}
|
|
288
333
|
}
|
|
289
334
|
|
|
290
335
|
private fun setPostalCodeFilter() {
|
|
291
|
-
cardFormViewBinding.postalCode.filters =
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
336
|
+
cardFormViewBinding.postalCode.filters =
|
|
337
|
+
arrayOf(
|
|
338
|
+
*cardFormViewBinding.postalCode.filters,
|
|
339
|
+
createPostalCodeInputFilter(),
|
|
340
|
+
)
|
|
295
341
|
}
|
|
296
342
|
|
|
297
343
|
@SuppressLint("RestrictedApi")
|
|
@@ -316,10 +362,12 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
316
362
|
post(mLayoutRunnable)
|
|
317
363
|
}
|
|
318
364
|
|
|
319
|
-
private val mLayoutRunnable =
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
365
|
+
private val mLayoutRunnable =
|
|
366
|
+
Runnable {
|
|
367
|
+
measure(
|
|
368
|
+
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
369
|
+
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
|
|
370
|
+
)
|
|
371
|
+
layout(left, top, right, bottom)
|
|
372
|
+
}
|
|
325
373
|
}
|
|
@@ -2,23 +2,28 @@ package com.reactnativestripesdk
|
|
|
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 = CardFormViewManager.REACT_CLASS)
|
|
10
11
|
class CardFormViewManager : SimpleViewManager<CardFormView>() {
|
|
11
|
-
override fun getName() =
|
|
12
|
+
override fun getName() = REACT_CLASS
|
|
12
13
|
|
|
13
14
|
private var reactContextRef: ThemedReactContext? = null
|
|
14
15
|
|
|
15
|
-
override fun getExportedCustomDirectEventTypeConstants()
|
|
16
|
-
|
|
17
|
-
CardFocusEvent.EVENT_NAME
|
|
18
|
-
CardFormCompleteEvent.EVENT_NAME
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
override fun receiveCommand(
|
|
16
|
+
override fun getExportedCustomDirectEventTypeConstants() =
|
|
17
|
+
mutableMapOf(
|
|
18
|
+
CardFocusEvent.EVENT_NAME to mutableMapOf("registrationName" to "onFocusChange"),
|
|
19
|
+
CardFormCompleteEvent.EVENT_NAME to mutableMapOf("registrationName" to "onFormComplete"),
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
override fun receiveCommand(
|
|
23
|
+
root: CardFormView,
|
|
24
|
+
commandId: String?,
|
|
25
|
+
args: ReadableArray?,
|
|
26
|
+
) {
|
|
22
27
|
when (commandId) {
|
|
23
28
|
"focus" -> root.requestFocusFromJS()
|
|
24
29
|
"blur" -> root.requestBlurFromJS()
|
|
@@ -27,48 +32,73 @@ class CardFormViewManager : SimpleViewManager<CardFormView>() {
|
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
@ReactProp(name = "dangerouslyGetFullCardDetails")
|
|
30
|
-
fun setDangerouslyGetFullCardDetails(
|
|
35
|
+
fun setDangerouslyGetFullCardDetails(
|
|
36
|
+
view: CardFormView,
|
|
37
|
+
dangerouslyGetFullCardDetails: Boolean = false,
|
|
38
|
+
) {
|
|
31
39
|
view.setDangerouslyGetFullCardDetails(dangerouslyGetFullCardDetails)
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
@ReactProp(name = "postalCodeEnabled")
|
|
35
|
-
fun setPostalCodeEnabled(
|
|
43
|
+
fun setPostalCodeEnabled(
|
|
44
|
+
view: CardFormView,
|
|
45
|
+
postalCodeEnabled: Boolean = false,
|
|
46
|
+
) {
|
|
36
47
|
view.setPostalCodeEnabled(postalCodeEnabled)
|
|
37
48
|
}
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
@ReactProp(name = "placeholders")
|
|
51
|
+
fun setPlaceHolders(
|
|
52
|
+
view: CardFormView,
|
|
53
|
+
placeholders: ReadableMap,
|
|
54
|
+
) {
|
|
55
|
+
view.setPlaceHolders(placeholders)
|
|
56
|
+
}
|
|
43
57
|
|
|
44
58
|
@ReactProp(name = "autofocus")
|
|
45
|
-
fun setAutofocus(
|
|
59
|
+
fun setAutofocus(
|
|
60
|
+
view: CardFormView,
|
|
61
|
+
autofocus: Boolean = false,
|
|
62
|
+
) {
|
|
46
63
|
view.setAutofocus(autofocus)
|
|
47
64
|
}
|
|
48
65
|
|
|
49
66
|
@ReactProp(name = "cardStyle")
|
|
50
|
-
fun setCardStyle(
|
|
67
|
+
fun setCardStyle(
|
|
68
|
+
view: CardFormView,
|
|
69
|
+
cardStyle: ReadableMap,
|
|
70
|
+
) {
|
|
51
71
|
view.setCardStyle(cardStyle)
|
|
52
72
|
}
|
|
53
73
|
|
|
54
74
|
@ReactProp(name = "defaultValues")
|
|
55
|
-
fun setDefaultValues(
|
|
75
|
+
fun setDefaultValues(
|
|
76
|
+
view: CardFormView,
|
|
77
|
+
defaults: ReadableMap,
|
|
78
|
+
) {
|
|
56
79
|
view.setDefaultValues(defaults)
|
|
57
80
|
}
|
|
58
81
|
|
|
59
82
|
@ReactProp(name = "disabled")
|
|
60
|
-
fun setDisabled(
|
|
83
|
+
fun setDisabled(
|
|
84
|
+
view: CardFormView,
|
|
85
|
+
isDisabled: Boolean,
|
|
86
|
+
) {
|
|
61
87
|
view.setDisabled(isDisabled)
|
|
62
88
|
}
|
|
63
89
|
|
|
64
90
|
@ReactProp(name = "preferredNetworks")
|
|
65
|
-
fun setPreferredNetworks(
|
|
91
|
+
fun setPreferredNetworks(
|
|
92
|
+
view: CardFormView,
|
|
93
|
+
preferredNetworks: ReadableArray?,
|
|
94
|
+
) {
|
|
66
95
|
val networks = preferredNetworks?.toArrayList()?.filterIsInstance<Int>()?.let { ArrayList(it) }
|
|
67
96
|
view.setPreferredNetworks(networks)
|
|
68
97
|
}
|
|
69
98
|
|
|
70
99
|
override fun createViewInstance(reactContext: ThemedReactContext): CardFormView {
|
|
71
|
-
val stripeSdkModule: StripeSdkModule? =
|
|
100
|
+
val stripeSdkModule: StripeSdkModule? =
|
|
101
|
+
reactContext.getNativeModule(StripeSdkModule::class.java)
|
|
72
102
|
val view = CardFormView(reactContext)
|
|
73
103
|
|
|
74
104
|
reactContextRef = reactContext
|
|
@@ -80,8 +110,13 @@ class CardFormViewManager : SimpleViewManager<CardFormView>() {
|
|
|
80
110
|
override fun onDropViewInstance(view: CardFormView) {
|
|
81
111
|
super.onDropViewInstance(view)
|
|
82
112
|
|
|
83
|
-
val stripeSdkModule: StripeSdkModule? =
|
|
113
|
+
val stripeSdkModule: StripeSdkModule? =
|
|
114
|
+
reactContextRef?.getNativeModule(StripeSdkModule::class.java)
|
|
84
115
|
stripeSdkModule?.cardFormView = null
|
|
85
116
|
reactContextRef = null
|
|
86
117
|
}
|
|
118
|
+
|
|
119
|
+
companion object {
|
|
120
|
+
const val REACT_CLASS = "CardForm"
|
|
121
|
+
}
|
|
87
122
|
}
|
package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt
CHANGED
|
@@ -5,16 +5,16 @@ import android.view.LayoutInflater
|
|
|
5
5
|
import android.view.View
|
|
6
6
|
import android.view.ViewGroup
|
|
7
7
|
import android.widget.FrameLayout
|
|
8
|
-
import androidx.appcompat.app.AppCompatActivity
|
|
9
8
|
import androidx.fragment.app.Fragment
|
|
10
|
-
import com.facebook.react.bridge.Arguments
|
|
11
9
|
import com.facebook.react.bridge.Promise
|
|
12
10
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
-
import com.reactnativestripesdk.utils
|
|
11
|
+
import com.reactnativestripesdk.utils.ErrorType
|
|
14
12
|
import com.reactnativestripesdk.utils.createError
|
|
15
13
|
import com.reactnativestripesdk.utils.createResult
|
|
14
|
+
import com.reactnativestripesdk.utils.mapFromFinancialConnectionsEvent
|
|
16
15
|
import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
|
|
17
16
|
import com.reactnativestripesdk.utils.mapFromSetupIntentResult
|
|
17
|
+
import com.reactnativestripesdk.utils.removeFragment
|
|
18
18
|
import com.stripe.android.financialconnections.FinancialConnections
|
|
19
19
|
import com.stripe.android.model.PaymentIntent
|
|
20
20
|
import com.stripe.android.model.SetupIntent
|
|
@@ -29,8 +29,8 @@ class CollectBankAccountLauncherFragment(
|
|
|
29
29
|
private val stripeAccountId: String?,
|
|
30
30
|
private val clientSecret: String,
|
|
31
31
|
private val isPaymentIntent: Boolean,
|
|
32
|
-
private val collectParams:
|
|
33
|
-
private val promise: Promise
|
|
32
|
+
private val collectParams: CollectBankAccountConfiguration.USBankAccount,
|
|
33
|
+
private val promise: Promise,
|
|
34
34
|
) : Fragment() {
|
|
35
35
|
private lateinit var collectBankAccountLauncher: CollectBankAccountLauncher
|
|
36
36
|
|
|
@@ -46,33 +46,35 @@ class CollectBankAccountLauncherFragment(
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
override fun onCreateView(
|
|
50
|
-
|
|
49
|
+
override fun onCreateView(
|
|
50
|
+
inflater: LayoutInflater,
|
|
51
|
+
container: ViewGroup?,
|
|
52
|
+
savedInstanceState: Bundle?,
|
|
53
|
+
): View {
|
|
51
54
|
collectBankAccountLauncher = createBankAccountLauncher()
|
|
52
55
|
|
|
53
|
-
return FrameLayout(requireActivity()).also {
|
|
54
|
-
it.visibility = View.GONE
|
|
55
|
-
}
|
|
56
|
+
return FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
override fun onViewCreated(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
override fun onViewCreated(
|
|
60
|
+
view: View,
|
|
61
|
+
savedInstanceState: Bundle?,
|
|
62
|
+
) {
|
|
63
|
+
super.onViewCreated(view, savedInstanceState)
|
|
62
64
|
|
|
63
65
|
if (isPaymentIntent) {
|
|
64
66
|
collectBankAccountLauncher.presentWithPaymentIntent(
|
|
65
67
|
publishableKey,
|
|
66
68
|
stripeAccountId,
|
|
67
69
|
clientSecret,
|
|
68
|
-
collectParams
|
|
70
|
+
collectParams,
|
|
69
71
|
)
|
|
70
72
|
} else {
|
|
71
73
|
collectBankAccountLauncher.presentWithSetupIntent(
|
|
72
74
|
publishableKey,
|
|
73
75
|
stripeAccountId,
|
|
74
76
|
clientSecret,
|
|
75
|
-
collectParams
|
|
77
|
+
collectParams,
|
|
76
78
|
)
|
|
77
79
|
}
|
|
78
80
|
}
|
|
@@ -84,24 +86,32 @@ class CollectBankAccountLauncherFragment(
|
|
|
84
86
|
FinancialConnections.clearEventListener()
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
private fun createBankAccountLauncher(): CollectBankAccountLauncher
|
|
88
|
-
|
|
89
|
+
private fun createBankAccountLauncher(): CollectBankAccountLauncher =
|
|
90
|
+
CollectBankAccountLauncher.create(this) { result ->
|
|
89
91
|
when (result) {
|
|
90
92
|
is CollectBankAccountResult.Completed -> {
|
|
91
93
|
val intent = result.response.intent
|
|
92
94
|
if (intent.status === StripeIntent.Status.RequiresPaymentMethod) {
|
|
93
|
-
promise.resolve(
|
|
95
|
+
promise.resolve(
|
|
96
|
+
createError(ErrorType.Canceled.toString(), "Bank account collection was canceled."),
|
|
97
|
+
)
|
|
94
98
|
} else if (intent.status === StripeIntent.Status.RequiresConfirmation) {
|
|
95
99
|
promise.resolve(
|
|
96
|
-
if (isPaymentIntent)
|
|
97
|
-
createResult(
|
|
98
|
-
|
|
100
|
+
if (isPaymentIntent) {
|
|
101
|
+
createResult(
|
|
102
|
+
"paymentIntent",
|
|
103
|
+
mapFromPaymentIntentResult(intent as PaymentIntent),
|
|
104
|
+
)
|
|
105
|
+
} else {
|
|
99
106
|
createResult("setupIntent", mapFromSetupIntentResult(intent as SetupIntent))
|
|
107
|
+
},
|
|
100
108
|
)
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
111
|
is CollectBankAccountResult.Cancelled -> {
|
|
104
|
-
promise.resolve(
|
|
112
|
+
promise.resolve(
|
|
113
|
+
createError(ErrorType.Canceled.toString(), "Bank account collection was canceled."),
|
|
114
|
+
)
|
|
105
115
|
}
|
|
106
116
|
is CollectBankAccountResult.Failed -> {
|
|
107
117
|
promise.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
@@ -109,7 +119,6 @@ class CollectBankAccountLauncherFragment(
|
|
|
109
119
|
}
|
|
110
120
|
removeFragment(context)
|
|
111
121
|
}
|
|
112
|
-
}
|
|
113
122
|
|
|
114
123
|
companion object {
|
|
115
124
|
internal const val TAG = "collect_bank_account_launcher_fragment"
|