@stripe/stripe-react-native 0.42.0 → 0.44.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 +26 -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 +8 -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 +422 -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 +656 -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 +13 -7
- package/ios/FinancialConnections.swift +6 -2
- package/ios/StripeSdk+CustomerSheet.swift +3 -1
- package/ios/StripeSdk+PaymentSheet.swift +86 -21
- 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 +16 -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 +91 -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/helpers.ts +2 -1
- package/src/types/Common.ts +3 -0
- package/src/types/CustomerSheet.ts +11 -0
- package/src/types/FinancialConnections.ts +3 -0
- package/src/types/PaymentMethod.ts +5 -1
- package/src/types/PaymentSheet.ts +85 -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
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt
CHANGED
|
@@ -3,15 +3,18 @@ package com.reactnativestripesdk.pushprovisioning
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import com.bumptech.glide.Glide
|
|
5
5
|
import com.facebook.react.bridge.ReadableMap
|
|
6
|
-
import com.facebook.react.
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
7
7
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
8
8
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
9
9
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
class AddToWalletButtonManager(
|
|
11
|
+
@ReactModule(name = AddToWalletButtonManager.REACT_CLASS)
|
|
12
|
+
class AddToWalletButtonManager(
|
|
13
|
+
applicationContext: Context,
|
|
14
|
+
) : SimpleViewManager<AddToWalletButtonView>() {
|
|
13
15
|
private val requestManager = Glide.with(applicationContext)
|
|
14
|
-
|
|
16
|
+
|
|
17
|
+
override fun getName() = REACT_CLASS
|
|
15
18
|
|
|
16
19
|
override fun onDropViewInstance(view: AddToWalletButtonView) {
|
|
17
20
|
view.onDropViewInstance()
|
|
@@ -23,33 +26,48 @@ class AddToWalletButtonManager(applicationContext: Context) : SimpleViewManager<
|
|
|
23
26
|
view.onAfterUpdateTransaction()
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
override fun createViewInstance(reactContext: ThemedReactContext): AddToWalletButtonView
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
+
override fun createViewInstance(reactContext: ThemedReactContext): AddToWalletButtonView =
|
|
30
|
+
AddToWalletButtonView(reactContext, requestManager)
|
|
29
31
|
|
|
30
|
-
override fun getExportedCustomDirectEventTypeConstants()
|
|
31
|
-
|
|
32
|
-
AddToWalletCompleteEvent.EVENT_NAME
|
|
32
|
+
override fun getExportedCustomDirectEventTypeConstants() =
|
|
33
|
+
mutableMapOf(
|
|
34
|
+
AddToWalletCompleteEvent.EVENT_NAME to
|
|
35
|
+
mutableMapOf("registrationName" to "onCompleteAction"),
|
|
33
36
|
)
|
|
34
|
-
}
|
|
35
37
|
|
|
36
38
|
@ReactProp(name = "androidAssetSource")
|
|
37
|
-
fun source(
|
|
39
|
+
fun source(
|
|
40
|
+
view: AddToWalletButtonView,
|
|
41
|
+
source: ReadableMap,
|
|
42
|
+
) {
|
|
38
43
|
view.setSourceMap(source)
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
@ReactProp(name = "cardDetails")
|
|
42
|
-
fun cardDetails(
|
|
47
|
+
fun cardDetails(
|
|
48
|
+
view: AddToWalletButtonView,
|
|
49
|
+
cardDetails: ReadableMap,
|
|
50
|
+
) {
|
|
43
51
|
view.setCardDetails(cardDetails)
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
@ReactProp(name = "ephemeralKey")
|
|
47
|
-
fun ephemeralKey(
|
|
55
|
+
fun ephemeralKey(
|
|
56
|
+
view: AddToWalletButtonView,
|
|
57
|
+
ephemeralKey: ReadableMap,
|
|
58
|
+
) {
|
|
48
59
|
view.setEphemeralKey(ephemeralKey)
|
|
49
60
|
}
|
|
50
61
|
|
|
51
62
|
@ReactProp(name = "token")
|
|
52
|
-
fun token(
|
|
63
|
+
fun token(
|
|
64
|
+
view: AddToWalletButtonView,
|
|
65
|
+
token: ReadableMap?,
|
|
66
|
+
) {
|
|
53
67
|
view.setToken(token)
|
|
54
68
|
}
|
|
69
|
+
|
|
70
|
+
companion object {
|
|
71
|
+
const val REACT_CLASS = "AddToWalletButton"
|
|
72
|
+
}
|
|
55
73
|
}
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.reactnativestripesdk.pushprovisioning
|
|
2
2
|
|
|
3
|
+
import android.annotation.SuppressLint
|
|
3
4
|
import android.content.res.ColorStateList
|
|
4
5
|
import android.graphics.Color
|
|
5
6
|
import android.graphics.drawable.Drawable
|
|
@@ -16,18 +17,19 @@ import com.bumptech.glide.request.target.Target
|
|
|
16
17
|
import com.facebook.react.bridge.ReadableMap
|
|
17
18
|
import com.facebook.react.bridge.WritableMap
|
|
18
19
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
19
|
-
import com.facebook.react.uimanager.
|
|
20
|
-
import com.facebook.react.uimanager.events.EventDispatcher
|
|
20
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
21
21
|
import com.reactnativestripesdk.utils.createError
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
class AddToWalletButtonView(
|
|
23
|
+
@SuppressLint("ViewConstructor")
|
|
24
|
+
class AddToWalletButtonView(
|
|
25
|
+
private val context: ThemedReactContext,
|
|
26
|
+
private val requestManager: RequestManager,
|
|
27
|
+
) : AppCompatImageView(context) {
|
|
25
28
|
private var cardDetails: ReadableMap? = null
|
|
26
29
|
private var ephemeralKey: String? = null
|
|
27
30
|
private var sourceMap: ReadableMap? = null
|
|
28
31
|
private var token: ReadableMap? = null
|
|
29
32
|
|
|
30
|
-
private var eventDispatcher: EventDispatcher? = context.getNativeModule(UIManagerModule::class.java)?.eventDispatcher
|
|
31
33
|
private var loadedSource: Any? = null
|
|
32
34
|
private var heightOverride: Int = 0
|
|
33
35
|
private var widthOverride: Int = 0
|
|
@@ -42,17 +44,26 @@ class AddToWalletButtonView(private val context: ThemedReactContext, private val
|
|
|
42
44
|
this,
|
|
43
45
|
cardDescription,
|
|
44
46
|
ephemeralKey,
|
|
45
|
-
token
|
|
46
|
-
} ?: run {
|
|
47
|
-
dispatchEvent(
|
|
48
|
-
createError("Failed", "Missing parameters. `ephemeralKey` must be supplied in the props to <AddToWalletButton />")
|
|
47
|
+
token,
|
|
49
48
|
)
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
?: run {
|
|
51
|
+
dispatchEvent(
|
|
52
|
+
createError(
|
|
53
|
+
"Failed",
|
|
54
|
+
"Missing parameters. `ephemeralKey` must be supplied in the props to <AddToWalletButton />",
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
}
|
|
55
58
|
}
|
|
59
|
+
?: run {
|
|
60
|
+
dispatchEvent(
|
|
61
|
+
createError(
|
|
62
|
+
"Failed",
|
|
63
|
+
"Missing parameters. `cardDetails.cardDescription` must be supplied in the props to <AddToWalletButton />",
|
|
64
|
+
),
|
|
65
|
+
)
|
|
66
|
+
}
|
|
56
67
|
return true
|
|
57
68
|
}
|
|
58
69
|
|
|
@@ -78,23 +89,38 @@ class AddToWalletButtonView(private val context: ThemedReactContext, private val
|
|
|
78
89
|
|
|
79
90
|
requestManager
|
|
80
91
|
.load(sourceToLoad)
|
|
81
|
-
.addListener(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
.addListener(
|
|
93
|
+
object : RequestListener<Drawable> {
|
|
94
|
+
override fun onLoadFailed(
|
|
95
|
+
e: GlideException?,
|
|
96
|
+
model: Any?,
|
|
97
|
+
target: Target<Drawable>?,
|
|
98
|
+
isFirstResource: Boolean,
|
|
99
|
+
): Boolean {
|
|
100
|
+
dispatchEvent(
|
|
101
|
+
createError("Failed", "Failed to load the source from $sourceToLoad"),
|
|
102
|
+
)
|
|
103
|
+
return true
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
override fun onResourceReady(
|
|
107
|
+
resource: Drawable?,
|
|
108
|
+
model: Any?,
|
|
109
|
+
target: Target<Drawable>?,
|
|
110
|
+
dataSource: DataSource?,
|
|
111
|
+
isFirstResource: Boolean,
|
|
112
|
+
): Boolean {
|
|
113
|
+
setImageDrawable(
|
|
114
|
+
RippleDrawable(
|
|
115
|
+
ColorStateList.valueOf(Color.parseColor("#e0e0e0")),
|
|
116
|
+
resource,
|
|
117
|
+
null,
|
|
118
|
+
),
|
|
119
|
+
)
|
|
120
|
+
return true
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
).centerCrop()
|
|
98
124
|
.override((widthOverride * scale).toInt(), (heightOverride * scale).toInt())
|
|
99
125
|
.into(this)
|
|
100
126
|
}
|
|
@@ -113,7 +139,12 @@ class AddToWalletButtonView(private val context: ThemedReactContext, private val
|
|
|
113
139
|
return null
|
|
114
140
|
}
|
|
115
141
|
|
|
116
|
-
override fun onSizeChanged(
|
|
142
|
+
override fun onSizeChanged(
|
|
143
|
+
w: Int,
|
|
144
|
+
h: Int,
|
|
145
|
+
oldw: Int,
|
|
146
|
+
oldh: Int,
|
|
147
|
+
) {
|
|
117
148
|
super.onSizeChanged(w, h, oldw, oldh)
|
|
118
149
|
if (w > 0 && h > 0) {
|
|
119
150
|
heightOverride = h
|
|
@@ -145,11 +176,6 @@ class AddToWalletButtonView(private val context: ThemedReactContext, private val
|
|
|
145
176
|
}
|
|
146
177
|
|
|
147
178
|
fun dispatchEvent(error: WritableMap?) {
|
|
148
|
-
|
|
149
|
-
AddToWalletCompleteEvent(
|
|
150
|
-
id,
|
|
151
|
-
error
|
|
152
|
-
)
|
|
153
|
-
)
|
|
179
|
+
UIManagerHelper.getEventDispatcherForReactTag(context, id)?.dispatchEvent(AddToWalletCompleteEvent(context.surfaceId, id, error))
|
|
154
180
|
}
|
|
155
181
|
}
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletCompleteEvent.kt
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
package com.reactnativestripesdk.pushprovisioning
|
|
2
|
+
|
|
2
3
|
import com.facebook.react.bridge.WritableMap
|
|
3
4
|
import com.facebook.react.uimanager.events.Event
|
|
4
|
-
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
5
5
|
|
|
6
|
-
internal class AddToWalletCompleteEvent
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
internal class AddToWalletCompleteEvent(
|
|
7
|
+
surfaceId: Int,
|
|
8
|
+
viewTag: Int,
|
|
9
|
+
private val error: WritableMap?,
|
|
10
|
+
) : Event<AddToWalletCompleteEvent>(surfaceId, viewTag) {
|
|
11
|
+
override fun getEventName(): String = EVENT_NAME
|
|
10
12
|
|
|
11
|
-
override fun
|
|
12
|
-
rctEventEmitter.receiveEvent(viewTag, eventName, serializeEventData())
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
private fun serializeEventData(): WritableMap? {
|
|
16
|
-
return error
|
|
17
|
-
}
|
|
13
|
+
override fun getEventData() = error
|
|
18
14
|
|
|
19
15
|
companion object {
|
|
20
|
-
const val EVENT_NAME = "
|
|
16
|
+
const val EVENT_NAME = "topCompleteAction"
|
|
21
17
|
}
|
|
22
18
|
}
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/EphemeralKeyProvider.kt
CHANGED
|
@@ -4,32 +4,30 @@ import android.os.Parcel
|
|
|
4
4
|
import android.os.Parcelable
|
|
5
5
|
import com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider
|
|
6
6
|
|
|
7
|
+
class EphemeralKeyProvider(
|
|
8
|
+
private val ephemeralKey: String,
|
|
9
|
+
) : PushProvisioningEphemeralKeyProvider {
|
|
10
|
+
private constructor(parcel: Parcel) : this(ephemeralKey = parcel.readString() ?: "")
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
override fun describeContents(): Int = hashCode()
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
override fun describeContents(): Int {
|
|
15
|
-
return hashCode()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
override fun writeToParcel(dest: Parcel, flags: Int) {
|
|
14
|
+
override fun writeToParcel(
|
|
15
|
+
dest: Parcel,
|
|
16
|
+
flags: Int,
|
|
17
|
+
) {
|
|
19
18
|
dest.writeString(ephemeralKey)
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
override fun createEphemeralKey(
|
|
21
|
+
override fun createEphemeralKey(
|
|
22
|
+
apiVersion: String,
|
|
23
|
+
keyUpdateListener: com.stripe.android.pushProvisioning.EphemeralKeyUpdateListener,
|
|
24
|
+
) {
|
|
23
25
|
keyUpdateListener.onKeyUpdate(ephemeralKey)
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
companion object CREATOR : Parcelable.Creator<EphemeralKeyProvider> {
|
|
27
|
-
override fun createFromParcel(parcel: Parcel): EphemeralKeyProvider
|
|
28
|
-
return EphemeralKeyProvider(parcel)
|
|
29
|
-
}
|
|
29
|
+
override fun createFromParcel(parcel: Parcel): EphemeralKeyProvider = EphemeralKeyProvider(parcel)
|
|
30
30
|
|
|
31
|
-
override fun newArray(size: Int): Array<EphemeralKeyProvider?>
|
|
32
|
-
return arrayOfNulls(size)
|
|
33
|
-
}
|
|
31
|
+
override fun newArray(size: Int): Array<EphemeralKeyProvider?> = arrayOfNulls(size)
|
|
34
32
|
}
|
|
35
33
|
}
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt
CHANGED
|
@@ -14,37 +14,34 @@ import com.reactnativestripesdk.utils.mapError
|
|
|
14
14
|
import com.stripe.android.pushProvisioning.PushProvisioningActivity
|
|
15
15
|
import com.stripe.android.pushProvisioning.PushProvisioningActivityStarter
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
object PushProvisioningProxy {
|
|
19
18
|
private const val TAG = "StripePushProvisioning"
|
|
20
19
|
private var description = "Added by Stripe"
|
|
21
20
|
private var tokenRequiringTokenization: ReadableMap? = null
|
|
22
21
|
|
|
23
|
-
fun getApiVersion(): String
|
|
24
|
-
|
|
22
|
+
fun getApiVersion(): String =
|
|
23
|
+
try {
|
|
25
24
|
Class.forName("com.stripe.android.pushProvisioning.PushProvisioningActivity")
|
|
26
25
|
PushProvisioningActivity.API_VERSION
|
|
27
26
|
} catch (e: Exception) {
|
|
28
27
|
Log.e(TAG, "PushProvisioning dependency not found")
|
|
29
28
|
""
|
|
30
29
|
}
|
|
31
|
-
}
|
|
32
30
|
|
|
33
|
-
fun isNFCEnabled(context: ReactApplicationContext): Boolean
|
|
34
|
-
|
|
31
|
+
fun isNFCEnabled(context: ReactApplicationContext): Boolean =
|
|
32
|
+
if (context.packageManager.hasSystemFeature(PackageManager.FEATURE_NFC)) {
|
|
35
33
|
val adapter = NfcAdapter.getDefaultAdapter(context)
|
|
36
34
|
adapter?.isEnabled ?: false
|
|
37
35
|
} else {
|
|
38
36
|
false
|
|
39
37
|
}
|
|
40
|
-
}
|
|
41
38
|
|
|
42
39
|
fun invoke(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
context: ReactApplicationContext,
|
|
41
|
+
view: AddToWalletButtonView,
|
|
42
|
+
cardDescription: String,
|
|
43
|
+
ephemeralKey: String,
|
|
44
|
+
token: ReadableMap?,
|
|
48
45
|
) {
|
|
49
46
|
try {
|
|
50
47
|
Class.forName("com.stripe.android.pushProvisioning.PushProvisioningActivityStarter")
|
|
@@ -52,65 +49,84 @@ object PushProvisioningProxy {
|
|
|
52
49
|
tokenRequiringTokenization = token
|
|
53
50
|
createActivityEventListener(context, view)
|
|
54
51
|
context.currentActivity?.let {
|
|
55
|
-
DefaultPushProvisioningProxy()
|
|
56
|
-
it,
|
|
57
|
-
description,
|
|
58
|
-
EphemeralKeyProvider(ephemeralKey)
|
|
59
|
-
)
|
|
60
|
-
} ?: run {
|
|
61
|
-
view.dispatchEvent(
|
|
62
|
-
createError(
|
|
63
|
-
"Failed",
|
|
64
|
-
"Activity doesn't exist yet. You can safely retry.")
|
|
65
|
-
)
|
|
52
|
+
DefaultPushProvisioningProxy()
|
|
53
|
+
.beginPushProvisioning(it, description, EphemeralKeyProvider(ephemeralKey))
|
|
66
54
|
}
|
|
55
|
+
?: run {
|
|
56
|
+
view.dispatchEvent(
|
|
57
|
+
createError("Failed", "Activity doesn't exist yet. You can safely retry."),
|
|
58
|
+
)
|
|
59
|
+
}
|
|
67
60
|
} catch (e: Exception) {
|
|
68
61
|
Log.e(TAG, "There was a problem using Stripe Android PushProvisioning: " + e.message)
|
|
69
62
|
}
|
|
70
63
|
}
|
|
71
64
|
|
|
72
|
-
fun isCardInWallet(
|
|
65
|
+
fun isCardInWallet(
|
|
66
|
+
activity: Activity,
|
|
67
|
+
cardLastFour: String,
|
|
68
|
+
callback: TokenCheckHandler,
|
|
69
|
+
) {
|
|
73
70
|
TapAndPayProxy.findExistingToken(activity, cardLastFour, callback)
|
|
74
71
|
}
|
|
75
72
|
|
|
76
|
-
private fun createActivityEventListener(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
73
|
+
private fun createActivityEventListener(
|
|
74
|
+
context: ReactApplicationContext,
|
|
75
|
+
view: AddToWalletButtonView,
|
|
76
|
+
) {
|
|
77
|
+
val listener =
|
|
78
|
+
object : BaseActivityEventListener() {
|
|
79
|
+
override fun onActivityResult(
|
|
80
|
+
activity: Activity,
|
|
81
|
+
requestCode: Int,
|
|
82
|
+
resultCode: Int,
|
|
83
|
+
data: Intent?,
|
|
84
|
+
) {
|
|
85
|
+
super.onActivityResult(activity, requestCode, resultCode, data)
|
|
86
|
+
if (requestCode == TapAndPayProxy.REQUEST_CODE_TOKENIZE) {
|
|
87
|
+
view.dispatchEvent(
|
|
88
|
+
if (resultCode == RESULT_OK) {
|
|
89
|
+
null
|
|
92
90
|
} else {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
mapError("Failed", "Failed to verify identity.", null, null, null, null)
|
|
92
|
+
},
|
|
93
|
+
)
|
|
94
|
+
} else if (requestCode == PushProvisioningActivityStarter.REQUEST_CODE) {
|
|
95
|
+
if (resultCode == PushProvisioningActivity.RESULT_OK) {
|
|
96
|
+
tokenRequiringTokenization?.let { tokenRequiringTokenization ->
|
|
97
|
+
val tokenReferenceId = tokenRequiringTokenization.getString("id")
|
|
98
|
+
if (tokenReferenceId.isNullOrBlank()) {
|
|
99
|
+
view.dispatchEvent(
|
|
100
|
+
mapError(
|
|
101
|
+
"Failed",
|
|
102
|
+
"Token object passed to `<AddToWalletButton />` is missing the `id` field.",
|
|
103
|
+
null,
|
|
104
|
+
null,
|
|
105
|
+
null,
|
|
106
|
+
null,
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
} else {
|
|
110
|
+
TapAndPayProxy.tokenize(
|
|
111
|
+
activity,
|
|
112
|
+
tokenReferenceId,
|
|
113
|
+
tokenRequiringTokenization,
|
|
114
|
+
description,
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
} ?: run { view.dispatchEvent(null) }
|
|
118
|
+
} else if (resultCode == PushProvisioningActivity.RESULT_ERROR) {
|
|
119
|
+
data?.let {
|
|
120
|
+
val error: PushProvisioningActivityStarter.Error =
|
|
121
|
+
PushProvisioningActivityStarter.Error.fromIntent(data)
|
|
122
|
+
view.dispatchEvent(
|
|
123
|
+
mapError(error.code.toString(), error.message, null, null, null, null),
|
|
98
124
|
)
|
|
99
125
|
}
|
|
100
|
-
} ?: run {
|
|
101
|
-
view.dispatchEvent(null)
|
|
102
|
-
}
|
|
103
|
-
} else if (resultCode == PushProvisioningActivity.RESULT_ERROR) {
|
|
104
|
-
data?.let {
|
|
105
|
-
val error: PushProvisioningActivityStarter.Error = PushProvisioningActivityStarter.Error.fromIntent(data)
|
|
106
|
-
view.dispatchEvent(
|
|
107
|
-
mapError(error.code.toString(), error.message, null, null, null, null)
|
|
108
|
-
)
|
|
109
126
|
}
|
|
110
127
|
}
|
|
111
128
|
}
|
|
112
129
|
}
|
|
113
|
-
}
|
|
114
130
|
context.addActivityEventListener(listener)
|
|
115
131
|
}
|
|
116
132
|
}
|
|
@@ -119,11 +135,11 @@ class DefaultPushProvisioningProxy {
|
|
|
119
135
|
fun beginPushProvisioning(
|
|
120
136
|
activity: Activity,
|
|
121
137
|
description: String,
|
|
122
|
-
provider: EphemeralKeyProvider
|
|
138
|
+
provider: EphemeralKeyProvider,
|
|
123
139
|
) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
140
|
+
PushProvisioningActivityStarter(
|
|
141
|
+
activity,
|
|
142
|
+
PushProvisioningActivityStarter.Args(description, provider, false),
|
|
143
|
+
).startForResult()
|
|
128
144
|
}
|
|
129
145
|
}
|