@stripe/stripe-react-native 0.42.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 +14 -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/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
- package/android/.project +0 -11
- package/android/.settings/org.eclipse.buildship.core.prefs +3 -3
- 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 +33 -24
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +107 -85
- 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 +137 -156
- 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 +295 -258
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -11
- package/ios/CustomerSheet/CustomerSheetUtils.swift +3 -1
- package/ios/FinancialConnections.swift +6 -2
- package/ios/StripeSdk+CustomerSheet.swift +2 -1
- package/ios/StripeSdk+PaymentSheet.swift +42 -0
- package/ios/StripeSdk.m +2 -0
- package/ios/StripeSdk.swift +72 -11
- 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.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.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.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.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 +4 -3
- 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 +6 -5
- 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 +3 -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 +21 -17
- 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 +16 -15
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentMethod.d.ts +21 -16
- 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 +32 -40
- package/src/NativeStripeSdk.tsx +4 -2
- 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 +13 -14
- package/src/types/Common.ts +3 -0
- package/src/types/CustomerSheet.ts +7 -0
- package/src/types/FinancialConnections.ts +3 -0
- package/src/types/PaymentMethod.ts +5 -1
- package/src/types/PaymentSheet.ts +64 -4
- package/src/types/components/CardFieldInput.ts +8 -4
- package/src/types/components/CardFormView.ts +8 -4
- package/stripe-react-native.podspec +2 -1
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- /package/android/.gradle/{8.9 → 8.11.1}/fileChanges/last-build.bin +0 -0
- /package/android/.gradle/{8.9/dependencies-accessors → 8.11.1}/gc.properties +0 -0
|
@@ -3,11 +3,13 @@ package com.reactnativestripesdk
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.graphics.Color
|
|
5
5
|
import android.os.Bundle
|
|
6
|
-
import com.facebook.react.bridge.ReactContext
|
|
7
6
|
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
8
7
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
9
8
|
|
|
10
|
-
fun buildPaymentSheetAppearance(
|
|
9
|
+
fun buildPaymentSheetAppearance(
|
|
10
|
+
userParams: Bundle?,
|
|
11
|
+
context: Context,
|
|
12
|
+
): PaymentSheet.Appearance {
|
|
11
13
|
val colorParams = userParams?.getBundle(PaymentSheetAppearanceKeys.COLORS)
|
|
12
14
|
val lightColorParams = colorParams?.getBundle(PaymentSheetAppearanceKeys.LIGHT) ?: colorParams
|
|
13
15
|
val darkColorParams = colorParams?.getBundle(PaymentSheetAppearanceKeys.DARK) ?: colorParams
|
|
@@ -17,58 +19,138 @@ fun buildPaymentSheetAppearance(userParams: Bundle?, context: Context): PaymentS
|
|
|
17
19
|
colorsLight = buildColors(lightColorParams, PaymentSheet.Colors.defaultLight),
|
|
18
20
|
colorsDark = buildColors(darkColorParams, PaymentSheet.Colors.defaultDark),
|
|
19
21
|
shapes = buildShapes(userParams?.getBundle(PaymentSheetAppearanceKeys.SHAPES)),
|
|
20
|
-
primaryButton =
|
|
22
|
+
primaryButton =
|
|
23
|
+
buildPrimaryButton(
|
|
24
|
+
userParams?.getBundle(PaymentSheetAppearanceKeys.PRIMARY_BUTTON),
|
|
25
|
+
context,
|
|
26
|
+
),
|
|
21
27
|
)
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
private fun buildTypography(
|
|
30
|
+
private fun buildTypography(
|
|
31
|
+
fontParams: Bundle?,
|
|
32
|
+
context: Context,
|
|
33
|
+
): PaymentSheet.Typography {
|
|
25
34
|
val scale = getDoubleOrNull(fontParams, PaymentSheetAppearanceKeys.SCALE)
|
|
26
|
-
val resId =
|
|
35
|
+
val resId =
|
|
36
|
+
getFontResId(
|
|
37
|
+
fontParams,
|
|
38
|
+
PaymentSheetAppearanceKeys.FAMILY,
|
|
39
|
+
PaymentSheet.Typography.default.fontResId,
|
|
40
|
+
context,
|
|
41
|
+
)
|
|
27
42
|
return PaymentSheet.Typography.default.copy(
|
|
28
43
|
sizeScaleFactor = scale?.toFloat() ?: PaymentSheet.Typography.default.sizeScaleFactor,
|
|
29
|
-
fontResId = resId
|
|
44
|
+
fontResId = resId,
|
|
30
45
|
)
|
|
31
46
|
}
|
|
32
47
|
|
|
33
48
|
@Throws(PaymentSheetAppearanceException::class)
|
|
34
|
-
private fun colorFromHexOrDefault(
|
|
35
|
-
|
|
49
|
+
private fun colorFromHexOrDefault(
|
|
50
|
+
hexString: String?,
|
|
51
|
+
default: Int,
|
|
52
|
+
): Int {
|
|
53
|
+
return hexString?.trim()?.replace("#", "")?.let {
|
|
36
54
|
if (it.length == 6 || it.length == 8) {
|
|
37
55
|
return Color.parseColor("#$it")
|
|
38
|
-
} else
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
} else {
|
|
57
|
+
throw PaymentSheetAppearanceException(
|
|
58
|
+
"Failed to set Payment Sheet appearance. Expected hex string of length 6 or 8, but received: $it",
|
|
59
|
+
)
|
|
60
|
+
}
|
|
41
61
|
}
|
|
62
|
+
?: run {
|
|
63
|
+
return default
|
|
64
|
+
}
|
|
42
65
|
}
|
|
43
66
|
|
|
44
|
-
private fun buildColors(
|
|
67
|
+
private fun buildColors(
|
|
68
|
+
colorParams: Bundle?,
|
|
69
|
+
default: PaymentSheet.Colors,
|
|
70
|
+
): PaymentSheet.Colors {
|
|
45
71
|
if (colorParams == null) {
|
|
46
72
|
return default
|
|
47
73
|
}
|
|
48
74
|
|
|
49
75
|
return default.copy(
|
|
50
|
-
primary =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
76
|
+
primary =
|
|
77
|
+
colorFromHexOrDefault(
|
|
78
|
+
colorParams.getString(PaymentSheetAppearanceKeys.PRIMARY),
|
|
79
|
+
default.primary,
|
|
80
|
+
),
|
|
81
|
+
surface =
|
|
82
|
+
colorFromHexOrDefault(
|
|
83
|
+
colorParams.getString(PaymentSheetAppearanceKeys.BACKGROUND),
|
|
84
|
+
default.surface,
|
|
85
|
+
),
|
|
86
|
+
component =
|
|
87
|
+
colorFromHexOrDefault(
|
|
88
|
+
colorParams.getString(PaymentSheetAppearanceKeys.COMPONENT_BACKGROUND),
|
|
89
|
+
default.component,
|
|
90
|
+
),
|
|
91
|
+
componentBorder =
|
|
92
|
+
colorFromHexOrDefault(
|
|
93
|
+
colorParams.getString(PaymentSheetAppearanceKeys.COMPONENT_BORDER),
|
|
94
|
+
default.componentBorder,
|
|
95
|
+
),
|
|
96
|
+
componentDivider =
|
|
97
|
+
colorFromHexOrDefault(
|
|
98
|
+
colorParams.getString(PaymentSheetAppearanceKeys.COMPONENT_DIVIDER),
|
|
99
|
+
default.componentDivider,
|
|
100
|
+
),
|
|
101
|
+
onComponent =
|
|
102
|
+
colorFromHexOrDefault(
|
|
103
|
+
colorParams.getString(PaymentSheetAppearanceKeys.COMPONENT_TEXT),
|
|
104
|
+
default.onComponent,
|
|
105
|
+
),
|
|
106
|
+
onSurface =
|
|
107
|
+
colorFromHexOrDefault(
|
|
108
|
+
colorParams.getString(PaymentSheetAppearanceKeys.PRIMARY_TEXT),
|
|
109
|
+
default.onSurface,
|
|
110
|
+
),
|
|
111
|
+
subtitle =
|
|
112
|
+
colorFromHexOrDefault(
|
|
113
|
+
colorParams.getString(PaymentSheetAppearanceKeys.SECONDARY_TEXT),
|
|
114
|
+
default.subtitle,
|
|
115
|
+
),
|
|
116
|
+
placeholderText =
|
|
117
|
+
colorFromHexOrDefault(
|
|
118
|
+
colorParams.getString(PaymentSheetAppearanceKeys.PLACEHOLDER_TEXT),
|
|
119
|
+
default.placeholderText,
|
|
120
|
+
),
|
|
121
|
+
appBarIcon =
|
|
122
|
+
colorFromHexOrDefault(
|
|
123
|
+
colorParams.getString(PaymentSheetAppearanceKeys.ICON),
|
|
124
|
+
default.appBarIcon,
|
|
125
|
+
),
|
|
126
|
+
error =
|
|
127
|
+
colorFromHexOrDefault(
|
|
128
|
+
colorParams.getString(PaymentSheetAppearanceKeys.ERROR),
|
|
129
|
+
default.error,
|
|
130
|
+
),
|
|
61
131
|
)
|
|
62
132
|
}
|
|
63
133
|
|
|
64
|
-
private fun buildShapes(shapeParams: Bundle?): PaymentSheet.Shapes
|
|
65
|
-
|
|
66
|
-
cornerRadiusDp =
|
|
67
|
-
|
|
134
|
+
private fun buildShapes(shapeParams: Bundle?): PaymentSheet.Shapes =
|
|
135
|
+
PaymentSheet.Shapes.default.copy(
|
|
136
|
+
cornerRadiusDp =
|
|
137
|
+
getFloatOr(
|
|
138
|
+
shapeParams,
|
|
139
|
+
PaymentSheetAppearanceKeys.BORDER_RADIUS,
|
|
140
|
+
PaymentSheet.Shapes.default.cornerRadiusDp,
|
|
141
|
+
),
|
|
142
|
+
borderStrokeWidthDp =
|
|
143
|
+
getFloatOr(
|
|
144
|
+
shapeParams,
|
|
145
|
+
PaymentSheetAppearanceKeys.BORDER_WIDTH,
|
|
146
|
+
PaymentSheet.Shapes.default.borderStrokeWidthDp,
|
|
147
|
+
),
|
|
68
148
|
)
|
|
69
|
-
}
|
|
70
149
|
|
|
71
|
-
private fun buildPrimaryButton(
|
|
150
|
+
private fun buildPrimaryButton(
|
|
151
|
+
params: Bundle?,
|
|
152
|
+
context: Context,
|
|
153
|
+
): PaymentSheet.PrimaryButton {
|
|
72
154
|
if (params == null) {
|
|
73
155
|
return PaymentSheet.PrimaryButton()
|
|
74
156
|
}
|
|
@@ -80,34 +162,61 @@ private fun buildPrimaryButton(params: Bundle?, context: Context): PaymentSheet.
|
|
|
80
162
|
val darkColorParams = colorParams.getBundle(PaymentSheetAppearanceKeys.DARK) ?: colorParams
|
|
81
163
|
|
|
82
164
|
return PaymentSheet.PrimaryButton(
|
|
83
|
-
colorsLight =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
165
|
+
colorsLight =
|
|
166
|
+
buildPrimaryButtonColors(lightColorParams, PaymentSheet.PrimaryButtonColors.defaultLight),
|
|
167
|
+
colorsDark =
|
|
168
|
+
buildPrimaryButtonColors(darkColorParams, PaymentSheet.PrimaryButtonColors.defaultDark),
|
|
169
|
+
shape =
|
|
170
|
+
PaymentSheet.PrimaryButtonShape(
|
|
171
|
+
cornerRadiusDp =
|
|
172
|
+
getFloatOrNull(shapeParams, PaymentSheetAppearanceKeys.BORDER_RADIUS),
|
|
173
|
+
borderStrokeWidthDp =
|
|
174
|
+
getFloatOrNull(shapeParams, PaymentSheetAppearanceKeys.BORDER_WIDTH),
|
|
175
|
+
),
|
|
176
|
+
typography =
|
|
177
|
+
PaymentSheet.PrimaryButtonTypography(
|
|
178
|
+
fontResId =
|
|
179
|
+
getFontResId(fontParams, PaymentSheetAppearanceKeys.FAMILY, null, context),
|
|
180
|
+
),
|
|
92
181
|
)
|
|
93
182
|
}
|
|
94
183
|
|
|
95
184
|
@Throws(PaymentSheetAppearanceException::class)
|
|
96
|
-
private fun buildPrimaryButtonColors(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
185
|
+
private fun buildPrimaryButtonColors(
|
|
186
|
+
colorParams: Bundle,
|
|
187
|
+
default: PaymentSheet.PrimaryButtonColors,
|
|
188
|
+
): PaymentSheet.PrimaryButtonColors =
|
|
189
|
+
PaymentSheet.PrimaryButtonColors(
|
|
190
|
+
background =
|
|
191
|
+
colorParams
|
|
192
|
+
.getString(PaymentSheetAppearanceKeys.BACKGROUND)
|
|
193
|
+
?.trim()
|
|
194
|
+
?.replace("#", "")
|
|
195
|
+
?.let {
|
|
196
|
+
if (it.length == 6 || it.length == 8) {
|
|
197
|
+
Color.parseColor("#$it")
|
|
198
|
+
} else {
|
|
199
|
+
throw PaymentSheetAppearanceException(
|
|
200
|
+
"Failed to set Payment Sheet appearance. Expected hex string of length 6 or 8, but received: $it",
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
} ?: run { null },
|
|
204
|
+
onBackground =
|
|
205
|
+
colorFromHexOrDefault(
|
|
206
|
+
colorParams.getString(PaymentSheetAppearanceKeys.TEXT),
|
|
207
|
+
default.onBackground,
|
|
208
|
+
),
|
|
209
|
+
border =
|
|
210
|
+
colorFromHexOrDefault(
|
|
211
|
+
colorParams.getString(PaymentSheetAppearanceKeys.BORDER),
|
|
212
|
+
default.border,
|
|
213
|
+
),
|
|
107
214
|
)
|
|
108
|
-
}
|
|
109
215
|
|
|
110
|
-
private fun getDoubleOrNull(
|
|
216
|
+
private fun getDoubleOrNull(
|
|
217
|
+
bundle: Bundle?,
|
|
218
|
+
key: String,
|
|
219
|
+
): Double? {
|
|
111
220
|
if (bundle?.containsKey(key) == true) {
|
|
112
221
|
val valueOfUnknownType = bundle.get(key)
|
|
113
222
|
if (valueOfUnknownType is Double) {
|
|
@@ -122,7 +231,11 @@ private fun getDoubleOrNull(bundle: Bundle?, key: String): Double? {
|
|
|
122
231
|
return null
|
|
123
232
|
}
|
|
124
233
|
|
|
125
|
-
private fun getFloatOr(
|
|
234
|
+
private fun getFloatOr(
|
|
235
|
+
bundle: Bundle?,
|
|
236
|
+
key: String,
|
|
237
|
+
defaultValue: Float,
|
|
238
|
+
): Float {
|
|
126
239
|
if (bundle?.containsKey(key) == true) {
|
|
127
240
|
val valueOfUnknownType = bundle.get(key)
|
|
128
241
|
if (valueOfUnknownType is Float) {
|
|
@@ -137,7 +250,10 @@ private fun getFloatOr(bundle: Bundle?, key: String, defaultValue: Float): Float
|
|
|
137
250
|
return defaultValue
|
|
138
251
|
}
|
|
139
252
|
|
|
140
|
-
private fun getFloatOrNull(
|
|
253
|
+
private fun getFloatOrNull(
|
|
254
|
+
bundle: Bundle?,
|
|
255
|
+
key: String,
|
|
256
|
+
): Float? {
|
|
141
257
|
if (bundle?.containsKey(key) == true) {
|
|
142
258
|
val valueOfUnknownType = bundle.get(key)
|
|
143
259
|
if (valueOfUnknownType is Float) {
|
|
@@ -153,17 +269,25 @@ private fun getFloatOrNull(bundle: Bundle?, key: String): Float? {
|
|
|
153
269
|
}
|
|
154
270
|
|
|
155
271
|
@Throws(PaymentSheetAppearanceException::class)
|
|
156
|
-
private fun getFontResId(
|
|
272
|
+
private fun getFontResId(
|
|
273
|
+
bundle: Bundle?,
|
|
274
|
+
key: String,
|
|
275
|
+
defaultValue: Int?,
|
|
276
|
+
context: Context,
|
|
277
|
+
): Int? {
|
|
157
278
|
val fontErrorPrefix = "Encountered an error when setting a custom font:"
|
|
158
279
|
if (bundle?.containsKey(key) != true) {
|
|
159
280
|
return defaultValue
|
|
160
281
|
}
|
|
161
282
|
|
|
162
|
-
val fontFileName =
|
|
163
|
-
|
|
283
|
+
val fontFileName =
|
|
284
|
+
bundle.getString(key)
|
|
285
|
+
?: throw PaymentSheetAppearanceException(
|
|
286
|
+
"$fontErrorPrefix expected String for font.$key, but received null.",
|
|
287
|
+
)
|
|
164
288
|
if (Regex("[^a-z0-9]").containsMatchIn(fontFileName)) {
|
|
165
289
|
throw PaymentSheetAppearanceException(
|
|
166
|
-
"$fontErrorPrefix appearance.font.$key should only contain lowercase alphanumeric characters on Android, but received '$fontFileName'. This value must match the filename in android/app/src/main/res/font"
|
|
290
|
+
"$fontErrorPrefix appearance.font.$key should only contain lowercase alphanumeric characters on Android, but received '$fontFileName'. This value must match the filename in android/app/src/main/res/font",
|
|
167
291
|
)
|
|
168
292
|
}
|
|
169
293
|
|