@stripe/stripe-react-native 0.50.0 → 0.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -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/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +10 -4
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +17 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +6 -2
- package/ios/PaymentSheetAppearance.swift +81 -67
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 0.50.1 - 2025-07-22
|
|
4
|
+
|
|
5
|
+
**Fixes**
|
|
6
|
+
- Fixed embedded payment element color support to accept both single color strings and light/dark color objects for `ThemedColor` properties (separatorColor, selectedColor, unselectedColor, checkmark color, chevron color).
|
|
7
|
+
- Fixed Android crash when providing partial `billingDetailsCollectionConfiguration` objects. Now gracefully handles missing fields like `attachDefaultsToPaymentMethod` by using safe accessor methods with default values.
|
|
8
|
+
- Fixed Android Kotlin compilation errors where nullable `ReadableMap?` was passed to functions expecting non-nullable `ReadableMap`. Added null checks in `EmbeddedPaymentElementViewManager` and `AddToWalletButtonManager`. [#1988](https://github.com/stripe/stripe-react-native/issues/1988)
|
|
9
|
+
|
|
3
10
|
## 0.50.0 - 2025-07-17
|
|
4
11
|
|
|
5
12
|
**Features**
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
@@ -17,6 +17,7 @@ import com.reactnativestripesdk.PaymentSheetFragment.Companion.buildGooglePayCon
|
|
|
17
17
|
import com.reactnativestripesdk.addresssheet.AddressSheetView
|
|
18
18
|
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
19
19
|
import com.reactnativestripesdk.utils.PaymentSheetException
|
|
20
|
+
import com.reactnativestripesdk.utils.getBooleanOr
|
|
20
21
|
import com.reactnativestripesdk.utils.mapToPreferredNetworks
|
|
21
22
|
import com.reactnativestripesdk.utils.parseCustomPaymentMethods
|
|
22
23
|
import com.reactnativestripesdk.utils.toBundleObject
|
|
@@ -54,10 +55,13 @@ class EmbeddedPaymentElementViewManager :
|
|
|
54
55
|
view: EmbeddedPaymentElementView,
|
|
55
56
|
cfg: Dynamic,
|
|
56
57
|
) {
|
|
57
|
-
val
|
|
58
|
+
val readableMap = cfg.asMap()
|
|
59
|
+
if (readableMap == null) return
|
|
60
|
+
|
|
61
|
+
val rowSelectionBehaviorType = parseRowSelectionBehavior(readableMap)
|
|
58
62
|
view.rowSelectionBehaviorType.value = rowSelectionBehaviorType
|
|
59
63
|
|
|
60
|
-
val elementConfig = parseElementConfiguration(
|
|
64
|
+
val elementConfig = parseElementConfiguration(readableMap, view.context)
|
|
61
65
|
view.latestElementConfig = elementConfig
|
|
62
66
|
// if intentConfig is already set, configure immediately:
|
|
63
67
|
view.latestIntentConfig?.let { intentCfg ->
|
|
@@ -74,7 +78,9 @@ class EmbeddedPaymentElementViewManager :
|
|
|
74
78
|
view: EmbeddedPaymentElementView,
|
|
75
79
|
cfg: Dynamic,
|
|
76
80
|
) {
|
|
77
|
-
val
|
|
81
|
+
val readableMap = cfg.asMap()
|
|
82
|
+
if (readableMap == null) return
|
|
83
|
+
val intentConfig = parseIntentConfiguration(readableMap)
|
|
78
84
|
view.latestIntentConfig = intentConfig
|
|
79
85
|
view.latestElementConfig?.let { elemCfg ->
|
|
80
86
|
view.configure(elemCfg, intentConfig)
|
|
@@ -147,7 +153,7 @@ class EmbeddedPaymentElementViewManager :
|
|
|
147
153
|
email = mapToCollectionMode(billingConfigParams?.getString("email")),
|
|
148
154
|
address = mapToAddressCollectionMode(billingConfigParams?.getString("address")),
|
|
149
155
|
attachDefaultsToPaymentMethod =
|
|
150
|
-
billingConfigParams?.
|
|
156
|
+
billingConfigParams?.getBooleanOr("attachDefaultsToPaymentMethod", false) ?: false,
|
|
151
157
|
)
|
|
152
158
|
val allowsRemovalOfLastSavedPaymentMethod =
|
|
153
159
|
if (map.hasKey("allowsRemovalOfLastSavedPaymentMethod")) {
|
|
@@ -478,9 +478,11 @@ private fun buildFormInsets(insetParams: Bundle?): PaymentSheet.Insets {
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
/**
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
481
|
+
* Parses a ThemedColor from [params] at [key]. Supports both:
|
|
482
|
+
* - Single hex string: "#RRGGBB"
|
|
483
|
+
* - Light/dark object: { "light": "#RRGGBB", "dark": "#RRGGBB" }
|
|
484
|
+
* For light/dark objects, chooses the appropriate color based on current UI mode.
|
|
485
|
+
* Falls back to [defaultColor] if no color is provided.
|
|
484
486
|
*/
|
|
485
487
|
private fun dynamicColorFromParams(
|
|
486
488
|
context: Context,
|
|
@@ -488,8 +490,12 @@ private fun dynamicColorFromParams(
|
|
|
488
490
|
key: String,
|
|
489
491
|
defaultColor: Int,
|
|
490
492
|
): Int {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
+
if (params == null) {
|
|
494
|
+
return defaultColor
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// First check if it's a nested Bundle { "light": "#RRGGBB", "dark": "#RRGGBB" }
|
|
498
|
+
val colorBundle = params.getBundle(key)
|
|
493
499
|
if (colorBundle != null) {
|
|
494
500
|
val isDark =
|
|
495
501
|
(
|
|
@@ -508,7 +514,12 @@ private fun dynamicColorFromParams(
|
|
|
508
514
|
return colorFromHexOrDefault(hex, defaultColor)
|
|
509
515
|
}
|
|
510
516
|
|
|
511
|
-
//
|
|
517
|
+
// Check if it's a single color string
|
|
518
|
+
params.getString(key)?.let { colorString ->
|
|
519
|
+
return colorFromHexOrDefault(colorString, defaultColor)
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// no override → just use default
|
|
512
523
|
return defaultColor
|
|
513
524
|
}
|
|
514
525
|
|
|
@@ -218,7 +218,7 @@ class PaymentSheetFragment :
|
|
|
218
218
|
email = mapToCollectionMode(billingConfigParams?.getString("email")),
|
|
219
219
|
address = mapToAddressCollectionMode(billingConfigParams?.getString("address")),
|
|
220
220
|
attachDefaultsToPaymentMethod =
|
|
221
|
-
billingConfigParams?.getBoolean("attachDefaultsToPaymentMethod") ?: false,
|
|
221
|
+
billingConfigParams?.getBoolean("attachDefaultsToPaymentMethod", false) ?: false,
|
|
222
222
|
)
|
|
223
223
|
|
|
224
224
|
var defaultBillingDetails: PaymentSheet.BillingDetails? = null
|
package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt
CHANGED
|
@@ -309,7 +309,7 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
309
309
|
phone = mapToCollectionMode(bundle.getString("phone")),
|
|
310
310
|
email = mapToCollectionMode(bundle.getString("email")),
|
|
311
311
|
address = mapToAddressCollectionMode(bundle.getString("address")),
|
|
312
|
-
attachDefaultsToPaymentMethod = bundle.getBoolean("attachDefaultsToPaymentMethod"),
|
|
312
|
+
attachDefaultsToPaymentMethod = bundle.getBoolean("attachDefaultsToPaymentMethod", false),
|
|
313
313
|
)
|
|
314
314
|
|
|
315
315
|
internal fun createCustomerAdapter(
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt
CHANGED
|
@@ -64,7 +64,9 @@ class AddToWalletButtonManager(
|
|
|
64
64
|
view: AddToWalletButtonView,
|
|
65
65
|
ephemeralKey: Dynamic,
|
|
66
66
|
) {
|
|
67
|
-
|
|
67
|
+
val map = ephemeralKey.asMap()
|
|
68
|
+
if (map == null) return
|
|
69
|
+
view.setEphemeralKey(map)
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
@ReactProp(name = "token")
|
|
@@ -72,7 +74,9 @@ class AddToWalletButtonManager(
|
|
|
72
74
|
view: AddToWalletButtonView,
|
|
73
75
|
token: Dynamic,
|
|
74
76
|
) {
|
|
75
|
-
|
|
77
|
+
val map = token.asMap()
|
|
78
|
+
if (map == null) return
|
|
79
|
+
view.setToken(map)
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
@ReactProp(name = "iOSButtonStyle")
|
|
@@ -10,7 +10,7 @@ internal class PaymentSheetAppearance {
|
|
|
10
10
|
class func buildAppearanceFromParams(userParams: NSDictionary?) throws -> PaymentSheet.Appearance {
|
|
11
11
|
var appearance = PaymentSheet.Appearance()
|
|
12
12
|
guard let userParams = userParams else { return appearance }
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
if let fontParams = userParams[PaymentSheetAppearanceKeys.FONT] as? NSDictionary {
|
|
15
15
|
appearance.font = try buildFont(params: fontParams)
|
|
16
16
|
}
|
|
@@ -27,19 +27,19 @@ internal class PaymentSheetAppearance {
|
|
|
27
27
|
if let primaryButtonParams = userParams[PaymentSheetAppearanceKeys.PRIMARY_BUTTON] as? NSDictionary {
|
|
28
28
|
appearance.primaryButton = try buildPrimaryButton(params: primaryButtonParams)
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
|
|
31
|
+
|
|
32
32
|
if let embeddedPaymentElementParams = userParams[PaymentSheetAppearanceKeys.EMBEDDED_PAYMENT_ELEMENT] as? NSDictionary {
|
|
33
33
|
appearance.embeddedPaymentElement = try buildEmbeddedPaymentElementAppearance(params: embeddedPaymentElementParams)
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
if let formInsetParams = userParams[PaymentSheetAppearanceKeys.FORM_INSETS] as? NSDictionary {
|
|
37
37
|
appearance.formInsets = try buildFormInsets(params: formInsetParams)
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
return appearance
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
private class func buildFont(params: NSDictionary) throws -> PaymentSheet.Appearance.Font {
|
|
44
44
|
var font = PaymentSheet.Appearance.Font()
|
|
45
45
|
if let fontName = params[PaymentSheetAppearanceKeys.FAMILY] as? String {
|
|
@@ -54,15 +54,15 @@ internal class PaymentSheetAppearance {
|
|
|
54
54
|
|
|
55
55
|
private class func buildColors(params: NSDictionary) throws -> PaymentSheet.Appearance.Colors {
|
|
56
56
|
var colors = PaymentSheet.Appearance.Colors()
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
if (params.object(forKey: PaymentSheetAppearanceKeys.LIGHT) != nil && params.object(forKey: PaymentSheetAppearanceKeys.DARK) == nil ||
|
|
59
59
|
params.object(forKey: PaymentSheetAppearanceKeys.DARK) != nil && params.object(forKey: PaymentSheetAppearanceKeys.LIGHT) == nil) {
|
|
60
60
|
throw PaymentSheetAppearanceError.missingAppearanceMode
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
let lightModeParams = params[PaymentSheetAppearanceKeys.LIGHT] as? NSDictionary ?? params
|
|
64
64
|
let darkModeParams = params[PaymentSheetAppearanceKeys.DARK] as? NSDictionary ?? params
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
colors.primary = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.PRIMARY, lightParams: lightModeParams, darkParams: darkModeParams) ?? PaymentSheet.Appearance.default.colors.primary
|
|
67
67
|
colors.background = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.BACKGROUND, lightParams: lightModeParams, darkParams: darkModeParams) ?? PaymentSheet.Appearance.default.colors.background
|
|
68
68
|
colors.componentBackground = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.COMPONENT_BACKGROUND, lightParams: lightModeParams, darkParams: darkModeParams) ?? PaymentSheet.Appearance.default.colors.componentBackground
|
|
@@ -74,13 +74,13 @@ internal class PaymentSheetAppearance {
|
|
|
74
74
|
colors.componentPlaceholderText = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.PLACEHOLDER_TEXT, lightParams: lightModeParams, darkParams: darkModeParams) ?? PaymentSheet.Appearance.default.colors.componentPlaceholderText
|
|
75
75
|
colors.icon = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.ICON, lightParams: lightModeParams, darkParams: darkModeParams) ?? PaymentSheet.Appearance.default.colors.icon
|
|
76
76
|
colors.danger = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.ERROR, lightParams: lightModeParams, darkParams: darkModeParams) ?? PaymentSheet.Appearance.default.colors.danger
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
return colors
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
private class func buildShadow(params: NSDictionary) throws -> PaymentSheet.Appearance.Shadow {
|
|
82
82
|
var shadow = PaymentSheet.Appearance.Shadow()
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
if let color = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.SHADOW_COLOR, lightParams: params, darkParams: params) {
|
|
85
85
|
shadow.color = color
|
|
86
86
|
}
|
|
@@ -98,10 +98,10 @@ internal class PaymentSheetAppearance {
|
|
|
98
98
|
|
|
99
99
|
return shadow
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
private class func buildPrimaryButton(params: NSDictionary) throws -> PaymentSheet.Appearance.PrimaryButton {
|
|
103
103
|
var primaryButton = PaymentSheet.Appearance.PrimaryButton()
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
if let fontName = (params[PaymentSheetAppearanceKeys.FONT] as? NSDictionary)?[PaymentSheetAppearanceKeys.FAMILY] as? String {
|
|
106
106
|
guard let customFont = UIFont(name: fontName, size: UIFont.systemFontSize) else {
|
|
107
107
|
throw PaymentSheetAppearanceError.missingFont(fontName)
|
|
@@ -127,23 +127,23 @@ internal class PaymentSheetAppearance {
|
|
|
127
127
|
colorParams.object(forKey: PaymentSheetAppearanceKeys.DARK) != nil && colorParams.object(forKey: PaymentSheetAppearanceKeys.LIGHT) == nil) {
|
|
128
128
|
throw PaymentSheetAppearanceError.missingAppearanceMode
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
let lightModeParams = colorParams[PaymentSheetAppearanceKeys.LIGHT] as? NSDictionary ?? colorParams
|
|
132
132
|
let darkModeParams = colorParams[PaymentSheetAppearanceKeys.DARK] as? NSDictionary ?? colorParams
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
primaryButton.backgroundColor = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.BACKGROUND, lightParams: lightModeParams, darkParams: darkModeParams)
|
|
135
135
|
primaryButton.textColor = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.TEXT, lightParams: lightModeParams, darkParams: darkModeParams)
|
|
136
136
|
primaryButton.borderColor = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.BORDER, lightParams: lightModeParams, darkParams: darkModeParams) ?? PaymentSheet.Appearance.default.primaryButton.borderColor
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
return primaryButton
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
|
|
142
142
|
private class func buildUserInterfaceStyleAwareColor(key: String, lightParams: NSDictionary, darkParams: NSDictionary) throws -> UIColor? {
|
|
143
143
|
guard let lightHexString = lightParams[key] as? String, let darkHexString = darkParams[key] as? String else {
|
|
144
144
|
return nil
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
let darkCount = darkHexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted).count
|
|
148
148
|
let lightCount = lightHexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted).count
|
|
149
149
|
if (lightCount != 6 && lightCount != 8) {
|
|
@@ -151,10 +151,10 @@ internal class PaymentSheetAppearance {
|
|
|
151
151
|
} else if (darkCount != 6 && darkCount != 8) {
|
|
152
152
|
throw PaymentSheetAppearanceError.unexpectedHexStringLength(darkHexString)
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
|
|
155
155
|
let lightColor = UIColor(hexString: lightHexString)
|
|
156
156
|
let darkColor = UIColor(hexString: darkHexString)
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
if #available(iOS 13.0, *) {
|
|
159
159
|
return UIColor.init { traits in
|
|
160
160
|
return traits.userInterfaceStyle == .dark ? darkColor : lightColor
|
|
@@ -163,7 +163,7 @@ internal class PaymentSheetAppearance {
|
|
|
163
163
|
return lightColor
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
private class func buildEmbeddedPaymentElementAppearance(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement {
|
|
168
168
|
var embeddedAppearance = PaymentSheet.Appearance.EmbeddedPaymentElement()
|
|
169
169
|
|
|
@@ -209,17 +209,16 @@ internal class PaymentSheetAppearance {
|
|
|
209
209
|
|
|
210
210
|
private class func buildEmbeddedFlat(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat {
|
|
211
211
|
var flat = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat
|
|
212
|
-
|
|
212
|
+
|
|
213
213
|
if let thickness = params[PaymentSheetAppearanceKeys.SEPARATOR_THICKNESS] as? CGFloat {
|
|
214
214
|
flat.separatorThickness = thickness
|
|
215
215
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
216
|
+
|
|
217
|
+
flat.separatorColor = parseThemedColor(
|
|
218
|
+
params: params,
|
|
219
|
+
key: PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
220
|
+
default: PaymentSheet.Appearance.default.colors.componentBorder
|
|
221
|
+
)
|
|
223
222
|
|
|
224
223
|
if let insetsParams = params[PaymentSheetAppearanceKeys.SEPARATOR_INSETS] as? NSDictionary {
|
|
225
224
|
flat.separatorInsets = try buildEdgeInsets(params: insetsParams)
|
|
@@ -251,21 +250,19 @@ internal class PaymentSheetAppearance {
|
|
|
251
250
|
private class func buildEmbeddedRadio(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Radio {
|
|
252
251
|
var radio = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat.radio
|
|
253
252
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
253
|
+
// Selected‐state color
|
|
254
|
+
radio.selectedColor = parseThemedColor(
|
|
255
|
+
params: params,
|
|
256
|
+
key: PaymentSheetAppearanceKeys.SELECTED_COLOR,
|
|
257
|
+
default: PaymentSheet.Appearance.default.colors.primary
|
|
258
|
+
)
|
|
259
|
+
|
|
262
260
|
// Unselected‐state color
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
261
|
+
radio.unselectedColor = parseThemedColor(
|
|
262
|
+
params: params,
|
|
263
|
+
key: PaymentSheetAppearanceKeys.UNSELECTED_COLOR,
|
|
264
|
+
default: PaymentSheet.Appearance.default.colors.componentBorder
|
|
265
|
+
)
|
|
269
266
|
|
|
270
267
|
return radio
|
|
271
268
|
}
|
|
@@ -273,12 +270,11 @@ internal class PaymentSheetAppearance {
|
|
|
273
270
|
private class func buildEmbeddedCheckmark(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Checkmark {
|
|
274
271
|
var checkmark = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat.checkmark
|
|
275
272
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
273
|
+
checkmark.color = parseThemedColor(
|
|
274
|
+
params: params,
|
|
275
|
+
key: PaymentSheetAppearanceKeys.COLOR,
|
|
276
|
+
default: PaymentSheet.Appearance.default.colors.primary
|
|
277
|
+
)
|
|
282
278
|
|
|
283
279
|
return checkmark
|
|
284
280
|
}
|
|
@@ -286,12 +282,11 @@ internal class PaymentSheetAppearance {
|
|
|
286
282
|
private class func buildEmbeddedChevron(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Chevron {
|
|
287
283
|
var chevron = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat.chevron
|
|
288
284
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
285
|
+
chevron.color = parseThemedColor(
|
|
286
|
+
params: params,
|
|
287
|
+
key: PaymentSheetAppearanceKeys.COLOR,
|
|
288
|
+
default: UIColor.systemGray // Default iOS system gray color
|
|
289
|
+
)
|
|
295
290
|
|
|
296
291
|
return chevron
|
|
297
292
|
}
|
|
@@ -311,7 +306,7 @@ internal class PaymentSheetAppearance {
|
|
|
311
306
|
let left = params[PaymentSheetAppearanceKeys.LEFT] as? CGFloat ?? 0
|
|
312
307
|
let bottom = params[PaymentSheetAppearanceKeys.BOTTOM] as? CGFloat ?? 0
|
|
313
308
|
let right = params[PaymentSheetAppearanceKeys.RIGHT] as? CGFloat ?? 0
|
|
314
|
-
|
|
309
|
+
|
|
315
310
|
return UIEdgeInsets(
|
|
316
311
|
top: top,
|
|
317
312
|
left: left,
|
|
@@ -319,7 +314,7 @@ internal class PaymentSheetAppearance {
|
|
|
319
314
|
right: right
|
|
320
315
|
)
|
|
321
316
|
}
|
|
322
|
-
|
|
317
|
+
|
|
323
318
|
private class func dynamicColor(
|
|
324
319
|
from hexDict: [String: String],
|
|
325
320
|
default defaultColor: UIColor
|
|
@@ -340,13 +335,32 @@ internal class PaymentSheetAppearance {
|
|
|
340
335
|
return defaultColor
|
|
341
336
|
})
|
|
342
337
|
}
|
|
343
|
-
|
|
338
|
+
|
|
339
|
+
private class func parseThemedColor(
|
|
340
|
+
params: NSDictionary,
|
|
341
|
+
key: String,
|
|
342
|
+
default defaultColor: UIColor
|
|
343
|
+
) -> UIColor {
|
|
344
|
+
// Check if it's a dictionary with light/dark keys
|
|
345
|
+
if let colorDict = params[key] as? [String: String] {
|
|
346
|
+
return dynamicColor(from: colorDict, default: defaultColor)
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Check if it's a plain string
|
|
350
|
+
if let colorString = params[key] as? String {
|
|
351
|
+
return UIColor(hexString: colorString)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Fall back to default if no color provided
|
|
355
|
+
return defaultColor
|
|
356
|
+
}
|
|
357
|
+
|
|
344
358
|
private class func buildFormInsets(params: NSDictionary) throws -> NSDirectionalEdgeInsets {
|
|
345
359
|
let top = params[PaymentSheetAppearanceKeys.TOP] as? CGFloat ?? PaymentSheet.Appearance.default.formInsets.top
|
|
346
360
|
let leading = params[PaymentSheetAppearanceKeys.LEFT] as? CGFloat ?? PaymentSheet.Appearance.default.formInsets.leading
|
|
347
361
|
let bottom = params[PaymentSheetAppearanceKeys.BOTTOM] as? CGFloat ?? PaymentSheet.Appearance.default.formInsets.bottom
|
|
348
362
|
let trailing = params[PaymentSheetAppearanceKeys.RIGHT] as? CGFloat ?? PaymentSheet.Appearance.default.formInsets.trailing
|
|
349
|
-
|
|
363
|
+
|
|
350
364
|
return NSDirectionalEdgeInsets(
|
|
351
365
|
top: top,
|
|
352
366
|
leading: leading,
|
|
@@ -362,7 +376,7 @@ enum PaymentSheetAppearanceError : Error {
|
|
|
362
376
|
case unexpectedHexStringLength(String)
|
|
363
377
|
case invalidRowStyle(String)
|
|
364
378
|
}
|
|
365
|
-
|
|
379
|
+
|
|
366
380
|
extension PaymentSheetAppearanceError: LocalizedError {
|
|
367
381
|
public var errorDescription: String? {
|
|
368
382
|
switch self {
|
|
@@ -393,11 +407,11 @@ private struct PaymentSheetAppearanceKeys {
|
|
|
393
407
|
static let PLACEHOLDER_TEXT = "placeholderText"
|
|
394
408
|
static let ICON = "icon"
|
|
395
409
|
static let ERROR = "error"
|
|
396
|
-
|
|
410
|
+
|
|
397
411
|
static let FONT = "font"
|
|
398
412
|
static let FAMILY = "family"
|
|
399
413
|
static let SCALE = "scale"
|
|
400
|
-
|
|
414
|
+
|
|
401
415
|
static let SHAPES = "shapes"
|
|
402
416
|
static let BORDER_RADIUS = "borderRadius"
|
|
403
417
|
static let BORDER_WIDTH = "borderWidth"
|
|
@@ -410,11 +424,11 @@ private struct PaymentSheetAppearanceKeys {
|
|
|
410
424
|
static let BLUR_RADIUS = "blurRadius"
|
|
411
425
|
static let X = "x"
|
|
412
426
|
static let Y = "y"
|
|
413
|
-
|
|
427
|
+
|
|
414
428
|
static let PRIMARY_BUTTON = "primaryButton"
|
|
415
429
|
static let TEXT = "text"
|
|
416
430
|
static let BORDER = "border"
|
|
417
|
-
|
|
431
|
+
|
|
418
432
|
static let EMBEDDED_PAYMENT_ELEMENT = "embeddedPaymentElement"
|
|
419
433
|
static let ROW = "row"
|
|
420
434
|
static let STYLE = "style"
|
|
@@ -437,12 +451,12 @@ private struct PaymentSheetAppearanceKeys {
|
|
|
437
451
|
static let BOTTOM = "bottom"
|
|
438
452
|
static let RIGHT = "right"
|
|
439
453
|
static let COLOR = "color"
|
|
440
|
-
|
|
454
|
+
|
|
441
455
|
// Row Style Enum Values (match TS string enum values)
|
|
442
456
|
static let ROW_STYLE_FLAT_WITH_RADIO = "flatWithRadio"
|
|
443
457
|
static let ROW_STYLE_FLOATING_BUTTON = "floatingButton"
|
|
444
458
|
static let ROW_STYLE_FLAT_WITH_CHECKMARK = "flatWithCheckmark"
|
|
445
459
|
static let ROW_STYLE_FLAT_WITH_CHEVRON = "flatWithChevron"
|
|
446
|
-
|
|
460
|
+
|
|
447
461
|
static let FORM_INSETS = "formInsetValues"
|
|
448
462
|
}
|