@stripe/stripe-react-native 0.64.0 → 0.64.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/README.md +2 -2
- package/android/build.gradle +2 -2
- package/android/detekt/detekt-baseline.xml +81 -0
- package/android/detekt/detekt.gradle +45 -0
- package/android/detekt/detekt.yml +722 -0
- package/android/gradle.properties +4 -4
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +5 -1
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementView.kt +26 -0
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementViewManager.kt +42 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +105 -49
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +72 -12
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetManager.kt +8 -4
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +26 -11
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +14 -5
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +6 -2
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfig.kt +7 -4
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementViewManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +8 -4
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +9 -3
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +110 -29
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +250 -12
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +6 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutAddressUpdate.kt +45 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutMappers.kt +101 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +4 -2
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +5 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +29 -17
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -1
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +6 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +2 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeCurrencySelectorElementManagerDelegate.java +35 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeCurrencySelectorElementManagerInterface.java +18 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +44 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfigTest.kt +3 -3
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +60 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +38 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +9 -4
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutMappersTest.kt +89 -0
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutTestFixtures.java +49 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +6 -8
- package/ios/CurrencySelectorElementManager.m +9 -0
- package/ios/CurrencySelectorElementManager.swift +12 -0
- package/ios/CurrencySelectorElementView.swift +24 -0
- package/ios/Mappers+Checkout.swift +193 -0
- package/ios/Mappers.swift +0 -5
- package/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm +16 -2
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.h +10 -0
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.mm +75 -0
- package/ios/PaymentMethodMessagingElementConfig.swift +6 -3
- package/ios/PaymentMethodMessagingElementView.swift +19 -0
- package/ios/StripeSdk.mm +123 -0
- package/ios/StripeSdkImpl+Checkout.swift +308 -0
- package/ios/StripeSdkImpl+Embedded.swift +108 -27
- package/ios/StripeSdkImpl+PaymentSheet.swift +18 -2
- package/ios/StripeSdkImpl.swift +3 -93
- package/jest/mock.js +14 -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/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/CurrencySelectorElement.js +2 -0
- package/lib/commonjs/components/CurrencySelectorElement.js.map +1 -0
- package/lib/commonjs/components/PaymentMethodMessagingElement.js +2 -0
- package/lib/commonjs/components/PaymentMethodMessagingElement.js.map +1 -0
- 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/connect/Components.js +1 -1
- package/lib/commonjs/connect/Components.js.map +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
- package/lib/commonjs/connect/NavigationBar.js +1 -1
- package/lib/commonjs/connect/NavigationBar.js.map +1 -1
- package/lib/commonjs/events.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/hooks/useCheckout.js +2 -0
- package/lib/commonjs/hooks/useCheckout.js.map +1 -0
- package/lib/commonjs/hooks/useOnramp.js +1 -1
- package/lib/commonjs/hooks/useOnramp.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +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 +1 -1
- package/lib/commonjs/specs/NativeCurrencySelectorElement.js +2 -0
- package/lib/commonjs/specs/NativeCurrencySelectorElement.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/NativeNavigationBar.js +1 -1
- package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/Checkout.js +2 -0
- package/lib/commonjs/types/Checkout.js.map +1 -0
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.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/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/CurrencySelectorElement.js +2 -0
- package/lib/module/components/CurrencySelectorElement.js.map +1 -0
- package/lib/module/components/PaymentMethodMessagingElement.js +2 -0
- package/lib/module/components/PaymentMethodMessagingElement.js.map +1 -0
- 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/connect/Components.js +1 -1
- package/lib/module/connect/Components.js.map +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/module/connect/EmbeddedComponent.js +1 -1
- package/lib/module/connect/EmbeddedComponent.js.map +1 -1
- package/lib/module/connect/ModalCloseButton.js +1 -1
- package/lib/module/connect/ModalCloseButton.js.map +1 -1
- package/lib/module/connect/NavigationBar.js +1 -1
- package/lib/module/connect/NavigationBar.js.map +1 -1
- package/lib/module/events.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/hooks/useCheckout.js +2 -0
- package/lib/module/hooks/useCheckout.js.map +1 -0
- package/lib/module/hooks/useOnramp.js +1 -1
- package/lib/module/hooks/useOnramp.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +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 +1 -1
- package/lib/module/specs/NativeCurrencySelectorElement.js +2 -0
- package/lib/module/specs/NativeCurrencySelectorElement.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/NativeNavigationBar.js +1 -1
- package/lib/module/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/module/specs/NativePaymentMethodMessagingElement.js.map +1 -1
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/Checkout.js +2 -0
- package/lib/module/types/Checkout.js.map +1 -0
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/typescript/src/components/CurrencySelectorElement.d.ts +62 -0
- package/lib/typescript/src/components/CurrencySelectorElement.d.ts.map +1 -0
- package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts +41 -0
- package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +11 -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/hooks/useCheckout.d.ts +21 -0
- package/lib/typescript/src/hooks/useCheckout.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts +1 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeCurrencySelectorElement.d.ts +25 -0
- package/lib/typescript/src/specs/NativeCurrencySelectorElement.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +5 -1
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePaymentMethodMessagingElement.d.ts +1 -6
- package/lib/typescript/src/specs/NativePaymentMethodMessagingElement.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +16 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Checkout.d.ts +336 -0
- package/lib/typescript/src/types/Checkout.d.ts.map +1 -0
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +36 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentMethod.d.ts +1 -5
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentSheet.d.ts +22 -6
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/components/PaymentMethodMessagingElementComponent.d.ts +16 -1
- package/lib/typescript/src/types/components/PaymentMethodMessagingElementComponent.d.ts.map +1 -1
- package/package.json +21 -7
- package/src/components/CurrencySelectorElement.tsx +95 -0
- package/src/components/PaymentMethodMessagingElement.tsx +109 -0
- package/src/events.ts +11 -0
- package/src/functions.ts +30 -1
- package/src/hooks/useCheckout.tsx +207 -0
- package/src/hooks/useOnramp.tsx +9 -3
- package/src/index.tsx +4 -0
- package/src/specs/NativeCurrencySelectorElement.ts +35 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +12 -2
- package/src/specs/NativePaymentMethodMessagingElement.ts +0 -7
- package/src/specs/NativeStripeSdkModule.ts +58 -1
- package/src/types/Checkout.ts +377 -0
- package/src/types/EmbeddedPaymentElement.tsx +117 -26
- package/src/types/PaymentMethod.ts +0 -6
- package/src/types/PaymentSheet.ts +29 -6
- package/src/types/components/PaymentMethodMessagingElementComponent.tsx +17 -1
- package/stripe-react-native.podspec +8 -8
- package/android/spotless.gradle +0 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
StripeSdk_kotlinVersion=2.2.21
|
|
2
|
-
StripeSdk_compileSdkVersion=
|
|
3
|
-
StripeSdk_targetSdkVersion=
|
|
4
|
-
StripeSdk_minSdkVersion=
|
|
2
|
+
StripeSdk_compileSdkVersion=36
|
|
3
|
+
StripeSdk_targetSdkVersion=36
|
|
4
|
+
StripeSdk_minSdkVersion=23
|
|
5
5
|
# Keep StripeSdk_stripeVersion in sync with https://github.com/stripe/stripe-identity-react-native/blob/main/android/gradle.properties
|
|
6
|
-
StripeSdk_stripeVersion=23.
|
|
6
|
+
StripeSdk_stripeVersion=23.6.+
|
|
@@ -109,7 +109,9 @@ class AuBECSDebitFormView(
|
|
|
109
109
|
"email" to billingDetails["email"] as String,
|
|
110
110
|
)
|
|
111
111
|
|
|
112
|
-
UIManagerHelper.getEventDispatcherForReactTag(context, id)?.dispatchEvent(
|
|
112
|
+
UIManagerHelper.getEventDispatcherForReactTag(context, id)?.dispatchEvent(
|
|
113
|
+
FormCompleteEvent(context.surfaceId, id, formDetails)
|
|
114
|
+
)
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
private fun setListeners() {
|
|
@@ -41,7 +41,8 @@ class AuBECSDebitFormViewManager :
|
|
|
41
41
|
view.setFormStyle(style.asMapOrNull())
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
override fun createViewInstance(reactContext: ThemedReactContext): AuBECSDebitFormView =
|
|
44
|
+
override fun createViewInstance(reactContext: ThemedReactContext): AuBECSDebitFormView =
|
|
45
|
+
AuBECSDebitFormView(reactContext)
|
|
45
46
|
|
|
46
47
|
companion object {
|
|
47
48
|
const val REACT_CLASS = "AuBECSDebitForm"
|
|
@@ -169,7 +169,7 @@ class CardFieldView(
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
mCardWidget.setPadding(
|
|
172
|
+
mCardWidget.setPadding(CARD_WIDGET_HORIZONTAL_PADDING, 0, CARD_WIDGET_HORIZONTAL_PADDING, 0)
|
|
173
173
|
mCardWidget.background =
|
|
174
174
|
MaterialShapeDrawable(
|
|
175
175
|
ShapeAppearanceModel()
|
|
@@ -530,4 +530,8 @@ class CardFieldView(
|
|
|
530
530
|
)
|
|
531
531
|
layout(left, top, right, bottom)
|
|
532
532
|
}
|
|
533
|
+
|
|
534
|
+
private companion object {
|
|
535
|
+
const val CARD_WIDGET_HORIZONTAL_PADDING = 20
|
|
536
|
+
}
|
|
533
537
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.widget.FrameLayout
|
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Minimal stub so the JS-side `CurrencySelectorElement` codegen mapping
|
|
9
|
+
* resolves at app launch. The full Compose-based implementation that hosts
|
|
10
|
+
* `Checkout.CurrencySelectorContent()` lives on the feature branch and will
|
|
11
|
+
* replace this once that lands.
|
|
12
|
+
*/
|
|
13
|
+
@SuppressLint("ViewConstructor")
|
|
14
|
+
class CurrencySelectorElementView(
|
|
15
|
+
context: ThemedReactContext,
|
|
16
|
+
) : FrameLayout(context) {
|
|
17
|
+
@Suppress("UnusedParameter")
|
|
18
|
+
fun setSessionKey(value: String?) {
|
|
19
|
+
// no-op stub
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Suppress("UnusedParameter")
|
|
23
|
+
fun setDisabled(value: Boolean) {
|
|
24
|
+
// no-op stub
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
6
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
7
|
+
import com.facebook.react.viewmanagers.StripeCurrencySelectorElementManagerDelegate
|
|
8
|
+
import com.facebook.react.viewmanagers.StripeCurrencySelectorElementManagerInterface
|
|
9
|
+
|
|
10
|
+
@ReactModule(name = CurrencySelectorElementViewManager.NAME)
|
|
11
|
+
class CurrencySelectorElementViewManager :
|
|
12
|
+
ViewGroupManager<CurrencySelectorElementView>(),
|
|
13
|
+
StripeCurrencySelectorElementManagerInterface<CurrencySelectorElementView> {
|
|
14
|
+
companion object {
|
|
15
|
+
const val NAME = "StripeCurrencySelectorElement"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private val delegate = StripeCurrencySelectorElementManagerDelegate(this)
|
|
19
|
+
|
|
20
|
+
override fun getName() = NAME
|
|
21
|
+
|
|
22
|
+
override fun getDelegate() = delegate
|
|
23
|
+
|
|
24
|
+
override fun createViewInstance(ctx: ThemedReactContext): CurrencySelectorElementView =
|
|
25
|
+
CurrencySelectorElementView(ctx)
|
|
26
|
+
|
|
27
|
+
@ReactProp(name = "sessionKey")
|
|
28
|
+
override fun setSessionKey(
|
|
29
|
+
view: CurrencySelectorElementView,
|
|
30
|
+
value: String?,
|
|
31
|
+
) {
|
|
32
|
+
view.setSessionKey(value)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@ReactProp(name = "disabled")
|
|
36
|
+
override fun setDisabled(
|
|
37
|
+
view: CurrencySelectorElementView,
|
|
38
|
+
value: Boolean,
|
|
39
|
+
) {
|
|
40
|
+
view.setDisabled(value)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -25,7 +25,9 @@ import com.reactnativestripesdk.utils.KeepJsAwakeTask
|
|
|
25
25
|
import com.reactnativestripesdk.utils.mapFromConfirmationToken
|
|
26
26
|
import com.reactnativestripesdk.utils.mapFromCustomPaymentMethod
|
|
27
27
|
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
28
|
+
import com.stripe.android.checkout.Checkout
|
|
28
29
|
import com.stripe.android.model.PaymentMethod
|
|
30
|
+
import com.stripe.android.paymentelement.CheckoutSessionPreview
|
|
29
31
|
import com.stripe.android.paymentelement.CustomPaymentMethodResult
|
|
30
32
|
import com.stripe.android.paymentelement.CustomPaymentMethodResultHandler
|
|
31
33
|
import com.stripe.android.paymentelement.EmbeddedPaymentElement
|
|
@@ -43,6 +45,7 @@ enum class RowSelectionBehaviorType {
|
|
|
43
45
|
ImmediateAction,
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
46
49
|
class EmbeddedPaymentElementView(
|
|
47
50
|
context: Context,
|
|
48
51
|
) : StripeAbstractComposeView(context) {
|
|
@@ -52,10 +55,19 @@ class EmbeddedPaymentElementView(
|
|
|
52
55
|
val intentConfiguration: PaymentSheet.IntentConfiguration,
|
|
53
56
|
) : Event
|
|
54
57
|
|
|
58
|
+
data class ConfigureWithCheckout(
|
|
59
|
+
val configuration: EmbeddedPaymentElement.Configuration,
|
|
60
|
+
val checkout: Checkout,
|
|
61
|
+
) : Event
|
|
62
|
+
|
|
55
63
|
data class Update(
|
|
56
64
|
val intentConfiguration: PaymentSheet.IntentConfiguration,
|
|
57
65
|
) : Event
|
|
58
66
|
|
|
67
|
+
data class UpdateWithCheckout(
|
|
68
|
+
val checkout: Checkout,
|
|
69
|
+
) : Event
|
|
70
|
+
|
|
59
71
|
data object Confirm : Event
|
|
60
72
|
|
|
61
73
|
data object ClearPaymentOption : Event
|
|
@@ -63,6 +75,7 @@ class EmbeddedPaymentElementView(
|
|
|
63
75
|
|
|
64
76
|
var latestIntentConfig: PaymentSheet.IntentConfiguration? = null
|
|
65
77
|
var latestElementConfig: EmbeddedPaymentElement.Configuration? = null
|
|
78
|
+
var latestCheckout: Checkout? = null
|
|
66
79
|
|
|
67
80
|
val rowSelectionBehaviorType = mutableStateOf<RowSelectionBehaviorType?>(null)
|
|
68
81
|
val useConfirmationTokenCallback = mutableStateOf(false)
|
|
@@ -115,7 +128,7 @@ class EmbeddedPaymentElementView(
|
|
|
115
128
|
coroutineScope.launch {
|
|
116
129
|
try {
|
|
117
130
|
// Give the CustomPaymentMethodActivity a moment to fully initialize
|
|
118
|
-
delay(
|
|
131
|
+
delay(CUSTOM_PAYMENT_METHOD_INIT_DELAY_MS)
|
|
119
132
|
|
|
120
133
|
// Emit event so JS can show the Alert and eventually respond via `customPaymentMethodResultCallback`.
|
|
121
134
|
stripeSdkModule.eventEmitter.emitOnCustomPaymentMethodConfirmHandlerCallback(
|
|
@@ -199,7 +212,9 @@ class EmbeddedPaymentElementView(
|
|
|
199
212
|
return@Builder CreateIntentResult.Failure(
|
|
200
213
|
cause =
|
|
201
214
|
Exception(
|
|
202
|
-
"Tried to call confirmationTokenConfirmHandler, but no callback was
|
|
215
|
+
"Tried to call confirmationTokenConfirmHandler, but no callback was " +
|
|
216
|
+
"found. Please file an issue: " +
|
|
217
|
+
"https://github.com/stripe/stripe-react-native/issues",
|
|
203
218
|
),
|
|
204
219
|
displayMessage = "An unexpected error occurred",
|
|
205
220
|
)
|
|
@@ -245,7 +260,8 @@ class EmbeddedPaymentElementView(
|
|
|
245
260
|
return@Builder CreateIntentResult.Failure(
|
|
246
261
|
cause =
|
|
247
262
|
Exception(
|
|
248
|
-
"Tried to call confirmHandler, but no callback was found. Please
|
|
263
|
+
"Tried to call confirmHandler, but no callback was found. Please " +
|
|
264
|
+
"file an issue: https://github.com/stripe/stripe-react-native/issues",
|
|
249
265
|
),
|
|
250
266
|
displayMessage = "An unexpected error occurred",
|
|
251
267
|
)
|
|
@@ -300,40 +316,25 @@ class EmbeddedPaymentElementView(
|
|
|
300
316
|
events.consumeAsFlow().collect { ev ->
|
|
301
317
|
when (ev) {
|
|
302
318
|
is Event.Configure -> {
|
|
303
|
-
|
|
304
|
-
val result =
|
|
319
|
+
handleConfigureResult(
|
|
305
320
|
embedded.configure(
|
|
306
321
|
intentConfiguration = ev.intentConfiguration,
|
|
307
322
|
configuration = ev.configuration,
|
|
308
|
-
)
|
|
323
|
+
),
|
|
324
|
+
)
|
|
325
|
+
}
|
|
309
326
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
val payload =
|
|
318
|
-
Arguments.createMap().apply {
|
|
319
|
-
putString("message", msg)
|
|
320
|
-
}
|
|
321
|
-
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementLoadingFailed(payload)
|
|
322
|
-
}
|
|
323
|
-
}
|
|
327
|
+
is Event.ConfigureWithCheckout -> {
|
|
328
|
+
handleConfigureResult(
|
|
329
|
+
embedded.configure(
|
|
330
|
+
checkout = ev.checkout,
|
|
331
|
+
configuration = ev.configuration,
|
|
332
|
+
),
|
|
333
|
+
)
|
|
324
334
|
}
|
|
325
335
|
|
|
326
336
|
is Event.Update -> {
|
|
327
|
-
val elemConfig = latestElementConfig
|
|
328
|
-
if (elemConfig == null) {
|
|
329
|
-
val payload =
|
|
330
|
-
Arguments.createMap().apply {
|
|
331
|
-
putString("message", "Cannot update: no element configuration exists")
|
|
332
|
-
}
|
|
333
|
-
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementLoadingFailed(payload)
|
|
334
|
-
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementUpdateComplete(null)
|
|
335
|
-
return@collect
|
|
336
|
-
}
|
|
337
|
+
val elemConfig = latestElementConfig ?: return@collect emitUpdateMissingConfiguration()
|
|
337
338
|
|
|
338
339
|
val result =
|
|
339
340
|
embedded.configure(
|
|
@@ -341,29 +342,25 @@ class EmbeddedPaymentElementView(
|
|
|
341
342
|
configuration = elemConfig,
|
|
342
343
|
)
|
|
343
344
|
|
|
344
|
-
|
|
345
|
-
is EmbeddedPaymentElement.ConfigureResult.Succeeded -> {
|
|
346
|
-
val payload =
|
|
347
|
-
Arguments.createMap().apply {
|
|
348
|
-
putString("status", "succeeded")
|
|
349
|
-
}
|
|
350
|
-
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementUpdateComplete(payload)
|
|
351
|
-
}
|
|
352
|
-
is EmbeddedPaymentElement.ConfigureResult.Failed -> {
|
|
353
|
-
val err = result.error
|
|
354
|
-
val msg = err.localizedMessage ?: err.toString()
|
|
355
|
-
val failPayload =
|
|
356
|
-
Arguments.createMap().apply {
|
|
357
|
-
putString("message", msg)
|
|
358
|
-
}
|
|
359
|
-
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementLoadingFailed(failPayload)
|
|
360
|
-
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementUpdateComplete(null)
|
|
361
|
-
}
|
|
362
|
-
}
|
|
345
|
+
handleUpdateResult(result)
|
|
363
346
|
|
|
364
347
|
latestIntentConfig = ev.intentConfiguration
|
|
365
348
|
}
|
|
366
349
|
|
|
350
|
+
is Event.UpdateWithCheckout -> {
|
|
351
|
+
val elemConfig = latestElementConfig ?: return@collect emitUpdateMissingConfiguration()
|
|
352
|
+
|
|
353
|
+
val result =
|
|
354
|
+
embedded.configure(
|
|
355
|
+
checkout = ev.checkout,
|
|
356
|
+
configuration = elemConfig,
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
handleUpdateResult(result)
|
|
360
|
+
|
|
361
|
+
latestCheckout = ev.checkout
|
|
362
|
+
}
|
|
363
|
+
|
|
367
364
|
is Event.Confirm -> {
|
|
368
365
|
embedded.confirm()
|
|
369
366
|
}
|
|
@@ -446,6 +443,50 @@ class EmbeddedPaymentElementView(
|
|
|
446
443
|
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementDidUpdateHeight(params)
|
|
447
444
|
}
|
|
448
445
|
|
|
446
|
+
private fun handleConfigureResult(result: EmbeddedPaymentElement.ConfigureResult) {
|
|
447
|
+
when (result) {
|
|
448
|
+
is EmbeddedPaymentElement.ConfigureResult.Succeeded -> reportHeightChange(1f)
|
|
449
|
+
is EmbeddedPaymentElement.ConfigureResult.Failed -> {
|
|
450
|
+
val err = result.error
|
|
451
|
+
val msg = err.localizedMessage ?: err.toString()
|
|
452
|
+
val payload =
|
|
453
|
+
Arguments.createMap().apply {
|
|
454
|
+
putString("message", msg)
|
|
455
|
+
}
|
|
456
|
+
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementLoadingFailed(payload)
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
private fun handleUpdateResult(result: EmbeddedPaymentElement.ConfigureResult) {
|
|
462
|
+
when (result) {
|
|
463
|
+
is EmbeddedPaymentElement.ConfigureResult.Succeeded -> {
|
|
464
|
+
val payload =
|
|
465
|
+
Arguments.createMap().apply {
|
|
466
|
+
putString("status", "succeeded")
|
|
467
|
+
}
|
|
468
|
+
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementUpdateComplete(payload)
|
|
469
|
+
}
|
|
470
|
+
is EmbeddedPaymentElement.ConfigureResult.Failed -> {
|
|
471
|
+
emitUpdateFailed(result.error)
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
private fun emitUpdateMissingConfiguration() {
|
|
477
|
+
emitUpdateFailed(IllegalStateException("Cannot update: no element configuration exists"))
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
private fun emitUpdateFailed(error: Throwable) {
|
|
481
|
+
val msg = error.localizedMessage ?: error.toString()
|
|
482
|
+
val payload =
|
|
483
|
+
Arguments.createMap().apply {
|
|
484
|
+
putString("message", msg)
|
|
485
|
+
}
|
|
486
|
+
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementLoadingFailed(payload)
|
|
487
|
+
requireStripeSdkModule().eventEmitter.emitEmbeddedPaymentElementUpdateComplete(null)
|
|
488
|
+
}
|
|
489
|
+
|
|
449
490
|
// APIs
|
|
450
491
|
fun configure(
|
|
451
492
|
config: EmbeddedPaymentElement.Configuration,
|
|
@@ -454,10 +495,21 @@ class EmbeddedPaymentElementView(
|
|
|
454
495
|
events.trySend(Event.Configure(config, intentConfig))
|
|
455
496
|
}
|
|
456
497
|
|
|
498
|
+
fun configureWithCheckout(
|
|
499
|
+
config: EmbeddedPaymentElement.Configuration,
|
|
500
|
+
checkout: Checkout,
|
|
501
|
+
) {
|
|
502
|
+
events.trySend(Event.ConfigureWithCheckout(config, checkout))
|
|
503
|
+
}
|
|
504
|
+
|
|
457
505
|
fun update(intentConfig: PaymentSheet.IntentConfiguration) {
|
|
458
506
|
events.trySend(Event.Update(intentConfig))
|
|
459
507
|
}
|
|
460
508
|
|
|
509
|
+
fun updateWithCheckout(checkout: Checkout) {
|
|
510
|
+
events.trySend(Event.UpdateWithCheckout(checkout))
|
|
511
|
+
}
|
|
512
|
+
|
|
461
513
|
fun confirm() {
|
|
462
514
|
events.trySend(Event.Confirm)
|
|
463
515
|
}
|
|
@@ -467,4 +519,8 @@ class EmbeddedPaymentElementView(
|
|
|
467
519
|
}
|
|
468
520
|
|
|
469
521
|
private fun requireStripeSdkModule() = requireNotNull(reactContext.getNativeModule(StripeSdkModule::class.java))
|
|
522
|
+
|
|
523
|
+
private companion object {
|
|
524
|
+
const val CUSTOM_PAYMENT_METHOD_INIT_DELAY_MS = 100L
|
|
525
|
+
}
|
|
470
526
|
}
|
|
@@ -23,6 +23,7 @@ import com.reactnativestripesdk.utils.getStringList
|
|
|
23
23
|
import com.reactnativestripesdk.utils.mapToPreferredNetworks
|
|
24
24
|
import com.reactnativestripesdk.utils.parseCustomPaymentMethods
|
|
25
25
|
import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi
|
|
26
|
+
import com.stripe.android.paymentelement.CheckoutSessionPreview
|
|
26
27
|
import com.stripe.android.paymentelement.EmbeddedPaymentElement
|
|
27
28
|
import com.stripe.android.paymentsheet.CardFundingFilteringPrivatePreview
|
|
28
29
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
@@ -30,6 +31,8 @@ import org.json.JSONArray
|
|
|
30
31
|
import org.json.JSONObject
|
|
31
32
|
|
|
32
33
|
@ReactModule(name = EmbeddedPaymentElementViewManager.NAME)
|
|
34
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
35
|
+
@Suppress("TooManyFunctions")
|
|
33
36
|
class EmbeddedPaymentElementViewManager :
|
|
34
37
|
ViewGroupManager<EmbeddedPaymentElementView>(),
|
|
35
38
|
EmbeddedPaymentElementViewManagerInterface<EmbeddedPaymentElementView> {
|
|
@@ -66,9 +69,7 @@ class EmbeddedPaymentElementViewManager :
|
|
|
66
69
|
|
|
67
70
|
val elementConfig = parseElementConfiguration(readableMap, view.context)
|
|
68
71
|
view.latestElementConfig = elementConfig
|
|
69
|
-
|
|
70
|
-
view.latestIntentConfig?.let { intentCfg ->
|
|
71
|
-
view.configure(elementConfig, intentCfg)
|
|
72
|
+
if (configureIfReady(view, elementConfig)) {
|
|
72
73
|
view.post {
|
|
73
74
|
view.requestLayout()
|
|
74
75
|
view.invalidate()
|
|
@@ -81,18 +82,55 @@ class EmbeddedPaymentElementViewManager :
|
|
|
81
82
|
view: EmbeddedPaymentElementView,
|
|
82
83
|
cfg: Dynamic,
|
|
83
84
|
) {
|
|
84
|
-
val readableMap = cfg.asMapOrNull()
|
|
85
|
-
|
|
85
|
+
val readableMap = cfg.asMapOrNull() ?: return
|
|
86
|
+
|
|
87
|
+
view.setUseConfirmationTokenCallback(readableMap.hasKey("confirmationTokenConfirmHandler"))
|
|
88
|
+
|
|
89
|
+
view.latestIntentConfig = parseIntentConfiguration(readableMap)
|
|
90
|
+
view.latestElementConfig?.let { configureIfReady(view, it) }
|
|
91
|
+
}
|
|
86
92
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
view
|
|
93
|
+
@ReactProp(name = "checkout")
|
|
94
|
+
override fun setCheckout(
|
|
95
|
+
view: EmbeddedPaymentElementView,
|
|
96
|
+
cfg: Dynamic,
|
|
97
|
+
) {
|
|
98
|
+
val sessionKey = cfg.asMapOrNull()?.getString("sessionKey") ?: return
|
|
90
99
|
|
|
91
|
-
val
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
val stripeSdkModule =
|
|
101
|
+
(view.context as ThemedReactContext).getNativeModule(StripeSdkModule::class.java)
|
|
102
|
+
val checkout = stripeSdkModule?.checkoutInstances?.get(sessionKey)
|
|
103
|
+
if (checkout == null) {
|
|
104
|
+
val payload =
|
|
105
|
+
Arguments.createMap().apply {
|
|
106
|
+
putString("message", "Checkout session not found.")
|
|
107
|
+
}
|
|
108
|
+
stripeSdkModule?.eventEmitter?.emitEmbeddedPaymentElementLoadingFailed(payload)
|
|
109
|
+
return
|
|
95
110
|
}
|
|
111
|
+
|
|
112
|
+
view.latestCheckout = checkout
|
|
113
|
+
view.latestElementConfig?.let { configureIfReady(view, it) }
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Configures the embedded element once both the element config and an
|
|
118
|
+
* intent source (intent configuration or checkout) have arrived. Returns
|
|
119
|
+
* `true` when a configure was dispatched.
|
|
120
|
+
*/
|
|
121
|
+
private fun configureIfReady(
|
|
122
|
+
view: EmbeddedPaymentElementView,
|
|
123
|
+
elementConfig: EmbeddedPaymentElement.Configuration,
|
|
124
|
+
): Boolean {
|
|
125
|
+
view.latestCheckout?.let { checkout ->
|
|
126
|
+
view.configureWithCheckout(elementConfig, checkout)
|
|
127
|
+
return true
|
|
128
|
+
}
|
|
129
|
+
view.latestIntentConfig?.let { intentCfg ->
|
|
130
|
+
view.configure(elementConfig, intentCfg)
|
|
131
|
+
return true
|
|
132
|
+
}
|
|
133
|
+
return false
|
|
96
134
|
}
|
|
97
135
|
|
|
98
136
|
@SuppressLint("RestrictedApi")
|
|
@@ -206,6 +244,28 @@ class EmbeddedPaymentElementViewManager :
|
|
|
206
244
|
}
|
|
207
245
|
}
|
|
208
246
|
|
|
247
|
+
override fun updateWithCheckout(
|
|
248
|
+
view: EmbeddedPaymentElementView,
|
|
249
|
+
sessionKey: String?,
|
|
250
|
+
) {
|
|
251
|
+
if (sessionKey == null) return
|
|
252
|
+
|
|
253
|
+
val stripeSdkModule =
|
|
254
|
+
(view.context as ThemedReactContext).getNativeModule(StripeSdkModule::class.java)
|
|
255
|
+
val checkout = stripeSdkModule?.checkoutInstances?.get(sessionKey)
|
|
256
|
+
if (checkout == null) {
|
|
257
|
+
val payload =
|
|
258
|
+
Arguments.createMap().apply {
|
|
259
|
+
putString("message", "Checkout session not found.")
|
|
260
|
+
}
|
|
261
|
+
stripeSdkModule?.eventEmitter?.emitEmbeddedPaymentElementLoadingFailed(payload)
|
|
262
|
+
stripeSdkModule?.eventEmitter?.emitEmbeddedPaymentElementUpdateComplete(null)
|
|
263
|
+
return
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
view.updateWithCheckout(checkout)
|
|
267
|
+
}
|
|
268
|
+
|
|
209
269
|
private fun jsonToWritableMap(json: JSONObject): WritableMap {
|
|
210
270
|
val map = Arguments.createMap()
|
|
211
271
|
val keys = json.keys()
|
|
@@ -138,7 +138,7 @@ class FinancialConnectionsSheetManager(
|
|
|
138
138
|
map.putString("status", mapFromStatus(account.status))
|
|
139
139
|
map.putString("institutionName", account.institutionName)
|
|
140
140
|
map.putString("last4", account.last4)
|
|
141
|
-
map.putDouble("created", account.created *
|
|
141
|
+
map.putDouble("created", account.created * SECONDS_TO_MILLIS)
|
|
142
142
|
map.putMap("balance", mapFromAccountBalance(account.balance))
|
|
143
143
|
map.putMap("balanceRefresh", mapFromAccountBalanceRefresh(account.balanceRefresh))
|
|
144
144
|
map.putString("category", mapFromCategory(account.category))
|
|
@@ -166,7 +166,7 @@ class FinancialConnectionsSheetManager(
|
|
|
166
166
|
return null
|
|
167
167
|
}
|
|
168
168
|
val map = Arguments.createMap()
|
|
169
|
-
map.putDouble("asOf", balance.asOf *
|
|
169
|
+
map.putDouble("asOf", balance.asOf * SECONDS_TO_MILLIS)
|
|
170
170
|
map.putString("type", mapFromBalanceType(balance.type))
|
|
171
171
|
Arguments.createMap().also {
|
|
172
172
|
for (entry in balance.current.entries) {
|
|
@@ -210,7 +210,7 @@ class FinancialConnectionsSheetManager(
|
|
|
210
210
|
}
|
|
211
211
|
val map = Arguments.createMap()
|
|
212
212
|
map.putString("status", mapFromBalanceRefreshStatus(balanceRefresh.status))
|
|
213
|
-
map.putDouble("lastAttemptedAt", balanceRefresh.lastAttemptedAt *
|
|
213
|
+
map.putDouble("lastAttemptedAt", balanceRefresh.lastAttemptedAt * SECONDS_TO_MILLIS)
|
|
214
214
|
return map
|
|
215
215
|
}
|
|
216
216
|
|
|
@@ -252,7 +252,9 @@ class FinancialConnectionsSheetManager(
|
|
|
252
252
|
FinancialConnectionsAccount.Permissions.UNKNOWN -> "unparsable"
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
private fun mapFromSupportedPaymentMethodTypes(
|
|
255
|
+
private fun mapFromSupportedPaymentMethodTypes(
|
|
256
|
+
type: FinancialConnectionsAccount.SupportedPaymentMethodTypes
|
|
257
|
+
): String =
|
|
256
258
|
when (type) {
|
|
257
259
|
FinancialConnectionsAccount.SupportedPaymentMethodTypes.US_BANK_ACCOUNT -> "usBankAccount"
|
|
258
260
|
FinancialConnectionsAccount.SupportedPaymentMethodTypes.LINK -> "link"
|
|
@@ -274,6 +276,8 @@ class FinancialConnectionsSheetManager(
|
|
|
274
276
|
BalanceRefresh.BalanceRefreshStatus.UNKNOWN -> "unparsable"
|
|
275
277
|
null -> "null"
|
|
276
278
|
}
|
|
279
|
+
|
|
280
|
+
private const val SECONDS_TO_MILLIS = 1000.0
|
|
277
281
|
}
|
|
278
282
|
}
|
|
279
283
|
|
|
@@ -17,7 +17,8 @@ class GooglePayButtonManager :
|
|
|
17
17
|
|
|
18
18
|
override fun getDelegate() = delegate
|
|
19
19
|
|
|
20
|
-
override fun createViewInstance(reactContext: ThemedReactContext): GooglePayButtonView =
|
|
20
|
+
override fun createViewInstance(reactContext: ThemedReactContext): GooglePayButtonView =
|
|
21
|
+
GooglePayButtonView(reactContext)
|
|
21
22
|
|
|
22
23
|
override fun onAfterUpdateTransaction(view: GooglePayButtonView) {
|
|
23
24
|
super.onAfterUpdateTransaction(view)
|
|
@@ -77,23 +77,23 @@ class GooglePayButtonView(
|
|
|
77
77
|
|
|
78
78
|
private fun getButtonType(): Int? =
|
|
79
79
|
when (this.type) {
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
BUTTON_TYPE_BUY_DEFAULT,
|
|
81
|
+
BUTTON_TYPE_BUY_ALT,
|
|
82
82
|
-> ButtonType.BUY
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
BUTTON_TYPE_BOOK -> ButtonType.BOOK
|
|
84
|
+
BUTTON_TYPE_CHECKOUT -> ButtonType.CHECKOUT
|
|
85
|
+
BUTTON_TYPE_DONATE -> ButtonType.DONATE
|
|
86
|
+
BUTTON_TYPE_ORDER -> ButtonType.ORDER
|
|
87
|
+
BUTTON_TYPE_SUBSCRIBE -> ButtonType.SUBSCRIBE
|
|
88
|
+
BUTTON_TYPE_PAY -> ButtonType.PAY
|
|
89
|
+
BUTTON_TYPE_PLAIN -> ButtonType.PLAIN
|
|
90
90
|
else -> null
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
private fun getButtonTheme(): Int? =
|
|
94
94
|
when (this.appearance) {
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
BUTTON_THEME_LIGHT_DEFAULT, BUTTON_THEME_LIGHT_ALT -> ButtonTheme.LIGHT
|
|
96
|
+
BUTTON_THEME_DARK -> ButtonTheme.DARK
|
|
97
97
|
else -> null
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -122,4 +122,19 @@ class GooglePayButtonView(
|
|
|
122
122
|
fun setBorderRadius(borderRadius: Int) {
|
|
123
123
|
this.borderRadius = borderRadius
|
|
124
124
|
}
|
|
125
|
+
|
|
126
|
+
private companion object {
|
|
127
|
+
const val BUTTON_TYPE_BUY_DEFAULT = 0
|
|
128
|
+
const val BUTTON_TYPE_BUY_ALT = 1
|
|
129
|
+
const val BUTTON_TYPE_DONATE = 4
|
|
130
|
+
const val BUTTON_TYPE_CHECKOUT = 5
|
|
131
|
+
const val BUTTON_TYPE_BOOK = 6
|
|
132
|
+
const val BUTTON_TYPE_SUBSCRIBE = 7
|
|
133
|
+
const val BUTTON_TYPE_ORDER = 11
|
|
134
|
+
const val BUTTON_TYPE_PAY = 1000
|
|
135
|
+
const val BUTTON_TYPE_PLAIN = 1001
|
|
136
|
+
const val BUTTON_THEME_LIGHT_DEFAULT = 0
|
|
137
|
+
const val BUTTON_THEME_LIGHT_ALT = 1
|
|
138
|
+
const val BUTTON_THEME_DARK = 2
|
|
139
|
+
}
|
|
125
140
|
}
|
|
@@ -76,7 +76,8 @@ class GooglePayLauncherManager(
|
|
|
76
76
|
null,
|
|
77
77
|
createError(
|
|
78
78
|
GooglePayErrorType.Failed.toString(),
|
|
79
|
-
"Google Pay is not available on this device. You can use isPlatformPaySupported
|
|
79
|
+
"Google Pay is not available on this device. You can use isPlatformPaySupported " +
|
|
80
|
+
"to preemptively check for Google Pay support.",
|
|
80
81
|
),
|
|
81
82
|
)
|
|
82
83
|
}
|
|
@@ -35,13 +35,13 @@ class NavigationBarView(
|
|
|
35
35
|
LayoutParams.WRAP_CONTENT,
|
|
36
36
|
)
|
|
37
37
|
setBackgroundColor(Color.WHITE)
|
|
38
|
-
elevation =
|
|
38
|
+
elevation = TOOLBAR_ELEVATION
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// Create title TextView
|
|
42
42
|
titleTextView =
|
|
43
43
|
TextView(context).apply {
|
|
44
|
-
textSize =
|
|
44
|
+
textSize = TITLE_TEXT_SIZE
|
|
45
45
|
setTextColor(Color.BLACK)
|
|
46
46
|
gravity = Gravity.CENTER
|
|
47
47
|
}
|
|
@@ -67,7 +67,9 @@ class NavigationBarView(
|
|
|
67
67
|
),
|
|
68
68
|
)
|
|
69
69
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
70
|
-
drawable?.setColorFilter(
|
|
70
|
+
drawable?.setColorFilter(
|
|
71
|
+
android.graphics.BlendModeColorFilter(Color.BLACK, android.graphics.BlendMode.SRC_IN)
|
|
72
|
+
)
|
|
71
73
|
} else {
|
|
72
74
|
@Suppress("DEPRECATION")
|
|
73
75
|
drawable?.setColorFilter(PorterDuffColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN))
|
|
@@ -86,7 +88,7 @@ class NavigationBarView(
|
|
|
86
88
|
Toolbar.LayoutParams.WRAP_CONTENT,
|
|
87
89
|
).apply {
|
|
88
90
|
gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
|
89
|
-
marginEnd =
|
|
91
|
+
marginEnd = CLOSE_BUTTON_MARGIN_END
|
|
90
92
|
}
|
|
91
93
|
toolbar.addView(closeButton, buttonParams)
|
|
92
94
|
|
|
@@ -115,7 +117,7 @@ class NavigationBarView(
|
|
|
115
117
|
) {
|
|
116
118
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
|
117
119
|
// Set a fixed height for the navigation bar
|
|
118
|
-
val desiredHeight = (
|
|
120
|
+
val desiredHeight = (NAV_BAR_HEIGHT_DP * resources.displayMetrics.density).toInt()
|
|
119
121
|
val newHeightMeasureSpec = MeasureSpec.makeMeasureSpec(desiredHeight, MeasureSpec.EXACTLY)
|
|
120
122
|
super.onMeasure(widthMeasureSpec, newHeightMeasureSpec)
|
|
121
123
|
}
|
|
@@ -128,4 +130,11 @@ class NavigationBarView(
|
|
|
128
130
|
|
|
129
131
|
override fun getEventData() = Arguments.createMap()
|
|
130
132
|
}
|
|
133
|
+
|
|
134
|
+
private companion object {
|
|
135
|
+
const val TOOLBAR_ELEVATION = 4f
|
|
136
|
+
const val TITLE_TEXT_SIZE = 17f
|
|
137
|
+
const val CLOSE_BUTTON_MARGIN_END = 16
|
|
138
|
+
const val NAV_BAR_HEIGHT_DP = 56
|
|
139
|
+
}
|
|
131
140
|
}
|