@stripe/stripe-react-native 0.57.0 → 0.57.1
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/android/build.gradle +76 -118
- package/android/gradle.properties +1 -1
- package/android/settings.gradle +2 -0
- package/android/spotless.gradle +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +20 -17
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +13 -11
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +17 -21
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherManager.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +4 -11
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +46 -119
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +0 -8
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetManager.kt +13 -15
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +7 -5
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarManager.kt +31 -0
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +120 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +228 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherManager.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +73 -30
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +19 -245
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +52 -14
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +15 -35
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +5 -10
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +90 -77
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +6 -4
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +13 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +41 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +92 -44
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +118 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +922 -0
- package/android/src/test/java/com/facebook/testutils/shadows/ShadowArguments.kt +29 -0
- package/android/src/test/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManagerTest.kt +163 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +976 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetAppearanceTest.kt +801 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +523 -0
- package/android/src/test/java/com/reactnativestripesdk/addresssheet/AddressSheetViewTest.kt +551 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +567 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +456 -0
- package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +43 -0
- package/android/src/test/resources/robolectric.properties +2 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +3 -3
- package/ios/AddressSheet/AddressSheetView.swift +25 -25
- package/ios/AddressSheet/AddressSheetViewManager.swift +2 -2
- package/ios/ApplePayButtonManager.swift +1 -1
- package/ios/ApplePayButtonView.swift +9 -10
- package/ios/ApplePayUtils.swift +51 -51
- package/ios/ApplePayViewController.swift +25 -29
- package/ios/AuBECSDebitFormManager.swift +1 -1
- package/ios/AuBECSDebitFormView.swift +13 -15
- package/ios/CardFieldManager.swift +4 -4
- package/ios/CardFieldView.swift +9 -9
- package/ios/CardFormManager.swift +3 -3
- package/ios/CardFormView.swift +28 -28
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +97 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +133 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.m +16 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.swift +17 -0
- package/ios/CustomerSheet/CustomerSheetUtils.swift +15 -16
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +19 -19
- package/ios/EmbeddedPaymentElementView.swift +2 -2
- package/ios/Errors.swift +22 -23
- package/ios/FinancialConnections.swift +37 -37
- package/ios/Mappers.swift +210 -71
- package/ios/NavigationBarManager.m +13 -0
- package/ios/NavigationBarManager.swift +17 -0
- package/ios/NavigationBarView.swift +65 -0
- package/ios/NewArch/NavigationBarComponentView.h +10 -0
- package/ios/NewArch/NavigationBarComponentView.mm +86 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +7 -1
- package/ios/PaymentMethodFactory.swift +24 -24
- package/ios/PaymentOptionDisplayData+ReactNative.swift +4 -4
- package/ios/PaymentPassFinder.swift +9 -10
- package/ios/PaymentSheetAppearance.swift +137 -138
- package/ios/PushProvisioning/AddToWalletButtonManager.swift +2 -2
- package/ios/PushProvisioning/AddToWalletButtonView.swift +15 -17
- package/ios/PushProvisioning/PushProvisioningUtils.swift +11 -11
- package/ios/StripeContainerManager.swift +1 -1
- package/ios/StripeContainerView.swift +3 -3
- package/ios/StripeOnrampSdk.h +17 -0
- package/ios/StripeOnrampSdk.mm +158 -0
- package/ios/StripeSdk.mm +8 -0
- package/ios/StripeSdkEmitter.swift +4 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +30 -25
- package/ios/StripeSdkImpl+Embedded.swift +11 -9
- package/ios/StripeSdkImpl+PaymentSheet.swift +36 -34
- package/ios/StripeSdkImpl.swift +913 -185
- package/ios/UIColorExtension.swift +72 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +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/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/connect/Components.js +2 -0
- package/lib/commonjs/connect/Components.js.map +1 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js +2 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/commonjs/connect/EmbeddedComponent.js +19 -0
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -0
- package/lib/commonjs/connect/ModalCloseButton.js +2 -0
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -0
- package/lib/commonjs/connect/NavigationBar.js +2 -0
- package/lib/commonjs/connect/NavigationBar.js.map +1 -0
- package/lib/commonjs/connect/connectTypes.js +2 -0
- package/lib/commonjs/connect/connectTypes.js.map +1 -0
- package/lib/commonjs/events.js +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +2 -0
- package/lib/commonjs/hooks/useOnramp.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +2 -0
- package/lib/commonjs/specs/NativeNavigationBar.js.map +1 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.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/Onramp.js +2 -0
- package/lib/commonjs/types/Onramp.js.map +1 -0
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js +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/PlatformPayButton.js +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/connect/Components.js +2 -0
- package/lib/module/connect/Components.js.map +1 -0
- package/lib/module/connect/ConnectComponentsProvider.js +2 -0
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/module/connect/EmbeddedComponent.js +19 -0
- package/lib/module/connect/EmbeddedComponent.js.map +1 -0
- package/lib/module/connect/ModalCloseButton.js +2 -0
- package/lib/module/connect/ModalCloseButton.js.map +1 -0
- package/lib/module/connect/NavigationBar.js +2 -0
- package/lib/module/connect/NavigationBar.js.map +1 -0
- package/lib/module/connect/connectTypes.js +2 -0
- package/lib/module/connect/connectTypes.js.map +1 -0
- package/lib/module/events.js +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +2 -0
- package/lib/module/hooks/useOnramp.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js.map +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js.map +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/module/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/module/specs/NativeNavigationBar.js +2 -0
- package/lib/module/specs/NativeNavigationBar.js.map +1 -0
- package/lib/module/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.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/Onramp.js +2 -0
- package/lib/module/types/Onramp.js.map +1 -0
- package/lib/module/types/PaymentSheet.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/components/StripeProvider.d.ts.map +1 -1
- package/lib/typescript/src/connect/Components.d.ts +23 -0
- package/lib/typescript/src/connect/Components.d.ts.map +1 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +22 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts +18 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts +7 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts.map +1 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts +8 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/connect/connectTypes.d.ts +464 -0
- package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +3 -0
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/helpers.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +158 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugin/withStripe.d.ts +15 -0
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts +14 -0
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts +11 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +28 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +5 -0
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +275 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +7 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +24 -12
- package/src/components/StripeProvider.tsx +5 -0
- package/src/connect/Components.tsx +279 -0
- package/src/connect/ConnectComponentsProvider.tsx +93 -0
- package/src/connect/EmbeddedComponent.tsx +407 -0
- package/src/connect/ModalCloseButton.tsx +44 -0
- package/src/connect/NavigationBar.tsx +29 -0
- package/src/connect/connectTypes.ts +626 -0
- package/src/events.ts +22 -0
- package/src/hooks/useOnramp.tsx +334 -0
- package/src/index.tsx +13 -0
- package/src/plugin/withStripe.ts +104 -7
- package/src/specs/NativeConnectAccountOnboardingView.ts +19 -0
- package/src/specs/NativeNavigationBar.ts +16 -0
- package/src/specs/NativeOnrampSdkModule.ts +47 -0
- package/src/specs/NativeStripeSdkModule.ts +5 -0
- package/src/types/Errors.ts +6 -0
- package/src/types/Onramp.ts +317 -0
- package/src/types/PaymentSheet.ts +7 -0
- package/src/types/index.ts +8 -0
- package/stripe-react-native.podspec +20 -7
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt
CHANGED
|
@@ -2,37 +2,45 @@ package com.reactnativestripesdk.pushprovisioning
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.res.ColorStateList
|
|
5
|
-
import android.graphics.Color
|
|
6
5
|
import android.graphics.drawable.Drawable
|
|
7
6
|
import android.graphics.drawable.RippleDrawable
|
|
8
7
|
import android.view.MotionEvent
|
|
9
8
|
import android.webkit.URLUtil
|
|
10
9
|
import androidx.appcompat.widget.AppCompatImageView
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import com.
|
|
15
|
-
import com.
|
|
16
|
-
import com.
|
|
10
|
+
import androidx.core.graphics.drawable.toDrawable
|
|
11
|
+
import androidx.core.graphics.toColorInt
|
|
12
|
+
import androidx.core.net.toUri
|
|
13
|
+
import com.facebook.common.executors.UiThreadImmediateExecutorService
|
|
14
|
+
import com.facebook.common.references.CloseableReference
|
|
15
|
+
import com.facebook.datasource.BaseDataSubscriber
|
|
16
|
+
import com.facebook.datasource.DataSource
|
|
17
|
+
import com.facebook.drawee.backends.pipeline.Fresco
|
|
18
|
+
import com.facebook.imagepipeline.image.CloseableBitmap
|
|
19
|
+
import com.facebook.imagepipeline.image.CloseableImage
|
|
20
|
+
import com.facebook.imagepipeline.request.ImageRequestBuilder
|
|
17
21
|
import com.facebook.react.bridge.ReadableMap
|
|
18
22
|
import com.facebook.react.bridge.WritableMap
|
|
19
23
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
20
24
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
25
|
+
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper
|
|
21
26
|
import com.reactnativestripesdk.utils.createError
|
|
22
27
|
|
|
23
28
|
@SuppressLint("ViewConstructor")
|
|
24
29
|
class AddToWalletButtonView(
|
|
25
30
|
private val context: ThemedReactContext,
|
|
26
|
-
private val requestManager: RequestManager,
|
|
27
31
|
) : AppCompatImageView(context) {
|
|
28
32
|
private var cardDetails: ReadableMap? = null
|
|
29
33
|
private var ephemeralKey: String? = null
|
|
30
34
|
private var sourceMap: ReadableMap? = null
|
|
31
35
|
private var token: ReadableMap? = null
|
|
32
36
|
|
|
33
|
-
private var loadedSource:
|
|
34
|
-
private var
|
|
35
|
-
|
|
37
|
+
private var loadedSource: String? = null
|
|
38
|
+
private var currentDataSource: DataSource<CloseableReference<CloseableImage>>? = null
|
|
39
|
+
|
|
40
|
+
init {
|
|
41
|
+
scaleType = ScaleType.CENTER_CROP
|
|
42
|
+
clipToOutline = true
|
|
43
|
+
}
|
|
36
44
|
|
|
37
45
|
override fun performClick(): Boolean {
|
|
38
46
|
super.performClick()
|
|
@@ -78,85 +86,90 @@ class AddToWalletButtonView(
|
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
fun onAfterUpdateTransaction() {
|
|
81
|
-
val
|
|
82
|
-
if (
|
|
83
|
-
|
|
89
|
+
val uri = sourceMap?.getString("uri")
|
|
90
|
+
if (uri == null) {
|
|
91
|
+
cancelCurrentRequest()
|
|
84
92
|
setImageDrawable(null)
|
|
85
93
|
loadedSource = null
|
|
86
|
-
|
|
87
|
-
loadedSource = sourceToLoad
|
|
88
|
-
val scale = sourceMap?.getDouble("scale") ?: 1.0
|
|
89
|
-
|
|
90
|
-
requestManager
|
|
91
|
-
.load(sourceToLoad)
|
|
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()
|
|
124
|
-
.override((widthOverride * scale).toInt(), (heightOverride * scale).toInt())
|
|
125
|
-
.into(this)
|
|
94
|
+
return
|
|
126
95
|
}
|
|
127
|
-
}
|
|
128
96
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// Debug mode
|
|
133
|
-
|
|
97
|
+
if (uri != loadedSource) {
|
|
98
|
+
loadedSource = uri
|
|
99
|
+
if (URLUtil.isValidUrl(uri)) {
|
|
100
|
+
// Debug mode: Image.resolveAssetSource resolves to local http:// URL
|
|
101
|
+
loadImageFromUrl(uri)
|
|
134
102
|
} else {
|
|
135
|
-
// Release mode
|
|
136
|
-
|
|
103
|
+
// Release mode: Image.resolveAssetSource resolves to a drawable resource name
|
|
104
|
+
loadImageFromDrawable(uri)
|
|
137
105
|
}
|
|
138
106
|
}
|
|
139
|
-
return null
|
|
140
107
|
}
|
|
141
108
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
109
|
+
private fun loadImageFromUrl(url: String) {
|
|
110
|
+
cancelCurrentRequest()
|
|
111
|
+
|
|
112
|
+
val imageRequest =
|
|
113
|
+
ImageRequestBuilder
|
|
114
|
+
.newBuilderWithSource(url.toUri())
|
|
115
|
+
.build()
|
|
116
|
+
|
|
117
|
+
val dataSource = Fresco.getImagePipeline().fetchDecodedImage(imageRequest, context)
|
|
118
|
+
currentDataSource = dataSource
|
|
119
|
+
|
|
120
|
+
dataSource.subscribe(
|
|
121
|
+
object : BaseDataSubscriber<CloseableReference<CloseableImage>>() {
|
|
122
|
+
override fun onNewResultImpl(dataSource: DataSource<CloseableReference<CloseableImage>>) {
|
|
123
|
+
if (!dataSource.isFinished) return
|
|
124
|
+
val imageRef = dataSource.result ?: return
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
val image = imageRef.get()
|
|
128
|
+
if (image is CloseableBitmap) {
|
|
129
|
+
val drawable = image.underlyingBitmap.toDrawable(resources)
|
|
130
|
+
setImageWithRipple(drawable)
|
|
131
|
+
}
|
|
132
|
+
} finally {
|
|
133
|
+
CloseableReference.closeSafely(imageRef)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
override fun onFailureImpl(dataSource: DataSource<CloseableReference<CloseableImage>>) {
|
|
138
|
+
dispatchEvent(createError("Failed", "Failed to load the source from $url"))
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
UiThreadImmediateExecutorService.getInstance(),
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private fun loadImageFromDrawable(resourceName: String) {
|
|
146
|
+
// Instance is deprecated, but have to use until we drop support for RN 0.79
|
|
147
|
+
@Suppress("DEPRECATION")
|
|
148
|
+
val drawable = ResourceDrawableIdHelper.instance.getResourceDrawable(context, resourceName)
|
|
149
|
+
if (drawable != null) {
|
|
150
|
+
setImageWithRipple(drawable)
|
|
151
|
+
} else {
|
|
152
|
+
dispatchEvent(createError("Failed", "Failed to load drawable resource: $resourceName"))
|
|
155
153
|
}
|
|
156
154
|
}
|
|
157
155
|
|
|
156
|
+
private fun setImageWithRipple(drawable: Drawable) {
|
|
157
|
+
setImageDrawable(
|
|
158
|
+
RippleDrawable(
|
|
159
|
+
ColorStateList.valueOf("#e0e0e0".toColorInt()),
|
|
160
|
+
drawable,
|
|
161
|
+
null,
|
|
162
|
+
),
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private fun cancelCurrentRequest() {
|
|
167
|
+
currentDataSource?.close()
|
|
168
|
+
currentDataSource = null
|
|
169
|
+
}
|
|
170
|
+
|
|
158
171
|
fun onDropViewInstance() {
|
|
159
|
-
|
|
172
|
+
cancelCurrentRequest()
|
|
160
173
|
}
|
|
161
174
|
|
|
162
175
|
fun setSourceMap(map: ReadableMap?) {
|
|
@@ -2,11 +2,12 @@ package com.reactnativestripesdk.pushprovisioning
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.util.Log
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
5
6
|
import com.facebook.react.bridge.ReadableMap
|
|
6
7
|
import com.facebook.react.bridge.WritableMap
|
|
7
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
8
8
|
import com.google.android.gms.tasks.Task
|
|
9
9
|
import com.reactnativestripesdk.utils.createError
|
|
10
|
+
import com.reactnativestripesdk.utils.getIntOr
|
|
10
11
|
|
|
11
12
|
typealias TokenCheckHandler =
|
|
12
13
|
(isCardInWallet: Boolean, token: WritableMap?, error: WritableMap?) -> Unit
|
|
@@ -25,6 +26,7 @@ object TapAndPayProxy {
|
|
|
25
26
|
val tapAndPayClientClass = Class.forName("com.google.android.gms.tapandpay.TapAndPayClient")
|
|
26
27
|
val listTokensMethod = tapAndPayClientClass.getMethod("listTokens")
|
|
27
28
|
|
|
29
|
+
@Suppress("UNCHECKED_CAST")
|
|
28
30
|
listTokensMethod.invoke(client) as Task<List<Any>>
|
|
29
31
|
} catch (e: Exception) {
|
|
30
32
|
Log.e(TAG, "There was a problem listing tokens with Google TapAndPay: " + e.message)
|
|
@@ -97,9 +99,9 @@ object TapAndPayProxy {
|
|
|
97
99
|
tapAndPayClient,
|
|
98
100
|
activity,
|
|
99
101
|
tokenReferenceId,
|
|
100
|
-
token.
|
|
102
|
+
token.getIntOr("serviceProvider", 0),
|
|
101
103
|
cardDescription,
|
|
102
|
-
token.
|
|
104
|
+
token.getIntOr("network", 0),
|
|
103
105
|
REQUEST_CODE_TOKENIZE,
|
|
104
106
|
)
|
|
105
107
|
} catch (e: Exception) {
|
|
@@ -108,7 +110,7 @@ object TapAndPayProxy {
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
private fun mapFromTokenInfo(token: Any?): WritableMap {
|
|
111
|
-
val result =
|
|
113
|
+
val result = Arguments.createMap()
|
|
112
114
|
token?.let {
|
|
113
115
|
try {
|
|
114
116
|
val tokenInfoClass = Class.forName("com.google.android.gms.tapandpay.issuer.TokenInfo")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
package com.reactnativestripesdk.utils
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
3
4
|
import com.facebook.react.bridge.WritableMap
|
|
4
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
5
5
|
import com.stripe.android.core.exception.APIException
|
|
6
6
|
import com.stripe.android.core.exception.AuthenticationException
|
|
7
7
|
import com.stripe.android.core.exception.InvalidRequestException
|
|
@@ -66,8 +66,8 @@ internal fun mapError(
|
|
|
66
66
|
type: String?,
|
|
67
67
|
stripeErrorCode: String?,
|
|
68
68
|
): WritableMap {
|
|
69
|
-
val map: WritableMap =
|
|
70
|
-
val details: WritableMap =
|
|
69
|
+
val map: WritableMap = Arguments.createMap()
|
|
70
|
+
val details: WritableMap = Arguments.createMap()
|
|
71
71
|
details.putString("code", code)
|
|
72
72
|
details.putString("message", message)
|
|
73
73
|
details.putString("localizedMessage", localizedMessage)
|
|
@@ -178,8 +178,18 @@ internal fun createError(
|
|
|
178
178
|
return mapError(code, error.message, error.localizedMessage, null, null, null)
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
internal fun createCanceledError(message: String? = null): WritableMap = createError(ErrorType.Canceled.toString(), message)
|
|
182
|
+
|
|
183
|
+
internal fun createFailedError(error: Throwable): WritableMap = createError(ErrorType.Failed.toString(), error)
|
|
184
|
+
|
|
181
185
|
internal fun createMissingInitError(): WritableMap =
|
|
182
186
|
createError(
|
|
183
187
|
ErrorType.Failed.toString(),
|
|
184
188
|
"Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.",
|
|
185
189
|
)
|
|
190
|
+
|
|
191
|
+
internal fun createOnrampNotConfiguredError(): WritableMap =
|
|
192
|
+
createError(
|
|
193
|
+
ErrorType.Failed.toString(),
|
|
194
|
+
"Onramp is not configured.",
|
|
195
|
+
)
|
|
@@ -45,6 +45,14 @@ fun ReadableMap?.getDoubleOr(
|
|
|
45
45
|
default: Double,
|
|
46
46
|
): Double = getDoubleOrNull(key) ?: default
|
|
47
47
|
|
|
48
|
+
fun ReadableMap?.getLongOrNull(key: String): Long? =
|
|
49
|
+
if (this?.hasKey(key) == true && this.getType(key) == ReadableType.Number) this.getDouble(key).toLong() else null
|
|
50
|
+
|
|
51
|
+
fun ReadableMap?.getLongOr(
|
|
52
|
+
key: String,
|
|
53
|
+
default: Long,
|
|
54
|
+
): Long = getLongOrNull(key) ?: default
|
|
55
|
+
|
|
48
56
|
fun ReadableMap?.getFloatOrNull(key: String): Float? =
|
|
49
57
|
if (this?.hasKey(key) == true && this.getType(key) == ReadableType.Number) this.getDouble(key).toFloat() else null
|
|
50
58
|
|
|
@@ -74,4 +82,37 @@ fun ReadableArray.forEachMap(callback: (map: ReadableMap) -> Unit) {
|
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Returns a List of Strings if the key exists and points to an array of strings, or null otherwise.
|
|
87
|
+
*/
|
|
88
|
+
fun ReadableMap.getStringList(key: String): List<String>? {
|
|
89
|
+
if (!hasKey(key) || getType(key) != ReadableType.Array) return null
|
|
90
|
+
val array: ReadableArray = getArray(key) ?: return null
|
|
91
|
+
|
|
92
|
+
val result = mutableListOf<String>()
|
|
93
|
+
for (i in 0 until array.size()) {
|
|
94
|
+
// getString returns null if the element isn't actually a string
|
|
95
|
+
array.getString(i)?.let { result.add(it) }
|
|
96
|
+
}
|
|
97
|
+
return result
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Returns a List of Ints if the key exists and points to an array of numbers, or null otherwise.
|
|
102
|
+
*/
|
|
103
|
+
fun ReadableMap.getIntegerList(key: String): List<Int>? {
|
|
104
|
+
if (!hasKey(key) || getType(key) != ReadableType.Array) return null
|
|
105
|
+
val array: ReadableArray = getArray(key) ?: return null
|
|
106
|
+
|
|
107
|
+
val result = mutableListOf<Int>()
|
|
108
|
+
for (i in 0 until array.size()) {
|
|
109
|
+
// getType check to skip non-number entries
|
|
110
|
+
if (array.getType(i) == ReadableType.Number) {
|
|
111
|
+
// if it's actually a float/double, this will truncate; adjust as needed
|
|
112
|
+
result.add(array.getInt(i))
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result
|
|
116
|
+
}
|
|
117
|
+
|
|
77
118
|
fun Dynamic.asMapOrNull(): ReadableMap? = if (this.type == ReadableType.Map) this.asMap() else null
|
|
@@ -37,7 +37,7 @@ internal class KeepJsAwakeTask(
|
|
|
37
37
|
|
|
38
38
|
try {
|
|
39
39
|
headlessJsTaskContext.finishTask(taskId)
|
|
40
|
-
} catch (
|
|
40
|
+
} catch (_: AssertionError) {
|
|
41
41
|
// Ignore if task already finished
|
|
42
42
|
Log.w("KeepJsAwakeTask", "Tried to stop a non-existent task (id=$taskId)")
|
|
43
43
|
} finally {
|