@stripe/stripe-react-native 0.41.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +0 -3
- package/CHANGELOG.md +27 -0
- package/README.md +3 -0
- package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
- package/android/.gradle/8.11.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.11.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.11.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.11.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +7 -1
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/android/gradle.properties +4 -1
- package/android/gradlew +249 -0
- package/android/gradlew.bat +92 -0
- package/android/spotless.gradle +19 -0
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +30 -34
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +20 -10
- package/android/src/main/java/com/reactnativestripesdk/CardChangedEvent.kt +12 -13
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +242 -105
- package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +58 -20
- package/android/src/main/java/com/reactnativestripesdk/CardFocusEvent.kt +8 -11
- package/android/src/main/java/com/reactnativestripesdk/CardFormCompleteEvent.kt +10 -12
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +135 -87
- package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +57 -22
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +53 -23
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +125 -83
- package/android/src/main/java/com/reactnativestripesdk/FormCompleteEvent.kt +9 -11
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +16 -9
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +36 -28
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +67 -43
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +21 -16
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +101 -56
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +244 -166
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +183 -123
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +181 -57
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +402 -258
- package/android/src/main/java/com/reactnativestripesdk/StripeContainerManager.kt +11 -4
- package/android/src/main/java/com/reactnativestripesdk/StripeContainerView.kt +5 -1
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +654 -299
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +12 -14
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +42 -37
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetEvent.kt +12 -11
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +29 -29
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +50 -18
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +227 -147
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +15 -18
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +33 -15
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +63 -37
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletCompleteEvent.kt +9 -13
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/EphemeralKeyProvider.kt +15 -17
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt +76 -60
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +71 -47
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +117 -51
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +4 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +39 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +337 -250
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -11
- package/ios/CustomerSheet/CustomerSheetUtils.swift +3 -1
- package/ios/FinancialConnections.swift +18 -2
- package/ios/Mappers.swift +23 -0
- package/ios/PaymentMethodFactory.swift +31 -29
- package/ios/StripeSdk+CustomerSheet.swift +2 -1
- package/ios/StripeSdk+PaymentSheet.swift +42 -0
- package/ios/StripeSdk.m +2 -0
- package/ios/StripeSdk.swift +116 -24
- package/lib/commonjs/NativeStripeSdk.js +1 -1
- package/lib/commonjs/NativeStripeSdk.js.map +1 -1
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/ApplePayButtonNative.js +1 -1
- package/lib/commonjs/components/ApplePayButtonNative.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/CustomerSheet.js +1 -1
- package/lib/commonjs/components/CustomerSheet.js.map +1 -1
- package/lib/commonjs/components/GooglePayButtonNative.js +1 -1
- package/lib/commonjs/components/GooglePayButtonNative.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useConfirmPayment.js.map +1 -1
- package/lib/commonjs/hooks/useConfirmSetupIntent.js.map +1 -1
- package/lib/commonjs/hooks/useFinancialConnectionsSheet.js +1 -1
- package/lib/commonjs/hooks/useFinancialConnectionsSheet.js.map +1 -1
- package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
- package/lib/commonjs/hooks/usePlatformPay.js.map +1 -1
- package/lib/commonjs/hooks/useStripe.js +1 -1
- package/lib/commonjs/hooks/useStripe.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/types/ApplePay.js.map +1 -1
- package/lib/commonjs/types/Common.js +1 -1
- package/lib/commonjs/types/Common.js.map +1 -1
- package/lib/commonjs/types/CustomerSheet.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/FinancialConnections.js +1 -1
- package/lib/commonjs/types/FinancialConnections.js.map +1 -1
- package/lib/commonjs/types/NextAction.js.map +1 -1
- package/lib/commonjs/types/PaymentIntent.js +1 -1
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/commonjs/types/PaymentMethod.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.js +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/PlatformPay.js +1 -1
- package/lib/commonjs/types/PlatformPay.js.map +1 -1
- package/lib/commonjs/types/PushProvisioning.js +1 -1
- package/lib/commonjs/types/PushProvisioning.js.map +1 -1
- package/lib/commonjs/types/SetupIntent.js +1 -1
- package/lib/commonjs/types/SetupIntent.js.map +1 -1
- package/lib/commonjs/types/ThreeDSecure.js +1 -1
- package/lib/commonjs/types/ThreeDSecure.js.map +1 -1
- package/lib/commonjs/types/Token.js.map +1 -1
- package/lib/commonjs/types/components/ApplePayButtonComponent.js.map +1 -1
- package/lib/commonjs/types/components/AuBECSDebitFormComponent.js.map +1 -1
- package/lib/commonjs/types/components/CardFieldInput.js +1 -1
- package/lib/commonjs/types/components/CardFieldInput.js.map +1 -1
- package/lib/commonjs/types/components/CardFormView.js.map +1 -1
- package/lib/commonjs/types/components/GooglePayButtonComponent.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/NativeStripeSdk.js +1 -1
- package/lib/module/NativeStripeSdk.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/ApplePayButtonNative.js +1 -1
- package/lib/module/components/ApplePayButtonNative.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/CustomerSheet.js +1 -1
- package/lib/module/components/CustomerSheet.js.map +1 -1
- package/lib/module/components/GooglePayButtonNative.js +1 -1
- package/lib/module/components/GooglePayButtonNative.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useConfirmPayment.js.map +1 -1
- package/lib/module/hooks/useConfirmSetupIntent.js.map +1 -1
- package/lib/module/hooks/useFinancialConnectionsSheet.js +1 -1
- package/lib/module/hooks/useFinancialConnectionsSheet.js.map +1 -1
- package/lib/module/hooks/usePaymentSheet.js.map +1 -1
- package/lib/module/hooks/usePlatformPay.js.map +1 -1
- package/lib/module/hooks/useStripe.js +1 -1
- package/lib/module/hooks/useStripe.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/types/ApplePay.js.map +1 -1
- package/lib/module/types/Common.js +1 -1
- package/lib/module/types/Common.js.map +1 -1
- package/lib/module/types/CustomerSheet.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/FinancialConnections.js +1 -1
- package/lib/module/types/FinancialConnections.js.map +1 -1
- package/lib/module/types/NextAction.js.map +1 -1
- package/lib/module/types/PaymentIntent.js +1 -1
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/module/types/PaymentMethod.js.map +1 -1
- package/lib/module/types/PaymentSheet.js +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/PlatformPay.js +1 -1
- package/lib/module/types/PlatformPay.js.map +1 -1
- package/lib/module/types/PushProvisioning.js +1 -1
- package/lib/module/types/PushProvisioning.js.map +1 -1
- package/lib/module/types/SetupIntent.js +1 -1
- package/lib/module/types/SetupIntent.js.map +1 -1
- package/lib/module/types/ThreeDSecure.js +1 -1
- package/lib/module/types/ThreeDSecure.js.map +1 -1
- package/lib/module/types/Token.js.map +1 -1
- package/lib/module/types/components/ApplePayButtonComponent.js.map +1 -1
- package/lib/module/types/components/AuBECSDebitFormComponent.js.map +1 -1
- package/lib/module/types/components/CardFieldInput.js +1 -1
- package/lib/module/types/components/CardFieldInput.js.map +1 -1
- package/lib/module/types/components/CardFormView.js.map +1 -1
- package/lib/module/types/components/GooglePayButtonComponent.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/NativeStripeSdk.d.ts +5 -4
- package/lib/typescript/src/NativeStripeSdk.d.ts.map +1 -0
- package/lib/typescript/src/components/AddToWalletButton.d.ts +3 -1
- package/lib/typescript/src/components/AddToWalletButton.d.ts.map +1 -0
- package/lib/typescript/src/components/AddressSheet.d.ts +4 -2
- package/lib/typescript/src/components/AddressSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts +1 -0
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts.map +1 -0
- package/lib/typescript/src/components/AuBECSDebitForm.d.ts +3 -1
- package/lib/typescript/src/components/AuBECSDebitForm.d.ts.map +1 -0
- package/lib/typescript/src/components/CardField.d.ts +1 -0
- package/lib/typescript/src/components/CardField.d.ts.map +1 -0
- package/lib/typescript/src/components/CardForm.d.ts +1 -0
- package/lib/typescript/src/components/CardForm.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomerSheet.d.ts +2 -1
- package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts +1 -0
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts.map +1 -0
- package/lib/typescript/src/components/PlatformPayButton.d.ts +3 -1
- package/lib/typescript/src/components/PlatformPayButton.d.ts.map +1 -0
- package/lib/typescript/src/components/StripeContainer.d.ts +2 -1
- package/lib/typescript/src/components/StripeContainer.d.ts.map +1 -0
- package/lib/typescript/src/components/StripeProvider.d.ts +3 -2
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -0
- package/lib/typescript/src/functions.d.ts +12 -7
- package/lib/typescript/src/functions.d.ts.map +1 -0
- package/lib/typescript/src/helpers.d.ts +1 -0
- package/lib/typescript/src/helpers.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useConfirmPayment.d.ts +2 -1
- package/lib/typescript/src/hooks/useConfirmPayment.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts +1 -0
- package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +5 -2
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePaymentSheet.d.ts +2 -1
- package/lib/typescript/src/hooks/usePaymentSheet.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePlatformPay.d.ts +4 -3
- package/lib/typescript/src/hooks/usePlatformPay.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useStripe.d.ts +11 -8
- package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/plugin/withStripe.d.ts +2 -1
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -0
- package/lib/typescript/src/types/ApplePay.d.ts +6 -5
- package/lib/typescript/src/types/ApplePay.d.ts.map +1 -0
- package/lib/typescript/src/types/Common.d.ts +4 -1
- package/lib/typescript/src/types/Common.d.ts.map +1 -0
- package/lib/typescript/src/types/CustomerSheet.d.ts +12 -4
- package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -0
- package/lib/typescript/src/types/Errors.d.ts +2 -1
- package/lib/typescript/src/types/Errors.d.ts.map +1 -0
- package/lib/typescript/src/types/FinancialConnections.d.ts +82 -14
- package/lib/typescript/src/types/FinancialConnections.d.ts.map +1 -0
- package/lib/typescript/src/types/NextAction.d.ts +9 -8
- package/lib/typescript/src/types/NextAction.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentIntent.d.ts +41 -14
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentMethod.d.ts +27 -15
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +72 -22
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -0
- package/lib/typescript/src/types/PlatformPay.d.ts +22 -21
- package/lib/typescript/src/types/PlatformPay.d.ts.map +1 -0
- package/lib/typescript/src/types/PushProvisioning.d.ts +5 -4
- package/lib/typescript/src/types/PushProvisioning.d.ts.map +1 -0
- package/lib/typescript/src/types/SetupIntent.d.ts +4 -3
- package/lib/typescript/src/types/SetupIntent.d.ts.map +1 -0
- package/lib/typescript/src/types/ThreeDSecure.d.ts +1 -0
- package/lib/typescript/src/types/ThreeDSecure.d.ts.map +1 -0
- package/lib/typescript/src/types/Token.d.ts +10 -9
- package/lib/typescript/src/types/Token.d.ts.map +1 -0
- package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts +3 -2
- package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts +1 -0
- package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/components/CardFieldInput.d.ts +8 -5
- package/lib/typescript/src/types/components/CardFieldInput.d.ts.map +1 -0
- package/lib/typescript/src/types/components/CardFormView.d.ts +9 -6
- package/lib/typescript/src/types/components/CardFormView.d.ts.map +1 -0
- package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts +1 -0
- package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +24 -23
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/package.json +33 -42
- package/src/NativeStripeSdk.tsx +5 -3
- package/src/components/CardField.tsx +1 -1
- package/src/components/CardForm.tsx +12 -9
- package/src/components/CustomerSheet.tsx +4 -6
- package/src/components/StripeProvider.tsx +17 -0
- package/src/functions.ts +70 -16
- package/src/hooks/useFinancialConnectionsSheet.tsx +12 -4
- package/src/hooks/useStripe.tsx +10 -4
- package/src/types/Common.ts +3 -0
- package/src/types/CustomerSheet.ts +7 -0
- package/src/types/FinancialConnections.ts +72 -0
- package/src/types/PaymentIntent.ts +30 -1
- package/src/types/PaymentMethod.ts +13 -1
- package/src/types/PaymentSheet.ts +65 -5
- package/src/types/components/CardFieldInput.ts +8 -4
- package/src/types/components/CardFormView.ts +8 -4
- package/stripe-react-native.podspec +2 -1
|
@@ -3,19 +3,45 @@ package com.reactnativestripesdk.utils
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.os.Bundle
|
|
5
5
|
import android.util.Log
|
|
6
|
-
import com.facebook.react.bridge
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
7
|
+
import com.facebook.react.bridge.ReadableArray
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap
|
|
9
|
+
import com.facebook.react.bridge.ReadableType
|
|
10
|
+
import com.facebook.react.bridge.WritableArray
|
|
11
|
+
import com.facebook.react.bridge.WritableMap
|
|
12
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
7
13
|
import com.stripe.android.PaymentAuthConfig
|
|
8
|
-
import com.stripe.android.
|
|
9
|
-
import com.stripe.android.model.
|
|
14
|
+
import com.stripe.android.financialconnections.analytics.FinancialConnectionsEvent
|
|
15
|
+
import com.stripe.android.model.Address
|
|
16
|
+
import com.stripe.android.model.BankAccount
|
|
17
|
+
import com.stripe.android.model.BankAccountTokenParams
|
|
18
|
+
import com.stripe.android.model.Card
|
|
19
|
+
import com.stripe.android.model.CardBrand
|
|
20
|
+
import com.stripe.android.model.ConfirmPaymentIntentParams
|
|
21
|
+
import com.stripe.android.model.GooglePayResult
|
|
22
|
+
import com.stripe.android.model.MicrodepositType
|
|
23
|
+
import com.stripe.android.model.PaymentIntent
|
|
24
|
+
import com.stripe.android.model.PaymentMethod
|
|
25
|
+
import com.stripe.android.model.SetupIntent
|
|
26
|
+
import com.stripe.android.model.StripeIntent
|
|
10
27
|
import com.stripe.android.model.StripeIntent.NextActionData
|
|
28
|
+
import com.stripe.android.model.StripeIntent.NextActionType
|
|
29
|
+
import com.stripe.android.model.Token
|
|
11
30
|
|
|
12
|
-
internal fun createResult(
|
|
31
|
+
internal fun createResult(
|
|
32
|
+
key: String,
|
|
33
|
+
value: WritableMap,
|
|
34
|
+
): WritableMap {
|
|
13
35
|
val map = WritableNativeMap()
|
|
14
36
|
map.putMap(key, value)
|
|
15
37
|
return map
|
|
16
38
|
}
|
|
17
39
|
|
|
18
|
-
internal fun createCanAddCardResult(
|
|
40
|
+
internal fun createCanAddCardResult(
|
|
41
|
+
canAddCard: Boolean,
|
|
42
|
+
status: String? = null,
|
|
43
|
+
token: WritableMap? = null,
|
|
44
|
+
): WritableNativeMap {
|
|
19
45
|
val result = WritableNativeMap()
|
|
20
46
|
val details = WritableNativeMap()
|
|
21
47
|
result.putBoolean("canAddCard", canAddCard)
|
|
@@ -29,8 +55,8 @@ internal fun createCanAddCardResult(canAddCard: Boolean, status: String? = null,
|
|
|
29
55
|
return result
|
|
30
56
|
}
|
|
31
57
|
|
|
32
|
-
internal fun mapIntentStatus(status: StripeIntent.Status?): String
|
|
33
|
-
|
|
58
|
+
internal fun mapIntentStatus(status: StripeIntent.Status?): String =
|
|
59
|
+
when (status) {
|
|
34
60
|
StripeIntent.Status.Succeeded -> "Succeeded"
|
|
35
61
|
StripeIntent.Status.RequiresPaymentMethod -> "RequiresPaymentMethod"
|
|
36
62
|
StripeIntent.Status.RequiresConfirmation -> "RequiresConfirmation"
|
|
@@ -40,24 +66,20 @@ internal fun mapIntentStatus(status: StripeIntent.Status?): String {
|
|
|
40
66
|
StripeIntent.Status.RequiresCapture -> "RequiresCapture"
|
|
41
67
|
else -> "Unknown"
|
|
42
68
|
}
|
|
43
|
-
}
|
|
44
69
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return when (captureMethod) {
|
|
70
|
+
internal fun mapCaptureMethod(captureMethod: PaymentIntent.CaptureMethod?): String =
|
|
71
|
+
when (captureMethod) {
|
|
48
72
|
PaymentIntent.CaptureMethod.Automatic -> "Automatic"
|
|
49
73
|
PaymentIntent.CaptureMethod.Manual -> "Manual"
|
|
50
74
|
else -> "Unknown"
|
|
51
75
|
}
|
|
52
|
-
}
|
|
53
76
|
|
|
54
|
-
internal fun mapConfirmationMethod(captureMethod: PaymentIntent.ConfirmationMethod?): String
|
|
55
|
-
|
|
77
|
+
internal fun mapConfirmationMethod(captureMethod: PaymentIntent.ConfirmationMethod?): String =
|
|
78
|
+
when (captureMethod) {
|
|
56
79
|
PaymentIntent.ConfirmationMethod.Automatic -> "Automatic"
|
|
57
80
|
PaymentIntent.ConfirmationMethod.Manual -> "Manual"
|
|
58
81
|
else -> "Unknown"
|
|
59
82
|
}
|
|
60
|
-
}
|
|
61
83
|
|
|
62
84
|
internal fun mapToReturnURL(urlScheme: String?): String? {
|
|
63
85
|
if (urlScheme != null) {
|
|
@@ -85,8 +107,8 @@ internal fun mapIntentShipping(shipping: PaymentIntent.Shipping): WritableMap {
|
|
|
85
107
|
return map
|
|
86
108
|
}
|
|
87
109
|
|
|
88
|
-
internal fun mapCardBrand(brand: CardBrand?): String
|
|
89
|
-
|
|
110
|
+
internal fun mapCardBrand(brand: CardBrand?): String =
|
|
111
|
+
when (brand) {
|
|
90
112
|
CardBrand.AmericanExpress -> "AmericanExpress"
|
|
91
113
|
CardBrand.DinersClub -> "DinersClub"
|
|
92
114
|
CardBrand.Discover -> "Discover"
|
|
@@ -97,10 +119,9 @@ internal fun mapCardBrand(brand: CardBrand?): String {
|
|
|
97
119
|
CardBrand.Unknown -> "Unknown"
|
|
98
120
|
else -> "Unknown"
|
|
99
121
|
}
|
|
100
|
-
}
|
|
101
122
|
|
|
102
|
-
internal fun mapPaymentMethodType(type: PaymentMethod.Type?): String
|
|
103
|
-
|
|
123
|
+
internal fun mapPaymentMethodType(type: PaymentMethod.Type?): String =
|
|
124
|
+
when (type) {
|
|
104
125
|
PaymentMethod.Type.AfterpayClearpay -> "AfterpayClearpay"
|
|
105
126
|
PaymentMethod.Type.Alipay -> "Alipay"
|
|
106
127
|
PaymentMethod.Type.AuBecsDebit -> "AuBecsDebit"
|
|
@@ -128,10 +149,9 @@ internal fun mapPaymentMethodType(type: PaymentMethod.Type?): String {
|
|
|
128
149
|
PaymentMethod.Type.RevolutPay -> "RevolutPay"
|
|
129
150
|
else -> "Unknown"
|
|
130
151
|
}
|
|
131
|
-
}
|
|
132
152
|
|
|
133
|
-
internal fun mapToPaymentMethodType(type: String?): PaymentMethod.Type?
|
|
134
|
-
|
|
153
|
+
internal fun mapToPaymentMethodType(type: String?): PaymentMethod.Type? =
|
|
154
|
+
when (type) {
|
|
135
155
|
"Card" -> PaymentMethod.Type.Card
|
|
136
156
|
"Ideal" -> PaymentMethod.Type.Ideal
|
|
137
157
|
"Alipay" -> PaymentMethod.Type.Alipay
|
|
@@ -159,7 +179,6 @@ internal fun mapToPaymentMethodType(type: String?): PaymentMethod.Type? {
|
|
|
159
179
|
"RevolutPay" -> PaymentMethod.Type.RevolutPay
|
|
160
180
|
else -> null
|
|
161
181
|
}
|
|
162
|
-
}
|
|
163
182
|
|
|
164
183
|
internal fun mapFromBillingDetails(billingDatails: PaymentMethod.BillingDetails?): WritableMap {
|
|
165
184
|
val details: WritableMap = WritableNativeMap()
|
|
@@ -180,8 +199,8 @@ internal fun mapFromBillingDetails(billingDatails: PaymentMethod.BillingDetails?
|
|
|
180
199
|
return details
|
|
181
200
|
}
|
|
182
201
|
|
|
183
|
-
internal fun mapTokenType(type: Token.Type): String
|
|
184
|
-
|
|
202
|
+
internal fun mapTokenType(type: Token.Type): String =
|
|
203
|
+
when (type) {
|
|
185
204
|
Token.Type.Account -> "Account"
|
|
186
205
|
Token.Type.BankAccount -> "BankAccount"
|
|
187
206
|
Token.Type.Card -> "Card"
|
|
@@ -190,26 +209,23 @@ internal fun mapTokenType(type: Token.Type): String {
|
|
|
190
209
|
Token.Type.Pii -> "Pii"
|
|
191
210
|
else -> "Unknown"
|
|
192
211
|
}
|
|
193
|
-
}
|
|
194
212
|
|
|
195
|
-
internal fun mapFromBankAccountType(type: BankAccount.Type?): String
|
|
196
|
-
|
|
213
|
+
internal fun mapFromBankAccountType(type: BankAccount.Type?): String =
|
|
214
|
+
when (type) {
|
|
197
215
|
BankAccount.Type.Company -> "Company"
|
|
198
216
|
BankAccount.Type.Individual -> "Individual"
|
|
199
217
|
else -> "Unknown"
|
|
200
218
|
}
|
|
201
|
-
}
|
|
202
219
|
|
|
203
|
-
internal fun mapToBankAccountType(type: String?): BankAccountTokenParams.Type
|
|
204
|
-
|
|
220
|
+
internal fun mapToBankAccountType(type: String?): BankAccountTokenParams.Type =
|
|
221
|
+
when (type) {
|
|
205
222
|
"Company" -> BankAccountTokenParams.Type.Company
|
|
206
223
|
"Individual" -> BankAccountTokenParams.Type.Individual
|
|
207
224
|
else -> BankAccountTokenParams.Type.Individual
|
|
208
225
|
}
|
|
209
|
-
}
|
|
210
226
|
|
|
211
|
-
internal fun mapFromBankAccountStatus(status: BankAccount.Status?): String
|
|
212
|
-
|
|
227
|
+
internal fun mapFromBankAccountStatus(status: BankAccount.Status?): String =
|
|
228
|
+
when (status) {
|
|
213
229
|
BankAccount.Status.Errored -> "Errored"
|
|
214
230
|
BankAccount.Status.New -> "New"
|
|
215
231
|
BankAccount.Status.Validated -> "Validated"
|
|
@@ -217,7 +233,6 @@ internal fun mapFromBankAccountStatus(status: BankAccount.Status?): String {
|
|
|
217
233
|
BankAccount.Status.Verified -> "Verified"
|
|
218
234
|
else -> "Unknown"
|
|
219
235
|
}
|
|
220
|
-
}
|
|
221
236
|
|
|
222
237
|
internal fun mapFromBankAccount(bankAccount: BankAccount?): WritableMap? {
|
|
223
238
|
if (bankAccount == null) {
|
|
@@ -228,7 +243,10 @@ internal fun mapFromBankAccount(bankAccount: BankAccount?): WritableMap? {
|
|
|
228
243
|
bankAccountMap.putString("id", bankAccount.id)
|
|
229
244
|
bankAccountMap.putString("bankName", bankAccount.bankName)
|
|
230
245
|
bankAccountMap.putString("accountHolderName", bankAccount.accountHolderName)
|
|
231
|
-
bankAccountMap.putString(
|
|
246
|
+
bankAccountMap.putString(
|
|
247
|
+
"accountHolderType",
|
|
248
|
+
mapFromBankAccountType(bankAccount.accountHolderType),
|
|
249
|
+
)
|
|
232
250
|
bankAccountMap.putString("currency", bankAccount.currency)
|
|
233
251
|
bankAccountMap.putString("country", bankAccount.countryCode)
|
|
234
252
|
bankAccountMap.putString("routingNumber", bankAccount.routingNumber)
|
|
@@ -239,37 +257,33 @@ internal fun mapFromBankAccount(bankAccount: BankAccount?): WritableMap? {
|
|
|
239
257
|
return bankAccountMap
|
|
240
258
|
}
|
|
241
259
|
|
|
242
|
-
internal fun mapToUSBankAccountHolderType(type: String?): PaymentMethod.USBankAccount.USBankAccountHolderType
|
|
243
|
-
|
|
260
|
+
internal fun mapToUSBankAccountHolderType(type: String?): PaymentMethod.USBankAccount.USBankAccountHolderType =
|
|
261
|
+
when (type) {
|
|
244
262
|
"Company" -> PaymentMethod.USBankAccount.USBankAccountHolderType.COMPANY
|
|
245
263
|
"Individual" -> PaymentMethod.USBankAccount.USBankAccountHolderType.INDIVIDUAL
|
|
246
264
|
else -> PaymentMethod.USBankAccount.USBankAccountHolderType.INDIVIDUAL
|
|
247
265
|
}
|
|
248
|
-
}
|
|
249
266
|
|
|
250
|
-
internal fun mapFromUSBankAccountHolderType(type: PaymentMethod.USBankAccount.USBankAccountHolderType?): String
|
|
251
|
-
|
|
267
|
+
internal fun mapFromUSBankAccountHolderType(type: PaymentMethod.USBankAccount.USBankAccountHolderType?): String =
|
|
268
|
+
when (type) {
|
|
252
269
|
PaymentMethod.USBankAccount.USBankAccountHolderType.COMPANY -> "Company"
|
|
253
270
|
PaymentMethod.USBankAccount.USBankAccountHolderType.INDIVIDUAL -> "Individual"
|
|
254
271
|
else -> "Unknown"
|
|
255
272
|
}
|
|
256
|
-
}
|
|
257
273
|
|
|
258
|
-
internal fun mapToUSBankAccountType(type: String?): PaymentMethod.USBankAccount.USBankAccountType
|
|
259
|
-
|
|
274
|
+
internal fun mapToUSBankAccountType(type: String?): PaymentMethod.USBankAccount.USBankAccountType =
|
|
275
|
+
when (type) {
|
|
260
276
|
"Savings" -> PaymentMethod.USBankAccount.USBankAccountType.SAVINGS
|
|
261
277
|
"Checking" -> PaymentMethod.USBankAccount.USBankAccountType.CHECKING
|
|
262
278
|
else -> PaymentMethod.USBankAccount.USBankAccountType.CHECKING
|
|
263
279
|
}
|
|
264
|
-
}
|
|
265
280
|
|
|
266
|
-
internal fun mapFromUSBankAccountType(type: PaymentMethod.USBankAccount.USBankAccountType?): String
|
|
267
|
-
|
|
281
|
+
internal fun mapFromUSBankAccountType(type: PaymentMethod.USBankAccount.USBankAccountType?): String =
|
|
282
|
+
when (type) {
|
|
268
283
|
PaymentMethod.USBankAccount.USBankAccountType.CHECKING -> "Checking"
|
|
269
284
|
PaymentMethod.USBankAccount.USBankAccountType.SAVINGS -> "Savings"
|
|
270
285
|
else -> "Unknown"
|
|
271
286
|
}
|
|
272
|
-
}
|
|
273
287
|
|
|
274
288
|
internal fun mapFromCard(card: Card?): WritableMap? {
|
|
275
289
|
val cardMap: WritableMap = WritableNativeMap()
|
|
@@ -284,17 +298,9 @@ internal fun mapFromCard(card: Card?): WritableMap? {
|
|
|
284
298
|
cardMap.putString("brand", mapCardBrand(card.brand))
|
|
285
299
|
cardMap.putString("currency", card.currency)
|
|
286
300
|
|
|
287
|
-
(card.expMonth)?.let {
|
|
288
|
-
cardMap.putInt("expMonth", it)
|
|
289
|
-
} ?: run {
|
|
290
|
-
cardMap.putNull("expMonth")
|
|
291
|
-
}
|
|
301
|
+
(card.expMonth)?.let { cardMap.putInt("expMonth", it) } ?: run { cardMap.putNull("expMonth") }
|
|
292
302
|
|
|
293
|
-
(card.expYear)?.let {
|
|
294
|
-
cardMap.putInt("expYear", it)
|
|
295
|
-
} ?: run {
|
|
296
|
-
cardMap.putNull("expYear")
|
|
297
|
-
}
|
|
303
|
+
(card.expYear)?.let { cardMap.putInt("expYear", it) } ?: run { cardMap.putNull("expYear") }
|
|
298
304
|
|
|
299
305
|
cardMap.putString("id", card.id)
|
|
300
306
|
cardMap.putString("last4", card.last4)
|
|
@@ -313,7 +319,6 @@ internal fun mapFromCard(card: Card?): WritableMap? {
|
|
|
313
319
|
return cardMap
|
|
314
320
|
}
|
|
315
321
|
|
|
316
|
-
|
|
317
322
|
internal fun mapFromToken(token: Token): WritableMap {
|
|
318
323
|
val tokenMap: WritableMap = WritableNativeMap()
|
|
319
324
|
tokenMap.putString("id", token.id)
|
|
@@ -335,66 +340,102 @@ internal fun mapFromPaymentMethod(paymentMethod: PaymentMethod): WritableMap {
|
|
|
335
340
|
pm.putBoolean("livemode", paymentMethod.liveMode)
|
|
336
341
|
pm.putString("customerId", paymentMethod.customerId)
|
|
337
342
|
pm.putMap("billingDetails", mapFromBillingDetails(paymentMethod.billingDetails))
|
|
338
|
-
pm.putMap(
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
it.
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
it.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
pm.putMap(
|
|
343
|
+
pm.putMap(
|
|
344
|
+
"Card",
|
|
345
|
+
WritableNativeMap().also {
|
|
346
|
+
it.putString("brand", mapCardBrand(paymentMethod.card?.brand))
|
|
347
|
+
it.putString("country", paymentMethod.card?.country)
|
|
348
|
+
paymentMethod.card?.expiryYear?.let { year -> it.putInt("expYear", year) }
|
|
349
|
+
paymentMethod.card?.expiryMonth?.let { month -> it.putInt("expMonth", month) }
|
|
350
|
+
it.putString("funding", paymentMethod.card?.funding)
|
|
351
|
+
it.putString("last4", paymentMethod.card?.last4)
|
|
352
|
+
it.putString("fingerprint", paymentMethod.card?.fingerprint)
|
|
353
|
+
it.putString("preferredNetwork", paymentMethod.card?.networks?.preferred)
|
|
354
|
+
it.putArray(
|
|
355
|
+
"availableNetworks",
|
|
356
|
+
paymentMethod.card
|
|
357
|
+
?.networks
|
|
358
|
+
?.available
|
|
359
|
+
?.toList() as? ReadableArray,
|
|
360
|
+
)
|
|
361
|
+
it.putMap(
|
|
362
|
+
"threeDSecureUsage",
|
|
363
|
+
WritableNativeMap().also { threeDSecureUsageMap ->
|
|
364
|
+
threeDSecureUsageMap.putBoolean(
|
|
365
|
+
"isSupported",
|
|
366
|
+
paymentMethod.card?.threeDSecureUsage?.isSupported ?: false,
|
|
367
|
+
)
|
|
368
|
+
},
|
|
369
|
+
)
|
|
370
|
+
},
|
|
371
|
+
)
|
|
372
|
+
pm.putMap(
|
|
373
|
+
"SepaDebit",
|
|
374
|
+
WritableNativeMap().also {
|
|
375
|
+
it.putString("bankCode", paymentMethod.sepaDebit?.bankCode)
|
|
376
|
+
it.putString("country", paymentMethod.sepaDebit?.country)
|
|
377
|
+
it.putString("fingerprint", paymentMethod.sepaDebit?.fingerprint)
|
|
378
|
+
it.putString("last4", paymentMethod.sepaDebit?.branchCode)
|
|
379
|
+
},
|
|
380
|
+
)
|
|
381
|
+
pm.putMap(
|
|
382
|
+
"BacsDebit",
|
|
383
|
+
WritableNativeMap().also {
|
|
384
|
+
it.putString("fingerprint", paymentMethod.bacsDebit?.fingerprint)
|
|
385
|
+
it.putString("last4", paymentMethod.bacsDebit?.last4)
|
|
386
|
+
it.putString("sortCode", paymentMethod.bacsDebit?.sortCode)
|
|
387
|
+
},
|
|
388
|
+
)
|
|
389
|
+
pm.putMap(
|
|
390
|
+
"AuBecsDebit",
|
|
368
391
|
WritableNativeMap().also {
|
|
369
392
|
it.putString("bsbNumber", paymentMethod.bacsDebit?.sortCode)
|
|
370
393
|
it.putString("fingerprint", paymentMethod.bacsDebit?.fingerprint)
|
|
371
394
|
it.putString("last4", paymentMethod.bacsDebit?.last4)
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
395
|
+
},
|
|
396
|
+
)
|
|
397
|
+
pm.putMap(
|
|
398
|
+
"Sofort",
|
|
399
|
+
WritableNativeMap().also { it.putString("country", paymentMethod.sofort?.country) },
|
|
400
|
+
)
|
|
401
|
+
pm.putMap(
|
|
402
|
+
"Ideal",
|
|
403
|
+
WritableNativeMap().also {
|
|
404
|
+
it.putString("bankName", paymentMethod.ideal?.bank)
|
|
405
|
+
it.putString("bankIdentifierCode", paymentMethod.ideal?.bankIdentifierCode)
|
|
406
|
+
},
|
|
407
|
+
)
|
|
408
|
+
pm.putMap(
|
|
409
|
+
"Fpx",
|
|
410
|
+
WritableNativeMap().also {
|
|
411
|
+
it.putString("accountHolderType", paymentMethod.fpx?.accountHolderType)
|
|
412
|
+
it.putString("bank", paymentMethod.fpx?.bank)
|
|
413
|
+
},
|
|
414
|
+
)
|
|
415
|
+
pm.putMap("Upi", WritableNativeMap().also { it.putString("vpa", paymentMethod.upi?.vpa) })
|
|
416
|
+
pm.putMap(
|
|
417
|
+
"USBankAccount",
|
|
418
|
+
WritableNativeMap().also {
|
|
419
|
+
it.putString("routingNumber", paymentMethod.usBankAccount?.routingNumber)
|
|
420
|
+
it.putString(
|
|
421
|
+
"accountType",
|
|
422
|
+
mapFromUSBankAccountType(paymentMethod.usBankAccount?.accountType),
|
|
423
|
+
)
|
|
424
|
+
it.putString(
|
|
425
|
+
"accountHolderType",
|
|
426
|
+
mapFromUSBankAccountHolderType(paymentMethod.usBankAccount?.accountHolderType),
|
|
427
|
+
)
|
|
428
|
+
it.putString("last4", paymentMethod.usBankAccount?.last4)
|
|
429
|
+
it.putString("bankName", paymentMethod.usBankAccount?.bankName)
|
|
430
|
+
it.putString("linkedAccount", paymentMethod.usBankAccount?.financialConnectionsAccount)
|
|
431
|
+
it.putString("fingerprint", paymentMethod.usBankAccount?.fingerprint)
|
|
432
|
+
it.putString("preferredNetworks", paymentMethod.usBankAccount?.networks?.preferred)
|
|
433
|
+
it.putArray(
|
|
434
|
+
"supportedNetworks",
|
|
435
|
+
paymentMethod.usBankAccount?.networks?.supported as? ReadableArray,
|
|
436
|
+
)
|
|
437
|
+
},
|
|
438
|
+
)
|
|
398
439
|
|
|
399
440
|
return pm
|
|
400
441
|
}
|
|
@@ -405,11 +446,10 @@ internal fun mapFromPaymentIntentResult(paymentIntent: PaymentIntent): WritableM
|
|
|
405
446
|
map.putString("clientSecret", paymentIntent.clientSecret)
|
|
406
447
|
map.putBoolean("livemode", paymentIntent.isLiveMode)
|
|
407
448
|
map.putString("paymentMethodId", paymentIntent.paymentMethodId)
|
|
408
|
-
map.putMap(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
})
|
|
449
|
+
map.putMap(
|
|
450
|
+
"paymentMethod",
|
|
451
|
+
paymentIntent.paymentMethod?.let { mapFromPaymentMethod(it) } ?: run { null },
|
|
452
|
+
)
|
|
413
453
|
map.putString("receiptEmail", paymentIntent.receiptEmail)
|
|
414
454
|
map.putString("currency", paymentIntent.currency)
|
|
415
455
|
map.putString("status", mapIntentStatus(paymentIntent.status))
|
|
@@ -418,7 +458,10 @@ internal fun mapFromPaymentIntentResult(paymentIntent: PaymentIntent): WritableM
|
|
|
418
458
|
map.putString("created", convertToUnixTimestamp(paymentIntent.created))
|
|
419
459
|
map.putString("captureMethod", mapCaptureMethod(paymentIntent.captureMethod))
|
|
420
460
|
map.putString("confirmationMethod", mapConfirmationMethod(paymentIntent.confirmationMethod))
|
|
421
|
-
map.putMap(
|
|
461
|
+
map.putMap(
|
|
462
|
+
"nextAction",
|
|
463
|
+
mapNextAction(paymentIntent.nextActionType, paymentIntent.nextActionData),
|
|
464
|
+
)
|
|
422
465
|
map.putNull("lastPaymentError")
|
|
423
466
|
map.putNull("shipping")
|
|
424
467
|
map.putNull("amount")
|
|
@@ -437,28 +480,26 @@ internal fun mapFromPaymentIntentResult(paymentIntent: PaymentIntent): WritableM
|
|
|
437
480
|
map.putMap("lastPaymentError", paymentError)
|
|
438
481
|
}
|
|
439
482
|
|
|
440
|
-
paymentIntent.shipping?.let {
|
|
441
|
-
map.putMap("shipping", mapIntentShipping(it))
|
|
442
|
-
}
|
|
483
|
+
paymentIntent.shipping?.let { map.putMap("shipping", mapIntentShipping(it)) }
|
|
443
484
|
|
|
444
|
-
paymentIntent.amount?.let {
|
|
445
|
-
map.putDouble("amount", it.toDouble())
|
|
446
|
-
}
|
|
485
|
+
paymentIntent.amount?.let { map.putDouble("amount", it.toDouble()) }
|
|
447
486
|
map.putString("canceledAt", convertToUnixTimestamp(paymentIntent.canceledAt))
|
|
448
487
|
return map
|
|
449
488
|
}
|
|
450
489
|
|
|
451
490
|
@SuppressLint("RestrictedApi")
|
|
452
|
-
internal fun mapFromMicrodepositType(type: MicrodepositType): String
|
|
453
|
-
|
|
491
|
+
internal fun mapFromMicrodepositType(type: MicrodepositType): String =
|
|
492
|
+
when (type) {
|
|
454
493
|
MicrodepositType.AMOUNTS -> "amounts"
|
|
455
494
|
MicrodepositType.DESCRIPTOR_CODE -> "descriptorCode"
|
|
456
495
|
else -> "unknown"
|
|
457
496
|
}
|
|
458
|
-
}
|
|
459
497
|
|
|
460
498
|
@SuppressLint("RestrictedApi")
|
|
461
|
-
internal fun mapNextAction(
|
|
499
|
+
internal fun mapNextAction(
|
|
500
|
+
type: NextActionType?,
|
|
501
|
+
data: NextActionData?,
|
|
502
|
+
): WritableNativeMap? {
|
|
462
503
|
val nextActionMap = WritableNativeMap()
|
|
463
504
|
when (type) {
|
|
464
505
|
NextActionType.RedirectToUrl -> {
|
|
@@ -492,7 +533,12 @@ internal fun mapNextAction(type: NextActionType?, data: NextActionData?): Writab
|
|
|
492
533
|
NextActionType.AlipayRedirect -> { // TODO: Can't access, private
|
|
493
534
|
return null
|
|
494
535
|
}
|
|
495
|
-
NextActionType.CashAppRedirect,
|
|
536
|
+
NextActionType.CashAppRedirect,
|
|
537
|
+
NextActionType.BlikAuthorize,
|
|
538
|
+
NextActionType.UseStripeSdk,
|
|
539
|
+
NextActionType.UpiAwaitNotification,
|
|
540
|
+
null,
|
|
541
|
+
-> {
|
|
496
542
|
return null
|
|
497
543
|
}
|
|
498
544
|
NextActionType.DisplayBoletoDetails -> {
|
|
@@ -523,8 +569,8 @@ internal fun mapNextAction(type: NextActionType?, data: NextActionData?): Writab
|
|
|
523
569
|
return nextActionMap
|
|
524
570
|
}
|
|
525
571
|
|
|
526
|
-
internal fun mapFromPaymentIntentLastErrorType(errorType: PaymentIntent.Error.Type?): String?
|
|
527
|
-
|
|
572
|
+
internal fun mapFromPaymentIntentLastErrorType(errorType: PaymentIntent.Error.Type?): String? =
|
|
573
|
+
when (errorType) {
|
|
528
574
|
PaymentIntent.Error.Type.ApiConnectionError -> "api_connection_error"
|
|
529
575
|
PaymentIntent.Error.Type.AuthenticationError -> "authentication_error"
|
|
530
576
|
PaymentIntent.Error.Type.ApiError -> "api_error"
|
|
@@ -534,10 +580,9 @@ internal fun mapFromPaymentIntentLastErrorType(errorType: PaymentIntent.Error.Ty
|
|
|
534
580
|
PaymentIntent.Error.Type.RateLimitError -> "rate_limit_error"
|
|
535
581
|
else -> null
|
|
536
582
|
}
|
|
537
|
-
}
|
|
538
583
|
|
|
539
|
-
internal fun mapFromSetupIntentLastErrorType(errorType: SetupIntent.Error.Type?): String?
|
|
540
|
-
|
|
584
|
+
internal fun mapFromSetupIntentLastErrorType(errorType: SetupIntent.Error.Type?): String? =
|
|
585
|
+
when (errorType) {
|
|
541
586
|
SetupIntent.Error.Type.ApiConnectionError -> "api_connection_error"
|
|
542
587
|
SetupIntent.Error.Type.AuthenticationError -> "authentication_error"
|
|
543
588
|
SetupIntent.Error.Type.ApiError -> "api_error"
|
|
@@ -547,15 +592,20 @@ internal fun mapFromSetupIntentLastErrorType(errorType: SetupIntent.Error.Type?)
|
|
|
547
592
|
SetupIntent.Error.Type.RateLimitError -> "rate_limit_error"
|
|
548
593
|
else -> null
|
|
549
594
|
}
|
|
550
|
-
}
|
|
551
595
|
|
|
552
|
-
fun getValOr(
|
|
553
|
-
|
|
596
|
+
fun getValOr(
|
|
597
|
+
map: ReadableMap?,
|
|
598
|
+
key: String,
|
|
599
|
+
default: String? = "",
|
|
600
|
+
): String? =
|
|
601
|
+
map?.let {
|
|
554
602
|
if (it.hasKey(key)) it.getString(key) else default
|
|
555
603
|
} ?: default
|
|
556
|
-
}
|
|
557
604
|
|
|
558
|
-
internal fun mapToAddress(
|
|
605
|
+
internal fun mapToAddress(
|
|
606
|
+
addressMap: ReadableMap?,
|
|
607
|
+
cardAddress: Address?,
|
|
608
|
+
): Address {
|
|
559
609
|
val address = Address.Builder()
|
|
560
610
|
|
|
561
611
|
addressMap?.let {
|
|
@@ -580,12 +630,15 @@ internal fun mapToAddress(addressMap: ReadableMap?, cardAddress: Address?): Addr
|
|
|
580
630
|
return address.build()
|
|
581
631
|
}
|
|
582
632
|
|
|
583
|
-
internal fun mapToBillingDetails(
|
|
633
|
+
internal fun mapToBillingDetails(
|
|
634
|
+
billingDetails: ReadableMap?,
|
|
635
|
+
cardAddress: Address?,
|
|
636
|
+
): PaymentMethod.BillingDetails? {
|
|
584
637
|
if (billingDetails == null && cardAddress == null) {
|
|
585
638
|
return null
|
|
586
639
|
}
|
|
587
640
|
val address = mapToAddress(getMapOrNull(billingDetails, "address"), cardAddress)
|
|
588
|
-
val paymentMethodBillingDetailsBuilder =
|
|
641
|
+
val paymentMethodBillingDetailsBuilder = PaymentMethod.BillingDetails.Builder()
|
|
589
642
|
|
|
590
643
|
if (billingDetails != null) {
|
|
591
644
|
paymentMethodBillingDetailsBuilder
|
|
@@ -598,6 +651,8 @@ internal fun mapToBillingDetails(billingDetails: ReadableMap?, cardAddress: Addr
|
|
|
598
651
|
return paymentMethodBillingDetailsBuilder.build()
|
|
599
652
|
}
|
|
600
653
|
|
|
654
|
+
internal fun mapToMetadata(metadata: ReadableMap?): Map<String, String>? = metadata?.toHashMap()?.mapValues { it.value.toString() }
|
|
655
|
+
|
|
601
656
|
internal fun mapToShippingDetails(shippingDetails: ReadableMap?): ConfirmPaymentIntentParams.Shipping? {
|
|
602
657
|
if (shippingDetails == null) {
|
|
603
658
|
return null
|
|
@@ -607,29 +662,31 @@ internal fun mapToShippingDetails(shippingDetails: ReadableMap?): ConfirmPayment
|
|
|
607
662
|
|
|
608
663
|
return ConfirmPaymentIntentParams.Shipping(
|
|
609
664
|
name = getValOr(shippingDetails, "name") ?: "",
|
|
610
|
-
address = address
|
|
665
|
+
address = address,
|
|
611
666
|
)
|
|
612
667
|
}
|
|
613
668
|
|
|
614
|
-
private fun getStringOrNull(
|
|
615
|
-
|
|
616
|
-
|
|
669
|
+
private fun getStringOrNull(
|
|
670
|
+
map: ReadableMap?,
|
|
671
|
+
key: String,
|
|
672
|
+
): String? = if (map?.hasKey(key) == true) map.getString(key) else null
|
|
617
673
|
|
|
618
|
-
fun getIntOrNull(
|
|
619
|
-
|
|
620
|
-
|
|
674
|
+
fun getIntOrNull(
|
|
675
|
+
map: ReadableMap?,
|
|
676
|
+
key: String,
|
|
677
|
+
): Int? = if (map?.hasKey(key) == true) map.getInt(key) else null
|
|
621
678
|
|
|
622
|
-
fun getMapOrNull(
|
|
623
|
-
|
|
624
|
-
|
|
679
|
+
fun getMapOrNull(
|
|
680
|
+
map: ReadableMap?,
|
|
681
|
+
key: String,
|
|
682
|
+
): ReadableMap? = if (map?.hasKey(key) == true) map.getMap(key) else null
|
|
625
683
|
|
|
626
|
-
fun getBooleanOrFalse(
|
|
627
|
-
|
|
628
|
-
|
|
684
|
+
fun getBooleanOrFalse(
|
|
685
|
+
map: ReadableMap?,
|
|
686
|
+
key: String,
|
|
687
|
+
): Boolean = if (map?.hasKey(key) == true) map.getBoolean(key) else false
|
|
629
688
|
|
|
630
|
-
private fun convertToUnixTimestamp(timestamp: Long): String
|
|
631
|
-
return (timestamp * 1000).toString()
|
|
632
|
-
}
|
|
689
|
+
private fun convertToUnixTimestamp(timestamp: Long): String = (timestamp * 1000).toString()
|
|
633
690
|
|
|
634
691
|
fun mapToUICustomization(params: ReadableMap): PaymentAuthConfig.Stripe3ds2UiCustomization {
|
|
635
692
|
val labelCustomization = getMapOrNull(params, "label")
|
|
@@ -651,35 +708,35 @@ fun mapToUICustomization(params: ReadableMap): PaymentAuthConfig.Stripe3ds2UiCus
|
|
|
651
708
|
val continueButtonCustomizationBuilder = PaymentAuthConfig.Stripe3ds2ButtonCustomization.Builder()
|
|
652
709
|
val resendButtonCustomizationBuilder = PaymentAuthConfig.Stripe3ds2ButtonCustomization.Builder()
|
|
653
710
|
|
|
654
|
-
getStringOrNull(labelCustomization,"headingTextColor")?.let {
|
|
711
|
+
getStringOrNull(labelCustomization, "headingTextColor")?.let {
|
|
655
712
|
labelCustomizationBuilder.setHeadingTextColor(it)
|
|
656
713
|
}
|
|
657
|
-
getStringOrNull(labelCustomization,"textColor")?.let {
|
|
714
|
+
getStringOrNull(labelCustomization, "textColor")?.let {
|
|
658
715
|
labelCustomizationBuilder.setTextColor(it)
|
|
659
716
|
}
|
|
660
|
-
getIntOrNull(labelCustomization,"headingFontSize")?.let {
|
|
717
|
+
getIntOrNull(labelCustomization, "headingFontSize")?.let {
|
|
661
718
|
labelCustomizationBuilder.setHeadingTextFontSize(it)
|
|
662
719
|
}
|
|
663
|
-
getIntOrNull(labelCustomization,"textFontSize")?.let {
|
|
720
|
+
getIntOrNull(labelCustomization, "textFontSize")?.let {
|
|
664
721
|
labelCustomizationBuilder.setTextFontSize(it)
|
|
665
722
|
}
|
|
666
723
|
|
|
667
|
-
getStringOrNull(navigationBarCustomization,"headerText")?.let {
|
|
724
|
+
getStringOrNull(navigationBarCustomization, "headerText")?.let {
|
|
668
725
|
toolbarCustomizationBuilder.setHeaderText(it)
|
|
669
726
|
}
|
|
670
|
-
getStringOrNull(navigationBarCustomization,"buttonText")?.let {
|
|
727
|
+
getStringOrNull(navigationBarCustomization, "buttonText")?.let {
|
|
671
728
|
toolbarCustomizationBuilder.setButtonText(it)
|
|
672
729
|
}
|
|
673
|
-
getStringOrNull(navigationBarCustomization,"textColor")?.let {
|
|
730
|
+
getStringOrNull(navigationBarCustomization, "textColor")?.let {
|
|
674
731
|
toolbarCustomizationBuilder.setTextColor(it)
|
|
675
732
|
}
|
|
676
|
-
getStringOrNull(navigationBarCustomization,"statusBarColor")?.let {
|
|
733
|
+
getStringOrNull(navigationBarCustomization, "statusBarColor")?.let {
|
|
677
734
|
toolbarCustomizationBuilder.setStatusBarColor(it)
|
|
678
735
|
}
|
|
679
|
-
getStringOrNull(navigationBarCustomization,"backgroundColor")?.let {
|
|
736
|
+
getStringOrNull(navigationBarCustomization, "backgroundColor")?.let {
|
|
680
737
|
toolbarCustomizationBuilder.setBackgroundColor(it)
|
|
681
738
|
}
|
|
682
|
-
getIntOrNull(navigationBarCustomization,"textFontSize")?.let {
|
|
739
|
+
getIntOrNull(navigationBarCustomization, "textFontSize")?.let {
|
|
683
740
|
toolbarCustomizationBuilder.setTextFontSize(it)
|
|
684
741
|
}
|
|
685
742
|
|
|
@@ -769,39 +826,29 @@ fun mapToUICustomization(params: ReadableMap): PaymentAuthConfig.Stripe3ds2UiCus
|
|
|
769
826
|
resendButtonCustomizationBuilder.setTextFontSize(it)
|
|
770
827
|
}
|
|
771
828
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
PaymentAuthConfig.Stripe3ds2UiCustomization.ButtonType.CANCEL
|
|
796
|
-
)
|
|
797
|
-
.setButtonCustomization(
|
|
798
|
-
resendButtonCustomizationBuilder.build(),
|
|
799
|
-
PaymentAuthConfig.Stripe3ds2UiCustomization.ButtonType.RESEND
|
|
800
|
-
)
|
|
801
|
-
|
|
802
|
-
getStringOrNull(params, "accentColor")?.let {
|
|
803
|
-
uiCustomization.setAccentColor(it)
|
|
804
|
-
}
|
|
829
|
+
val uiCustomization =
|
|
830
|
+
PaymentAuthConfig.Stripe3ds2UiCustomization
|
|
831
|
+
.Builder()
|
|
832
|
+
.setLabelCustomization(labelCustomizationBuilder.build())
|
|
833
|
+
.setToolbarCustomization(toolbarCustomizationBuilder.build())
|
|
834
|
+
.setButtonCustomization(
|
|
835
|
+
submitButtonCustomizationBuilder.build(),
|
|
836
|
+
PaymentAuthConfig.Stripe3ds2UiCustomization.ButtonType.SUBMIT,
|
|
837
|
+
).setButtonCustomization(
|
|
838
|
+
continueButtonCustomizationBuilder.build(),
|
|
839
|
+
PaymentAuthConfig.Stripe3ds2UiCustomization.ButtonType.CONTINUE,
|
|
840
|
+
).setButtonCustomization(
|
|
841
|
+
nextButtonCustomizationBuilder.build(),
|
|
842
|
+
PaymentAuthConfig.Stripe3ds2UiCustomization.ButtonType.SELECT,
|
|
843
|
+
).setButtonCustomization(
|
|
844
|
+
cancelButtonCustomizationBuilder.build(),
|
|
845
|
+
PaymentAuthConfig.Stripe3ds2UiCustomization.ButtonType.CANCEL,
|
|
846
|
+
).setButtonCustomization(
|
|
847
|
+
resendButtonCustomizationBuilder.build(),
|
|
848
|
+
PaymentAuthConfig.Stripe3ds2UiCustomization.ButtonType.RESEND,
|
|
849
|
+
)
|
|
850
|
+
|
|
851
|
+
getStringOrNull(params, "accentColor")?.let { uiCustomization.setAccentColor(it) }
|
|
805
852
|
|
|
806
853
|
return uiCustomization.build()
|
|
807
854
|
}
|
|
@@ -815,11 +862,10 @@ internal fun mapFromSetupIntentResult(setupIntent: SetupIntent): WritableMap {
|
|
|
815
862
|
map.putBoolean("livemode", setupIntent.isLiveMode)
|
|
816
863
|
map.putString("clientSecret", setupIntent.clientSecret)
|
|
817
864
|
map.putString("paymentMethodId", setupIntent.paymentMethodId)
|
|
818
|
-
map.putMap(
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
})
|
|
865
|
+
map.putMap(
|
|
866
|
+
"paymentMethod",
|
|
867
|
+
setupIntent.paymentMethod?.let { mapFromPaymentMethod(it) } ?: run { null },
|
|
868
|
+
)
|
|
823
869
|
map.putString("usage", mapSetupIntentUsage(setupIntent.usage))
|
|
824
870
|
map.putString("created", convertToUnixTimestamp(setupIntent.created))
|
|
825
871
|
map.putMap("nextAction", mapNextAction(setupIntent.nextActionType, setupIntent.nextActionData))
|
|
@@ -847,22 +893,20 @@ internal fun mapFromSetupIntentResult(setupIntent: SetupIntent): WritableMap {
|
|
|
847
893
|
return map
|
|
848
894
|
}
|
|
849
895
|
|
|
850
|
-
internal fun mapSetupIntentUsage(type: StripeIntent.Usage?): String
|
|
851
|
-
|
|
896
|
+
internal fun mapSetupIntentUsage(type: StripeIntent.Usage?): String =
|
|
897
|
+
when (type) {
|
|
852
898
|
StripeIntent.Usage.OffSession -> "OffSession"
|
|
853
899
|
StripeIntent.Usage.OnSession -> "OnSession"
|
|
854
900
|
StripeIntent.Usage.OneTime -> "OneTime"
|
|
855
901
|
else -> "Unknown"
|
|
856
902
|
}
|
|
857
|
-
}
|
|
858
903
|
|
|
859
|
-
fun mapToPaymentIntentFutureUsage(type: String?): ConfirmPaymentIntentParams.SetupFutureUsage?
|
|
860
|
-
|
|
861
|
-
"OffSession" ->
|
|
862
|
-
"OnSession" ->
|
|
863
|
-
else ->
|
|
904
|
+
fun mapToPaymentIntentFutureUsage(type: String?): ConfirmPaymentIntentParams.SetupFutureUsage? =
|
|
905
|
+
when (type) {
|
|
906
|
+
"OffSession" -> ConfirmPaymentIntentParams.SetupFutureUsage.OffSession
|
|
907
|
+
"OnSession" -> ConfirmPaymentIntentParams.SetupFutureUsage.OnSession
|
|
908
|
+
else -> null
|
|
864
909
|
}
|
|
865
|
-
}
|
|
866
910
|
|
|
867
911
|
fun toBundleObject(readableMap: ReadableMap?): Bundle {
|
|
868
912
|
val result = Bundle()
|
|
@@ -875,17 +919,18 @@ fun toBundleObject(readableMap: ReadableMap?): Bundle {
|
|
|
875
919
|
when (readableMap.getType(key)) {
|
|
876
920
|
ReadableType.Null -> result.putString(key, null)
|
|
877
921
|
ReadableType.Boolean -> result.putBoolean(key, readableMap.getBoolean(key))
|
|
878
|
-
ReadableType.Number ->
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
922
|
+
ReadableType.Number ->
|
|
923
|
+
try {
|
|
924
|
+
val numAsInt = readableMap.getInt(key)
|
|
925
|
+
val numAsDouble = readableMap.getDouble(key)
|
|
926
|
+
if (numAsDouble - numAsInt != 0.0) {
|
|
927
|
+
result.putDouble(key, numAsDouble)
|
|
928
|
+
} else {
|
|
929
|
+
result.putInt(key, numAsInt)
|
|
930
|
+
}
|
|
931
|
+
} catch (e: Exception) {
|
|
932
|
+
Log.e("toBundleException", "Failed to add number to bundle. Failed on: $key.")
|
|
885
933
|
}
|
|
886
|
-
} catch (e: Exception) {
|
|
887
|
-
Log.e("toBundleException", "Failed to add number to bundle. Failed on: $key.")
|
|
888
|
-
}
|
|
889
934
|
ReadableType.String -> result.putString(key, readableMap.getString(key))
|
|
890
935
|
ReadableType.Map -> result.putBundle(key, toBundleObject(readableMap.getMap(key)))
|
|
891
936
|
ReadableType.Array -> {
|
|
@@ -898,7 +943,11 @@ fun toBundleObject(readableMap: ReadableMap?): Bundle {
|
|
|
898
943
|
when (list.first()) {
|
|
899
944
|
is String -> result.putStringArrayList(key, list as java.util.ArrayList<String>)
|
|
900
945
|
is Int -> result.putIntegerArrayList(key, list as java.util.ArrayList<Int>)
|
|
901
|
-
else ->
|
|
946
|
+
else ->
|
|
947
|
+
Log.e(
|
|
948
|
+
"toBundleException",
|
|
949
|
+
"Cannot put arrays of objects into bundles. Failed on: $key.",
|
|
950
|
+
)
|
|
902
951
|
}
|
|
903
952
|
}
|
|
904
953
|
}
|
|
@@ -915,11 +964,8 @@ internal fun mapFromShippingContact(googlePayResult: GooglePayResult): WritableM
|
|
|
915
964
|
googlePayResult.name
|
|
916
965
|
name.putString("givenName", googlePayResult.shippingInformation?.name)
|
|
917
966
|
map.putMap("name", name)
|
|
918
|
-
googlePayResult.shippingInformation?.phone?.let {
|
|
919
|
-
map.putString("phoneNumber",
|
|
920
|
-
} ?: run {
|
|
921
|
-
map.putString("phoneNumber", googlePayResult.phoneNumber)
|
|
922
|
-
}
|
|
967
|
+
googlePayResult.shippingInformation?.phone?.let { map.putString("phoneNumber", it) }
|
|
968
|
+
?: run { map.putString("phoneNumber", googlePayResult.phoneNumber) }
|
|
923
969
|
val postalAddress = WritableNativeMap()
|
|
924
970
|
postalAddress.putString("city", googlePayResult.shippingInformation?.address?.city)
|
|
925
971
|
postalAddress.putString("country", googlePayResult.shippingInformation?.address?.country)
|
|
@@ -927,9 +973,7 @@ internal fun mapFromShippingContact(googlePayResult: GooglePayResult): WritableM
|
|
|
927
973
|
postalAddress.putString("state", googlePayResult.shippingInformation?.address?.state)
|
|
928
974
|
val line1: String? = googlePayResult.shippingInformation?.address?.line1
|
|
929
975
|
val line2: String? = googlePayResult.shippingInformation?.address?.line2
|
|
930
|
-
val street =
|
|
931
|
-
(if (line1 != null) "$line1" else "") +
|
|
932
|
-
(if (line2 != null) "\n$line2" else "")
|
|
976
|
+
val street = (if (line1 != null) "$line1" else "") + (if (line2 != null) "\n$line2" else "")
|
|
933
977
|
postalAddress.putString("street", street)
|
|
934
978
|
postalAddress.putString("isoCountryCode", googlePayResult.shippingInformation?.address?.country)
|
|
935
979
|
map.putMap("postalAddress", postalAddress)
|
|
@@ -941,19 +985,62 @@ internal fun mapToPreferredNetworks(networksAsInts: ArrayList<Int>?): List<CardB
|
|
|
941
985
|
return emptyList()
|
|
942
986
|
}
|
|
943
987
|
|
|
944
|
-
val intToCardBrand =
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
988
|
+
val intToCardBrand =
|
|
989
|
+
mapOf(
|
|
990
|
+
0 to CardBrand.JCB,
|
|
991
|
+
1 to CardBrand.AmericanExpress,
|
|
992
|
+
2 to CardBrand.CartesBancaires,
|
|
993
|
+
3 to CardBrand.DinersClub,
|
|
994
|
+
4 to CardBrand.Discover,
|
|
995
|
+
5 to CardBrand.MasterCard,
|
|
996
|
+
6 to CardBrand.UnionPay,
|
|
997
|
+
7 to CardBrand.Visa,
|
|
998
|
+
8 to CardBrand.Unknown,
|
|
999
|
+
)
|
|
1000
|
+
|
|
1001
|
+
return networksAsInts.mapNotNull { intToCardBrand[it] }
|
|
1002
|
+
}
|
|
955
1003
|
|
|
956
|
-
|
|
957
|
-
|
|
1004
|
+
internal fun mapFromFinancialConnectionsEvent(event: FinancialConnectionsEvent): WritableMap =
|
|
1005
|
+
Arguments.createMap().apply {
|
|
1006
|
+
putString("name", event.name.value)
|
|
1007
|
+
putMap("metadata", event.metadata.toMap().toReadableMap())
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
private fun List<Any?>.toWritableArray(): WritableArray {
|
|
1011
|
+
val writableArray = Arguments.createArray()
|
|
1012
|
+
|
|
1013
|
+
forEach { value ->
|
|
1014
|
+
when (value) {
|
|
1015
|
+
null -> writableArray.pushNull()
|
|
1016
|
+
is Boolean -> writableArray.pushBoolean(value)
|
|
1017
|
+
is Int -> writableArray.pushInt(value)
|
|
1018
|
+
is Double -> writableArray.pushDouble(value)
|
|
1019
|
+
is String -> writableArray.pushString(value)
|
|
1020
|
+
is Map<*, *> -> writableArray.pushMap((value as Map<String, Any?>).toReadableMap())
|
|
1021
|
+
is List<*> -> writableArray.pushArray((value as List<Any?>).toWritableArray())
|
|
1022
|
+
else -> writableArray.pushString(value.toString())
|
|
1023
|
+
}
|
|
958
1024
|
}
|
|
1025
|
+
|
|
1026
|
+
return writableArray
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
private fun Map<String, Any?>.toReadableMap(): ReadableMap {
|
|
1030
|
+
val writableMap = Arguments.createMap()
|
|
1031
|
+
|
|
1032
|
+
forEach { (key, value) ->
|
|
1033
|
+
when (value) {
|
|
1034
|
+
null -> writableMap.putNull(key)
|
|
1035
|
+
is Boolean -> writableMap.putBoolean(key, value)
|
|
1036
|
+
is Int -> writableMap.putInt(key, value)
|
|
1037
|
+
is Double -> writableMap.putDouble(key, value)
|
|
1038
|
+
is String -> writableMap.putString(key, value)
|
|
1039
|
+
is Map<*, *> -> writableMap.putMap(key, (value as Map<String, Any?>).toReadableMap())
|
|
1040
|
+
is List<*> -> writableMap.putArray(key, (value as List<Any?>).toWritableArray())
|
|
1041
|
+
else -> writableMap.putString(key, value.toString())
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
return writableMap
|
|
959
1046
|
}
|