@stripe/stripe-react-native 0.65.0 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/android/detekt/detekt-baseline.xml +1 -76
- 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 +56 -58
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementEvent.kt +26 -0
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementView.kt +139 -0
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementViewManager.kt +59 -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/EventEmitterCompat.kt +4 -0
- 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 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfig.kt +6 -2
- 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 +118 -48
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +281 -46
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +2 -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 +8 -18
- 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 +127 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/DefaultActivityLifecycleCallbacks.kt +41 -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 -13
- 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/NativeOnrampSdkModuleSpec.java +17 -3
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +13 -1
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +116 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +109 -1
- package/android/src/test/java/com/reactnativestripesdk/DrawableLoadingTest.kt +6 -2
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +60 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +145 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +9 -4
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutMappersTest.kt +98 -0
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutTestFixtures.java +57 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +6 -8
- package/ios/CurrencySelectorElementManager.m +16 -0
- package/ios/CurrencySelectorElementView.swift +159 -0
- package/ios/EmbeddedPaymentElementView.swift +1 -1
- package/ios/Mappers+Checkout.swift +337 -0
- package/ios/Mappers.swift +90 -2
- package/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm +16 -2
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.h +10 -0
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.mm +89 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +6 -0
- package/ios/PaymentOptionDisplayData+ReactNative.swift +1 -1
- package/ios/PaymentSheetAppearance.swift +1 -1
- package/ios/StripeOnrampSdk.mm +19 -0
- package/ios/StripeSdk.mm +136 -0
- package/ios/StripeSdkEmitter.swift +1 -0
- package/ios/StripeSdkImpl+Checkout.swift +360 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +1 -1
- package/ios/StripeSdkImpl+Embedded.swift +108 -27
- package/ios/StripeSdkImpl+PaymentSheet.swift +18 -2
- package/ios/StripeSdkImpl.swift +89 -7
- package/jest/mock.js +13 -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 +1 -1
- package/lib/commonjs/components/PaymentMethodMessagingElement.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/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 +1 -1
- package/lib/commonjs/hooks/useCheckout.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +1 -1
- package/lib/commonjs/hooks/useOnramp.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/NativeOnrampSdkModule.js.map +1 -1
- package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js +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/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 +1 -1
- package/lib/module/components/PaymentMethodMessagingElement.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/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 +1 -1
- package/lib/module/hooks/useCheckout.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +1 -1
- package/lib/module/hooks/useOnramp.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/NativeOnrampSdkModule.js.map +1 -1
- package/lib/module/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js +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/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 +1 -1
- package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts.map +1 -1
- 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.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +22 -0
- package/lib/typescript/src/hooks/useOnramp.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/NativeOnrampSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +5 -2
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Checkout.d.ts +268 -86
- package/lib/typescript/src/types/Checkout.d.ts.map +1 -1
- 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/Onramp.d.ts +94 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
- package/package.json +16 -4
- package/src/components/CurrencySelectorElement.tsx +95 -0
- package/src/components/PaymentMethodMessagingElement.tsx +54 -52
- package/src/events.ts +11 -0
- package/src/functions.ts +30 -1
- package/src/hooks/useCheckout.tsx +129 -74
- package/src/hooks/useOnramp.tsx +44 -0
- package/src/specs/NativeCurrencySelectorElement.ts +35 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +12 -2
- package/src/specs/NativeOnrampSdkModule.ts +5 -0
- package/src/specs/NativeStripeSdkModule.ts +16 -2
- package/src/types/Checkout.ts +291 -86
- package/src/types/EmbeddedPaymentElement.tsx +117 -26
- package/src/types/Onramp.ts +109 -0
- package/stripe-react-native.podspec +1 -1
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -835
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -17
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
package com.reactnativestripesdk.utils
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.stripe.android.paymentelement.CheckoutSessionPreview
|
|
5
|
+
import com.stripe.android.checkout.Address as CheckoutAddress
|
|
6
|
+
|
|
7
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
8
|
+
internal data class CheckoutAddressUpdate(
|
|
9
|
+
val name: String? = null,
|
|
10
|
+
val phone: String? = null,
|
|
11
|
+
val country: String,
|
|
12
|
+
val line1: String? = null,
|
|
13
|
+
val line2: String? = null,
|
|
14
|
+
val city: String? = null,
|
|
15
|
+
val state: String? = null,
|
|
16
|
+
val postalCode: String? = null,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
internal fun buildCheckoutAddressUpdate(
|
|
20
|
+
name: String?,
|
|
21
|
+
phone: String?,
|
|
22
|
+
address: ReadableMap,
|
|
23
|
+
): CheckoutAddressUpdate? {
|
|
24
|
+
val country = address.getString("country")?.trim()?.takeIf { it.isNotEmpty() } ?: return null
|
|
25
|
+
return CheckoutAddressUpdate(
|
|
26
|
+
name = name?.trim(),
|
|
27
|
+
phone = phone?.trim(),
|
|
28
|
+
country = country,
|
|
29
|
+
line1 = address.getString("line1")?.trim(),
|
|
30
|
+
line2 = address.getString("line2")?.trim(),
|
|
31
|
+
city = address.getString("city")?.trim(),
|
|
32
|
+
state = address.getString("state")?.trim(),
|
|
33
|
+
postalCode = address.getString("postalCode")?.trim(),
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
38
|
+
internal fun CheckoutAddressUpdate.toCheckoutAddress(): CheckoutAddress =
|
|
39
|
+
CheckoutAddress()
|
|
40
|
+
.country(country)
|
|
41
|
+
.line1(line1)
|
|
42
|
+
.line2(line2)
|
|
43
|
+
.city(city)
|
|
44
|
+
.state(state)
|
|
45
|
+
.postalCode(postalCode)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
package com.reactnativestripesdk.utils
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableArray
|
|
5
|
+
import com.facebook.react.bridge.WritableMap
|
|
6
|
+
import com.stripe.android.checkout.Checkout
|
|
7
|
+
import com.stripe.android.checkout.CheckoutSession
|
|
8
|
+
import com.stripe.android.paymentelement.CheckoutSessionPreview
|
|
9
|
+
|
|
10
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
11
|
+
internal fun mapFromCheckoutState(checkout: Checkout): WritableMap =
|
|
12
|
+
mapFromCheckoutState(
|
|
13
|
+
isLoading = checkout.isLoading.value,
|
|
14
|
+
session = checkout.checkoutSession.value,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
18
|
+
internal fun mapFromCheckoutState(
|
|
19
|
+
isLoading: Boolean,
|
|
20
|
+
session: CheckoutSession,
|
|
21
|
+
): WritableMap =
|
|
22
|
+
Arguments.createMap().apply {
|
|
23
|
+
putString("status", if (isLoading) "loading" else "loaded")
|
|
24
|
+
putMap("session", mapFromCheckoutSession(session))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
28
|
+
private fun mapFromCheckoutSession(session: CheckoutSession): WritableMap =
|
|
29
|
+
Arguments.createMap().apply {
|
|
30
|
+
putString("id", session.id)
|
|
31
|
+
putBoolean("livemode", false)
|
|
32
|
+
|
|
33
|
+
if (session.currency.isNotBlank()) {
|
|
34
|
+
putString("currency", session.currency)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
putMap("status", mapFromStatus(session.status))
|
|
38
|
+
putMap("tax", mapFromTax(session.tax))
|
|
39
|
+
session.totalSummary?.let { putMap("total", mapFromTotal(it)) }
|
|
40
|
+
|
|
41
|
+
putArray("lineItems", mapFromLineItems(session))
|
|
42
|
+
putArray("shippingOptions", mapFromShippingOptions(session))
|
|
43
|
+
putArray("discountAmounts", Arguments.createArray())
|
|
44
|
+
putArray("currencyOptions", Arguments.createArray())
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
48
|
+
private fun mapFromStatus(status: CheckoutSession.Status): WritableMap =
|
|
49
|
+
Arguments.createMap().apply {
|
|
50
|
+
putString(
|
|
51
|
+
"type",
|
|
52
|
+
when (status) {
|
|
53
|
+
CheckoutSession.Status.Open -> "open"
|
|
54
|
+
CheckoutSession.Status.Complete -> "complete"
|
|
55
|
+
CheckoutSession.Status.Expired -> "expired"
|
|
56
|
+
else -> "unknown"
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
62
|
+
private fun mapFromTax(tax: CheckoutSession.Tax): WritableMap =
|
|
63
|
+
Arguments.createMap().apply {
|
|
64
|
+
putString(
|
|
65
|
+
"status",
|
|
66
|
+
when (tax.status) {
|
|
67
|
+
CheckoutSession.Tax.Status.Ready -> "ready"
|
|
68
|
+
CheckoutSession.Tax.Status.RequiresShippingAddress -> "requiresShippingAddress"
|
|
69
|
+
CheckoutSession.Tax.Status.RequiresBillingAddress -> "requiresBillingAddress"
|
|
70
|
+
else -> "unknown"
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
76
|
+
private fun mapFromTotal(totals: CheckoutSession.TotalSummary): WritableMap =
|
|
77
|
+
Arguments.createMap().apply {
|
|
78
|
+
val taxTotal = totals.taxAmounts.sumOf { it.amount }
|
|
79
|
+
|
|
80
|
+
putMap("subtotal", makeAmount(totals.subtotal))
|
|
81
|
+
putMap("taxExclusive", makeAmount(taxTotal))
|
|
82
|
+
putMap("taxInclusive", makeAmount(0L))
|
|
83
|
+
putMap("shippingRate", makeAmount(totals.shippingRate?.amount ?: 0L))
|
|
84
|
+
putMap("discount", makeAmount(0L))
|
|
85
|
+
putMap("total", makeAmount(totals.totalAmountDue))
|
|
86
|
+
putMap("appliedBalance", makeAmount(0L))
|
|
87
|
+
putBoolean("balanceAppliedToNextInvoice", false)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
91
|
+
private fun mapFromLineItems(session: CheckoutSession): WritableArray =
|
|
92
|
+
Arguments.createArray().apply {
|
|
93
|
+
session.lineItems.forEach { item ->
|
|
94
|
+
pushMap(
|
|
95
|
+
Arguments.createMap().apply {
|
|
96
|
+
putString("id", item.id)
|
|
97
|
+
putString("name", item.name)
|
|
98
|
+
putInt("quantity", item.quantity)
|
|
99
|
+
putArray("images", Arguments.createArray())
|
|
100
|
+
putArray("discountAmounts", Arguments.createArray())
|
|
101
|
+
putArray("taxAmounts", Arguments.createArray())
|
|
102
|
+
item.unitAmount?.let { putMap("unitAmount", makeAmount(it)) }
|
|
103
|
+
},
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@OptIn(CheckoutSessionPreview::class)
|
|
109
|
+
private fun mapFromShippingOptions(session: CheckoutSession): WritableArray =
|
|
110
|
+
Arguments.createArray().apply {
|
|
111
|
+
session.shippingOptions.forEach { option ->
|
|
112
|
+
pushMap(
|
|
113
|
+
Arguments.createMap().apply {
|
|
114
|
+
putString("id", option.id)
|
|
115
|
+
putString("displayName", option.displayName)
|
|
116
|
+
putMap("amount", makeAmount(option.amount))
|
|
117
|
+
putString("currency", session.currency)
|
|
118
|
+
},
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private fun makeAmount(minorUnits: Long): WritableMap =
|
|
124
|
+
Arguments.createMap().apply {
|
|
125
|
+
putString("amount", "")
|
|
126
|
+
putDouble("minorUnitsAmount", minorUnits.toDouble())
|
|
127
|
+
}
|
package/android/src/main/java/com/reactnativestripesdk/utils/DefaultActivityLifecycleCallbacks.kt
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package com.reactnativestripesdk.utils
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.app.Application
|
|
5
|
+
import android.os.Bundle
|
|
6
|
+
|
|
7
|
+
internal open class DefaultActivityLifecycleCallbacks : Application.ActivityLifecycleCallbacks {
|
|
8
|
+
override fun onActivityCreated(
|
|
9
|
+
activity: Activity,
|
|
10
|
+
savedInstanceState: Bundle?,
|
|
11
|
+
) {
|
|
12
|
+
// NO-OP
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
override fun onActivityStarted(activity: Activity) {
|
|
16
|
+
// NO-OP
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun onActivityResumed(activity: Activity) {
|
|
20
|
+
// NO-OP
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override fun onActivityPaused(activity: Activity) {
|
|
24
|
+
// NO-OP
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override fun onActivityStopped(activity: Activity) {
|
|
28
|
+
// NO-OP
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override fun onActivitySaveInstanceState(
|
|
32
|
+
activity: Activity,
|
|
33
|
+
outState: Bundle,
|
|
34
|
+
) {
|
|
35
|
+
// NO-OP
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override fun onActivityDestroyed(activity: Activity) {
|
|
39
|
+
// NO-OP
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -186,14 +186,16 @@ internal fun createError(
|
|
|
186
186
|
return mapError(code, error.message, error.localizedMessage, null, null, null)
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
internal fun createCanceledError(message: String? = null): WritableMap =
|
|
189
|
+
internal fun createCanceledError(message: String? = null): WritableMap =
|
|
190
|
+
createError(ErrorType.Canceled.toString(), message)
|
|
190
191
|
|
|
191
192
|
internal fun createFailedError(error: Throwable): WritableMap = createError(ErrorType.Failed.toString(), error)
|
|
192
193
|
|
|
193
194
|
internal fun createMissingInitError(): WritableMap =
|
|
194
195
|
createError(
|
|
195
196
|
ErrorType.Failed.toString(),
|
|
196
|
-
"Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component
|
|
197
|
+
"Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component " +
|
|
198
|
+
"or the initStripe method.",
|
|
197
199
|
)
|
|
198
200
|
|
|
199
201
|
internal fun createOnrampNotConfiguredError(): WritableMap =
|
|
@@ -27,7 +27,11 @@ fun View.hideSoftKeyboard() {
|
|
|
27
27
|
fun ReadableMap?.getBooleanOr(
|
|
28
28
|
key: String,
|
|
29
29
|
default: Boolean,
|
|
30
|
-
): Boolean = if (this?.hasKey(key) == true && this.getType(key) == ReadableType.Boolean)
|
|
30
|
+
): Boolean = if (this?.hasKey(key) == true && this.getType(key) == ReadableType.Boolean) {
|
|
31
|
+
this.getBoolean(key)
|
|
32
|
+
} else {
|
|
33
|
+
default
|
|
34
|
+
}
|
|
31
35
|
|
|
32
36
|
fun ReadableMap?.getIntOrNull(key: String): Int? =
|
|
33
37
|
if (this?.hasKey(key) == true && this.getType(key) == ReadableType.Number) this.getInt(key) else null
|
|
@@ -205,7 +205,9 @@ internal fun mapFromBillingDetails(billingDatails: PaymentMethod.BillingDetails?
|
|
|
205
205
|
return details
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
internal fun mapFromPaymentSheetBillingDetails(
|
|
208
|
+
internal fun mapFromPaymentSheetBillingDetails(
|
|
209
|
+
billing: com.stripe.android.paymentsheet.PaymentSheet.BillingDetails?
|
|
210
|
+
): WritableMap {
|
|
209
211
|
val details = Arguments.createMap()
|
|
210
212
|
details.putString("name", billing?.name)
|
|
211
213
|
details.putString("email", billing?.email)
|
|
@@ -712,7 +714,7 @@ internal fun mapToShippingDetails(shippingDetails: ReadableMap?): ConfirmPayment
|
|
|
712
714
|
)
|
|
713
715
|
}
|
|
714
716
|
|
|
715
|
-
private fun convertToUnixTimestamp(timestamp: Long): String = (timestamp *
|
|
717
|
+
private fun convertToUnixTimestamp(timestamp: Long): String = (timestamp * SECONDS_TO_MILLIS).toString()
|
|
716
718
|
|
|
717
719
|
fun mapToUICustomization(params: ReadableMap): PaymentAuthConfig.Stripe3ds2UiCustomization {
|
|
718
720
|
val labelCustomization = params.getMap("label")
|
|
@@ -964,15 +966,15 @@ internal fun mapToPreferredNetworks(networksAsInts: List<Int>?): List<CardBrand>
|
|
|
964
966
|
|
|
965
967
|
val intToCardBrand =
|
|
966
968
|
mapOf(
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
969
|
+
CARD_BRAND_JCB to CardBrand.JCB,
|
|
970
|
+
CARD_BRAND_AMEX to CardBrand.AmericanExpress,
|
|
971
|
+
CARD_BRAND_CARTES_BANCAIRES to CardBrand.CartesBancaires,
|
|
972
|
+
CARD_BRAND_DINERS_CLUB to CardBrand.DinersClub,
|
|
973
|
+
CARD_BRAND_DISCOVER to CardBrand.Discover,
|
|
974
|
+
CARD_BRAND_MASTERCARD to CardBrand.MasterCard,
|
|
975
|
+
CARD_BRAND_UNION_PAY to CardBrand.UnionPay,
|
|
976
|
+
CARD_BRAND_VISA to CardBrand.Visa,
|
|
977
|
+
CARD_BRAND_UNKNOWN to CardBrand.Unknown,
|
|
976
978
|
)
|
|
977
979
|
|
|
978
980
|
return networksAsInts.mapNotNull { intToCardBrand[it] }
|
|
@@ -1034,7 +1036,9 @@ private fun Map<String, Any?>.toReadableMap(): ReadableMap {
|
|
|
1034
1036
|
}
|
|
1035
1037
|
|
|
1036
1038
|
@SuppressLint("RestrictedApi")
|
|
1037
|
-
internal fun parseCustomPaymentMethods(
|
|
1039
|
+
internal fun parseCustomPaymentMethods(
|
|
1040
|
+
customPaymentMethodConfig: ReadableMap?
|
|
1041
|
+
): List<PaymentSheet.CustomPaymentMethod> {
|
|
1038
1042
|
if (customPaymentMethodConfig == null) {
|
|
1039
1043
|
return emptyList()
|
|
1040
1044
|
}
|
|
@@ -1047,7 +1051,8 @@ internal fun parseCustomPaymentMethods(customPaymentMethodConfig: ReadableMap?):
|
|
|
1047
1051
|
val id = customPaymentMethodMap.getString("id")
|
|
1048
1052
|
if (id != null) {
|
|
1049
1053
|
val subtitle = customPaymentMethodMap.getString("subtitle")
|
|
1050
|
-
val disableBillingDetailCollection = customPaymentMethodMap
|
|
1054
|
+
val disableBillingDetailCollection = customPaymentMethodMap
|
|
1055
|
+
.getBooleanOr("disableBillingDetailCollection", false)
|
|
1051
1056
|
result.add(
|
|
1052
1057
|
PaymentSheet.CustomPaymentMethod(
|
|
1053
1058
|
id = id,
|
|
@@ -1190,3 +1195,14 @@ fun readableArrayOf(vararg elements: Any?): ReadableArray =
|
|
|
1190
1195
|
}
|
|
1191
1196
|
}
|
|
1192
1197
|
}
|
|
1198
|
+
|
|
1199
|
+
private const val SECONDS_TO_MILLIS = 1000
|
|
1200
|
+
private const val CARD_BRAND_JCB = 0
|
|
1201
|
+
private const val CARD_BRAND_AMEX = 1
|
|
1202
|
+
private const val CARD_BRAND_CARTES_BANCAIRES = 2
|
|
1203
|
+
private const val CARD_BRAND_DINERS_CLUB = 3
|
|
1204
|
+
private const val CARD_BRAND_DISCOVER = 4
|
|
1205
|
+
private const val CARD_BRAND_MASTERCARD = 5
|
|
1206
|
+
private const val CARD_BRAND_UNION_PAY = 6
|
|
1207
|
+
private const val CARD_BRAND_VISA = 7
|
|
1208
|
+
private const val CARD_BRAND_UNKNOWN = 8
|
|
@@ -2,7 +2,8 @@ package com.reactnativestripesdk.utils
|
|
|
2
2
|
|
|
3
3
|
class PostalCodeUtilities {
|
|
4
4
|
companion object {
|
|
5
|
-
internal fun isValidGlobalPostalCodeCharacter(c: Char): Boolean =
|
|
5
|
+
internal fun isValidGlobalPostalCodeCharacter(c: Char): Boolean =
|
|
6
|
+
Character.isLetterOrDigit(c) || c.isWhitespace() || c == '-'
|
|
6
7
|
|
|
7
8
|
internal fun isValidUsPostalCodeCharacter(c: Char): Boolean = Character.isDigit(c) || c.isWhitespace() || c == '-'
|
|
8
9
|
}
|
|
@@ -30,6 +30,9 @@ public class EmbeddedPaymentElementViewManagerDelegate<T extends View, U extends
|
|
|
30
30
|
case "intentConfiguration":
|
|
31
31
|
mViewManager.setIntentConfiguration(view, new DynamicFromObject(value));
|
|
32
32
|
break;
|
|
33
|
+
case "checkout":
|
|
34
|
+
mViewManager.setCheckout(view, new DynamicFromObject(value));
|
|
35
|
+
break;
|
|
33
36
|
default:
|
|
34
37
|
super.setProperty(view, propName, value);
|
|
35
38
|
}
|
|
@@ -47,6 +50,9 @@ public class EmbeddedPaymentElementViewManagerDelegate<T extends View, U extends
|
|
|
47
50
|
case "update":
|
|
48
51
|
mViewManager.update(view, args != null ? args.getString(0) : null);
|
|
49
52
|
break;
|
|
53
|
+
case "updateWithCheckout":
|
|
54
|
+
mViewManager.updateWithCheckout(view, args != null ? args.getString(0) : null);
|
|
55
|
+
break;
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
58
|
}
|
|
@@ -16,7 +16,9 @@ import com.facebook.react.bridge.Dynamic;
|
|
|
16
16
|
public interface EmbeddedPaymentElementViewManagerInterface<T extends View> {
|
|
17
17
|
void setConfiguration(T view, Dynamic value);
|
|
18
18
|
void setIntentConfiguration(T view, Dynamic value);
|
|
19
|
+
void setCheckout(T view, Dynamic value);
|
|
19
20
|
void confirm(T view);
|
|
20
21
|
void clearPaymentOption(T view);
|
|
21
22
|
void update(T view, @Nullable String intentConfigurationJson);
|
|
23
|
+
void updateWithCheckout(T view, @Nullable String sessionKey);
|
|
22
24
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
import com.facebook.react.uimanager.BaseViewManager;
|
|
15
|
+
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
16
|
+
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
17
|
+
|
|
18
|
+
public class StripeCurrencySelectorElementManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & StripeCurrencySelectorElementManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
19
|
+
public StripeCurrencySelectorElementManagerDelegate(U viewManager) {
|
|
20
|
+
super(viewManager);
|
|
21
|
+
}
|
|
22
|
+
@Override
|
|
23
|
+
public void setProperty(T view, String propName, @Nullable Object value) {
|
|
24
|
+
switch (propName) {
|
|
25
|
+
case "sessionKey":
|
|
26
|
+
mViewManager.setSessionKey(view, value == null ? null : (String) value);
|
|
27
|
+
break;
|
|
28
|
+
case "disabled":
|
|
29
|
+
mViewManager.setDisabled(view, value == null ? false : (boolean) value);
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
super.setProperty(view, propName, value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaInterface.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
|
|
15
|
+
public interface StripeCurrencySelectorElementManagerInterface<T extends View> {
|
|
16
|
+
void setSessionKey(T view, @Nullable String value);
|
|
17
|
+
void setDisabled(T view, boolean value);
|
|
18
|
+
}
|
|
@@ -17,9 +17,11 @@ import com.facebook.react.bridge.Promise;
|
|
|
17
17
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
18
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
19
19
|
import com.facebook.react.bridge.ReactMethod;
|
|
20
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
20
21
|
import com.facebook.react.bridge.ReadableMap;
|
|
21
22
|
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
22
23
|
import javax.annotation.Nonnull;
|
|
24
|
+
import javax.annotation.Nullable;
|
|
23
25
|
|
|
24
26
|
public abstract class NativeOnrampSdkModuleSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
25
27
|
public static final String NAME = "OnrampSdk";
|
|
@@ -57,6 +59,18 @@ public abstract class NativeOnrampSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
57
59
|
@DoNotStrip
|
|
58
60
|
public abstract void attachKycInfo(ReadableMap kycInfo, Promise promise);
|
|
59
61
|
|
|
62
|
+
@ReactMethod
|
|
63
|
+
@DoNotStrip
|
|
64
|
+
public abstract void retrieveMissingIdentifiers(Promise promise);
|
|
65
|
+
|
|
66
|
+
@ReactMethod
|
|
67
|
+
@DoNotStrip
|
|
68
|
+
public abstract void submitIdentifiers(ReadableArray identifiers, Promise promise);
|
|
69
|
+
|
|
70
|
+
@ReactMethod
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
public abstract void presentCRSCARFDeclaration(Promise promise);
|
|
73
|
+
|
|
60
74
|
@ReactMethod
|
|
61
75
|
@DoNotStrip
|
|
62
76
|
public abstract void updatePhoneNumber(String phone, Promise promise);
|
|
@@ -71,7 +85,7 @@ public abstract class NativeOnrampSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
71
85
|
|
|
72
86
|
@ReactMethod
|
|
73
87
|
@DoNotStrip
|
|
74
|
-
public abstract void provideCheckoutClientSecret(String clientSecret);
|
|
88
|
+
public abstract void provideCheckoutClientSecret(@Nullable String clientSecret);
|
|
75
89
|
|
|
76
90
|
@ReactMethod
|
|
77
91
|
@DoNotStrip
|
|
@@ -91,11 +105,11 @@ public abstract class NativeOnrampSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
91
105
|
|
|
92
106
|
@ReactMethod
|
|
93
107
|
@DoNotStrip
|
|
94
|
-
public abstract void authenticateUserWithToken(String
|
|
108
|
+
public abstract void authenticateUserWithToken(String linkAuthTokenClientSecret, Promise promise);
|
|
95
109
|
|
|
96
110
|
@ReactMethod
|
|
97
111
|
@DoNotStrip
|
|
98
|
-
public abstract void presentKycInfoVerification(ReadableMap updatedAddress, Promise promise);
|
|
112
|
+
public abstract void presentKycInfoVerification(@Nullable ReadableMap updatedAddress, Promise promise);
|
|
99
113
|
|
|
100
114
|
@ReactMethod
|
|
101
115
|
@DoNotStrip
|
|
@@ -253,6 +253,10 @@ public abstract class NativeStripeSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
253
253
|
@DoNotStrip
|
|
254
254
|
public abstract void createEmbeddedPaymentElement(ReadableMap intentConfig, ReadableMap configuration, Promise promise);
|
|
255
255
|
|
|
256
|
+
@ReactMethod
|
|
257
|
+
@DoNotStrip
|
|
258
|
+
public abstract void createEmbeddedPaymentElementWithCheckout(String sessionKey, ReadableMap configuration, Promise promise);
|
|
259
|
+
|
|
256
260
|
@ReactMethod
|
|
257
261
|
@DoNotStrip
|
|
258
262
|
public abstract void confirmEmbeddedPaymentElement(double viewTag, Promise promise);
|
|
@@ -261,6 +265,10 @@ public abstract class NativeStripeSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
261
265
|
@DoNotStrip
|
|
262
266
|
public abstract void updateEmbeddedPaymentElement(ReadableMap intentConfig, Promise promise);
|
|
263
267
|
|
|
268
|
+
@ReactMethod
|
|
269
|
+
@DoNotStrip
|
|
270
|
+
public abstract void updateEmbeddedPaymentElementWithCheckout(String sessionKey, Promise promise);
|
|
271
|
+
|
|
264
272
|
@ReactMethod
|
|
265
273
|
@DoNotStrip
|
|
266
274
|
public abstract void clearEmbeddedPaymentOption(double viewTag, Promise promise);
|
|
@@ -327,7 +335,11 @@ public abstract class NativeStripeSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
327
335
|
|
|
328
336
|
@ReactMethod
|
|
329
337
|
@DoNotStrip
|
|
330
|
-
public abstract void
|
|
338
|
+
public abstract void checkoutRunServerUpdateStart(String sessionKey, Promise promise);
|
|
339
|
+
|
|
340
|
+
@ReactMethod
|
|
341
|
+
@DoNotStrip
|
|
342
|
+
public abstract void checkoutRunServerUpdateComplete(String sessionKey, @Nullable String error, Promise promise);
|
|
331
343
|
|
|
332
344
|
@ReactMethod
|
|
333
345
|
@DoNotStrip
|
|
@@ -5,11 +5,20 @@ package com.reactnativestripesdk
|
|
|
5
5
|
import android.annotation.SuppressLint
|
|
6
6
|
import androidx.compose.ui.graphics.Color
|
|
7
7
|
import com.facebook.react.bridge.Arguments
|
|
8
|
+
import com.facebook.react.bridge.ReadableArray
|
|
8
9
|
import com.facebook.react.bridge.ReadableMap
|
|
10
|
+
import com.facebook.react.bridge.WritableArray
|
|
11
|
+
import com.stripe.android.core.model.CountryCode
|
|
9
12
|
import com.stripe.android.crypto.onramp.ExperimentalCryptoOnramp
|
|
10
13
|
import com.stripe.android.crypto.onramp.model.KycInfo
|
|
11
14
|
import com.stripe.android.crypto.onramp.model.OnrampConfiguration
|
|
12
15
|
import com.stripe.android.crypto.onramp.model.PaymentMethodDisplayData
|
|
16
|
+
import com.stripe.android.crypto.onramp.model.compliance.ComplianceIdentifier
|
|
17
|
+
import com.stripe.android.crypto.onramp.model.compliance.ComplianceIdentifierAlternativeGroup
|
|
18
|
+
import com.stripe.android.crypto.onramp.model.compliance.ComplianceIdentifierRequirement
|
|
19
|
+
import com.stripe.android.crypto.onramp.model.compliance.ComplianceIdentifierRequirements
|
|
20
|
+
import com.stripe.android.crypto.onramp.model.compliance.ComplianceIdentifierType
|
|
21
|
+
import com.stripe.android.crypto.onramp.model.compliance.SubmitIdentifiersResult
|
|
13
22
|
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
14
23
|
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher
|
|
15
24
|
import com.stripe.android.link.LinkAppearance
|
|
@@ -178,10 +187,110 @@ internal fun mapFromKycInfo(kycInfo: KycInfo): ReadableMap {
|
|
|
178
187
|
kycInfo.idNumber?.let { result.putString("idNumber", it) }
|
|
179
188
|
kycInfo.address?.let { result.putMap("address", mapFromKycAddress(it)) }
|
|
180
189
|
kycInfo.dateOfBirth?.let { result.putMap("dateOfBirth", mapFromDateOfBirth(it)) }
|
|
190
|
+
kycInfo.birthCountry?.let { result.putString("birthCountry", it.value) }
|
|
191
|
+
kycInfo.birthCity?.let { result.putString("birthCity", it) }
|
|
192
|
+
kycInfo.nationalities?.let {
|
|
193
|
+
result.putArray("nationalities", mapFromCountryCodes(it))
|
|
194
|
+
}
|
|
181
195
|
|
|
182
196
|
return result
|
|
183
197
|
}
|
|
184
198
|
|
|
199
|
+
internal fun mapToComplianceIdentifiers(identifiers: ReadableArray): List<ComplianceIdentifier> {
|
|
200
|
+
val complianceIdentifiers = mutableListOf<ComplianceIdentifier>()
|
|
201
|
+
|
|
202
|
+
for (index in 0 until identifiers.size()) {
|
|
203
|
+
val identifierMap =
|
|
204
|
+
runCatching { identifiers.getMap(index) }
|
|
205
|
+
.getOrNull()
|
|
206
|
+
?: throw InvalidIdentifiersArrayException()
|
|
207
|
+
val type = identifierMap.getRequiredNormalizedString("type")
|
|
208
|
+
val value = identifierMap.getRequiredNormalizedString("value")
|
|
209
|
+
|
|
210
|
+
complianceIdentifiers.add(
|
|
211
|
+
ComplianceIdentifier()
|
|
212
|
+
.type(ComplianceIdentifierType(type))
|
|
213
|
+
.value(value),
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return complianceIdentifiers
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
internal fun mapFromComplianceIdentifierRequirements(
|
|
221
|
+
requirements: ComplianceIdentifierRequirements,
|
|
222
|
+
) = Arguments.createMap().apply {
|
|
223
|
+
putArray("identifiers", mapFromComplianceIdentifierRequirementsList(requirements.identifiers))
|
|
224
|
+
putArray("alternatives", mapFromComplianceIdentifierAlternativeGroups(requirements.alternatives))
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
internal fun mapFromSubmitIdentifiersResult(
|
|
228
|
+
result: SubmitIdentifiersResult,
|
|
229
|
+
) = Arguments.createMap().apply {
|
|
230
|
+
putBoolean("valid", result.valid)
|
|
231
|
+
putArray("identifiers", mapFromComplianceIdentifierRequirementsList(result.identifiers))
|
|
232
|
+
putArray("alternatives", mapFromComplianceIdentifierAlternativeGroups(result.alternatives))
|
|
233
|
+
putArray("invalidIdentifiers", mapFromComplianceIdentifierTypes(result.invalidIdentifiers))
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private fun mapFromComplianceIdentifierRequirementsList(
|
|
237
|
+
requirements: List<ComplianceIdentifierRequirement>,
|
|
238
|
+
): WritableArray =
|
|
239
|
+
Arguments.createArray().apply {
|
|
240
|
+
requirements.forEach { requirement ->
|
|
241
|
+
pushMap(
|
|
242
|
+
Arguments.createMap().apply {
|
|
243
|
+
putString("type", requirement.type.value)
|
|
244
|
+
putString("regulation", requirement.regulation.value)
|
|
245
|
+
},
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private fun mapFromComplianceIdentifierAlternativeGroups(
|
|
251
|
+
groups: List<ComplianceIdentifierAlternativeGroup>,
|
|
252
|
+
): WritableArray =
|
|
253
|
+
Arguments.createArray().apply {
|
|
254
|
+
groups.forEach { group ->
|
|
255
|
+
pushMap(
|
|
256
|
+
Arguments.createMap().apply {
|
|
257
|
+
putArray(
|
|
258
|
+
"originalMissingIdentifiers",
|
|
259
|
+
mapFromComplianceIdentifierTypes(group.originalMissingIdentifiers),
|
|
260
|
+
)
|
|
261
|
+
putArray(
|
|
262
|
+
"alternativeMissingIdentifiers",
|
|
263
|
+
mapFromComplianceIdentifierTypes(group.alternativeMissingIdentifiers),
|
|
264
|
+
)
|
|
265
|
+
},
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
private fun mapFromComplianceIdentifierTypes(
|
|
271
|
+
identifierTypes: List<ComplianceIdentifierType>,
|
|
272
|
+
): WritableArray =
|
|
273
|
+
Arguments.createArray().apply {
|
|
274
|
+
identifierTypes.forEach { identifierType ->
|
|
275
|
+
pushString(identifierType.value)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private fun mapFromCountryCodes(
|
|
280
|
+
countryCodes: List<CountryCode>,
|
|
281
|
+
): WritableArray =
|
|
282
|
+
Arguments.createArray().apply {
|
|
283
|
+
countryCodes.forEach { countryCode ->
|
|
284
|
+
pushString(countryCode.value)
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
private fun ReadableMap.getRequiredNormalizedString(key: String): String =
|
|
289
|
+
getString(key)
|
|
290
|
+
?.trim()
|
|
291
|
+
?.takeIf { it.isNotEmpty() }
|
|
292
|
+
?: throw ComplianceIdentifierFieldException(key)
|
|
293
|
+
|
|
185
294
|
private fun mapFromKycAddress(address: PaymentSheet.Address): ReadableMap {
|
|
186
295
|
val result = Arguments.createMap()
|
|
187
296
|
|
|
@@ -202,3 +311,10 @@ private fun mapFromDateOfBirth(dateOfBirth: DateOfBirth): ReadableMap {
|
|
|
202
311
|
result.putInt("year", dateOfBirth.year)
|
|
203
312
|
return result
|
|
204
313
|
}
|
|
314
|
+
|
|
315
|
+
internal class ComplianceIdentifierFieldException(
|
|
316
|
+
field: String,
|
|
317
|
+
) : IllegalArgumentException("Invalid format for field: $field")
|
|
318
|
+
|
|
319
|
+
internal class InvalidIdentifiersArrayException :
|
|
320
|
+
IllegalArgumentException("Unexpected format of identifiers array. Expected dictionaries with String keys.")
|