@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
|
@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.requiredHeight
|
|
|
9
9
|
import androidx.compose.runtime.Composable
|
|
10
10
|
import androidx.compose.runtime.LaunchedEffect
|
|
11
11
|
import androidx.compose.runtime.getValue
|
|
12
|
-
import androidx.compose.runtime.mutableIntStateOf
|
|
13
12
|
import androidx.compose.runtime.mutableStateOf
|
|
14
13
|
import androidx.compose.runtime.remember
|
|
15
14
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
@@ -22,7 +21,6 @@ import androidx.compose.ui.unit.IntOffset
|
|
|
22
21
|
import androidx.compose.ui.unit.dp
|
|
23
22
|
import com.facebook.react.bridge.Arguments
|
|
24
23
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
25
|
-
import com.reactnativestripesdk.toWritableMap
|
|
26
24
|
import com.reactnativestripesdk.utils.KeepJsAwakeTask
|
|
27
25
|
import com.reactnativestripesdk.utils.mapFromConfirmationToken
|
|
28
26
|
import com.reactnativestripesdk.utils.mapFromCustomPaymentMethod
|
|
@@ -196,7 +194,7 @@ class EmbeddedPaymentElementView(
|
|
|
196
194
|
val stripeSdkModule =
|
|
197
195
|
try {
|
|
198
196
|
requireStripeSdkModule()
|
|
199
|
-
} catch (
|
|
197
|
+
} catch (_: IllegalArgumentException) {
|
|
200
198
|
return@Builder CreateIntentResult.Failure(
|
|
201
199
|
cause =
|
|
202
200
|
Exception(
|
|
@@ -242,7 +240,7 @@ class EmbeddedPaymentElementView(
|
|
|
242
240
|
val stripeSdkModule =
|
|
243
241
|
try {
|
|
244
242
|
requireStripeSdkModule()
|
|
245
|
-
} catch (
|
|
243
|
+
} catch (_: IllegalArgumentException) {
|
|
246
244
|
return@Builder CreateIntentResult.Failure(
|
|
247
245
|
cause =
|
|
248
246
|
Exception(
|
|
@@ -295,9 +293,6 @@ class EmbeddedPaymentElementView(
|
|
|
295
293
|
}
|
|
296
294
|
|
|
297
295
|
val embedded = rememberEmbeddedPaymentElement(builder)
|
|
298
|
-
var height by remember {
|
|
299
|
-
mutableIntStateOf(0)
|
|
300
|
-
}
|
|
301
296
|
|
|
302
297
|
// collect events: configure, confirm, clear
|
|
303
298
|
LaunchedEffect(Unit) {
|
|
@@ -348,10 +343,8 @@ class EmbeddedPaymentElementView(
|
|
|
348
343
|
}
|
|
349
344
|
}
|
|
350
345
|
|
|
351
|
-
val density = LocalDensity.current
|
|
352
|
-
|
|
353
346
|
Box {
|
|
354
|
-
|
|
347
|
+
MeasuredEmbeddedElement(
|
|
355
348
|
reportHeightChange = { h -> reportHeightChange(h) },
|
|
356
349
|
) {
|
|
357
350
|
embedded.Content()
|
|
@@ -360,7 +353,7 @@ class EmbeddedPaymentElementView(
|
|
|
360
353
|
}
|
|
361
354
|
|
|
362
355
|
@Composable
|
|
363
|
-
private fun
|
|
356
|
+
private fun MeasuredEmbeddedElement(
|
|
364
357
|
reportHeightChange: (Float) -> Unit,
|
|
365
358
|
content: @Composable () -> Unit,
|
|
366
359
|
) {
|
|
@@ -3,21 +3,20 @@ package com.reactnativestripesdk
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
5
|
import com.facebook.react.bridge.Dynamic
|
|
6
|
-
import com.facebook.react.bridge.ReadableArray
|
|
7
6
|
import com.facebook.react.bridge.ReadableMap
|
|
8
|
-
import com.facebook.react.bridge.ReadableType
|
|
9
7
|
import com.facebook.react.module.annotations.ReactModule
|
|
10
8
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
11
9
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
12
10
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
13
11
|
import com.facebook.react.viewmanagers.EmbeddedPaymentElementViewManagerDelegate
|
|
14
12
|
import com.facebook.react.viewmanagers.EmbeddedPaymentElementViewManagerInterface
|
|
15
|
-
import com.reactnativestripesdk.PaymentSheetManager.Companion.buildCustomerConfiguration
|
|
16
|
-
import com.reactnativestripesdk.PaymentSheetManager.Companion.buildGooglePayConfig
|
|
17
13
|
import com.reactnativestripesdk.addresssheet.AddressSheetView
|
|
18
14
|
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
19
15
|
import com.reactnativestripesdk.utils.PaymentSheetException
|
|
16
|
+
import com.reactnativestripesdk.utils.asMapOrNull
|
|
20
17
|
import com.reactnativestripesdk.utils.getBooleanOr
|
|
18
|
+
import com.reactnativestripesdk.utils.getIntegerList
|
|
19
|
+
import com.reactnativestripesdk.utils.getStringList
|
|
21
20
|
import com.reactnativestripesdk.utils.mapToPreferredNetworks
|
|
22
21
|
import com.reactnativestripesdk.utils.parseCustomPaymentMethods
|
|
23
22
|
import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi
|
|
@@ -54,10 +53,10 @@ class EmbeddedPaymentElementViewManager :
|
|
|
54
53
|
view: EmbeddedPaymentElementView,
|
|
55
54
|
cfg: Dynamic,
|
|
56
55
|
) {
|
|
57
|
-
val readableMap = cfg.
|
|
56
|
+
val readableMap = cfg.asMapOrNull()
|
|
58
57
|
if (readableMap == null) return
|
|
59
58
|
|
|
60
|
-
val rowSelectionBehaviorType =
|
|
59
|
+
val rowSelectionBehaviorType = mapToRowSelectionBehaviorType(readableMap)
|
|
61
60
|
view.rowSelectionBehaviorType.value = rowSelectionBehaviorType
|
|
62
61
|
|
|
63
62
|
val elementConfig = parseElementConfiguration(readableMap, view.context)
|
|
@@ -77,7 +76,7 @@ class EmbeddedPaymentElementViewManager :
|
|
|
77
76
|
view: EmbeddedPaymentElementView,
|
|
78
77
|
cfg: Dynamic,
|
|
79
78
|
) {
|
|
80
|
-
val readableMap = cfg.
|
|
79
|
+
val readableMap = cfg.asMapOrNull()
|
|
81
80
|
if (readableMap == null) return
|
|
82
81
|
|
|
83
82
|
// Detect which callback type to use based on the presence of the confirmation token handler
|
|
@@ -101,45 +100,18 @@ class EmbeddedPaymentElementViewManager :
|
|
|
101
100
|
context: Context,
|
|
102
101
|
): EmbeddedPaymentElement.Configuration {
|
|
103
102
|
val merchantDisplayName = map.getString("merchantDisplayName").orEmpty()
|
|
104
|
-
val allowsDelayedPaymentMethods
|
|
105
|
-
|
|
106
|
-
map.getType("allowsDelayedPaymentMethods") == ReadableType.Boolean
|
|
107
|
-
) {
|
|
108
|
-
map.getBoolean("allowsDelayedPaymentMethods")
|
|
109
|
-
} else {
|
|
110
|
-
false // default
|
|
111
|
-
}
|
|
112
|
-
var defaultBillingDetails: PaymentSheet.BillingDetails? = null
|
|
113
|
-
val billingDetailsMap = map.getMap("defaultBillingDetails")
|
|
114
|
-
if (billingDetailsMap != null) {
|
|
115
|
-
val addressMap = billingDetailsMap.getMap("address")
|
|
116
|
-
val address =
|
|
117
|
-
PaymentSheet.Address(
|
|
118
|
-
addressMap?.getString("city"),
|
|
119
|
-
addressMap?.getString("country"),
|
|
120
|
-
addressMap?.getString("line1"),
|
|
121
|
-
addressMap?.getString("line2"),
|
|
122
|
-
addressMap?.getString("postalCode"),
|
|
123
|
-
addressMap?.getString("state"),
|
|
124
|
-
)
|
|
125
|
-
defaultBillingDetails =
|
|
126
|
-
PaymentSheet.BillingDetails(
|
|
127
|
-
address,
|
|
128
|
-
billingDetailsMap.getString("email"),
|
|
129
|
-
billingDetailsMap.getString("name"),
|
|
130
|
-
billingDetailsMap.getString("phone"),
|
|
131
|
-
)
|
|
132
|
-
}
|
|
103
|
+
val allowsDelayedPaymentMethods = map.getBooleanOr("allowsDelayedPaymentMethods", false)
|
|
104
|
+
val defaultBillingDetails = buildBillingDetails(map.getMap("defaultBillingDetails"))
|
|
133
105
|
|
|
134
106
|
val customerConfiguration =
|
|
135
107
|
try {
|
|
136
108
|
buildCustomerConfiguration(map)
|
|
137
|
-
} catch (
|
|
109
|
+
} catch (_: PaymentSheetException) {
|
|
138
110
|
throw Error() // TODO handle error
|
|
139
111
|
}
|
|
140
112
|
|
|
141
113
|
val googlePayConfig = buildGooglePayConfig(map.getMap("googlePay"))
|
|
142
|
-
val linkConfig =
|
|
114
|
+
val linkConfig = buildLinkConfig(map.getMap("link"))
|
|
143
115
|
val shippingDetails =
|
|
144
116
|
map.getMap("defaultShippingDetails")?.let {
|
|
145
117
|
AddressSheetView.buildAddressDetails(it)
|
|
@@ -147,45 +119,24 @@ class EmbeddedPaymentElementViewManager :
|
|
|
147
119
|
val appearance =
|
|
148
120
|
try {
|
|
149
121
|
buildPaymentSheetAppearance(map.getMap("appearance"), context)
|
|
150
|
-
} catch (
|
|
122
|
+
} catch (_: PaymentSheetAppearanceException) {
|
|
151
123
|
throw Error() // TODO handle error
|
|
152
124
|
}
|
|
153
|
-
val billingConfigParams = map.getMap("billingDetailsCollectionConfiguration")
|
|
154
125
|
val billingDetailsConfig =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
phone = mapToCollectionMode(billingConfigParams?.getString("phone")),
|
|
158
|
-
email = mapToCollectionMode(billingConfigParams?.getString("email")),
|
|
159
|
-
address = mapToAddressCollectionMode(billingConfigParams?.getString("address")),
|
|
160
|
-
attachDefaultsToPaymentMethod =
|
|
161
|
-
billingConfigParams?.getBooleanOr("attachDefaultsToPaymentMethod", false) ?: false,
|
|
126
|
+
buildBillingDetailsCollectionConfiguration(
|
|
127
|
+
map.getMap("billingDetailsCollectionConfiguration"),
|
|
162
128
|
)
|
|
163
|
-
val allowsRemovalOfLastSavedPaymentMethod =
|
|
164
|
-
if (map.hasKey("allowsRemovalOfLastSavedPaymentMethod")) {
|
|
165
|
-
map.getBoolean("allowsRemovalOfLastSavedPaymentMethod")
|
|
166
|
-
} else {
|
|
167
|
-
true
|
|
168
|
-
}
|
|
129
|
+
val allowsRemovalOfLastSavedPaymentMethod = map.getBooleanOr("allowsRemovalOfLastSavedPaymentMethod", true)
|
|
169
130
|
val primaryButtonLabel = map.getString("primaryButtonLabel")
|
|
170
|
-
val paymentMethodOrder = map.
|
|
131
|
+
val paymentMethodOrder = map.getStringList("paymentMethodOrder")
|
|
171
132
|
|
|
172
|
-
val formSheetAction =
|
|
173
|
-
map
|
|
174
|
-
.getMap("formSheetAction")
|
|
175
|
-
?.getString("type")
|
|
176
|
-
?.let { type ->
|
|
177
|
-
when (type) {
|
|
178
|
-
"confirm" -> EmbeddedPaymentElement.FormSheetAction.Confirm
|
|
179
|
-
else -> EmbeddedPaymentElement.FormSheetAction.Continue
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
?: EmbeddedPaymentElement.FormSheetAction.Continue
|
|
133
|
+
val formSheetAction = mapToFormSheetAction(map)
|
|
183
134
|
|
|
184
135
|
val configurationBuilder =
|
|
185
136
|
EmbeddedPaymentElement.Configuration
|
|
186
137
|
.Builder(merchantDisplayName)
|
|
187
138
|
.formSheetAction(formSheetAction)
|
|
188
|
-
.allowsDelayedPaymentMethods(allowsDelayedPaymentMethods
|
|
139
|
+
.allowsDelayedPaymentMethods(allowsDelayedPaymentMethods)
|
|
189
140
|
.defaultBillingDetails(defaultBillingDetails)
|
|
190
141
|
.customer(customerConfiguration)
|
|
191
142
|
.googlePay(googlePayConfig)
|
|
@@ -196,19 +147,13 @@ class EmbeddedPaymentElementViewManager :
|
|
|
196
147
|
.preferredNetworks(
|
|
197
148
|
mapToPreferredNetworks(
|
|
198
149
|
map
|
|
199
|
-
.
|
|
150
|
+
.getIntegerList("preferredNetworks")
|
|
200
151
|
?.let { ArrayList(it) },
|
|
201
152
|
),
|
|
202
153
|
).allowsRemovalOfLastSavedPaymentMethod(allowsRemovalOfLastSavedPaymentMethod)
|
|
203
154
|
.cardBrandAcceptance(mapToCardBrandAcceptance(map))
|
|
204
155
|
.embeddedViewDisplaysMandateText(
|
|
205
|
-
|
|
206
|
-
map.getType("embeddedViewDisplaysMandateText") == ReadableType.Boolean
|
|
207
|
-
) {
|
|
208
|
-
map.getBoolean("embeddedViewDisplaysMandateText")
|
|
209
|
-
} else {
|
|
210
|
-
true // default value
|
|
211
|
-
},
|
|
156
|
+
map.getBooleanOr("embeddedViewDisplaysMandateText", true),
|
|
212
157
|
).customPaymentMethods(
|
|
213
158
|
parseCustomPaymentMethods(
|
|
214
159
|
map.getMap("customPaymentMethodConfiguration"),
|
|
@@ -221,23 +166,8 @@ class EmbeddedPaymentElementViewManager :
|
|
|
221
166
|
return configurationBuilder.build()
|
|
222
167
|
}
|
|
223
168
|
|
|
224
|
-
private fun parseRowSelectionBehavior(map: ReadableMap): RowSelectionBehaviorType {
|
|
225
|
-
val rowSelectionBehavior =
|
|
226
|
-
map
|
|
227
|
-
.getMap("rowSelectionBehavior")
|
|
228
|
-
?.getString("type")
|
|
229
|
-
?.let { type ->
|
|
230
|
-
when (type) {
|
|
231
|
-
"immediateAction" -> RowSelectionBehaviorType.ImmediateAction
|
|
232
|
-
else -> RowSelectionBehaviorType.Default
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
?: RowSelectionBehaviorType.Default
|
|
236
|
-
return rowSelectionBehavior
|
|
237
|
-
}
|
|
238
|
-
|
|
239
169
|
private fun parseIntentConfiguration(map: ReadableMap): PaymentSheet.IntentConfiguration {
|
|
240
|
-
val intentConfig =
|
|
170
|
+
val intentConfig = buildIntentConfiguration(map)
|
|
241
171
|
return intentConfig ?: throw IllegalArgumentException("IntentConfiguration is null")
|
|
242
172
|
}
|
|
243
173
|
|
|
@@ -250,35 +180,32 @@ class EmbeddedPaymentElementViewManager :
|
|
|
250
180
|
}
|
|
251
181
|
}
|
|
252
182
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return
|
|
183
|
+
internal fun mapToRowSelectionBehaviorType(map: ReadableMap?): RowSelectionBehaviorType {
|
|
184
|
+
val rowSelectionBehavior =
|
|
185
|
+
map
|
|
186
|
+
?.getMap("rowSelectionBehavior")
|
|
187
|
+
?.getString("type")
|
|
188
|
+
?.let { type ->
|
|
189
|
+
when (type) {
|
|
190
|
+
"immediateAction" -> RowSelectionBehaviorType.ImmediateAction
|
|
191
|
+
else -> RowSelectionBehaviorType.Default
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
?: RowSelectionBehaviorType.Default
|
|
195
|
+
return rowSelectionBehavior
|
|
266
196
|
}
|
|
267
197
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return result
|
|
198
|
+
internal fun mapToFormSheetAction(map: ReadableMap?): EmbeddedPaymentElement.FormSheetAction {
|
|
199
|
+
val formSheetAction =
|
|
200
|
+
map
|
|
201
|
+
?.getMap("formSheetAction")
|
|
202
|
+
?.getString("type")
|
|
203
|
+
?.let { type ->
|
|
204
|
+
when (type) {
|
|
205
|
+
"confirm" -> EmbeddedPaymentElement.FormSheetAction.Confirm
|
|
206
|
+
else -> EmbeddedPaymentElement.FormSheetAction.Continue
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
?: EmbeddedPaymentElement.FormSheetAction.Continue
|
|
210
|
+
return formSheetAction
|
|
284
211
|
}
|
|
@@ -32,10 +32,6 @@ class EventEmitterCompat(
|
|
|
32
32
|
invoke("onFinancialConnectionsEvent", value)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
fun emitOnOrderTrackingCallback() {
|
|
36
|
-
invoke("onOrderTrackingCallback")
|
|
37
|
-
}
|
|
38
|
-
|
|
39
35
|
fun emitOnCustomerAdapterFetchPaymentMethodsCallback() {
|
|
40
36
|
invoke("onCustomerAdapterFetchPaymentMethodsCallback")
|
|
41
37
|
}
|
|
@@ -72,10 +68,6 @@ class EventEmitterCompat(
|
|
|
72
68
|
invoke("embeddedPaymentElementDidUpdateHeight", value)
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
fun emitEmbeddedPaymentElementWillPresent() {
|
|
76
|
-
invoke("embeddedPaymentElementWillPresent")
|
|
77
|
-
}
|
|
78
|
-
|
|
79
71
|
fun emitEmbeddedPaymentElementDidUpdatePaymentOption(value: ReadableMap?) {
|
|
80
72
|
invoke("embeddedPaymentElementDidUpdatePaymentOption", value)
|
|
81
73
|
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap
|
|
7
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
8
|
+
import com.reactnativestripesdk.utils.createFailedError
|
|
9
|
+
|
|
10
|
+
@ReactModule(name = NativeOnrampSdkModuleSpec.NAME)
|
|
11
|
+
class FakeOnrampSdkModule(
|
|
12
|
+
reactContext: ReactApplicationContext,
|
|
13
|
+
) : NativeOnrampSdkModuleSpec(reactContext) {
|
|
14
|
+
@ReactMethod
|
|
15
|
+
override fun initialise(
|
|
16
|
+
params: ReadableMap?,
|
|
17
|
+
promise: Promise?,
|
|
18
|
+
) {
|
|
19
|
+
promise?.resolve(null)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@ReactMethod
|
|
23
|
+
override fun configureOnramp(
|
|
24
|
+
config: ReadableMap?,
|
|
25
|
+
promise: Promise?,
|
|
26
|
+
) {
|
|
27
|
+
promise?.resolveNotImplemented()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@ReactMethod
|
|
31
|
+
override fun hasLinkAccount(
|
|
32
|
+
email: String?,
|
|
33
|
+
promise: Promise?,
|
|
34
|
+
) {
|
|
35
|
+
promise?.resolveNotImplemented()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@ReactMethod
|
|
39
|
+
override fun registerLinkUser(
|
|
40
|
+
info: ReadableMap?,
|
|
41
|
+
promise: Promise?,
|
|
42
|
+
) {
|
|
43
|
+
promise?.resolveNotImplemented()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@ReactMethod
|
|
47
|
+
override fun registerWalletAddress(
|
|
48
|
+
walletAddress: String?,
|
|
49
|
+
network: String?,
|
|
50
|
+
promise: Promise?,
|
|
51
|
+
) {
|
|
52
|
+
promise?.resolveNotImplemented()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@ReactMethod
|
|
56
|
+
override fun attachKycInfo(
|
|
57
|
+
kycInfo: ReadableMap?,
|
|
58
|
+
promise: Promise?,
|
|
59
|
+
) {
|
|
60
|
+
promise?.resolveNotImplemented()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@ReactMethod
|
|
64
|
+
override fun updatePhoneNumber(
|
|
65
|
+
phone: String?,
|
|
66
|
+
promise: Promise?,
|
|
67
|
+
) {
|
|
68
|
+
promise?.resolveNotImplemented()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@ReactMethod
|
|
72
|
+
override fun authenticateUser(promise: Promise?) {
|
|
73
|
+
promise?.resolveNotImplemented()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@ReactMethod
|
|
77
|
+
override fun verifyIdentity(promise: Promise?) {
|
|
78
|
+
promise?.resolveNotImplemented()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@ReactMethod
|
|
82
|
+
override fun presentKycInfoVerification(
|
|
83
|
+
updatedAddress: ReadableMap?,
|
|
84
|
+
promise: Promise,
|
|
85
|
+
) {
|
|
86
|
+
promise?.resolveNotImplemented()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@ReactMethod
|
|
90
|
+
override fun collectPaymentMethod(
|
|
91
|
+
paymentMethod: String?,
|
|
92
|
+
platformPayParams: ReadableMap?,
|
|
93
|
+
promise: Promise?,
|
|
94
|
+
) {
|
|
95
|
+
promise?.resolveNotImplemented()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@ReactMethod
|
|
99
|
+
override fun provideCheckoutClientSecret(clientSecret: String?) {
|
|
100
|
+
// No-op
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@ReactMethod
|
|
104
|
+
override fun createCryptoPaymentToken(promise: Promise?) {
|
|
105
|
+
promise?.resolveNotImplemented()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@ReactMethod
|
|
109
|
+
override fun performCheckout(
|
|
110
|
+
onrampSessionId: String?,
|
|
111
|
+
promise: Promise?,
|
|
112
|
+
) {
|
|
113
|
+
promise?.resolveNotImplemented()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@ReactMethod
|
|
117
|
+
override fun onrampAuthorize(
|
|
118
|
+
linkAuthIntentId: String?,
|
|
119
|
+
promise: Promise?,
|
|
120
|
+
) {
|
|
121
|
+
promise?.resolveNotImplemented()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@ReactMethod
|
|
125
|
+
override fun logout(promise: Promise?) {
|
|
126
|
+
promise?.resolveNotImplemented()
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@ReactMethod
|
|
130
|
+
override fun getCryptoTokenDisplayData(
|
|
131
|
+
token: ReadableMap,
|
|
132
|
+
promise: Promise,
|
|
133
|
+
) {
|
|
134
|
+
promise?.resolveNotImplemented()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@ReactMethod
|
|
138
|
+
override fun authenticateUserWithToken(
|
|
139
|
+
token: String,
|
|
140
|
+
promise: Promise,
|
|
141
|
+
) {
|
|
142
|
+
promise.resolveNotImplemented()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private fun Promise.resolveNotImplemented() {
|
|
146
|
+
this.resolve(
|
|
147
|
+
createFailedError(
|
|
148
|
+
NotImplementedError(
|
|
149
|
+
"To enable Onramp, add 'StripeSdk_includeOnramp=true' to gradle.properties.",
|
|
150
|
+
),
|
|
151
|
+
),
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -6,7 +6,6 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
6
6
|
import com.facebook.react.bridge.ReadableArray
|
|
7
7
|
import com.facebook.react.bridge.WritableArray
|
|
8
8
|
import com.facebook.react.bridge.WritableMap
|
|
9
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
10
9
|
import com.reactnativestripesdk.utils.ErrorType
|
|
11
10
|
import com.reactnativestripesdk.utils.StripeUIManager
|
|
12
11
|
import com.reactnativestripesdk.utils.createError
|
|
@@ -105,7 +104,7 @@ class FinancialConnectionsSheetManager(
|
|
|
105
104
|
|
|
106
105
|
is FinancialConnectionsSheetResult.Completed -> {
|
|
107
106
|
promise?.resolve(
|
|
108
|
-
|
|
107
|
+
Arguments.createMap().also {
|
|
109
108
|
it.putMap("session", mapFromSession(result.financialConnectionsSession))
|
|
110
109
|
},
|
|
111
110
|
)
|
|
@@ -115,13 +114,13 @@ class FinancialConnectionsSheetManager(
|
|
|
115
114
|
|
|
116
115
|
companion object {
|
|
117
116
|
private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap =
|
|
118
|
-
|
|
117
|
+
Arguments.createMap().also {
|
|
119
118
|
it.putMap("session", mapFromSession(result.financialConnectionsSession))
|
|
120
119
|
it.putMap("token", mapFromToken(result.token))
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
private fun mapFromSession(financialConnectionsSession: FinancialConnectionsSession): WritableMap {
|
|
124
|
-
val session =
|
|
123
|
+
val session = Arguments.createMap()
|
|
125
124
|
session.putString("id", financialConnectionsSession.id)
|
|
126
125
|
session.putString("clientSecret", financialConnectionsSession.clientSecret)
|
|
127
126
|
session.putBoolean("livemode", financialConnectionsSession.livemode)
|
|
@@ -132,7 +131,7 @@ class FinancialConnectionsSheetManager(
|
|
|
132
131
|
private fun mapFromAccountsList(accounts: FinancialConnectionsAccountList): ReadableArray {
|
|
133
132
|
val results: WritableArray = Arguments.createArray()
|
|
134
133
|
for (account in accounts.data) {
|
|
135
|
-
val map =
|
|
134
|
+
val map = Arguments.createMap()
|
|
136
135
|
map.putString("id", account.id)
|
|
137
136
|
map.putBoolean("livemode", account.livemode)
|
|
138
137
|
map.putString("displayName", account.displayName)
|
|
@@ -166,10 +165,10 @@ class FinancialConnectionsSheetManager(
|
|
|
166
165
|
if (balance == null) {
|
|
167
166
|
return null
|
|
168
167
|
}
|
|
169
|
-
val map =
|
|
168
|
+
val map = Arguments.createMap()
|
|
170
169
|
map.putDouble("asOf", balance.asOf * 1000.0)
|
|
171
170
|
map.putString("type", mapFromBalanceType(balance.type))
|
|
172
|
-
|
|
171
|
+
Arguments.createMap().also {
|
|
173
172
|
for (entry in balance.current.entries) {
|
|
174
173
|
it.putInt(entry.key, entry.value)
|
|
175
174
|
}
|
|
@@ -181,9 +180,9 @@ class FinancialConnectionsSheetManager(
|
|
|
181
180
|
return map
|
|
182
181
|
}
|
|
183
182
|
|
|
184
|
-
private fun mapFromCashAvailable(balance: Balance):
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
private fun mapFromCashAvailable(balance: Balance): WritableMap =
|
|
184
|
+
Arguments.createMap().also { cashMap ->
|
|
185
|
+
Arguments.createMap().also { availableMap ->
|
|
187
186
|
balance.cash?.available?.entries?.let { entries ->
|
|
188
187
|
for (entry in entries) {
|
|
189
188
|
availableMap.putInt(entry.key, entry.value)
|
|
@@ -193,9 +192,9 @@ class FinancialConnectionsSheetManager(
|
|
|
193
192
|
}
|
|
194
193
|
}
|
|
195
194
|
|
|
196
|
-
private fun mapFromCreditUsed(balance: Balance):
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
private fun mapFromCreditUsed(balance: Balance): WritableMap =
|
|
196
|
+
Arguments.createMap().also { creditMap ->
|
|
197
|
+
Arguments.createMap().also { usedMap ->
|
|
199
198
|
balance.credit?.used?.entries?.let { entries ->
|
|
200
199
|
for (entry in entries) {
|
|
201
200
|
usedMap.putInt(entry.key, entry.value)
|
|
@@ -209,7 +208,7 @@ class FinancialConnectionsSheetManager(
|
|
|
209
208
|
if (balanceRefresh == null) {
|
|
210
209
|
return null
|
|
211
210
|
}
|
|
212
|
-
val map =
|
|
211
|
+
val map = Arguments.createMap()
|
|
213
212
|
map.putString("status", mapFromBalanceRefreshStatus(balanceRefresh.status))
|
|
214
213
|
map.putDouble("lastAttemptedAt", balanceRefresh.lastAttemptedAt * 1000.0)
|
|
215
214
|
return map
|
|
@@ -251,7 +250,6 @@ class FinancialConnectionsSheetManager(
|
|
|
251
250
|
FinancialConnectionsAccount.Permissions.TRANSACTIONS -> "transactions"
|
|
252
251
|
FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
|
|
253
252
|
FinancialConnectionsAccount.Permissions.UNKNOWN -> "unparsable"
|
|
254
|
-
FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
|
|
255
253
|
}
|
|
256
254
|
|
|
257
255
|
private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String =
|
|
@@ -108,7 +108,7 @@ class GooglePayButtonView(
|
|
|
108
108
|
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
109
109
|
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
|
|
110
110
|
)
|
|
111
|
-
|
|
111
|
+
layout(left, top, right, bottom)
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
fun setType(type: Int) {
|
|
@@ -30,7 +30,7 @@ class GooglePayLauncherManager(
|
|
|
30
30
|
private var configuration =
|
|
31
31
|
GooglePayLauncher.Config(
|
|
32
32
|
environment =
|
|
33
|
-
if (googlePayParams.
|
|
33
|
+
if (googlePayParams.getBooleanOr("testEnv", false)) {
|
|
34
34
|
GooglePayEnvironment.Test
|
|
35
35
|
} else {
|
|
36
36
|
GooglePayEnvironment.Production
|
|
@@ -3,9 +3,9 @@ package com.reactnativestripesdk
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.content.Intent
|
|
5
5
|
import androidx.fragment.app.FragmentActivity
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
6
7
|
import com.facebook.react.bridge.Promise
|
|
7
8
|
import com.facebook.react.bridge.ReadableMap
|
|
8
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
9
9
|
import com.google.android.gms.tasks.Task
|
|
10
10
|
import com.google.android.gms.wallet.AutoResolveHelper
|
|
11
11
|
import com.google.android.gms.wallet.PaymentData
|
|
@@ -15,6 +15,7 @@ import com.google.android.gms.wallet.WalletConstants
|
|
|
15
15
|
import com.reactnativestripesdk.utils.ErrorType
|
|
16
16
|
import com.reactnativestripesdk.utils.createError
|
|
17
17
|
import com.reactnativestripesdk.utils.getBooleanOr
|
|
18
|
+
import com.reactnativestripesdk.utils.getIntOr
|
|
18
19
|
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
19
20
|
import com.reactnativestripesdk.utils.mapFromShippingContact
|
|
20
21
|
import com.reactnativestripesdk.utils.mapFromToken
|
|
@@ -58,7 +59,7 @@ class GooglePayRequestHelper {
|
|
|
58
59
|
Wallet.WalletOptions
|
|
59
60
|
.Builder()
|
|
60
61
|
.setEnvironment(
|
|
61
|
-
if (googlePayParams.
|
|
62
|
+
if (googlePayParams.getBooleanOr("testEnv", false)) {
|
|
62
63
|
WalletConstants.ENVIRONMENT_TEST
|
|
63
64
|
} else {
|
|
64
65
|
WalletConstants.ENVIRONMENT_PRODUCTION
|
|
@@ -107,7 +108,7 @@ class GooglePayRequestHelper {
|
|
|
107
108
|
private fun buildTransactionInfo(params: ReadableMap): GooglePayJsonFactory.TransactionInfo {
|
|
108
109
|
val countryCode = params.getString("merchantCountryCode").orEmpty()
|
|
109
110
|
val currencyCode = params.getString("currencyCode") ?: "USD"
|
|
110
|
-
val amount = params.
|
|
111
|
+
val amount = params.getIntOr("amount", 0)
|
|
111
112
|
val label = params.getString("label")
|
|
112
113
|
|
|
113
114
|
return GooglePayJsonFactory.TransactionInfo(
|
|
@@ -124,6 +125,7 @@ class GooglePayRequestHelper {
|
|
|
124
125
|
request: Task<PaymentData>,
|
|
125
126
|
activity: FragmentActivity,
|
|
126
127
|
) {
|
|
128
|
+
@Suppress("DEPRECATION")
|
|
127
129
|
AutoResolveHelper.resolveTask(request, activity, LOAD_PAYMENT_DATA_REQUEST_CODE)
|
|
128
130
|
}
|
|
129
131
|
|
|
@@ -165,7 +167,7 @@ class GooglePayRequestHelper {
|
|
|
165
167
|
promise: Promise,
|
|
166
168
|
) {
|
|
167
169
|
val paymentInformation = JSONObject(paymentData.toJson())
|
|
168
|
-
val promiseResult =
|
|
170
|
+
val promiseResult = Arguments.createMap()
|
|
169
171
|
stripe.createPaymentMethod(
|
|
170
172
|
PaymentMethodCreateParams.createFromGooglePay(paymentInformation),
|
|
171
173
|
callback =
|
|
@@ -193,7 +195,7 @@ class GooglePayRequestHelper {
|
|
|
193
195
|
) {
|
|
194
196
|
val paymentInformation = JSONObject(paymentData.toJson())
|
|
195
197
|
val googlePayResult = GooglePayResult.fromJson(paymentInformation)
|
|
196
|
-
val promiseResult =
|
|
198
|
+
val promiseResult = Arguments.createMap()
|
|
197
199
|
googlePayResult.token?.let {
|
|
198
200
|
promiseResult.putMap("token", mapFromToken(it))
|
|
199
201
|
if (googlePayResult.shippingInformation != null) {
|