diff --git a/packages/stripe_android/android/build.gradle b/packages/stripe_android/android/build.gradle index 625babc3c..1daa0a496 100644 --- a/packages/stripe_android/android/build.gradle +++ b/packages/stripe_android/android/build.gradle @@ -3,7 +3,7 @@ version '1.0-SNAPSHOT' buildscript { ext.kotlin_version = '1.8.0' - ext.stripe_version = '21.19.+' + ext.stripe_version = '21.26.+' repositories { google() diff --git a/packages/stripe_android/android/src/main/kotlin/com/facebook/react/bridge/WritableNativeMap.java b/packages/stripe_android/android/src/main/kotlin/com/facebook/react/bridge/WritableNativeMap.java index 224f635fb..0de87c7d8 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/facebook/react/bridge/WritableNativeMap.java +++ b/packages/stripe_android/android/src/main/kotlin/com/facebook/react/bridge/WritableNativeMap.java @@ -21,4 +21,13 @@ public WritableNativeMap(Map map) { public WritableNativeMap() { super(new HashMap<>()); } + + public void merge(ReadableMap source) { + if (source == null) { + return; + } + for (String key : source.keySet()) { + put(key, source.get(key)); + } + } } diff --git a/packages/stripe_android/android/src/main/kotlin/com/facebook/react/modules/core/DeviceEventManagerModule.java b/packages/stripe_android/android/src/main/kotlin/com/facebook/react/modules/core/DeviceEventManagerModule.java index 71d900081..4d7c8ac92 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/facebook/react/modules/core/DeviceEventManagerModule.java +++ b/packages/stripe_android/android/src/main/kotlin/com/facebook/react/modules/core/DeviceEventManagerModule.java @@ -18,7 +18,7 @@ public RCTDeviceEventEmitter(MethodChannel channel) { this.channel = channel; } - public void emit(String eventName, ReadableMap params) { + public void emit(String eventName, Object params) { uiThreadHandler.post(() -> channel.invokeMethod(eventName, params)); } } diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt index b09c46c25..c41e78e42 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt @@ -35,7 +35,7 @@ class CollectBankAccountLauncherFragment : StripeFragment() { if (stripeSdkModule != null) { FinancialConnections.setEventListener { event -> val params = mapFromFinancialConnectionsEvent(event) - stripeSdkModule.emitOnFinancialConnectionsEvent(params) + stripeSdkModule.eventEmitter.emitOnFinancialConnectionsEvent(params) } } diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/EventEmitterCompat.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/EventEmitterCompat.kt new file mode 100644 index 000000000..54e05dd9f --- /dev/null +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/EventEmitterCompat.kt @@ -0,0 +1,86 @@ +// This is a temporary compat layer for event emitters on new arch. +// Versions before RN 0.80 crash sometimes when setting the event emitter callback. +// Remove this layer once we drop support for RN < 0.80. +package com.reactnativestripesdk + +import com.facebook.react.bridge.ReactApplicationContext +import com.facebook.react.bridge.ReadableMap +import com.facebook.react.modules.core.DeviceEventManagerModule + +class EventEmitterCompat( + private val reactApplicationContext: ReactApplicationContext, +) { + private fun invoke( + eventName: String, + params: ReadableMap? = null, + ) { + reactApplicationContext + .getJSModule( + DeviceEventManagerModule.RCTDeviceEventEmitter::class.java, + ).emit(eventName, params) + } + + fun emitOnConfirmHandlerCallback(value: ReadableMap?) { + invoke("onConfirmHandlerCallback", value) + } + + fun emitOnFinancialConnectionsEvent(value: ReadableMap?) { + invoke("onFinancialConnectionsEvent", value) + } + + fun emitOnOrderTrackingCallback() { + invoke("onOrderTrackingCallback") + } + + fun emitOnCustomerAdapterFetchPaymentMethodsCallback() { + invoke("onCustomerAdapterFetchPaymentMethodsCallback") + } + + fun emitOnCustomerAdapterAttachPaymentMethodCallback(value: ReadableMap?) { + invoke("onCustomerAdapterAttachPaymentMethodCallback", value) + } + + fun emitOnCustomerAdapterDetachPaymentMethodCallback(value: ReadableMap?) { + invoke("onCustomerAdapterDetachPaymentMethodCallback", value) + } + + fun emitOnCustomerAdapterSetSelectedPaymentOptionCallback(value: ReadableMap?) { + invoke("onCustomerAdapterSetSelectedPaymentOptionCallback", value) + } + + fun emitOnCustomerAdapterFetchSelectedPaymentOptionCallback() { + invoke("onCustomerAdapterFetchSelectedPaymentOptionCallback") + } + + fun emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback() { + invoke("onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback") + } + + fun emitEmbeddedPaymentElementDidUpdateHeight(value: ReadableMap?) { + invoke("embeddedPaymentElementDidUpdateHeight", value) + } + + fun emitEmbeddedPaymentElementWillPresent() { + invoke("embeddedPaymentElementWillPresent") + } + + fun emitEmbeddedPaymentElementDidUpdatePaymentOption(value: ReadableMap?) { + invoke("embeddedPaymentElementDidUpdatePaymentOption", value) + } + + fun emitEmbeddedPaymentElementFormSheetConfirmComplete(value: ReadableMap?) { + invoke("embeddedPaymentElementFormSheetConfirmComplete", value) + } + + fun emitEmbeddedPaymentElementRowSelectionImmediateAction() { + invoke("embeddedPaymentElementRowSelectionImmediateAction") + } + + fun emitEmbeddedPaymentElementLoadingFailed(value: ReadableMap?) { + invoke("embeddedPaymentElementLoadingFailed", value) + } + + fun emitOnCustomPaymentMethodConfirmHandlerCallback(value: ReadableMap?) { + invoke("onCustomPaymentMethodConfirmHandlerCallback", value) + } +} diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt index af058a8ea..516d4d0a4 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt @@ -39,7 +39,7 @@ class FinancialConnectionsSheetFragment : StripeFragment() { val stripeSdkModule: StripeSdkModule? = context.getNativeModule(StripeSdkModule::class.java) FinancialConnections.setEventListener { event -> val params = mapFromFinancialConnectionsEvent(event) - stripeSdkModule?.emitOnFinancialConnectionsEvent(params) + stripeSdkModule?.eventEmitter?.emitOnFinancialConnectionsEvent(params) } when (mode) { diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java index 7751a38cf..8e8e22ca7 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java @@ -45,7 +45,7 @@ public NativeStripeSdkModuleSpec(ReactApplicationContext reactContext) { return NAME; } - private void invoke(String eventName, ReadableMap params) { + private void invoke(String eventName, Object params) { getReactApplicationContext() .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, params); @@ -316,4 +316,16 @@ protected final void emitOnCustomPaymentMethodConfirmHandlerCallback(ReadableMap @ReactMethod @DoNotStrip public abstract void clearEmbeddedPaymentOption(double viewTag, Promise promise); + + @ReactMethod + @DoNotStrip + public abstract void setFinancialConnectionsForceNativeFlow(boolean enabled, Promise promise); + + @ReactMethod + @DoNotStrip + public abstract void addListener(String eventType); + + @ReactMethod + @DoNotStrip + public abstract void removeListeners(double count); } diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentLauncherFragment.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentLauncherFragment.kt index f9a500763..d51965da2 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentLauncherFragment.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentLauncherFragment.kt @@ -383,6 +383,7 @@ class PaymentLauncherFragment : StripeFragment() { StripeIntent.NextActionType.DisplayKonbiniDetails, StripeIntent.NextActionType.VerifyWithMicrodeposits, StripeIntent.NextActionType.DisplayMultibancoDetails, + StripeIntent.NextActionType.DisplayPayNowDetails, -> true StripeIntent.NextActionType.RedirectToUrl, StripeIntent.NextActionType.UseStripeSdk, diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt index 54a80b847..e4681c97e 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt @@ -39,6 +39,7 @@ class PaymentMethodCreateParamsFactory( PaymentMethod.Type.Ideal -> createIDEALParams() PaymentMethod.Type.Alipay -> createAlipayParams() PaymentMethod.Type.Bancontact -> createBancontactParams() + PaymentMethod.Type.Billie -> createBillieParams() PaymentMethod.Type.SepaDebit -> createSepaParams() PaymentMethod.Type.Oxxo -> createOXXOParams() PaymentMethod.Type.Giropay -> createGiropayParams() @@ -90,6 +91,13 @@ class PaymentMethodCreateParamsFactory( throw PaymentMethodCreateParamsException("You must provide billing details") } + @Throws(PaymentMethodCreateParamsException::class) + private fun createBillieParams(): PaymentMethodCreateParams = + PaymentMethodCreateParams.createBillie( + billingDetails = billingDetailsParams, + metadata = metadataParams, + ) + @Throws(PaymentMethodCreateParamsException::class) private fun createSepaParams(): PaymentMethodCreateParams { billingDetailsParams?.let { @@ -200,21 +208,11 @@ class PaymentMethodCreateParamsFactory( } @Throws(PaymentMethodCreateParamsException::class) - private fun createKlarnaParams(): PaymentMethodCreateParams { - if (billingDetailsParams == null || - billingDetailsParams.address?.country.isNullOrBlank() || - billingDetailsParams.email.isNullOrBlank() - ) { - throw PaymentMethodCreateParamsException( - "Klarna requires that you provide the following billing details: email, country", - ) - } - - return PaymentMethodCreateParams.createKlarna( + private fun createKlarnaParams(): PaymentMethodCreateParams = + PaymentMethodCreateParams.createKlarna( billingDetails = billingDetailsParams, metadata = metadataParams, ) - } @Throws(PaymentMethodCreateParamsException::class) private fun createPayPalParams(): PaymentMethodCreateParams = PaymentMethodCreateParams.createPayPal(metadata = metadataParams) @@ -256,6 +254,7 @@ class PaymentMethodCreateParamsFactory( PaymentMethod.Type.Ideal, PaymentMethod.Type.Alipay, PaymentMethod.Type.Bancontact, + PaymentMethod.Type.Billie, PaymentMethod.Type.SepaDebit, PaymentMethod.Type.Oxxo, PaymentMethod.Type.Giropay, diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt index 81c8e3919..e7e37c257 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt @@ -1,15 +1,219 @@ +package com.reactnativestripesdk + +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.LinkAnnotation +import androidx.compose.ui.text.SpanStyle +import androidx.compose.ui.text.font.FontStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextDecoration +import androidx.compose.ui.unit.TextUnit import com.facebook.react.bridge.Arguments import com.facebook.react.bridge.WritableMap +import com.reactnativestripesdk.getBase64FromBitmap +import com.reactnativestripesdk.getBitmapFromDrawable import com.reactnativestripesdk.utils.mapFromPaymentSheetBillingDetails import com.stripe.android.paymentelement.EmbeddedPaymentElement +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import kotlinx.coroutines.withTimeout /** * Serialize Stripe's PaymentOptionDisplayData into a WritableMap * that can be sent over the RN bridge. */ -fun EmbeddedPaymentElement.PaymentOptionDisplayData.toWritableMap(): WritableMap = +suspend fun EmbeddedPaymentElement.PaymentOptionDisplayData.toWritableMap(): WritableMap = Arguments.createMap().apply { putString("label", label) putString("paymentMethodType", paymentMethodType) putMap("billingDetails", mapFromPaymentSheetBillingDetails(billingDetails)) + + val mandateTextHTML = mandateText?.toHtmlString() + if (!mandateTextHTML.isNullOrEmpty()) { + putString("mandateHTML", mandateTextHTML) + } else { + putNull("mandateHTML") + } + + // Load image off the main thread with a timeout + val imageBase64 = + try { + withContext(Dispatchers.Default) { + val drawable = + withTimeout(5_000L) { + withContext(Dispatchers.IO) { + imageLoader() + } + } + getBitmapFromDrawable(drawable)?.let { bitmap -> + getBase64FromBitmap(bitmap) + } ?: "" + } + } catch (e: Exception) { + // If imageLoader fails or times out, return empty string + "" + } + putString("image", imageBase64) + } + +fun AnnotatedString.toHtmlString(): String { + val htmlBuilder = StringBuilder() + var currentIndex = 0 + + val allAnnotations = mutableListOf() + + spanStyles.forEach { range -> + allAnnotations.add( + AnnotationInfo( + start = range.start, + end = range.end, + type = AnnotationType.SPAN_STYLE, + data = range.item, + ), + ) + } + + getStringAnnotations(0, length).forEach { range -> + allAnnotations.add( + AnnotationInfo( + start = range.start, + end = range.end, + type = AnnotationType.STRING_ANNOTATION, + data = range, + ), + ) + } + + getLinkAnnotations(0, length).forEach { range -> + allAnnotations.add( + AnnotationInfo( + start = range.start, + end = range.end, + type = AnnotationType.LINK_ANNOTATION, + data = range, + ), + ) + } + + allAnnotations.sortWith(compareBy({ it.start }, { -it.end })) + + val openTags = mutableListOf() + + while (currentIndex < length) { + openTags + .filter { it.end == currentIndex } + .reversed() + .forEach { tagInfo -> + htmlBuilder.append(tagInfo.closeTag) + openTags.remove(tagInfo) + } + + allAnnotations.filter { it.start == currentIndex }.forEach { annotation -> + when (annotation.type) { + AnnotationType.SPAN_STYLE -> { + val spanStyle = annotation.data as SpanStyle + val tags = getHtmlTagsForSpanStyle(spanStyle) + tags.forEach { (openTag, closeTag) -> + htmlBuilder.append(openTag) + openTags.add(TagInfo(annotation.end, closeTag)) + } + } + AnnotationType.STRING_ANNOTATION -> { + val stringAnnotation = annotation.data as AnnotatedString.Range + when (stringAnnotation.tag) { + "URL", "LINK_TAG" -> { + val url = stringAnnotation.item + htmlBuilder.append("") + openTags.add(TagInfo(annotation.end, "")) + } + } + } + AnnotationType.LINK_ANNOTATION -> { + val linkAnnotation = annotation.data as AnnotatedString.Range + when (val linkItem = linkAnnotation.item) { + is LinkAnnotation.Url -> { + htmlBuilder.append("") + openTags.add(TagInfo(annotation.end, "")) + } + } + } + } + } + + htmlBuilder.append(escapeHtml(text[currentIndex].toString())) + currentIndex++ + } + + openTags.reversed().forEach { tagInfo -> + htmlBuilder.append(tagInfo.closeTag) } + + return htmlBuilder.toString() +} + +private fun getHtmlTagsForSpanStyle(spanStyle: SpanStyle): List> { + val tags = mutableListOf>() + + if (spanStyle.fontWeight == FontWeight.Bold || + (spanStyle.fontWeight?.weight ?: 0) >= FontWeight.Bold.weight + ) { + tags.add("" to "") + } + + if (spanStyle.fontStyle == FontStyle.Italic) { + tags.add("" to "") + } + + spanStyle.color.takeIf { it != Color.Unspecified }?.let { color -> + val hexColor = String.format("#%06X", 0xFFFFFF and color.toArgb()) + tags.add("" to "") + } + + spanStyle.fontSize.takeIf { it != TextUnit.Unspecified }?.let { fontSize -> + val emSize = fontSize.value / 16f + tags.add("" to "") + } + + spanStyle.textDecoration?.let { decoration -> + if (decoration.contains(TextDecoration.Underline)) { + tags.add("" to "") + } + if (decoration.contains(TextDecoration.LineThrough)) { + tags.add("" to "") + } + } + + spanStyle.background.takeIf { it != Color.Unspecified }?.let { bgColor -> + val hexBgColor = String.format("#%06X", 0xFFFFFF and bgColor.toArgb()) + tags.add("" to "") + } + + return tags +} + +private fun escapeHtml(text: String): String = + text + .replace("&", "&") + .replace("<", "<") + .replace(">", ">") + .replace("\"", """) + .replace("'", "'") + +private data class AnnotationInfo( + val start: Int, + val end: Int, + val type: AnnotationType, + val data: Any, +) + +private enum class AnnotationType { + SPAN_STYLE, + STRING_ANNOTATION, + LINK_ANNOTATION, +} + +private data class TagInfo( + val end: Int, + val closeTag: String, +) diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentSheetAppearance.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentSheetAppearance.kt index 593c01e66..f49f74d75 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentSheetAppearance.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentSheetAppearance.kt @@ -194,9 +194,9 @@ private fun buildPrimaryButton( return PaymentSheet.PrimaryButton( colorsLight = - buildPrimaryButtonColors(lightColorParams, PaymentSheet.PrimaryButtonColors.defaultLight), + buildPrimaryButtonColors(lightColorParams, PaymentSheet.PrimaryButtonColors.defaultLight, context), colorsDark = - buildPrimaryButtonColors(darkColorParams, PaymentSheet.PrimaryButtonColors.defaultDark), + buildPrimaryButtonColors(darkColorParams, PaymentSheet.PrimaryButtonColors.defaultDark, context), shape = PaymentSheet.PrimaryButtonShape( cornerRadiusDp = @@ -217,6 +217,7 @@ private fun buildPrimaryButton( private fun buildPrimaryButtonColors( colorParams: Bundle, default: PaymentSheet.PrimaryButtonColors, + context: Context, ): PaymentSheet.PrimaryButtonColors = PaymentSheet.PrimaryButtonColors( background = @@ -243,6 +244,20 @@ private fun buildPrimaryButtonColors( colorParams.getString(PaymentSheetAppearanceKeys.BORDER), default.border, ), + successBackgroundColor = + dynamicColorFromParams( + context, + colorParams, + PaymentSheetAppearanceKeys.SUCCESS_BACKGROUND, + default.successBackgroundColor, + ), + onSuccessBackgroundColor = + dynamicColorFromParams( + context, + colorParams, + PaymentSheetAppearanceKeys.SUCCESS_TEXT, + default.onSuccessBackgroundColor, + ), ) @SuppressLint("RestrictedApi") @@ -341,7 +356,7 @@ private fun buildEmbeddedAppearance( val checkmarkParams = getBundleOrNull(flatParams, PaymentSheetAppearanceKeys.CHECKMARK) val separatorInsetsParams = getBundleOrNull(flatParams, PaymentSheetAppearanceKeys.SEPARATOR_INSETS) - // Default separator insets specific to FlatWithCheckmark and FlatWithChevron + // Default separator insets specific to FlatWithCheckmark and FlatWithDisclosure val defaultSeparatorStartInsetDp = 0.0f val defaultSeparatorEndInsetDp = 0.0f @@ -392,12 +407,12 @@ private fun buildEmbeddedAppearance( colorsDark = flatCheckmarkColors, ) } - "flatWithChevron" -> { + "flatWithDisclosure" -> { val flatParams = getBundleOrNull(rowParams, PaymentSheetAppearanceKeys.FLAT) - val chevronParams = getBundleOrNull(flatParams, PaymentSheetAppearanceKeys.CHEVRON) + val disclosureParams = getBundleOrNull(flatParams, PaymentSheetAppearanceKeys.DISCLOSURE) val separatorInsetsParams = getBundleOrNull(flatParams, PaymentSheetAppearanceKeys.SEPARATOR_INSETS) - // Default separator insets specific to FlatWithCheckmark and FlatWithChevron + // Default separator insets specific to FlatWithCheckmark and FlatWithDisclosure val defaultSeparatorStartInsetDp = 0.0f val defaultSeparatorEndInsetDp = 0.0f @@ -418,32 +433,33 @@ private fun buildEmbeddedAppearance( Color.GRAY, ) - val parsedChevronColor = + val parsedDisclosureColor = dynamicColorFromParams( context, - chevronParams, + disclosureParams, PaymentSheetAppearanceKeys.COLOR, defaultColors.componentBorder, // Default to component border color like other elements ) // Create the required Colors object - val flatChevronColors = - PaymentSheet.Appearance.Embedded.RowStyle.FlatWithChevron.Colors( + val flatDisclosureColors = + PaymentSheet.Appearance.Embedded.RowStyle.FlatWithDisclosure.Colors( separatorColor = parsedSeparatorColor, - chevronColor = parsedChevronColor, + disclosureColor = parsedDisclosureColor, ) - PaymentSheet.Appearance.Embedded.RowStyle.FlatWithChevron( - separatorThicknessDp = separatorThickness, - startSeparatorInsetDp = startSeparatorInset, - endSeparatorInsetDp = endSeparatorInset, - topSeparatorEnabled = topEnabled, - bottomSeparatorEnabled = bottomEnabled, - additionalVerticalInsetsDp = additionalInsets, - horizontalInsetsDp = 0.0F, // We do not have an iOS equal for this API so it's not configurable in React Native - colorsLight = flatChevronColors, - colorsDark = flatChevronColors, - ) + PaymentSheet.Appearance.Embedded.RowStyle.FlatWithDisclosure + .Builder() + .separatorThicknessDp(separatorThickness) + .startSeparatorInsetDp(startSeparatorInset) + .endSeparatorInsetDp(endSeparatorInset) + .topSeparatorEnabled(topEnabled) + .bottomSeparatorEnabled(bottomEnabled) + .additionalVerticalInsetsDp(additionalInsets) + .horizontalInsetsDp(0.0F) // We do not have an iOS equal for this API so it's not configurable in React Native + .colorsLight(flatDisclosureColors) + .colorsDark(flatDisclosureColors) + .build() } "floatingButton" -> { val floatingParams = getBundleOrNull(rowParams, PaymentSheetAppearanceKeys.FLOATING) @@ -654,6 +670,8 @@ private class PaymentSheetAppearanceKeys { const val PRIMARY_BUTTON = "primaryButton" const val TEXT = "text" const val BORDER = "border" + const val SUCCESS_BACKGROUND = "successBackgroundColor" + const val SUCCESS_TEXT = "successTextColor" const val EMBEDDED_PAYMENT_ELEMENT = "embeddedPaymentElement" const val ROW = "row" @@ -670,7 +688,7 @@ private class PaymentSheetAppearanceKeys { const val SELECTED_COLOR = "selectedColor" const val UNSELECTED_COLOR = "unselectedColor" const val CHECKMARK = "checkmark" - const val CHEVRON = "chevron" + const val DISCLOSURE = "disclosure" const val COLOR = "color" const val CHECKMARK_INSET = "inset" diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentSheetFragment.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentSheetFragment.kt index 7b161b608..bf3976a0a 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentSheetFragment.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/PaymentSheetFragment.kt @@ -45,7 +45,7 @@ import com.stripe.android.paymentelement.PaymentMethodOptionsSetupFutureUsagePre import com.stripe.android.paymentsheet.CreateIntentCallback import com.stripe.android.paymentsheet.CreateIntentResult import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi -import com.stripe.android.paymentsheet.PaymentOptionCallback +import com.stripe.android.paymentsheet.PaymentOptionResultCallback import com.stripe.android.paymentsheet.PaymentSheet import com.stripe.android.paymentsheet.PaymentSheetResult import com.stripe.android.paymentsheet.PaymentSheetResultCallback @@ -124,15 +124,16 @@ class PaymentSheetFragment : } val paymentOptionCallback = - PaymentOptionCallback { paymentOption -> + PaymentOptionResultCallback { paymentOptionResult -> val result = - paymentOption?.let { + paymentOptionResult.paymentOption?.let { val bitmap = getBitmapFromVectorDrawable(context, it.drawableResourceId) val imageString = getBase64FromBitmap(bitmap) val option: WritableMap = WritableNativeMap() option.putString("label", it.label) option.putString("image", imageString) - createResult("paymentOption", option) + val additionalFields: Map = mapOf("didCancel" to paymentOptionResult.didCancel) + createResult("paymentOption", option, additionalFields) } ?: run { if (paymentSheetTimedOut) { @@ -193,7 +194,7 @@ class PaymentSheetFragment : putBoolean("shouldSavePaymentMethod", shouldSavePaymentMethod) } - stripeSdkModule?.emitOnConfirmHandlerCallback(params) + stripeSdkModule?.eventEmitter?.emitOnConfirmHandlerCallback(params) val resultFromJavascript = paymentSheetIntentCreationCallback.await() // reset the completable @@ -250,6 +251,7 @@ class PaymentSheetFragment : .googlePay(googlePayConfig) .appearance(appearance) .shippingDetails(shippingDetails) + .link(linkConfig) .billingDetailsCollectionConfiguration(billingDetailsConfig) .preferredNetworks( mapToPreferredNetworks(arguments?.getIntegerArrayList("preferredNetworks")), @@ -272,7 +274,7 @@ class PaymentSheetFragment : PaymentSheet.FlowController .Builder( resultCallback = paymentResultCallback, - paymentOptionCallback = paymentOptionCallback, + paymentOptionResultCallback = paymentOptionCallback, ).createIntentCallback(createIntentCallback) .confirmCustomPaymentMethodCallback(this) .build(this) @@ -280,7 +282,7 @@ class PaymentSheetFragment : PaymentSheet.FlowController .Builder( resultCallback = paymentResultCallback, - paymentOptionCallback = paymentOptionCallback, + paymentOptionResultCallback = paymentOptionCallback, ).confirmCustomPaymentMethodCallback(this) .build(this) } @@ -479,7 +481,7 @@ class PaymentSheetFragment : delay(100) // Emit event so JS can show the Alert and eventually respond via `customPaymentMethodResultCallback`. - stripeSdkModule.emitOnCustomPaymentMethodConfirmHandlerCallback( + stripeSdkModule.eventEmitter.emitOnCustomPaymentMethodConfirmHandlerCallback( mapFromCustomPaymentMethod(customPaymentMethod, billingDetails), ) @@ -550,7 +552,7 @@ class PaymentSheetFragment : ) internal fun buildGooglePayConfig(params: Bundle?): PaymentSheet.GooglePayConfiguration? { - if (params == null) { + if (params == null || params.isEmpty) { return null } @@ -617,14 +619,13 @@ class PaymentSheetFragment : } @OptIn(PaymentMethodOptionsSetupFutureUsagePreview::class) - private fun buildIntentConfigurationMode(modeParams: Bundle): PaymentSheet.IntentConfiguration.Mode { - val currencyCode = - modeParams.getString("currencyCode") - ?: throw PaymentSheetException( - "You must provide a value to intentConfiguration.mode.currencyCode", - ) - - return if (modeParams.containsKey("amount")) { + private fun buildIntentConfigurationMode(modeParams: Bundle): PaymentSheet.IntentConfiguration.Mode = + if (modeParams.containsKey("amount")) { + val currencyCode = + modeParams.getString("currencyCode") + ?: throw PaymentSheetException( + "You must provide a value to intentConfiguration.mode.currencyCode", + ) PaymentSheet.IntentConfiguration.Mode.Payment( amount = modeParams.getInt("amount").toLong(), currency = currencyCode, @@ -639,11 +640,10 @@ class PaymentSheetFragment : "You must provide a value to intentConfiguration.mode.setupFutureUsage", ) PaymentSheet.IntentConfiguration.Mode.Setup( - currency = currencyCode, + currency = modeParams.getString("currencyCode"), setupFutureUse = setupFutureUsage, ) } - } @OptIn(ExperimentalCustomerSessionApi::class) @Throws(PaymentSheetException::class) @@ -693,7 +693,7 @@ fun getBitmapFromDrawable(drawable: Drawable): Bitmap? { drawableCompat.intrinsicHeight, Bitmap.Config.ARGB_8888, ) - bitmap.eraseColor(Color.WHITE) + bitmap.eraseColor(Color.TRANSPARENT) val canvas = Canvas(bitmap) drawable.setBounds(0, 0, canvas.width, canvas.height) drawable.draw(canvas) diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/StripeSdkModule.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/StripeSdkModule.kt index e277e1998..2bae28a9f 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/StripeSdkModule.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/StripeSdkModule.kt @@ -98,6 +98,8 @@ class StripeSdkModule( internal var composeCompatView: StripeAbstractComposeView.CompatView? = null + val eventEmitter: EventEmitterCompat by lazy { EventEmitterCompat(reactApplicationContext) } + // If you create a new Fragment, you must put the tag here, otherwise result callbacks for that // Fragment will not work on RN < 0.65 private val allStripeFragmentTags: List @@ -1298,6 +1300,22 @@ class StripeSdkModule( // noop, iOS only } + @ReactMethod + override fun setFinancialConnectionsForceNativeFlow( + enabled: Boolean, + promise: Promise, + ) { + // noop, iOS only + } + + override fun addListener(eventType: String?) { + // noop, iOS only + } + + override fun removeListeners(count: Double) { + // noop, iOS only + } + override fun handleURLCallback( url: String, promise: Promise, diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt index d558381d2..6f68535dc 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt @@ -30,7 +30,7 @@ class ReactNativeCustomerAdapter( if (overridesFetchPaymentMethods) { CompletableDeferred>().also { fetchPaymentMethodsCallback = it - stripeSdkModule?.emitOnCustomerAdapterFetchPaymentMethodsCallback() + stripeSdkModule?.eventEmitter?.emitOnCustomerAdapterFetchPaymentMethodsCallback() val resultFromJavascript = it.await() return CustomerAdapter.Result.success(resultFromJavascript) } @@ -44,7 +44,7 @@ class ReactNativeCustomerAdapter( CompletableDeferred().also { attachPaymentMethodCallback = it val params = Arguments.createMap().also { it.putString("paymentMethodId", paymentMethodId) } - stripeSdkModule?.emitOnCustomerAdapterAttachPaymentMethodCallback(params) + stripeSdkModule?.eventEmitter?.emitOnCustomerAdapterAttachPaymentMethodCallback(params) val resultFromJavascript = it.await() return CustomerAdapter.Result.success(resultFromJavascript) } @@ -58,7 +58,7 @@ class ReactNativeCustomerAdapter( CompletableDeferred().also { detachPaymentMethodCallback = it val params = Arguments.createMap().also { it.putString("paymentMethodId", paymentMethodId) } - stripeSdkModule?.emitOnCustomerAdapterDetachPaymentMethodCallback(params) + stripeSdkModule?.eventEmitter?.emitOnCustomerAdapterDetachPaymentMethodCallback(params) val resultFromJavascript = it.await() return CustomerAdapter.Result.success(resultFromJavascript) } @@ -72,7 +72,7 @@ class ReactNativeCustomerAdapter( CompletableDeferred().also { setSelectedPaymentOptionCallback = it val params = Arguments.createMap().also { it.putString("paymentOption", paymentOption?.id) } - stripeSdkModule?.emitOnCustomerAdapterSetSelectedPaymentOptionCallback(params) + stripeSdkModule?.eventEmitter?.emitOnCustomerAdapterSetSelectedPaymentOptionCallback(params) val resultFromJavascript = it.await() return CustomerAdapter.Result.success(resultFromJavascript) } @@ -85,7 +85,7 @@ class ReactNativeCustomerAdapter( if (overridesFetchSelectedPaymentOption) { CompletableDeferred().also { fetchSelectedPaymentOptionCallback = it - stripeSdkModule?.emitOnCustomerAdapterFetchSelectedPaymentOptionCallback() + stripeSdkModule?.eventEmitter?.emitOnCustomerAdapterFetchSelectedPaymentOptionCallback() val resultFromJavascript = it.await() return CustomerAdapter.Result.success( if (resultFromJavascript != null) { @@ -104,7 +104,7 @@ class ReactNativeCustomerAdapter( if (overridesSetupIntentClientSecretForCustomerAttach) { CompletableDeferred().also { setupIntentClientSecretForCustomerAttachCallback = it - stripeSdkModule?.emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback() + stripeSdkModule?.eventEmitter?.emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback() val resultFromJavascript = it.await() return CustomerAdapter.Result.success(resultFromJavascript) } diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt index b7c1a4de6..e7544ea58 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt @@ -1,5 +1,6 @@ package com.reactnativestripesdk.utils +import android.util.Log import com.facebook.react.bridge.Arguments import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.UiThreadUtil @@ -33,7 +34,14 @@ internal class KeepJsAwakeTask( fun stop() { val taskId = taskId ?: return val headlessJsTaskContext = HeadlessJsTaskContext.getInstance(context) - headlessJsTaskContext.finishTask(taskId) - this.taskId = null + + try { + headlessJsTaskContext.finishTask(taskId) + } catch (e: AssertionError) { + // Ignore if task already finished + Log.w("KeepJsAwakeTask", "Tried to stop a non-existent task (id=$taskId)") + } finally { + this.taskId = null + } } } diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/utils/Mappers.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/utils/Mappers.kt index ccf809d5e..f7b2001d5 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/utils/Mappers.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/utils/Mappers.kt @@ -33,9 +33,11 @@ import com.stripe.android.paymentsheet.PaymentSheet internal fun createResult( key: String, value: WritableMap, + additionalFields: Map? = null, ): WritableMap { val map = WritableNativeMap() map.putMap(key, value) + additionalFields?.let { map.merge(it.toReadableMap()) } return map } @@ -129,6 +131,7 @@ internal fun mapPaymentMethodType(type: PaymentMethod.Type?): String = PaymentMethod.Type.AuBecsDebit -> "AuBecsDebit" PaymentMethod.Type.BacsDebit -> "BacsDebit" PaymentMethod.Type.Bancontact -> "Bancontact" + PaymentMethod.Type.Billie -> "Billie" PaymentMethod.Type.Card -> "Card" PaymentMethod.Type.CardPresent -> "CardPresent" PaymentMethod.Type.Eps -> "Eps" @@ -159,6 +162,7 @@ internal fun mapToPaymentMethodType(type: String?): PaymentMethod.Type? = "AuBecsDebit" -> PaymentMethod.Type.AuBecsDebit "BacsDebit" -> PaymentMethod.Type.BacsDebit "Bancontact" -> PaymentMethod.Type.Bancontact + "Billie" -> PaymentMethod.Type.Billie "AfterpayClearpay" -> PaymentMethod.Type.AfterpayClearpay "CardPresent" -> PaymentMethod.Type.CardPresent "Eps" -> PaymentMethod.Type.Eps @@ -554,6 +558,7 @@ internal fun mapNextAction( NextActionType.BlikAuthorize, NextActionType.UseStripeSdk, NextActionType.UpiAwaitNotification, + NextActionType.DisplayPayNowDetails, null, -> { return null diff --git a/packages/stripe_ios/ios/stripe_ios.podspec b/packages/stripe_ios/ios/stripe_ios.podspec index ad65850c8..9a2782e50 100644 --- a/packages/stripe_ios/ios/stripe_ios.podspec +++ b/packages/stripe_ios/ios/stripe_ios.podspec @@ -2,7 +2,7 @@ # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. # Run `pod lib lint stripe_ios.podspec' to validate before publishing. # -stripe_version = '~> 24.16.1' +stripe_version = '~> 24.23.0' Pod::Spec.new do |s| s.name = 'stripe_ios' s.version = '0.0.1' diff --git a/packages/stripe_ios/ios/stripe_ios/Package.swift b/packages/stripe_ios/ios/stripe_ios/Package.swift index 8aefa36c1..30f98bc74 100644 --- a/packages/stripe_ios/ios/stripe_ios/Package.swift +++ b/packages/stripe_ios/ios/stripe_ios/Package.swift @@ -12,7 +12,7 @@ let package = Package( .library(name: "stripe-ios", targets: ["stripe_ios"]) ], dependencies: [ - .package(url: "https://github.com/stripe/stripe-ios-spm", exact: "24.16.1") + .package(url: "https://github.com/stripe/stripe-ios-spm", exact: "24.23.0") ], targets: [ .target( diff --git a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/Mappers.swift b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/Mappers.swift index b57957441..e960d6e7a 100644 --- a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/Mappers.swift +++ b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/Mappers.swift @@ -3,8 +3,11 @@ import PassKit import StripePaymentSheet class Mappers { - class func createResult(_ key: String, _ value: NSDictionary?) -> NSDictionary { - return [key: value ?? NSNull()] + class func createResult(_ key: String, _ value: NSDictionary?, additionalFields: [String: Any]? = nil) -> NSDictionary { + let result = NSMutableDictionary() + result[key] = value ?? NSNull() + additionalFields?.forEach { (a, b) in result[a] = b } + return result } class func mapToPKContactField(field: String) -> PKContactField { @@ -285,6 +288,7 @@ class Mappers { case STPPaymentMethodType.przelewy24: return "P24" case STPPaymentMethodType.EPS: return "Eps" case STPPaymentMethodType.bancontact: return "Bancontact" + case STPPaymentMethodType.billie: return "Billie" case STPPaymentMethodType.OXXO: return "Oxxo" case STPPaymentMethodType.UPI: return "Upi" case STPPaymentMethodType.afterpayClearpay: return "AfterpayClearpay" @@ -315,6 +319,7 @@ class Mappers { case "P24": return STPPaymentMethodType.przelewy24 case "Eps": return STPPaymentMethodType.EPS case "Bancontact": return STPPaymentMethodType.bancontact + case "Billie": return STPPaymentMethodType.billie case "Oxxo": return STPPaymentMethodType.OXXO case "Upi": return STPPaymentMethodType.UPI case "AfterpayClearpay": return STPPaymentMethodType.afterpayClearpay diff --git a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentMethodFactory.swift b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentMethodFactory.swift index 6130991f0..96ad91769 100644 --- a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentMethodFactory.swift +++ b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentMethodFactory.swift @@ -33,6 +33,8 @@ class PaymentMethodFactory { return try createAlipayPaymentMethodParams() case STPPaymentMethodType.bancontact: return try createBancontactPaymentMethodParams() + case STPPaymentMethodType.billie: + return try createBilliePaymentMethodParams() case STPPaymentMethodType.SEPADebit: return try createSepaPaymentMethodParams() case STPPaymentMethodType.giropay: @@ -84,6 +86,8 @@ class PaymentMethodFactory { return try createAlipayPaymentMethodOptions() case STPPaymentMethodType.bancontact: return nil + case STPPaymentMethodType.billie: + return nil case STPPaymentMethodType.SEPADebit: return nil case STPPaymentMethodType.OXXO: @@ -256,6 +260,16 @@ class PaymentMethodFactory { return STPPaymentMethodParams(bancontact: params, billingDetails: billingDetails, metadata: metadata) } + private func createBilliePaymentMethodParams() throws -> STPPaymentMethodParams { + let params = STPPaymentMethodBillieParams() + + if let billingDetails = billingDetailsParams { + return STPPaymentMethodParams(billie: params, billingDetails: billingDetails, metadata: metadata) + } else { + throw PaymentMethodError.billiePaymentMissingParams + } + } + private func createSepaPaymentMethodParams() throws -> STPPaymentMethodParams { let params = STPPaymentMethodSEPADebitParams() @@ -328,11 +342,7 @@ class PaymentMethodFactory { private func createKlarnaPaymentMethodParams() throws -> STPPaymentMethodParams { let params = STPPaymentMethodKlarnaParams() - if let billingDetails = billingDetailsParams, billingDetails.address?.country != nil, billingDetails.email != nil { - return STPPaymentMethodParams(klarna: params, billingDetails: billingDetails, metadata: metadata) - } else { - throw PaymentMethodError.klarnaPaymentMissingParams - } + return STPPaymentMethodParams(klarna: params, billingDetails: billingDetailsParams, metadata: metadata) } private func createUSBankAccountPaymentMethodParams() throws -> STPPaymentMethodParams { @@ -399,11 +409,12 @@ enum PaymentMethodError: Error { case paymentNotSupported case cardPaymentOptionsMissingParams case bancontactPaymentMissingParams + case billiePaymentMissingParams case sepaPaymentMissingParams case giropayPaymentMissingParams case p24PaymentMissingParams case afterpayClearpayPaymentMissingParams - case klarnaPaymentMissingParams + // Klarna no longer requires email and country in billing details case weChatPayPaymentMissingParams case usBankAccountPaymentMissingParams case usBankAccountPaymentMissingAccountNumber @@ -423,6 +434,8 @@ extension PaymentMethodError: LocalizedError { return NSLocalizedString("You must provide billing details", comment: "Create payment error") case .bancontactPaymentMissingParams: return NSLocalizedString("You must provide billing details", comment: "Create payment error") + case .billiePaymentMissingParams: + return NSLocalizedString("Billie requires that you provide the following billing details: email, country", comment: "Create payment error") case .sepaPaymentMissingParams: return NSLocalizedString("You must provide billing details and IBAN", comment: "Create payment error") case .epsPaymentMissingParams: @@ -435,8 +448,6 @@ extension PaymentMethodError: LocalizedError { return NSLocalizedString("You must provide CVC number", comment: "Create payment error") case .weChatPayPaymentMissingParams: return NSLocalizedString("You must provide appId", comment: "Create payment error") - case .klarnaPaymentMissingParams: - return NSLocalizedString("Klarna requires that you provide the following billing details: email, country", comment: "Create payment error") case .usBankAccountPaymentMissingParams: return NSLocalizedString("When creating a US bank account payment method, you must provide the following billing details: name", comment: "Create payment error") case .usBankAccountPaymentMissingAccountNumber: diff --git a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentOptionDisplayData+ReactNative.swift b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentOptionDisplayData+ReactNative.swift index eab885565..c5573a2c3 100644 --- a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentOptionDisplayData+ReactNative.swift +++ b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentOptionDisplayData+ReactNative.swift @@ -16,13 +16,13 @@ extension EmbeddedPaymentElement.PaymentOptionDisplayData { guard let data = image.pngData() else { return "" } return data.base64EncodedString() }() - + // Convert BillingDetails to a dictionary let billingDetailsDict: [String: Any] = { guard let billing = billingDetails else { return [:] } - + // Extract address let addressDict: [String: Any] = { let addr = billing.address @@ -35,7 +35,7 @@ extension EmbeddedPaymentElement.PaymentOptionDisplayData { "state": addr.state ?? "" ] }() - + return [ "name": billing.name ?? "", "email": billing.email ?? "", @@ -43,13 +43,33 @@ extension EmbeddedPaymentElement.PaymentOptionDisplayData { "address": addressDict ] }() - + + // Convert NSAttributedString mandateText to HTML + let mandateTextHTML: String? = { + guard let mandateText = mandateText else { return nil } + + do { + let htmlData = try mandateText.data( + from: NSRange(location: 0, length: mandateText.length), + documentAttributes: [ + .documentType: NSAttributedString.DocumentType.html, + .characterEncoding: String.Encoding.utf8.rawValue + ] + ) + return String(data: htmlData, encoding: .utf8) + } catch { + // Fallback to plain string if HTML conversion fails + return mandateText.string + } + }() + // Return as a dictionary return [ "image": imageBase64, "label": label, "billingDetails": billingDetailsDict, - "paymentMethodType": paymentMethodType + "paymentMethodType": paymentMethodType, + "mandateHTML": mandateTextHTML ] } } diff --git a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentSheetAppearance.swift b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentSheetAppearance.swift index 41344db86..b82567c94 100644 --- a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentSheetAppearance.swift +++ b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/PaymentSheetAppearance.swift @@ -136,6 +136,8 @@ internal class PaymentSheetAppearance { primaryButton.backgroundColor = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.BACKGROUND, lightParams: lightModeParams, darkParams: darkModeParams) primaryButton.textColor = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.TEXT, lightParams: lightModeParams, darkParams: darkModeParams) primaryButton.borderColor = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.BORDER, lightParams: lightModeParams, darkParams: darkModeParams) ?? PaymentSheet.Appearance.default.primaryButton.borderColor + primaryButton.successBackgroundColor = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.SUCCESS_BACKGROUND, lightParams: lightModeParams, darkParams: darkModeParams) ?? PaymentSheet.Appearance.default.primaryButton.successBackgroundColor + primaryButton.successTextColor = try buildUserInterfaceStyleAwareColor(key: PaymentSheetAppearanceKeys.SUCCESS_TEXT, lightParams: lightModeParams, darkParams: darkModeParams) } return primaryButton @@ -187,8 +189,8 @@ internal class PaymentSheetAppearance { row.style = .floatingButton case PaymentSheetAppearanceKeys.ROW_STYLE_FLAT_WITH_CHECKMARK: row.style = .flatWithCheckmark - case PaymentSheetAppearanceKeys.ROW_STYLE_FLAT_WITH_CHEVRON: - row.style = .flatWithChevron + case PaymentSheetAppearanceKeys.ROW_STYLE_FLAT_WITH_DISCLOSURE: + row.style = .flatWithDisclosure default: throw PaymentSheetAppearanceError.invalidRowStyle(styleString) } @@ -242,8 +244,8 @@ internal class PaymentSheetAppearance { flat.checkmark = try buildEmbeddedCheckmark(params: checkmarkParams) } - if let chevronParams = params[PaymentSheetAppearanceKeys.CHEVRON] as? NSDictionary { - flat.chevron = try buildEmbeddedChevron(params: chevronParams) + if let disclosureParams = params[PaymentSheetAppearanceKeys.DISCLOSURE] as? NSDictionary { + flat.disclosure = try buildEmbeddedDisclosure(params: disclosureParams) } return flat @@ -281,16 +283,16 @@ internal class PaymentSheetAppearance { return checkmark } - private class func buildEmbeddedChevron(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Chevron { - var chevron = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat.chevron + private class func buildEmbeddedDisclosure(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Disclosure { + var disclosure = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat.disclosure - chevron.color = parseThemedColor( + disclosure.color = parseThemedColor( params: params, key: PaymentSheetAppearanceKeys.COLOR, default: UIColor.systemGray // Default iOS system gray color ) - return chevron + return disclosure } private class func buildEmbeddedFloating(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Floating { @@ -389,7 +391,7 @@ extension PaymentSheetAppearanceError: LocalizedError { case .unexpectedHexStringLength(let hexString): return NSLocalizedString("Failed to set Payment Sheet appearance. Expected hex string of length 6 or 8, but received: \(hexString)", comment: "Failed to set color") case .invalidRowStyle(let styleString): - return NSLocalizedString("Failed to set Embedded Payment Element appearance. Invalid row style '\(styleString)'. Expected one of: 'flatWithRadio', 'floatingButton', 'flatWithCheckmark', 'flatWithChevron'.", comment: "Invalid row style string") + return NSLocalizedString("Failed to set Embedded Payment Element appearance. Invalid row style '\(styleString)'. Expected one of: 'flatWithRadio', 'floatingButton', 'flatWithCheckmark', 'flatWithDisclosure'.", comment: "Invalid row style string") } } } @@ -430,6 +432,8 @@ private struct PaymentSheetAppearanceKeys { static let PRIMARY_BUTTON = "primaryButton" static let TEXT = "text" static let BORDER = "border" + static let SUCCESS_BACKGROUND = "successBackgroundColor" + static let SUCCESS_TEXT = "successTextColor" static let EMBEDDED_PAYMENT_ELEMENT = "embeddedPaymentElement" static let ROW = "row" @@ -446,7 +450,7 @@ private struct PaymentSheetAppearanceKeys { static let SELECTED_COLOR = "selectedColor" static let UNSELECTED_COLOR = "unselectedColor" static let CHECKMARK = "checkmark" - static let CHEVRON = "chevron" + static let DISCLOSURE = "disclosure" static let SPACING = "spacing" static let TOP = "top" static let LEFT = "left" @@ -458,7 +462,7 @@ private struct PaymentSheetAppearanceKeys { static let ROW_STYLE_FLAT_WITH_RADIO = "flatWithRadio" static let ROW_STYLE_FLOATING_BUTTON = "floatingButton" static let ROW_STYLE_FLAT_WITH_CHECKMARK = "flatWithCheckmark" - static let ROW_STYLE_FLAT_WITH_CHEVRON = "flatWithChevron" + static let ROW_STYLE_FLAT_WITH_DISCLOSURE = "flatWithDisclosure" static let FORM_INSETS = "formInsetValues" } diff --git a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/StripeSdkImpl+Embedded.swift b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/StripeSdkImpl+Embedded.swift index a0007aa93..073d8e10f 100644 --- a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/StripeSdkImpl+Embedded.swift +++ b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/StripeSdkImpl+Embedded.swift @@ -216,6 +216,10 @@ extension StripeSdkImpl { configuration.allowsDelayedPaymentMethods = allowsDelayedPaymentMethods } + if let embeddedViewDisplaysMandateText = params["embeddedViewDisplaysMandateText"] as? Bool { + configuration.embeddedViewDisplaysMandateText = embeddedViewDisplaysMandateText + } + if let removeSavedPaymentMethodMessage = params["removeSavedPaymentMethodMessage"] as? String { configuration.removeSavedPaymentMethodMessage = removeSavedPaymentMethodMessage } diff --git a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/StripeSdkImpl.swift b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/StripeSdkImpl.swift index 3ea3db8a2..7febd580a 100644 --- a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/StripeSdkImpl.swift +++ b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/StripeSdkImpl.swift @@ -1,6 +1,7 @@ import PassKit @_spi(DashboardOnly) @_spi(STP) import Stripe @_spi(EmbeddedPaymentElementPrivateBeta) import StripePaymentSheet +@_spi(STP) import StripePayments import StripeFinancialConnections import Foundation @@ -136,7 +137,7 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate { paymentSheetIntentCreationCallback(.failure(error)) } } - + @objc(customPaymentMethodResultCallback:resolver:rejecter:) @MainActor public func customPaymentMethodResultCallback(result: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { @@ -211,14 +212,14 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate { paymentSheetViewController = UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController() if let paymentSheetFlowController = self.paymentSheetFlowController { paymentSheetFlowController.presentPaymentOptions(from: findViewControllerPresenter(from: paymentSheetViewController!) - ) { + ) { didCancel in paymentSheetViewController = nil if let paymentOption = self.paymentSheetFlowController?.paymentOption { let option: NSDictionary = [ "label": paymentOption.label, "image": paymentOption.image.pngData()?.base64EncodedString() ?? "" ] - resolve(Mappers.createResult("paymentOption", option)) + resolve(Mappers.createResult("paymentOption", option, additionalFields: ["didCancel": didCancel])) } else { resolve(Errors.createError(ErrorType.Canceled, "The payment option selection flow has been canceled")) } @@ -467,6 +468,12 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate { return } + // Prevent multiple simultaneous Apple Pay presentations + if self.confirmApplePayResolver != nil { + resolve(Errors.createError(ErrorType.Failed, "Apple Pay is already in progress")) + return + } + self.applePaySummaryItems = paymentRequest.paymentSummaryItems self.applePayShippingMethods = paymentRequest.shippingMethods ?? [] self.applePayShippingAddressErrors = nil @@ -812,7 +819,7 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate { @objc(confirmPayment:data:options:resolver:rejecter:) public func confirmPayment( paymentIntentClientSecret: String, - params: NSDictionary?, + params: NSDictionary, options: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock @@ -820,8 +827,10 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate { self.confirmPaymentResolver = resolve self.confirmPaymentClientSecret = paymentIntentClientSecret - let paymentMethodData = params?["paymentMethodData"] as? NSDictionary - let (missingPaymentMethodError, paymentMethodType) = getPaymentMethodType(params: params) + // Handle React Native null values - when null is passed from JS, it becomes NSNull + let actualParams = (params == NSNull()) ? nil : params + let paymentMethodData = actualParams?["paymentMethodData"] as? NSDictionary + let (missingPaymentMethodError, paymentMethodType) = getPaymentMethodType(params: actualParams) if (missingPaymentMethodError != nil) { resolve(missingPaymentMethodError) return @@ -1141,6 +1150,16 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate { #endif } + @objc(setFinancialConnectionsForceNativeFlow:resolver:rejecter:) + public func setFinancialConnectionsForceNativeFlow( + enabled: Bool, + resolver resolve: @escaping RCTPromiseResolveBlock, + rejecter reject: @escaping RCTPromiseRejectBlock + ) { + UserDefaults.standard.set(enabled, forKey: "FINANCIAL_CONNECTIONS_EXAMPLE_APP_ENABLE_NATIVE") + resolve(nil) + } + public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { confirmPaymentResolver?(Errors.createError(ErrorType.Canceled, "FPX Payment has been canceled")) } @@ -1175,7 +1194,7 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate { break } } - + struct ConfirmationError: Error, LocalizedError { private var errorMessage: String init(errorMessage: String) { diff --git a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/StripePlugin.swift b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/StripePlugin.swift index cd98414c0..bb357cc3c 100644 --- a/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/StripePlugin.swift +++ b/packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/StripePlugin.swift @@ -39,23 +39,23 @@ func RCTMakeAndLogError(_ error: String, _ something: String?, _ anotherSomethin @objc(StripePlugin) class StripePlugin: StripeSdkImpl, FlutterPlugin, ViewManagerDelegate { - - + + private var channel: FlutterMethodChannel static func register(with registrar: FlutterPluginRegistrar) { // Method Channel let channel = FlutterMethodChannel(name: "flutter.stripe/payments", binaryMessenger: registrar.messenger(), codec: FlutterJSONMethodCodec()) - + let instance = StripePlugin(channel: channel) instance.emitter = instance registrar.addMethodCallDelegate(instance, channel: channel) registrar.addApplicationDelegate(instance) - + // Card Field let cardFieldFactory = CardFieldViewFactory(messenger: registrar.messenger(), delegate:instance) registrar.register(cardFieldFactory, withId: "flutter.stripe/card_field") - + // Card Form let cardFormFactory = CardFormFactory(messenger: registrar.messenger(), delegate: instance) registrar.register(cardFormFactory, withId: "flutter.stripe/card_form_field") @@ -63,17 +63,17 @@ class StripePlugin: StripeSdkImpl, FlutterPlugin, ViewManagerDelegate { // AueBECS Debit Form let auebecsFormFactory = AuBECSDebitFormFactory(messenger: registrar.messenger(), delegate: instance) registrar.register(auebecsFormFactory, withId: "flutter.stripe/aubecs_form_field") - + // Apple Pay Button let applePayFactory = ApplePayButtonViewFactory(messenger: registrar.messenger(),stripeSdk: instance) registrar.register(applePayFactory, withId: "flutter.stripe/apple_pay") - + // Addressheet let addressSheetFactory = AddressSheetViewFactory(messenger: registrar.messenger(), delegate: instance) registrar.register(addressSheetFactory, withId: "flutter.stripe/address_sheet") - + } - + init(channel : FlutterMethodChannel) { self.channel = channel super.init() @@ -219,7 +219,7 @@ class StripePlugin: StripeSdkImpl, FlutterPlugin, ViewManagerDelegate { case "customerAdapterFetchSelectedPaymentOptionCallback": let arguments = call.arguments as? FlutterMap let paymentOption = arguments?["paymentOption"] as? String - + return customerAdapterFetchSelectedPaymentOptionCallback( paymentOption: paymentOption, resolver: resolver(for: result), @@ -242,8 +242,8 @@ class StripePlugin: StripeSdkImpl, FlutterPlugin, ViewManagerDelegate { result(FlutterMethodNotImplemented) } } - - + + func resolver(for result: @escaping FlutterResult) -> RCTPromiseResolveBlock { return { (response) in var data : Any? @@ -256,23 +256,23 @@ class StripePlugin: StripeSdkImpl, FlutterPlugin, ViewManagerDelegate { result(NSNull.replaceForNil(data as AnyObject)) } } - + func rejecter(for result: @escaping FlutterResult) -> RCTPromiseRejectBlock { return { (code, message, error) in result(FlutterError.init(code: code ?? "Failed", message: message, details: error)) } } - + func sendEvent(withName name: String, body: [String: Any]) { channel.invokeMethod(name, arguments: body) } - + func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { return StripeAPI.handleURLCallback(with: url) } - + func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]) -> Void) -> Bool { - + if userActivity.activityType == NSUserActivityTypeBrowsingWeb { if let url = userActivity.webpageURL { return StripeAPI.handleURLCallback(with: url) @@ -286,74 +286,74 @@ extension StripePlugin: StripeSdkEmitter { func emitOnCustomPaymentMethodConfirmHandlerCallback(_ value: [String : Any]) { self.sendEvent(withName: "onCustomPaymentMethodConfirmHandlerCallback", body: value) } - - + + func emitOnConfirmHandlerCallback(_ value: [String : Any]) { self.sendEvent(withName: "onConfirmHandlerCallback", body: value) } - + func emitOnFinancialConnectionsEvent(_ value: [String : Any]) { self.sendEvent(withName: "onFinancialConnectionsEvent", body: value) } - + func emitOnOrderTrackingCallback() { self.sendEvent(withName: "onOrderTrackingCallback", body:[:]) } - + func emitOnCustomerAdapterFetchPaymentMethodsCallback() { self.sendEvent(withName: "onCustomerAdapterFetchPaymentMethodsCallback", body:[:]) } - + func emitOnCustomerAdapterAttachPaymentMethodCallback(_ value: [String : Any]) { self.sendEvent(withName: "onCustomerAdapterAttachPaymentMethodCallback", body:value) } - + func emitOnCustomerAdapterDetachPaymentMethodCallback(_ value: [String : Any]) { self.sendEvent(withName: "onCustomerAdapterDetachPaymentMethodCallback", body:value) } - + func emitOnCustomerAdapterSetSelectedPaymentOptionCallback(_ value: [String : Any]) { self.sendEvent(withName: "onCustomerAdapterSetSelectedPaymentOptionCallback", body:value) } - + func emitOnCustomerAdapterFetchSelectedPaymentOptionCallback() { self.sendEvent(withName: "onCustomerAdapterFetchSelectedPaymentOptionCallback", body:[:]) } - + func emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback() { self.sendEvent(withName: "onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback", body:[:]) } - + func emitEmbeddedPaymentElementDidUpdateHeight(_ value: [String : Any]) { self.sendEvent(withName: "embeddedPaymentElementDidUpdateHeight", body:value) } - + func emitEmbeddedPaymentElementWillPresent() { self.sendEvent(withName: "embeddedPaymentElementWillPresent", body:[:]) } - + func emitEmbeddedPaymentElementDidUpdatePaymentOption(_ value: [String : Any]) { self.sendEvent(withName: "embeddedPaymentElementDidUpdatePaymentOption", body: value) } - + func emitEmbeddedPaymentElementFormSheetConfirmComplete(_ value: [String : Any]) { self.sendEvent(withName: "embeddedPaymentElementFormSheetConfirmComplete", body: value) } - + func emitEmbeddedPaymentElementRowSelectionImmediateAction() { self.sendEvent(withName: "embeddedPaymentElementRowSelectionImmediateAction", body:[:]) } - + func emitEmbeddedPaymentElementLoadingFailed(_ value: [String : Any]) { self.sendEvent(withName: "embeddedPaymentElementLoadingFailed", body:value) } - + } // Mark: MethodChannel handlers extension StripePlugin { - + func initialise(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let params = call.arguments as? NSDictionary else { result(FlutterError.invalidParams) @@ -361,7 +361,7 @@ extension StripePlugin { } initialise(params: params, resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func initPaymentSheet(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, var params = arguments["params"] as? NSDictionary else { @@ -377,11 +377,11 @@ extension StripePlugin { } initPaymentSheet(params: params, resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func confirmPaymentSheetPayment(_ call: FlutterMethodCall, result: @escaping FlutterResult) { confirmPaymentSheetPayment(resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func presentPaymentSheet(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let options = arguments["options"] as? NSDictionary else { @@ -397,7 +397,7 @@ extension StripePlugin { } }, rejecter: rejecter(for: result)) } - + func createTokenForCVCUpdate(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap else { result(FlutterError.invalidParams) @@ -406,7 +406,7 @@ extension StripePlugin { let cvc = arguments["cvc"] as? String createTokenForCVCUpdate(cvc: cvc, resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func confirmSetupIntent(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let setupIntentClientSecret = arguments["setupIntentClientSecret"] as? String, @@ -417,14 +417,14 @@ extension StripePlugin { } confirmSetupIntent(setupIntentClientSecret: setupIntentClientSecret, params: params, options: options,resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func openApplePaySetup(_ call: FlutterMethodCall, result: @escaping FlutterResult) { openApplePaySetup( resolver: resolver(for: result), rejecter: rejecter(for: result) ) } - + func verifyMicrodeposits(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let isPaymentIntent = arguments["isPaymentIntent"] as? Bool, @@ -441,7 +441,7 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func collectBankAccount(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let isPaymentIntent = arguments["isPaymentIntent"] as? Bool, @@ -458,7 +458,7 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func isCardInWallet(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let params = arguments["params"] as? NSDictionary else { @@ -471,7 +471,7 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func canAddCardToWallet(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let params = arguments["params"] as? NSDictionary else { @@ -484,7 +484,7 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func handleURLCallback(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? NSDictionary, let url = arguments["url"] as? String else { @@ -497,7 +497,7 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func createPaymentMethod(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let params = arguments["data"] as? NSDictionary, @@ -512,7 +512,7 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func handleNextAction(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let paymentIntentClientSecret = arguments["paymentIntentClientSecret"] as? String else { @@ -526,7 +526,7 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func handleNextActionForSetupIntent(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let paymentIntentClientSecret = arguments["setupIntentClientSecret"] as? String else { @@ -540,15 +540,16 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func confirmPayment(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let paymentIntentClientSecret = arguments["paymentIntentClientSecret"] as? String, - let options = arguments["options"] as? NSDictionary else { + let options = arguments["options"] as? NSDictionary, + let params = arguments["params"] as? NSDictionary else { result(FlutterError.invalidParams) return } - let params = arguments["params"] as? NSDictionary + confirmPayment( paymentIntentClientSecret: paymentIntentClientSecret, params: params, @@ -557,7 +558,7 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func retrievePaymentIntent(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let clientSecret = arguments["clientSecret"] as? String else { @@ -570,7 +571,7 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func retrieveSetupIntent(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let clientSecret = arguments["clientSecret"] as? String else { @@ -583,8 +584,8 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - - + + func configure3dSecure(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let params = arguments["params"] as? NSDictionary else { @@ -594,7 +595,7 @@ extension StripePlugin { configure3dSecure(params) result(nil) } - + func createToken(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let params = arguments["params"] as? NSDictionary else { @@ -605,7 +606,7 @@ extension StripePlugin { resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func collectBankAccountToken(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap else { result(FlutterError.invalidParams) @@ -624,7 +625,7 @@ extension StripePlugin { resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func collectFinancialConnectionsAccounts(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap else { result(FlutterError.invalidParams) @@ -643,34 +644,34 @@ extension StripePlugin { resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func resetPaymentSheetCustomer(_ call: FlutterMethodCall, result: @escaping FlutterResult) { resetPaymentSheetCustomer(resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func updatePlatformPaySheet(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap else { result(FlutterError.invalidParams) return } - + guard let params = arguments["params"] as? NSDictionary else{ result(FlutterError.invalidParams) return } - + guard let summaryItems = params["summaryItems"] as? NSArray, let shippingMethods = params["shippingMethods"] as? NSArray else { result(FlutterError.invalidParams) return } - + let errors = params["errors"] as? [NSDictionary] - + updatePlatformPaySheet(summaryItems: summaryItems, shippingMethods: shippingMethods, errors: errors ?? [], resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func isPlatformPaySupported(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let params = arguments["params"] as? NSDictionary else { @@ -679,7 +680,7 @@ extension StripePlugin { } isPlatformPaySupported(params: params, resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func createPlatformPayPaymentMethod(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let params = arguments["params"] as? NSDictionary, @@ -690,11 +691,11 @@ extension StripePlugin { } createPlatformPayPaymentMethod(params: params, usesDeprecatedTokenFlow: usesDeprecatedTokenFlow, resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func dismissPlatformPay(_ call: FlutterMethodCall, result: @escaping FlutterResult) { dismissPlatformPay(resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func confirmPlatformPay(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let clientSecret = arguments["clientSecret"] as? String, @@ -706,7 +707,7 @@ extension StripePlugin { } confirmPlatformPay(clientSecret: clientSecret, params: params, isPaymentIntent: isPaymentIntent, resolver: resolver(for: result), rejecter: rejecter(for: result)) } - + func configureOrderTracking(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let orderTypeIdentifier = arguments["orderTypeIdentifier"] as? String, @@ -726,7 +727,7 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func handleNextActionForSetup(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let setupIntentClientSecret = arguments["setupIntentClientSecret"] as? String, @@ -742,15 +743,15 @@ extension StripePlugin { rejecter: rejecter(for: result) ) } - + func addListener(_ call: FlutterMethodCall, result: @escaping FlutterResult) { //startObserving() } - + func removeListener(_ call: FlutterMethodCall, result: @escaping FlutterResult) { //stopObserving() } - + func intentCreationCallback(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let params = arguments["params"] as? NSDictionary @@ -758,11 +759,11 @@ extension StripePlugin { result(FlutterError.invalidParams) return } - + intentCreationCallback(result: params, resolver: resolver(for: result), rejecter: rejecter(for: result)) result(nil) } - + func confirmCustomPaymentMethodCallback (_ call: FlutterMethodCall, result: @escaping FlutterResult){ guard let arguments = call.arguments as? FlutterMap, let params = arguments["params"] as? NSDictionary @@ -770,11 +771,11 @@ extension StripePlugin { result(FlutterError.invalidParams) return } - + customPaymentMethodResultCallback(result: params, resolver: resolver(for: result), rejecter: rejecter(for: result)) result(nil) } - + func dangerouslyUpdateCardDetails(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let params = arguments["params"] as? NSDictionary else { diff --git a/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.dart b/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.dart index cc212c06a..3dbf727da 100644 --- a/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.dart +++ b/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.dart @@ -31,7 +31,6 @@ abstract class IdPaymentMethodDetails implements PaymentMethodDetails { /// It supports creating a payment method from an id or custom payment /// method details like [CardPaymentMethodDetails]. @Target({TargetKind.parameter}) -@internal const paymentMethodDetailJsonKey = JsonKey( name: "payment_method", toJson: PaymentMethodDetails.toJsonConverter, diff --git a/packages/stripe_platform_interface/lib/src/models/payment_methods.dart b/packages/stripe_platform_interface/lib/src/models/payment_methods.dart index deb64a1f1..26713fb12 100644 --- a/packages/stripe_platform_interface/lib/src/models/payment_methods.dart +++ b/packages/stripe_platform_interface/lib/src/models/payment_methods.dart @@ -421,8 +421,6 @@ abstract class PaymentMethodParams with _$PaymentMethodParams { const factory PaymentMethodParams.klarna({ /// Paymentmethod data for this paymentmethod. /// - /// Make sure to add an email and country (part of the address) in the - /// billingdetails which is required for using Klarna. required PaymentMethodData paymentMethodData, }) = _PaymentMethodParamsKlarna; @@ -449,6 +447,12 @@ abstract class PaymentMethodParams with _$PaymentMethodParams { required PaymentMethodDataUsBank paymentMethodData, }) = _PaymentMethodParamsUsBankAccount; + @JsonSerializable(explicitToJson: true) + @FreezedUnionValue('Billie') + factory PaymentMethodParams.billie({ + required PaymentMethodData paymentMethodData, + }) = _PaymentMethodParamsBillie; + // TODO uncomment and regenerate when we can re-enable wechat pay // @JsonSerializable(explicitToJson: true) // @FreezedUnionValue('WeChatPay') diff --git a/packages/stripe_platform_interface/lib/src/models/payment_methods.freezed.dart b/packages/stripe_platform_interface/lib/src/models/payment_methods.freezed.dart index 5396cdbb6..f0fb6635f 100644 --- a/packages/stripe_platform_interface/lib/src/models/payment_methods.freezed.dart +++ b/packages/stripe_platform_interface/lib/src/models/payment_methods.freezed.dart @@ -3177,6 +3177,10 @@ PaymentMethodParams _$PaymentMethodParamsFromJson( return _PaymentMethodParamsUsBankAccount.fromJson( json ); + case 'Billie': + return _PaymentMethodParamsBillie.fromJson( + json + ); default: throw CheckedFromJsonException( @@ -3236,7 +3240,7 @@ extension PaymentMethodParamsPatterns on PaymentMethodParams { /// } /// ``` -@optionalTypeArgs TResult maybeMap({TResult Function( _PaymentMethodParamsCard value)? card,TResult Function( _PaymentMethodParamsCardWithToken value)? cardFromToken,TResult Function( _PaymentMethodParamsCardWithMethodId value)? cardFromMethodId,TResult Function( _PaymentMethodParamsAlipay value)? alipay,TResult Function( _PaymentMethodParamsCashAppPay value)? cashAppPay,TResult Function( _PaymentMethodParamsIdeal value)? ideal,TResult Function( _PaymentMethodParamsAubecs value)? aubecs,TResult Function( _PaymentMethodParamsBankContact value)? bancontact,TResult Function( _PaymentMethodParamsGiroPay value)? giroPay,TResult Function( _PaymentMethodParamsEps value)? eps,TResult Function( _PaymentMethodParamsAffirm value)? affirm,TResult Function( _PaymentMethodParamsPay value)? grabPay,TResult Function( _PaymentMethodParamsP24 value)? p24,TResult Function( _PaymentMethodParamsFpx value)? fpx,TResult Function( _PaymentMethodParamsSepaDebit value)? sepaDebit,TResult Function( _PaymentMethodParamsAfterpayClearpay value)? afterpayClearpay,TResult Function( _PaymentMethodParamsOxxo value)? oxxo,TResult Function( _PaymentMethodParamsKlarna value)? klarna,TResult Function( _PaymentMethodParamsPayPal value)? payPal,TResult Function( _PaymentMethodParamsRevolutPay value)? revolutPay,TResult Function( _PaymentMethodParamsUsBankAccount value)? usBankAccount,required TResult orElse(),}){ +@optionalTypeArgs TResult maybeMap({TResult Function( _PaymentMethodParamsCard value)? card,TResult Function( _PaymentMethodParamsCardWithToken value)? cardFromToken,TResult Function( _PaymentMethodParamsCardWithMethodId value)? cardFromMethodId,TResult Function( _PaymentMethodParamsAlipay value)? alipay,TResult Function( _PaymentMethodParamsCashAppPay value)? cashAppPay,TResult Function( _PaymentMethodParamsIdeal value)? ideal,TResult Function( _PaymentMethodParamsAubecs value)? aubecs,TResult Function( _PaymentMethodParamsBankContact value)? bancontact,TResult Function( _PaymentMethodParamsGiroPay value)? giroPay,TResult Function( _PaymentMethodParamsEps value)? eps,TResult Function( _PaymentMethodParamsAffirm value)? affirm,TResult Function( _PaymentMethodParamsPay value)? grabPay,TResult Function( _PaymentMethodParamsP24 value)? p24,TResult Function( _PaymentMethodParamsFpx value)? fpx,TResult Function( _PaymentMethodParamsSepaDebit value)? sepaDebit,TResult Function( _PaymentMethodParamsAfterpayClearpay value)? afterpayClearpay,TResult Function( _PaymentMethodParamsOxxo value)? oxxo,TResult Function( _PaymentMethodParamsKlarna value)? klarna,TResult Function( _PaymentMethodParamsPayPal value)? payPal,TResult Function( _PaymentMethodParamsRevolutPay value)? revolutPay,TResult Function( _PaymentMethodParamsUsBankAccount value)? usBankAccount,TResult Function( _PaymentMethodParamsBillie value)? billie,required TResult orElse(),}){ final _that = this; switch (_that) { case _PaymentMethodParamsCard() when card != null: @@ -3260,7 +3264,8 @@ return oxxo(_that);case _PaymentMethodParamsKlarna() when klarna != null: return klarna(_that);case _PaymentMethodParamsPayPal() when payPal != null: return payPal(_that);case _PaymentMethodParamsRevolutPay() when revolutPay != null: return revolutPay(_that);case _PaymentMethodParamsUsBankAccount() when usBankAccount != null: -return usBankAccount(_that);case _: +return usBankAccount(_that);case _PaymentMethodParamsBillie() when billie != null: +return billie(_that);case _: return orElse(); } @@ -3278,7 +3283,7 @@ return usBankAccount(_that);case _: /// } /// ``` -@optionalTypeArgs TResult map({required TResult Function( _PaymentMethodParamsCard value) card,required TResult Function( _PaymentMethodParamsCardWithToken value) cardFromToken,required TResult Function( _PaymentMethodParamsCardWithMethodId value) cardFromMethodId,required TResult Function( _PaymentMethodParamsAlipay value) alipay,required TResult Function( _PaymentMethodParamsCashAppPay value) cashAppPay,required TResult Function( _PaymentMethodParamsIdeal value) ideal,required TResult Function( _PaymentMethodParamsAubecs value) aubecs,required TResult Function( _PaymentMethodParamsBankContact value) bancontact,required TResult Function( _PaymentMethodParamsGiroPay value) giroPay,required TResult Function( _PaymentMethodParamsEps value) eps,required TResult Function( _PaymentMethodParamsAffirm value) affirm,required TResult Function( _PaymentMethodParamsPay value) grabPay,required TResult Function( _PaymentMethodParamsP24 value) p24,required TResult Function( _PaymentMethodParamsFpx value) fpx,required TResult Function( _PaymentMethodParamsSepaDebit value) sepaDebit,required TResult Function( _PaymentMethodParamsAfterpayClearpay value) afterpayClearpay,required TResult Function( _PaymentMethodParamsOxxo value) oxxo,required TResult Function( _PaymentMethodParamsKlarna value) klarna,required TResult Function( _PaymentMethodParamsPayPal value) payPal,required TResult Function( _PaymentMethodParamsRevolutPay value) revolutPay,required TResult Function( _PaymentMethodParamsUsBankAccount value) usBankAccount,}){ +@optionalTypeArgs TResult map({required TResult Function( _PaymentMethodParamsCard value) card,required TResult Function( _PaymentMethodParamsCardWithToken value) cardFromToken,required TResult Function( _PaymentMethodParamsCardWithMethodId value) cardFromMethodId,required TResult Function( _PaymentMethodParamsAlipay value) alipay,required TResult Function( _PaymentMethodParamsCashAppPay value) cashAppPay,required TResult Function( _PaymentMethodParamsIdeal value) ideal,required TResult Function( _PaymentMethodParamsAubecs value) aubecs,required TResult Function( _PaymentMethodParamsBankContact value) bancontact,required TResult Function( _PaymentMethodParamsGiroPay value) giroPay,required TResult Function( _PaymentMethodParamsEps value) eps,required TResult Function( _PaymentMethodParamsAffirm value) affirm,required TResult Function( _PaymentMethodParamsPay value) grabPay,required TResult Function( _PaymentMethodParamsP24 value) p24,required TResult Function( _PaymentMethodParamsFpx value) fpx,required TResult Function( _PaymentMethodParamsSepaDebit value) sepaDebit,required TResult Function( _PaymentMethodParamsAfterpayClearpay value) afterpayClearpay,required TResult Function( _PaymentMethodParamsOxxo value) oxxo,required TResult Function( _PaymentMethodParamsKlarna value) klarna,required TResult Function( _PaymentMethodParamsPayPal value) payPal,required TResult Function( _PaymentMethodParamsRevolutPay value) revolutPay,required TResult Function( _PaymentMethodParamsUsBankAccount value) usBankAccount,required TResult Function( _PaymentMethodParamsBillie value) billie,}){ final _that = this; switch (_that) { case _PaymentMethodParamsCard(): @@ -3302,7 +3307,8 @@ return oxxo(_that);case _PaymentMethodParamsKlarna(): return klarna(_that);case _PaymentMethodParamsPayPal(): return payPal(_that);case _PaymentMethodParamsRevolutPay(): return revolutPay(_that);case _PaymentMethodParamsUsBankAccount(): -return usBankAccount(_that);case _: +return usBankAccount(_that);case _PaymentMethodParamsBillie(): +return billie(_that);case _: throw StateError('Unexpected subclass'); } @@ -3319,7 +3325,7 @@ return usBankAccount(_that);case _: /// } /// ``` -@optionalTypeArgs TResult? mapOrNull({TResult? Function( _PaymentMethodParamsCard value)? card,TResult? Function( _PaymentMethodParamsCardWithToken value)? cardFromToken,TResult? Function( _PaymentMethodParamsCardWithMethodId value)? cardFromMethodId,TResult? Function( _PaymentMethodParamsAlipay value)? alipay,TResult? Function( _PaymentMethodParamsCashAppPay value)? cashAppPay,TResult? Function( _PaymentMethodParamsIdeal value)? ideal,TResult? Function( _PaymentMethodParamsAubecs value)? aubecs,TResult? Function( _PaymentMethodParamsBankContact value)? bancontact,TResult? Function( _PaymentMethodParamsGiroPay value)? giroPay,TResult? Function( _PaymentMethodParamsEps value)? eps,TResult? Function( _PaymentMethodParamsAffirm value)? affirm,TResult? Function( _PaymentMethodParamsPay value)? grabPay,TResult? Function( _PaymentMethodParamsP24 value)? p24,TResult? Function( _PaymentMethodParamsFpx value)? fpx,TResult? Function( _PaymentMethodParamsSepaDebit value)? sepaDebit,TResult? Function( _PaymentMethodParamsAfterpayClearpay value)? afterpayClearpay,TResult? Function( _PaymentMethodParamsOxxo value)? oxxo,TResult? Function( _PaymentMethodParamsKlarna value)? klarna,TResult? Function( _PaymentMethodParamsPayPal value)? payPal,TResult? Function( _PaymentMethodParamsRevolutPay value)? revolutPay,TResult? Function( _PaymentMethodParamsUsBankAccount value)? usBankAccount,}){ +@optionalTypeArgs TResult? mapOrNull({TResult? Function( _PaymentMethodParamsCard value)? card,TResult? Function( _PaymentMethodParamsCardWithToken value)? cardFromToken,TResult? Function( _PaymentMethodParamsCardWithMethodId value)? cardFromMethodId,TResult? Function( _PaymentMethodParamsAlipay value)? alipay,TResult? Function( _PaymentMethodParamsCashAppPay value)? cashAppPay,TResult? Function( _PaymentMethodParamsIdeal value)? ideal,TResult? Function( _PaymentMethodParamsAubecs value)? aubecs,TResult? Function( _PaymentMethodParamsBankContact value)? bancontact,TResult? Function( _PaymentMethodParamsGiroPay value)? giroPay,TResult? Function( _PaymentMethodParamsEps value)? eps,TResult? Function( _PaymentMethodParamsAffirm value)? affirm,TResult? Function( _PaymentMethodParamsPay value)? grabPay,TResult? Function( _PaymentMethodParamsP24 value)? p24,TResult? Function( _PaymentMethodParamsFpx value)? fpx,TResult? Function( _PaymentMethodParamsSepaDebit value)? sepaDebit,TResult? Function( _PaymentMethodParamsAfterpayClearpay value)? afterpayClearpay,TResult? Function( _PaymentMethodParamsOxxo value)? oxxo,TResult? Function( _PaymentMethodParamsKlarna value)? klarna,TResult? Function( _PaymentMethodParamsPayPal value)? payPal,TResult? Function( _PaymentMethodParamsRevolutPay value)? revolutPay,TResult? Function( _PaymentMethodParamsUsBankAccount value)? usBankAccount,TResult? Function( _PaymentMethodParamsBillie value)? billie,}){ final _that = this; switch (_that) { case _PaymentMethodParamsCard() when card != null: @@ -3343,7 +3349,8 @@ return oxxo(_that);case _PaymentMethodParamsKlarna() when klarna != null: return klarna(_that);case _PaymentMethodParamsPayPal() when payPal != null: return payPal(_that);case _PaymentMethodParamsRevolutPay() when revolutPay != null: return revolutPay(_that);case _PaymentMethodParamsUsBankAccount() when usBankAccount != null: -return usBankAccount(_that);case _: +return usBankAccount(_that);case _PaymentMethodParamsBillie() when billie != null: +return billie(_that);case _: return null; } @@ -3360,7 +3367,7 @@ return usBankAccount(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen({TResult Function( PaymentMethodData paymentMethodData)? card,TResult Function( PaymentMethodDataCardFromToken paymentMethodData)? cardFromToken,TResult Function( PaymentMethodDataCardFromMethod paymentMethodData)? cardFromMethodId,TResult Function( PaymentMethodData paymentMethodData)? alipay,TResult Function( PaymentMethodData paymentMethodData)? cashAppPay,TResult Function( PaymentMethodDataIdeal paymentMethodData)? ideal,TResult Function( PaymentMethodDataAubecs paymentMethodData)? aubecs,TResult Function( PaymentMethodData paymentMethodData)? bancontact,TResult Function( PaymentMethodData paymentMethodData)? giroPay,TResult Function( PaymentMethodData paymentMethodData)? eps,TResult Function( PaymentMethodData paymentMethodData)? affirm,TResult Function( PaymentMethodData paymentMethodData)? grabPay,TResult Function( PaymentMethodData paymentMethodData)? p24,TResult Function( PaymentMethodDataFpx paymentMethodData)? fpx,TResult Function( PaymentMethodDataSepa paymentMethodData)? sepaDebit,TResult Function( PaymentMethodDataAfterPay paymentMethodData)? afterpayClearpay,TResult Function( PaymentMethodData paymentMethodData)? oxxo,TResult Function( PaymentMethodData paymentMethodData)? klarna,TResult Function( PaymentMethodData paymentMethodData)? payPal,TResult Function( PaymentMethodData paymentMethodData)? revolutPay,TResult Function( PaymentMethodDataUsBank paymentMethodData)? usBankAccount,required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen({TResult Function( PaymentMethodData paymentMethodData)? card,TResult Function( PaymentMethodDataCardFromToken paymentMethodData)? cardFromToken,TResult Function( PaymentMethodDataCardFromMethod paymentMethodData)? cardFromMethodId,TResult Function( PaymentMethodData paymentMethodData)? alipay,TResult Function( PaymentMethodData paymentMethodData)? cashAppPay,TResult Function( PaymentMethodDataIdeal paymentMethodData)? ideal,TResult Function( PaymentMethodDataAubecs paymentMethodData)? aubecs,TResult Function( PaymentMethodData paymentMethodData)? bancontact,TResult Function( PaymentMethodData paymentMethodData)? giroPay,TResult Function( PaymentMethodData paymentMethodData)? eps,TResult Function( PaymentMethodData paymentMethodData)? affirm,TResult Function( PaymentMethodData paymentMethodData)? grabPay,TResult Function( PaymentMethodData paymentMethodData)? p24,TResult Function( PaymentMethodDataFpx paymentMethodData)? fpx,TResult Function( PaymentMethodDataSepa paymentMethodData)? sepaDebit,TResult Function( PaymentMethodDataAfterPay paymentMethodData)? afterpayClearpay,TResult Function( PaymentMethodData paymentMethodData)? oxxo,TResult Function( PaymentMethodData paymentMethodData)? klarna,TResult Function( PaymentMethodData paymentMethodData)? payPal,TResult Function( PaymentMethodData paymentMethodData)? revolutPay,TResult Function( PaymentMethodDataUsBank paymentMethodData)? usBankAccount,TResult Function( PaymentMethodData paymentMethodData)? billie,required TResult orElse(),}) {final _that = this; switch (_that) { case _PaymentMethodParamsCard() when card != null: return card(_that.paymentMethodData);case _PaymentMethodParamsCardWithToken() when cardFromToken != null: @@ -3383,7 +3390,8 @@ return oxxo(_that.paymentMethodData);case _PaymentMethodParamsKlarna() when klar return klarna(_that.paymentMethodData);case _PaymentMethodParamsPayPal() when payPal != null: return payPal(_that.paymentMethodData);case _PaymentMethodParamsRevolutPay() when revolutPay != null: return revolutPay(_that.paymentMethodData);case _PaymentMethodParamsUsBankAccount() when usBankAccount != null: -return usBankAccount(_that.paymentMethodData);case _: +return usBankAccount(_that.paymentMethodData);case _PaymentMethodParamsBillie() when billie != null: +return billie(_that.paymentMethodData);case _: return orElse(); } @@ -3401,7 +3409,7 @@ return usBankAccount(_that.paymentMethodData);case _: /// } /// ``` -@optionalTypeArgs TResult when({required TResult Function( PaymentMethodData paymentMethodData) card,required TResult Function( PaymentMethodDataCardFromToken paymentMethodData) cardFromToken,required TResult Function( PaymentMethodDataCardFromMethod paymentMethodData) cardFromMethodId,required TResult Function( PaymentMethodData paymentMethodData) alipay,required TResult Function( PaymentMethodData paymentMethodData) cashAppPay,required TResult Function( PaymentMethodDataIdeal paymentMethodData) ideal,required TResult Function( PaymentMethodDataAubecs paymentMethodData) aubecs,required TResult Function( PaymentMethodData paymentMethodData) bancontact,required TResult Function( PaymentMethodData paymentMethodData) giroPay,required TResult Function( PaymentMethodData paymentMethodData) eps,required TResult Function( PaymentMethodData paymentMethodData) affirm,required TResult Function( PaymentMethodData paymentMethodData) grabPay,required TResult Function( PaymentMethodData paymentMethodData) p24,required TResult Function( PaymentMethodDataFpx paymentMethodData) fpx,required TResult Function( PaymentMethodDataSepa paymentMethodData) sepaDebit,required TResult Function( PaymentMethodDataAfterPay paymentMethodData) afterpayClearpay,required TResult Function( PaymentMethodData paymentMethodData) oxxo,required TResult Function( PaymentMethodData paymentMethodData) klarna,required TResult Function( PaymentMethodData paymentMethodData) payPal,required TResult Function( PaymentMethodData paymentMethodData) revolutPay,required TResult Function( PaymentMethodDataUsBank paymentMethodData) usBankAccount,}) {final _that = this; +@optionalTypeArgs TResult when({required TResult Function( PaymentMethodData paymentMethodData) card,required TResult Function( PaymentMethodDataCardFromToken paymentMethodData) cardFromToken,required TResult Function( PaymentMethodDataCardFromMethod paymentMethodData) cardFromMethodId,required TResult Function( PaymentMethodData paymentMethodData) alipay,required TResult Function( PaymentMethodData paymentMethodData) cashAppPay,required TResult Function( PaymentMethodDataIdeal paymentMethodData) ideal,required TResult Function( PaymentMethodDataAubecs paymentMethodData) aubecs,required TResult Function( PaymentMethodData paymentMethodData) bancontact,required TResult Function( PaymentMethodData paymentMethodData) giroPay,required TResult Function( PaymentMethodData paymentMethodData) eps,required TResult Function( PaymentMethodData paymentMethodData) affirm,required TResult Function( PaymentMethodData paymentMethodData) grabPay,required TResult Function( PaymentMethodData paymentMethodData) p24,required TResult Function( PaymentMethodDataFpx paymentMethodData) fpx,required TResult Function( PaymentMethodDataSepa paymentMethodData) sepaDebit,required TResult Function( PaymentMethodDataAfterPay paymentMethodData) afterpayClearpay,required TResult Function( PaymentMethodData paymentMethodData) oxxo,required TResult Function( PaymentMethodData paymentMethodData) klarna,required TResult Function( PaymentMethodData paymentMethodData) payPal,required TResult Function( PaymentMethodData paymentMethodData) revolutPay,required TResult Function( PaymentMethodDataUsBank paymentMethodData) usBankAccount,required TResult Function( PaymentMethodData paymentMethodData) billie,}) {final _that = this; switch (_that) { case _PaymentMethodParamsCard(): return card(_that.paymentMethodData);case _PaymentMethodParamsCardWithToken(): @@ -3424,7 +3432,8 @@ return oxxo(_that.paymentMethodData);case _PaymentMethodParamsKlarna(): return klarna(_that.paymentMethodData);case _PaymentMethodParamsPayPal(): return payPal(_that.paymentMethodData);case _PaymentMethodParamsRevolutPay(): return revolutPay(_that.paymentMethodData);case _PaymentMethodParamsUsBankAccount(): -return usBankAccount(_that.paymentMethodData);case _: +return usBankAccount(_that.paymentMethodData);case _PaymentMethodParamsBillie(): +return billie(_that.paymentMethodData);case _: throw StateError('Unexpected subclass'); } @@ -3441,7 +3450,7 @@ return usBankAccount(_that.paymentMethodData);case _: /// } /// ``` -@optionalTypeArgs TResult? whenOrNull({TResult? Function( PaymentMethodData paymentMethodData)? card,TResult? Function( PaymentMethodDataCardFromToken paymentMethodData)? cardFromToken,TResult? Function( PaymentMethodDataCardFromMethod paymentMethodData)? cardFromMethodId,TResult? Function( PaymentMethodData paymentMethodData)? alipay,TResult? Function( PaymentMethodData paymentMethodData)? cashAppPay,TResult? Function( PaymentMethodDataIdeal paymentMethodData)? ideal,TResult? Function( PaymentMethodDataAubecs paymentMethodData)? aubecs,TResult? Function( PaymentMethodData paymentMethodData)? bancontact,TResult? Function( PaymentMethodData paymentMethodData)? giroPay,TResult? Function( PaymentMethodData paymentMethodData)? eps,TResult? Function( PaymentMethodData paymentMethodData)? affirm,TResult? Function( PaymentMethodData paymentMethodData)? grabPay,TResult? Function( PaymentMethodData paymentMethodData)? p24,TResult? Function( PaymentMethodDataFpx paymentMethodData)? fpx,TResult? Function( PaymentMethodDataSepa paymentMethodData)? sepaDebit,TResult? Function( PaymentMethodDataAfterPay paymentMethodData)? afterpayClearpay,TResult? Function( PaymentMethodData paymentMethodData)? oxxo,TResult? Function( PaymentMethodData paymentMethodData)? klarna,TResult? Function( PaymentMethodData paymentMethodData)? payPal,TResult? Function( PaymentMethodData paymentMethodData)? revolutPay,TResult? Function( PaymentMethodDataUsBank paymentMethodData)? usBankAccount,}) {final _that = this; +@optionalTypeArgs TResult? whenOrNull({TResult? Function( PaymentMethodData paymentMethodData)? card,TResult? Function( PaymentMethodDataCardFromToken paymentMethodData)? cardFromToken,TResult? Function( PaymentMethodDataCardFromMethod paymentMethodData)? cardFromMethodId,TResult? Function( PaymentMethodData paymentMethodData)? alipay,TResult? Function( PaymentMethodData paymentMethodData)? cashAppPay,TResult? Function( PaymentMethodDataIdeal paymentMethodData)? ideal,TResult? Function( PaymentMethodDataAubecs paymentMethodData)? aubecs,TResult? Function( PaymentMethodData paymentMethodData)? bancontact,TResult? Function( PaymentMethodData paymentMethodData)? giroPay,TResult? Function( PaymentMethodData paymentMethodData)? eps,TResult? Function( PaymentMethodData paymentMethodData)? affirm,TResult? Function( PaymentMethodData paymentMethodData)? grabPay,TResult? Function( PaymentMethodData paymentMethodData)? p24,TResult? Function( PaymentMethodDataFpx paymentMethodData)? fpx,TResult? Function( PaymentMethodDataSepa paymentMethodData)? sepaDebit,TResult? Function( PaymentMethodDataAfterPay paymentMethodData)? afterpayClearpay,TResult? Function( PaymentMethodData paymentMethodData)? oxxo,TResult? Function( PaymentMethodData paymentMethodData)? klarna,TResult? Function( PaymentMethodData paymentMethodData)? payPal,TResult? Function( PaymentMethodData paymentMethodData)? revolutPay,TResult? Function( PaymentMethodDataUsBank paymentMethodData)? usBankAccount,TResult? Function( PaymentMethodData paymentMethodData)? billie,}) {final _that = this; switch (_that) { case _PaymentMethodParamsCard() when card != null: return card(_that.paymentMethodData);case _PaymentMethodParamsCardWithToken() when cardFromToken != null: @@ -3464,7 +3473,8 @@ return oxxo(_that.paymentMethodData);case _PaymentMethodParamsKlarna() when klar return klarna(_that.paymentMethodData);case _PaymentMethodParamsPayPal() when payPal != null: return payPal(_that.paymentMethodData);case _PaymentMethodParamsRevolutPay() when revolutPay != null: return revolutPay(_that.paymentMethodData);case _PaymentMethodParamsUsBankAccount() when usBankAccount != null: -return usBankAccount(_that.paymentMethodData);case _: +return usBankAccount(_that.paymentMethodData);case _PaymentMethodParamsBillie() when billie != null: +return billie(_that.paymentMethodData);case _: return null; } @@ -4891,8 +4901,6 @@ class _PaymentMethodParamsKlarna implements PaymentMethodParams { /// Paymentmethod data for this paymentmethod. /// -/// Make sure to add an email and country (part of the address) in the -/// billingdetails which is required for using Klarna. @override final PaymentMethodData paymentMethodData; @JsonKey(name: 'paymentMethodType') @@ -5217,6 +5225,88 @@ $PaymentMethodDataUsBankCopyWith<$Res> get paymentMethodData { } } +/// @nodoc + +@JsonSerializable(explicitToJson: true) +class _PaymentMethodParamsBillie implements PaymentMethodParams { + _PaymentMethodParamsBillie({required this.paymentMethodData, final String? $type}): $type = $type ?? 'Billie'; + factory _PaymentMethodParamsBillie.fromJson(Map json) => _$PaymentMethodParamsBillieFromJson(json); + +@override final PaymentMethodData paymentMethodData; + +@JsonKey(name: 'paymentMethodType') +final String $type; + + +/// Create a copy of PaymentMethodParams +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PaymentMethodParamsBillieCopyWith<_PaymentMethodParamsBillie> get copyWith => __$PaymentMethodParamsBillieCopyWithImpl<_PaymentMethodParamsBillie>(this, _$identity); + +@override +Map toJson() { + return _$PaymentMethodParamsBillieToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PaymentMethodParamsBillie&&(identical(other.paymentMethodData, paymentMethodData) || other.paymentMethodData == paymentMethodData)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,paymentMethodData); + +@override +String toString() { + return 'PaymentMethodParams.billie(paymentMethodData: $paymentMethodData)'; +} + + +} + +/// @nodoc +abstract mixin class _$PaymentMethodParamsBillieCopyWith<$Res> implements $PaymentMethodParamsCopyWith<$Res> { + factory _$PaymentMethodParamsBillieCopyWith(_PaymentMethodParamsBillie value, $Res Function(_PaymentMethodParamsBillie) _then) = __$PaymentMethodParamsBillieCopyWithImpl; +@useResult +$Res call({ + PaymentMethodData paymentMethodData +}); + + +$PaymentMethodDataCopyWith<$Res> get paymentMethodData; + +} +/// @nodoc +class __$PaymentMethodParamsBillieCopyWithImpl<$Res> + implements _$PaymentMethodParamsBillieCopyWith<$Res> { + __$PaymentMethodParamsBillieCopyWithImpl(this._self, this._then); + + final _PaymentMethodParamsBillie _self; + final $Res Function(_PaymentMethodParamsBillie) _then; + +/// Create a copy of PaymentMethodParams +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? paymentMethodData = null,}) { + return _then(_PaymentMethodParamsBillie( +paymentMethodData: null == paymentMethodData ? _self.paymentMethodData : paymentMethodData // ignore: cast_nullable_to_non_nullable +as PaymentMethodData, + )); +} + +/// Create a copy of PaymentMethodParams +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$PaymentMethodDataCopyWith<$Res> get paymentMethodData { + + return $PaymentMethodDataCopyWith<$Res>(_self.paymentMethodData, (value) { + return _then(_self.copyWith(paymentMethodData: value)); + }); +} +} + /// @nodoc mixin _$PaymentMethodData { diff --git a/packages/stripe_platform_interface/lib/src/models/payment_methods.g.dart b/packages/stripe_platform_interface/lib/src/models/payment_methods.g.dart index cc33d1b64..c695f9b03 100644 --- a/packages/stripe_platform_interface/lib/src/models/payment_methods.g.dart +++ b/packages/stripe_platform_interface/lib/src/models/payment_methods.g.dart @@ -545,6 +545,22 @@ Map _$PaymentMethodParamsUsBankAccountToJson( 'paymentMethodType': instance.$type, }; +_PaymentMethodParamsBillie _$PaymentMethodParamsBillieFromJson( + Map json, +) => _PaymentMethodParamsBillie( + paymentMethodData: PaymentMethodData.fromJson( + json['paymentMethodData'] as Map, + ), + $type: json['paymentMethodType'] as String?, +); + +Map _$PaymentMethodParamsBillieToJson( + _PaymentMethodParamsBillie instance, +) => { + 'paymentMethodData': instance.paymentMethodData.toJson(), + 'paymentMethodType': instance.$type, +}; + _PaymentMethodData _$PaymentMethodDataFromJson(Map json) => _PaymentMethodData( billingDetails: json['billingDetails'] == null diff --git a/packages/stripe_platform_interface/lib/src/models/payment_sheet.dart b/packages/stripe_platform_interface/lib/src/models/payment_sheet.dart index e6fcb6101..a109f623d 100644 --- a/packages/stripe_platform_interface/lib/src/models/payment_sheet.dart +++ b/packages/stripe_platform_interface/lib/src/models/payment_sheet.dart @@ -443,6 +443,15 @@ abstract class PaymentSheetPrimaryButtonThemeColors /// Primary button border color @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border, + + /// The background color of the primary button when in a success state. + @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) + Color? successBackgroundColor, + + /// The text color of the primary button when in a success state. Supports both single color strings and light/dark color objects. + @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) + Color? successTextColor, + }) = _PaymentSheetPrimaryButtonThemeColors; factory PaymentSheetPrimaryButtonThemeColors.fromJson( @@ -706,9 +715,9 @@ enum RowStyle { /// A flat style with a checkmark flatWithCheckmark, - /// A flat style with a chevron + /// A flat style with a disclosure /// Note that the EmbeddedPaymentElementConfiguration.rowSelectionBehavior must be set to `immediateAction` to use this style. - flatWithChevron, + flatWithDisclosure, } /// Describes the appearance of the radio button @@ -743,17 +752,17 @@ abstract class CheckmarkConfig with _$CheckmarkConfig { _$CheckmarkConfigFromJson(json); } -/// Describes the appearance of the chevron +/// Describes the appearance of the disclosure indicator @freezed -abstract class ChevronConfig with _$ChevronConfig { - const factory ChevronConfig({ - /// The color of the chevron, represented as a hex string #AARRGGBB or #RRGGBB. +abstract class DisclosureConfig with _$DisclosureConfig { + const factory DisclosureConfig({ + /// The color of the disclosure indicator, represented as a hex string #AARRGGBB or #RRGGBB. /// @default The iOS or Android system gray color @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? color, - }) = _ChevronConfig; + }) = _DisclosureConfig; - factory ChevronConfig.fromJson(Map json) => - _$ChevronConfigFromJson(json); + factory DisclosureConfig.fromJson(Map json) => + _$DisclosureConfigFromJson(json); } /// Describes the appearance of the flat style row @@ -771,7 +780,7 @@ abstract class FlatConfig with _$FlatConfig { /// The insets of the separator line between rows. /// @default { top: 0, left: 30, bottom: 0, right: 0 } for RowStyle.FlatWithRadio - /// @default { top: 0, left: 0, bottom: 0, right: 0 } for RowStyle.FlatWithCheckmark, RowStyle.FlatWithChevron, and RowStyle.FloatingButton + /// @default { top: 0, left: 0, bottom: 0, right: 0 } for RowStyle.FlatWithCheckmark, RowStyle.FlatWithDisclosuse, and RowStyle.FloatingButton EdgeInsetsConfig? separatorInsets, /// Determines if the top separator is visible at the top of the Element. @@ -788,8 +797,8 @@ abstract class FlatConfig with _$FlatConfig { /// Appearance settings for the checkmark (used when RowStyle is FlatWithCheckmark) CheckmarkConfig? checkmark, - /// Appearance settings for the chevron (used when RowStyle is FlatWithChevron) - ChevronConfig? chevron, + /// Appearance settings for the disclosure indicator (used when RowStyle is FlatWithDisclosure) + DisclosureConfig? disclosure, }) = _FlatConfig; factory FlatConfig.fromJson(Map json) => diff --git a/packages/stripe_platform_interface/lib/src/models/payment_sheet.freezed.dart b/packages/stripe_platform_interface/lib/src/models/payment_sheet.freezed.dart index bba420e71..1227cd487 100644 --- a/packages/stripe_platform_interface/lib/src/models/payment_sheet.freezed.dart +++ b/packages/stripe_platform_interface/lib/src/models/payment_sheet.freezed.dart @@ -4563,7 +4563,9 @@ mixin _$PaymentSheetPrimaryButtonThemeColors { /// Primary button background color @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? get background;/// Primary button text color @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? get text;/// Primary button border color -@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? get border; +@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? get border;/// The background color of the primary button when in a success state. +@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? get successBackgroundColor;/// The text color of the primary button when in a success state. Supports both single color strings and light/dark color objects. +@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? get successTextColor; /// Create a copy of PaymentSheetPrimaryButtonThemeColors /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -4576,16 +4578,16 @@ $PaymentSheetPrimaryButtonThemeColorsCopyWith Object.hash(runtimeType,background,text,border); +int get hashCode => Object.hash(runtimeType,background,text,border,successBackgroundColor,successTextColor); @override String toString() { - return 'PaymentSheetPrimaryButtonThemeColors(background: $background, text: $text, border: $border)'; + return 'PaymentSheetPrimaryButtonThemeColors(background: $background, text: $text, border: $border, successBackgroundColor: $successBackgroundColor, successTextColor: $successTextColor)'; } @@ -4596,7 +4598,7 @@ abstract mixin class $PaymentSheetPrimaryButtonThemeColorsCopyWith<$Res> { factory $PaymentSheetPrimaryButtonThemeColorsCopyWith(PaymentSheetPrimaryButtonThemeColors value, $Res Function(PaymentSheetPrimaryButtonThemeColors) _then) = _$PaymentSheetPrimaryButtonThemeColorsCopyWithImpl; @useResult $Res call({ -@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? background,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? text,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border +@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? background,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? text,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? successBackgroundColor,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? successTextColor }); @@ -4613,11 +4615,13 @@ class _$PaymentSheetPrimaryButtonThemeColorsCopyWithImpl<$Res> /// Create a copy of PaymentSheetPrimaryButtonThemeColors /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? background = freezed,Object? text = freezed,Object? border = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? background = freezed,Object? text = freezed,Object? border = freezed,Object? successBackgroundColor = freezed,Object? successTextColor = freezed,}) { return _then(_self.copyWith( background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable as Color?,text: freezed == text ? _self.text : text // ignore: cast_nullable_to_non_nullable as Color?,border: freezed == border ? _self.border : border // ignore: cast_nullable_to_non_nullable +as Color?,successBackgroundColor: freezed == successBackgroundColor ? _self.successBackgroundColor : successBackgroundColor // ignore: cast_nullable_to_non_nullable +as Color?,successTextColor: freezed == successTextColor ? _self.successTextColor : successTextColor // ignore: cast_nullable_to_non_nullable as Color?, )); } @@ -4703,10 +4707,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function(@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? background, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? text, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function(@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? background, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? text, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? successBackgroundColor, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? successTextColor)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _PaymentSheetPrimaryButtonThemeColors() when $default != null: -return $default(_that.background,_that.text,_that.border);case _: +return $default(_that.background,_that.text,_that.border,_that.successBackgroundColor,_that.successTextColor);case _: return orElse(); } @@ -4724,10 +4728,10 @@ return $default(_that.background,_that.text,_that.border);case _: /// } /// ``` -@optionalTypeArgs TResult when(TResult Function(@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? background, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? text, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function(@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? background, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? text, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? successBackgroundColor, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? successTextColor) $default,) {final _that = this; switch (_that) { case _PaymentSheetPrimaryButtonThemeColors(): -return $default(_that.background,_that.text,_that.border);case _: +return $default(_that.background,_that.text,_that.border,_that.successBackgroundColor,_that.successTextColor);case _: throw StateError('Unexpected subclass'); } @@ -4744,10 +4748,10 @@ return $default(_that.background,_that.text,_that.border);case _: /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function(@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? background, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? text, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function(@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? background, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? text, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? successBackgroundColor, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? successTextColor)? $default,) {final _that = this; switch (_that) { case _PaymentSheetPrimaryButtonThemeColors() when $default != null: -return $default(_that.background,_that.text,_that.border);case _: +return $default(_that.background,_that.text,_that.border,_that.successBackgroundColor,_that.successTextColor);case _: return null; } @@ -4759,7 +4763,7 @@ return $default(_that.background,_that.text,_that.border);case _: @JsonSerializable() class _PaymentSheetPrimaryButtonThemeColors implements PaymentSheetPrimaryButtonThemeColors { - const _PaymentSheetPrimaryButtonThemeColors({@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.background, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.text, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.border}); + const _PaymentSheetPrimaryButtonThemeColors({@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.background, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.text, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.border, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.successBackgroundColor, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.successTextColor}); factory _PaymentSheetPrimaryButtonThemeColors.fromJson(Map json) => _$PaymentSheetPrimaryButtonThemeColorsFromJson(json); /// Primary button background color @@ -4768,6 +4772,10 @@ class _PaymentSheetPrimaryButtonThemeColors implements PaymentSheetPrimaryButton @override@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) final Color? text; /// Primary button border color @override@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) final Color? border; +/// The background color of the primary button when in a success state. +@override@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) final Color? successBackgroundColor; +/// The text color of the primary button when in a success state. Supports both single color strings and light/dark color objects. +@override@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) final Color? successTextColor; /// Create a copy of PaymentSheetPrimaryButtonThemeColors /// with the given fields replaced by the non-null parameter values. @@ -4782,16 +4790,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _PaymentSheetPrimaryButtonThemeColors&&(identical(other.background, background) || other.background == background)&&(identical(other.text, text) || other.text == text)&&(identical(other.border, border) || other.border == border)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PaymentSheetPrimaryButtonThemeColors&&(identical(other.background, background) || other.background == background)&&(identical(other.text, text) || other.text == text)&&(identical(other.border, border) || other.border == border)&&(identical(other.successBackgroundColor, successBackgroundColor) || other.successBackgroundColor == successBackgroundColor)&&(identical(other.successTextColor, successTextColor) || other.successTextColor == successTextColor)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,background,text,border); +int get hashCode => Object.hash(runtimeType,background,text,border,successBackgroundColor,successTextColor); @override String toString() { - return 'PaymentSheetPrimaryButtonThemeColors(background: $background, text: $text, border: $border)'; + return 'PaymentSheetPrimaryButtonThemeColors(background: $background, text: $text, border: $border, successBackgroundColor: $successBackgroundColor, successTextColor: $successTextColor)'; } @@ -4802,7 +4810,7 @@ abstract mixin class _$PaymentSheetPrimaryButtonThemeColorsCopyWith<$Res> implem factory _$PaymentSheetPrimaryButtonThemeColorsCopyWith(_PaymentSheetPrimaryButtonThemeColors value, $Res Function(_PaymentSheetPrimaryButtonThemeColors) _then) = __$PaymentSheetPrimaryButtonThemeColorsCopyWithImpl; @override @useResult $Res call({ -@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? background,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? text,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border +@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? background,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? text,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? border,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? successBackgroundColor,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? successTextColor }); @@ -4819,11 +4827,13 @@ class __$PaymentSheetPrimaryButtonThemeColorsCopyWithImpl<$Res> /// Create a copy of PaymentSheetPrimaryButtonThemeColors /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? background = freezed,Object? text = freezed,Object? border = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? background = freezed,Object? text = freezed,Object? border = freezed,Object? successBackgroundColor = freezed,Object? successTextColor = freezed,}) { return _then(_PaymentSheetPrimaryButtonThemeColors( background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable as Color?,text: freezed == text ? _self.text : text // ignore: cast_nullable_to_non_nullable as Color?,border: freezed == border ? _self.border : border // ignore: cast_nullable_to_non_nullable +as Color?,successBackgroundColor: freezed == successBackgroundColor ? _self.successBackgroundColor : successBackgroundColor // ignore: cast_nullable_to_non_nullable +as Color?,successTextColor: freezed == successTextColor ? _self.successTextColor : successTextColor // ignore: cast_nullable_to_non_nullable as Color?, )); } @@ -7514,24 +7524,24 @@ as Color?, /// @nodoc -mixin _$ChevronConfig { +mixin _$DisclosureConfig { -/// The color of the chevron, represented as a hex string #AARRGGBB or #RRGGBB. +/// The color of the disclosure indicator, represented as a hex string #AARRGGBB or #RRGGBB. /// @default The iOS or Android system gray color @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? get color; -/// Create a copy of ChevronConfig +/// Create a copy of DisclosureConfig /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @pragma('vm:prefer-inline') -$ChevronConfigCopyWith get copyWith => _$ChevronConfigCopyWithImpl(this as ChevronConfig, _$identity); +$DisclosureConfigCopyWith get copyWith => _$DisclosureConfigCopyWithImpl(this as DisclosureConfig, _$identity); - /// Serializes this ChevronConfig to a JSON map. + /// Serializes this DisclosureConfig to a JSON map. Map toJson(); @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is ChevronConfig&&(identical(other.color, color) || other.color == color)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is DisclosureConfig&&(identical(other.color, color) || other.color == color)); } @JsonKey(includeFromJson: false, includeToJson: false) @@ -7540,15 +7550,15 @@ int get hashCode => Object.hash(runtimeType,color); @override String toString() { - return 'ChevronConfig(color: $color)'; + return 'DisclosureConfig(color: $color)'; } } /// @nodoc -abstract mixin class $ChevronConfigCopyWith<$Res> { - factory $ChevronConfigCopyWith(ChevronConfig value, $Res Function(ChevronConfig) _then) = _$ChevronConfigCopyWithImpl; +abstract mixin class $DisclosureConfigCopyWith<$Res> { + factory $DisclosureConfigCopyWith(DisclosureConfig value, $Res Function(DisclosureConfig) _then) = _$DisclosureConfigCopyWithImpl; @useResult $Res call({ @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? color @@ -7559,14 +7569,14 @@ $Res call({ } /// @nodoc -class _$ChevronConfigCopyWithImpl<$Res> - implements $ChevronConfigCopyWith<$Res> { - _$ChevronConfigCopyWithImpl(this._self, this._then); +class _$DisclosureConfigCopyWithImpl<$Res> + implements $DisclosureConfigCopyWith<$Res> { + _$DisclosureConfigCopyWithImpl(this._self, this._then); - final ChevronConfig _self; - final $Res Function(ChevronConfig) _then; + final DisclosureConfig _self; + final $Res Function(DisclosureConfig) _then; -/// Create a copy of ChevronConfig +/// Create a copy of DisclosureConfig /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({Object? color = freezed,}) { return _then(_self.copyWith( @@ -7578,8 +7588,8 @@ as Color?, } -/// Adds pattern-matching-related methods to [ChevronConfig]. -extension ChevronConfigPatterns on ChevronConfig { +/// Adds pattern-matching-related methods to [DisclosureConfig]. +extension DisclosureConfigPatterns on DisclosureConfig { /// A variant of `map` that fallback to returning `orElse`. /// /// It is equivalent to doing: @@ -7592,10 +7602,10 @@ extension ChevronConfigPatterns on ChevronConfig { /// } /// ``` -@optionalTypeArgs TResult maybeMap(TResult Function( _ChevronConfig value)? $default,{required TResult orElse(),}){ +@optionalTypeArgs TResult maybeMap(TResult Function( _DisclosureConfig value)? $default,{required TResult orElse(),}){ final _that = this; switch (_that) { -case _ChevronConfig() when $default != null: +case _DisclosureConfig() when $default != null: return $default(_that);case _: return orElse(); @@ -7614,10 +7624,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult map(TResult Function( _ChevronConfig value) $default,){ +@optionalTypeArgs TResult map(TResult Function( _DisclosureConfig value) $default,){ final _that = this; switch (_that) { -case _ChevronConfig(): +case _DisclosureConfig(): return $default(_that);case _: throw StateError('Unexpected subclass'); @@ -7635,10 +7645,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult? mapOrNull(TResult? Function( _ChevronConfig value)? $default,){ +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _DisclosureConfig value)? $default,){ final _that = this; switch (_that) { -case _ChevronConfig() when $default != null: +case _DisclosureConfig() when $default != null: return $default(_that);case _: return null; @@ -7658,7 +7668,7 @@ return $default(_that);case _: @optionalTypeArgs TResult maybeWhen(TResult Function(@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? color)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { -case _ChevronConfig() when $default != null: +case _DisclosureConfig() when $default != null: return $default(_that.color);case _: return orElse(); @@ -7679,7 +7689,7 @@ return $default(_that.color);case _: @optionalTypeArgs TResult when(TResult Function(@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? color) $default,) {final _that = this; switch (_that) { -case _ChevronConfig(): +case _DisclosureConfig(): return $default(_that.color);case _: throw StateError('Unexpected subclass'); @@ -7699,7 +7709,7 @@ return $default(_that.color);case _: @optionalTypeArgs TResult? whenOrNull(TResult? Function(@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? color)? $default,) {final _that = this; switch (_that) { -case _ChevronConfig() when $default != null: +case _DisclosureConfig() when $default != null: return $default(_that.color);case _: return null; @@ -7711,28 +7721,28 @@ return $default(_that.color);case _: /// @nodoc @JsonSerializable() -class _ChevronConfig implements ChevronConfig { - const _ChevronConfig({@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.color}); - factory _ChevronConfig.fromJson(Map json) => _$ChevronConfigFromJson(json); +class _DisclosureConfig implements DisclosureConfig { + const _DisclosureConfig({@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.color}); + factory _DisclosureConfig.fromJson(Map json) => _$DisclosureConfigFromJson(json); -/// The color of the chevron, represented as a hex string #AARRGGBB or #RRGGBB. +/// The color of the disclosure indicator, represented as a hex string #AARRGGBB or #RRGGBB. /// @default The iOS or Android system gray color @override@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) final Color? color; -/// Create a copy of ChevronConfig +/// Create a copy of DisclosureConfig /// with the given fields replaced by the non-null parameter values. @override @JsonKey(includeFromJson: false, includeToJson: false) @pragma('vm:prefer-inline') -_$ChevronConfigCopyWith<_ChevronConfig> get copyWith => __$ChevronConfigCopyWithImpl<_ChevronConfig>(this, _$identity); +_$DisclosureConfigCopyWith<_DisclosureConfig> get copyWith => __$DisclosureConfigCopyWithImpl<_DisclosureConfig>(this, _$identity); @override Map toJson() { - return _$ChevronConfigToJson(this, ); + return _$DisclosureConfigToJson(this, ); } @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChevronConfig&&(identical(other.color, color) || other.color == color)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _DisclosureConfig&&(identical(other.color, color) || other.color == color)); } @JsonKey(includeFromJson: false, includeToJson: false) @@ -7741,15 +7751,15 @@ int get hashCode => Object.hash(runtimeType,color); @override String toString() { - return 'ChevronConfig(color: $color)'; + return 'DisclosureConfig(color: $color)'; } } /// @nodoc -abstract mixin class _$ChevronConfigCopyWith<$Res> implements $ChevronConfigCopyWith<$Res> { - factory _$ChevronConfigCopyWith(_ChevronConfig value, $Res Function(_ChevronConfig) _then) = __$ChevronConfigCopyWithImpl; +abstract mixin class _$DisclosureConfigCopyWith<$Res> implements $DisclosureConfigCopyWith<$Res> { + factory _$DisclosureConfigCopyWith(_DisclosureConfig value, $Res Function(_DisclosureConfig) _then) = __$DisclosureConfigCopyWithImpl; @override @useResult $Res call({ @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? color @@ -7760,17 +7770,17 @@ $Res call({ } /// @nodoc -class __$ChevronConfigCopyWithImpl<$Res> - implements _$ChevronConfigCopyWith<$Res> { - __$ChevronConfigCopyWithImpl(this._self, this._then); +class __$DisclosureConfigCopyWithImpl<$Res> + implements _$DisclosureConfigCopyWith<$Res> { + __$DisclosureConfigCopyWithImpl(this._self, this._then); - final _ChevronConfig _self; - final $Res Function(_ChevronConfig) _then; + final _DisclosureConfig _self; + final $Res Function(_DisclosureConfig) _then; -/// Create a copy of ChevronConfig +/// Create a copy of DisclosureConfig /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $Res call({Object? color = freezed,}) { - return _then(_ChevronConfig( + return _then(_DisclosureConfig( color: freezed == color ? _self.color : color // ignore: cast_nullable_to_non_nullable as Color?, )); @@ -7789,15 +7799,15 @@ mixin _$FlatConfig { /// @default The root appearance.colors.componentBorder @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? get separatorColor;/// The insets of the separator line between rows. /// @default { top: 0, left: 30, bottom: 0, right: 0 } for RowStyle.FlatWithRadio -/// @default { top: 0, left: 0, bottom: 0, right: 0 } for RowStyle.FlatWithCheckmark, RowStyle.FlatWithChevron, and RowStyle.FloatingButton +/// @default { top: 0, left: 0, bottom: 0, right: 0 } for RowStyle.FlatWithCheckmark, RowStyle.FlatWithDisclosuse, and RowStyle.FloatingButton EdgeInsetsConfig? get separatorInsets;/// Determines if the top separator is visible at the top of the Element. /// @default true bool? get topSeparatorEnabled;/// Determines if the bottom separator is visible at the bottom of the Element. /// @default true bool? get bottomSeparatorEnabled;/// Appearance settings for the radio button (used when RowStyle is FlatWithRadio) RadioConfig? get radio;/// Appearance settings for the checkmark (used when RowStyle is FlatWithCheckmark) - CheckmarkConfig? get checkmark;/// Appearance settings for the chevron (used when RowStyle is FlatWithChevron) - ChevronConfig? get chevron; + CheckmarkConfig? get checkmark;/// Appearance settings for the disclosure indicator (used when RowStyle is FlatWithDisclosure) + DisclosureConfig? get disclosure; /// Create a copy of FlatConfig /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -7810,16 +7820,16 @@ $FlatConfigCopyWith get copyWith => _$FlatConfigCopyWithImpl Object.hash(runtimeType,separatorThickness,separatorColor,separatorInsets,topSeparatorEnabled,bottomSeparatorEnabled,radio,checkmark,chevron); +int get hashCode => Object.hash(runtimeType,separatorThickness,separatorColor,separatorInsets,topSeparatorEnabled,bottomSeparatorEnabled,radio,checkmark,disclosure); @override String toString() { - return 'FlatConfig(separatorThickness: $separatorThickness, separatorColor: $separatorColor, separatorInsets: $separatorInsets, topSeparatorEnabled: $topSeparatorEnabled, bottomSeparatorEnabled: $bottomSeparatorEnabled, radio: $radio, checkmark: $checkmark, chevron: $chevron)'; + return 'FlatConfig(separatorThickness: $separatorThickness, separatorColor: $separatorColor, separatorInsets: $separatorInsets, topSeparatorEnabled: $topSeparatorEnabled, bottomSeparatorEnabled: $bottomSeparatorEnabled, radio: $radio, checkmark: $checkmark, disclosure: $disclosure)'; } @@ -7830,11 +7840,11 @@ abstract mixin class $FlatConfigCopyWith<$Res> { factory $FlatConfigCopyWith(FlatConfig value, $Res Function(FlatConfig) _then) = _$FlatConfigCopyWithImpl; @useResult $Res call({ - double? separatorThickness,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? separatorColor, EdgeInsetsConfig? separatorInsets, bool? topSeparatorEnabled, bool? bottomSeparatorEnabled, RadioConfig? radio, CheckmarkConfig? checkmark, ChevronConfig? chevron + double? separatorThickness,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? separatorColor, EdgeInsetsConfig? separatorInsets, bool? topSeparatorEnabled, bool? bottomSeparatorEnabled, RadioConfig? radio, CheckmarkConfig? checkmark, DisclosureConfig? disclosure }); -$EdgeInsetsConfigCopyWith<$Res>? get separatorInsets;$RadioConfigCopyWith<$Res>? get radio;$CheckmarkConfigCopyWith<$Res>? get checkmark;$ChevronConfigCopyWith<$Res>? get chevron; +$EdgeInsetsConfigCopyWith<$Res>? get separatorInsets;$RadioConfigCopyWith<$Res>? get radio;$CheckmarkConfigCopyWith<$Res>? get checkmark;$DisclosureConfigCopyWith<$Res>? get disclosure; } /// @nodoc @@ -7847,7 +7857,7 @@ class _$FlatConfigCopyWithImpl<$Res> /// Create a copy of FlatConfig /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? separatorThickness = freezed,Object? separatorColor = freezed,Object? separatorInsets = freezed,Object? topSeparatorEnabled = freezed,Object? bottomSeparatorEnabled = freezed,Object? radio = freezed,Object? checkmark = freezed,Object? chevron = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? separatorThickness = freezed,Object? separatorColor = freezed,Object? separatorInsets = freezed,Object? topSeparatorEnabled = freezed,Object? bottomSeparatorEnabled = freezed,Object? radio = freezed,Object? checkmark = freezed,Object? disclosure = freezed,}) { return _then(_self.copyWith( separatorThickness: freezed == separatorThickness ? _self.separatorThickness : separatorThickness // ignore: cast_nullable_to_non_nullable as double?,separatorColor: freezed == separatorColor ? _self.separatorColor : separatorColor // ignore: cast_nullable_to_non_nullable @@ -7856,8 +7866,8 @@ as EdgeInsetsConfig?,topSeparatorEnabled: freezed == topSeparatorEnabled ? _self as bool?,bottomSeparatorEnabled: freezed == bottomSeparatorEnabled ? _self.bottomSeparatorEnabled : bottomSeparatorEnabled // ignore: cast_nullable_to_non_nullable as bool?,radio: freezed == radio ? _self.radio : radio // ignore: cast_nullable_to_non_nullable as RadioConfig?,checkmark: freezed == checkmark ? _self.checkmark : checkmark // ignore: cast_nullable_to_non_nullable -as CheckmarkConfig?,chevron: freezed == chevron ? _self.chevron : chevron // ignore: cast_nullable_to_non_nullable -as ChevronConfig?, +as CheckmarkConfig?,disclosure: freezed == disclosure ? _self.disclosure : disclosure // ignore: cast_nullable_to_non_nullable +as DisclosureConfig?, )); } /// Create a copy of FlatConfig @@ -7900,13 +7910,13 @@ $CheckmarkConfigCopyWith<$Res>? get checkmark { /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') -$ChevronConfigCopyWith<$Res>? get chevron { - if (_self.chevron == null) { +$DisclosureConfigCopyWith<$Res>? get disclosure { + if (_self.disclosure == null) { return null; } - return $ChevronConfigCopyWith<$Res>(_self.chevron!, (value) { - return _then(_self.copyWith(chevron: value)); + return $DisclosureConfigCopyWith<$Res>(_self.disclosure!, (value) { + return _then(_self.copyWith(disclosure: value)); }); } } @@ -7990,10 +8000,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( double? separatorThickness, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? separatorColor, EdgeInsetsConfig? separatorInsets, bool? topSeparatorEnabled, bool? bottomSeparatorEnabled, RadioConfig? radio, CheckmarkConfig? checkmark, ChevronConfig? chevron)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( double? separatorThickness, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? separatorColor, EdgeInsetsConfig? separatorInsets, bool? topSeparatorEnabled, bool? bottomSeparatorEnabled, RadioConfig? radio, CheckmarkConfig? checkmark, DisclosureConfig? disclosure)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _FlatConfig() when $default != null: -return $default(_that.separatorThickness,_that.separatorColor,_that.separatorInsets,_that.topSeparatorEnabled,_that.bottomSeparatorEnabled,_that.radio,_that.checkmark,_that.chevron);case _: +return $default(_that.separatorThickness,_that.separatorColor,_that.separatorInsets,_that.topSeparatorEnabled,_that.bottomSeparatorEnabled,_that.radio,_that.checkmark,_that.disclosure);case _: return orElse(); } @@ -8011,10 +8021,10 @@ return $default(_that.separatorThickness,_that.separatorColor,_that.separatorIns /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( double? separatorThickness, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? separatorColor, EdgeInsetsConfig? separatorInsets, bool? topSeparatorEnabled, bool? bottomSeparatorEnabled, RadioConfig? radio, CheckmarkConfig? checkmark, ChevronConfig? chevron) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( double? separatorThickness, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? separatorColor, EdgeInsetsConfig? separatorInsets, bool? topSeparatorEnabled, bool? bottomSeparatorEnabled, RadioConfig? radio, CheckmarkConfig? checkmark, DisclosureConfig? disclosure) $default,) {final _that = this; switch (_that) { case _FlatConfig(): -return $default(_that.separatorThickness,_that.separatorColor,_that.separatorInsets,_that.topSeparatorEnabled,_that.bottomSeparatorEnabled,_that.radio,_that.checkmark,_that.chevron);case _: +return $default(_that.separatorThickness,_that.separatorColor,_that.separatorInsets,_that.topSeparatorEnabled,_that.bottomSeparatorEnabled,_that.radio,_that.checkmark,_that.disclosure);case _: throw StateError('Unexpected subclass'); } @@ -8031,10 +8041,10 @@ return $default(_that.separatorThickness,_that.separatorColor,_that.separatorIns /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( double? separatorThickness, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? separatorColor, EdgeInsetsConfig? separatorInsets, bool? topSeparatorEnabled, bool? bottomSeparatorEnabled, RadioConfig? radio, CheckmarkConfig? checkmark, ChevronConfig? chevron)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( double? separatorThickness, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? separatorColor, EdgeInsetsConfig? separatorInsets, bool? topSeparatorEnabled, bool? bottomSeparatorEnabled, RadioConfig? radio, CheckmarkConfig? checkmark, DisclosureConfig? disclosure)? $default,) {final _that = this; switch (_that) { case _FlatConfig() when $default != null: -return $default(_that.separatorThickness,_that.separatorColor,_that.separatorInsets,_that.topSeparatorEnabled,_that.bottomSeparatorEnabled,_that.radio,_that.checkmark,_that.chevron);case _: +return $default(_that.separatorThickness,_that.separatorColor,_that.separatorInsets,_that.topSeparatorEnabled,_that.bottomSeparatorEnabled,_that.radio,_that.checkmark,_that.disclosure);case _: return null; } @@ -8046,7 +8056,7 @@ return $default(_that.separatorThickness,_that.separatorColor,_that.separatorIns @JsonSerializable() class _FlatConfig implements FlatConfig { - const _FlatConfig({this.separatorThickness, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.separatorColor, this.separatorInsets, this.topSeparatorEnabled, this.bottomSeparatorEnabled, this.radio, this.checkmark, this.chevron}); + const _FlatConfig({this.separatorThickness, @JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) this.separatorColor, this.separatorInsets, this.topSeparatorEnabled, this.bottomSeparatorEnabled, this.radio, this.checkmark, this.disclosure}); factory _FlatConfig.fromJson(Map json) => _$FlatConfigFromJson(json); /// The thickness of the separator line between rows. @@ -8057,7 +8067,7 @@ class _FlatConfig implements FlatConfig { @override@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) final Color? separatorColor; /// The insets of the separator line between rows. /// @default { top: 0, left: 30, bottom: 0, right: 0 } for RowStyle.FlatWithRadio -/// @default { top: 0, left: 0, bottom: 0, right: 0 } for RowStyle.FlatWithCheckmark, RowStyle.FlatWithChevron, and RowStyle.FloatingButton +/// @default { top: 0, left: 0, bottom: 0, right: 0 } for RowStyle.FlatWithCheckmark, RowStyle.FlatWithDisclosuse, and RowStyle.FloatingButton @override final EdgeInsetsConfig? separatorInsets; /// Determines if the top separator is visible at the top of the Element. /// @default true @@ -8069,8 +8079,8 @@ class _FlatConfig implements FlatConfig { @override final RadioConfig? radio; /// Appearance settings for the checkmark (used when RowStyle is FlatWithCheckmark) @override final CheckmarkConfig? checkmark; -/// Appearance settings for the chevron (used when RowStyle is FlatWithChevron) -@override final ChevronConfig? chevron; +/// Appearance settings for the disclosure indicator (used when RowStyle is FlatWithDisclosure) +@override final DisclosureConfig? disclosure; /// Create a copy of FlatConfig /// with the given fields replaced by the non-null parameter values. @@ -8085,16 +8095,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _FlatConfig&&(identical(other.separatorThickness, separatorThickness) || other.separatorThickness == separatorThickness)&&(identical(other.separatorColor, separatorColor) || other.separatorColor == separatorColor)&&(identical(other.separatorInsets, separatorInsets) || other.separatorInsets == separatorInsets)&&(identical(other.topSeparatorEnabled, topSeparatorEnabled) || other.topSeparatorEnabled == topSeparatorEnabled)&&(identical(other.bottomSeparatorEnabled, bottomSeparatorEnabled) || other.bottomSeparatorEnabled == bottomSeparatorEnabled)&&(identical(other.radio, radio) || other.radio == radio)&&(identical(other.checkmark, checkmark) || other.checkmark == checkmark)&&(identical(other.chevron, chevron) || other.chevron == chevron)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _FlatConfig&&(identical(other.separatorThickness, separatorThickness) || other.separatorThickness == separatorThickness)&&(identical(other.separatorColor, separatorColor) || other.separatorColor == separatorColor)&&(identical(other.separatorInsets, separatorInsets) || other.separatorInsets == separatorInsets)&&(identical(other.topSeparatorEnabled, topSeparatorEnabled) || other.topSeparatorEnabled == topSeparatorEnabled)&&(identical(other.bottomSeparatorEnabled, bottomSeparatorEnabled) || other.bottomSeparatorEnabled == bottomSeparatorEnabled)&&(identical(other.radio, radio) || other.radio == radio)&&(identical(other.checkmark, checkmark) || other.checkmark == checkmark)&&(identical(other.disclosure, disclosure) || other.disclosure == disclosure)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,separatorThickness,separatorColor,separatorInsets,topSeparatorEnabled,bottomSeparatorEnabled,radio,checkmark,chevron); +int get hashCode => Object.hash(runtimeType,separatorThickness,separatorColor,separatorInsets,topSeparatorEnabled,bottomSeparatorEnabled,radio,checkmark,disclosure); @override String toString() { - return 'FlatConfig(separatorThickness: $separatorThickness, separatorColor: $separatorColor, separatorInsets: $separatorInsets, topSeparatorEnabled: $topSeparatorEnabled, bottomSeparatorEnabled: $bottomSeparatorEnabled, radio: $radio, checkmark: $checkmark, chevron: $chevron)'; + return 'FlatConfig(separatorThickness: $separatorThickness, separatorColor: $separatorColor, separatorInsets: $separatorInsets, topSeparatorEnabled: $topSeparatorEnabled, bottomSeparatorEnabled: $bottomSeparatorEnabled, radio: $radio, checkmark: $checkmark, disclosure: $disclosure)'; } @@ -8105,11 +8115,11 @@ abstract mixin class _$FlatConfigCopyWith<$Res> implements $FlatConfigCopyWith<$ factory _$FlatConfigCopyWith(_FlatConfig value, $Res Function(_FlatConfig) _then) = __$FlatConfigCopyWithImpl; @override @useResult $Res call({ - double? separatorThickness,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? separatorColor, EdgeInsetsConfig? separatorInsets, bool? topSeparatorEnabled, bool? bottomSeparatorEnabled, RadioConfig? radio, CheckmarkConfig? checkmark, ChevronConfig? chevron + double? separatorThickness,@JsonKey(toJson: ColorKey.toJson, fromJson: ColorKey.fromJson) Color? separatorColor, EdgeInsetsConfig? separatorInsets, bool? topSeparatorEnabled, bool? bottomSeparatorEnabled, RadioConfig? radio, CheckmarkConfig? checkmark, DisclosureConfig? disclosure }); -@override $EdgeInsetsConfigCopyWith<$Res>? get separatorInsets;@override $RadioConfigCopyWith<$Res>? get radio;@override $CheckmarkConfigCopyWith<$Res>? get checkmark;@override $ChevronConfigCopyWith<$Res>? get chevron; +@override $EdgeInsetsConfigCopyWith<$Res>? get separatorInsets;@override $RadioConfigCopyWith<$Res>? get radio;@override $CheckmarkConfigCopyWith<$Res>? get checkmark;@override $DisclosureConfigCopyWith<$Res>? get disclosure; } /// @nodoc @@ -8122,7 +8132,7 @@ class __$FlatConfigCopyWithImpl<$Res> /// Create a copy of FlatConfig /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? separatorThickness = freezed,Object? separatorColor = freezed,Object? separatorInsets = freezed,Object? topSeparatorEnabled = freezed,Object? bottomSeparatorEnabled = freezed,Object? radio = freezed,Object? checkmark = freezed,Object? chevron = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? separatorThickness = freezed,Object? separatorColor = freezed,Object? separatorInsets = freezed,Object? topSeparatorEnabled = freezed,Object? bottomSeparatorEnabled = freezed,Object? radio = freezed,Object? checkmark = freezed,Object? disclosure = freezed,}) { return _then(_FlatConfig( separatorThickness: freezed == separatorThickness ? _self.separatorThickness : separatorThickness // ignore: cast_nullable_to_non_nullable as double?,separatorColor: freezed == separatorColor ? _self.separatorColor : separatorColor // ignore: cast_nullable_to_non_nullable @@ -8131,8 +8141,8 @@ as EdgeInsetsConfig?,topSeparatorEnabled: freezed == topSeparatorEnabled ? _self as bool?,bottomSeparatorEnabled: freezed == bottomSeparatorEnabled ? _self.bottomSeparatorEnabled : bottomSeparatorEnabled // ignore: cast_nullable_to_non_nullable as bool?,radio: freezed == radio ? _self.radio : radio // ignore: cast_nullable_to_non_nullable as RadioConfig?,checkmark: freezed == checkmark ? _self.checkmark : checkmark // ignore: cast_nullable_to_non_nullable -as CheckmarkConfig?,chevron: freezed == chevron ? _self.chevron : chevron // ignore: cast_nullable_to_non_nullable -as ChevronConfig?, +as CheckmarkConfig?,disclosure: freezed == disclosure ? _self.disclosure : disclosure // ignore: cast_nullable_to_non_nullable +as DisclosureConfig?, )); } @@ -8176,13 +8186,13 @@ $CheckmarkConfigCopyWith<$Res>? get checkmark { /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') -$ChevronConfigCopyWith<$Res>? get chevron { - if (_self.chevron == null) { +$DisclosureConfigCopyWith<$Res>? get disclosure { + if (_self.disclosure == null) { return null; } - return $ChevronConfigCopyWith<$Res>(_self.chevron!, (value) { - return _then(_self.copyWith(chevron: value)); + return $DisclosureConfigCopyWith<$Res>(_self.disclosure!, (value) { + return _then(_self.copyWith(disclosure: value)); }); } } diff --git a/packages/stripe_platform_interface/lib/src/models/payment_sheet.g.dart b/packages/stripe_platform_interface/lib/src/models/payment_sheet.g.dart index 11be97c9a..e457f1fbb 100644 --- a/packages/stripe_platform_interface/lib/src/models/payment_sheet.g.dart +++ b/packages/stripe_platform_interface/lib/src/models/payment_sheet.g.dart @@ -466,6 +466,8 @@ _$PaymentSheetPrimaryButtonThemeColorsFromJson(Map json) => background: ColorKey.fromJson(json['background']), text: ColorKey.fromJson(json['text']), border: ColorKey.fromJson(json['border']), + successBackgroundColor: ColorKey.fromJson(json['successBackgroundColor']), + successTextColor: ColorKey.fromJson(json['successTextColor']), ); Map _$PaymentSheetPrimaryButtonThemeColorsToJson( @@ -474,6 +476,8 @@ Map _$PaymentSheetPrimaryButtonThemeColorsToJson( 'background': ColorKey.toJson(instance.background), 'text': ColorKey.toJson(instance.text), 'border': ColorKey.toJson(instance.border), + 'successBackgroundColor': ColorKey.toJson(instance.successBackgroundColor), + 'successTextColor': ColorKey.toJson(instance.successTextColor), }; _PresentParameters _$PresentParametersFromJson(Map json) => @@ -657,10 +661,10 @@ _CheckmarkConfig _$CheckmarkConfigFromJson(Map json) => Map _$CheckmarkConfigToJson(_CheckmarkConfig instance) => {'color': ColorKey.toJson(instance.color)}; -_ChevronConfig _$ChevronConfigFromJson(Map json) => - _ChevronConfig(color: ColorKey.fromJson(json['color'])); +_DisclosureConfig _$DisclosureConfigFromJson(Map json) => + _DisclosureConfig(color: ColorKey.fromJson(json['color'])); -Map _$ChevronConfigToJson(_ChevronConfig instance) => +Map _$DisclosureConfigToJson(_DisclosureConfig instance) => {'color': ColorKey.toJson(instance.color)}; _FlatConfig _$FlatConfigFromJson(Map json) => _FlatConfig( @@ -679,9 +683,9 @@ _FlatConfig _$FlatConfigFromJson(Map json) => _FlatConfig( checkmark: json['checkmark'] == null ? null : CheckmarkConfig.fromJson(json['checkmark'] as Map), - chevron: json['chevron'] == null + disclosure: json['disclosure'] == null ? null - : ChevronConfig.fromJson(json['chevron'] as Map), + : DisclosureConfig.fromJson(json['disclosure'] as Map), ); Map _$FlatConfigToJson(_FlatConfig instance) => @@ -693,7 +697,7 @@ Map _$FlatConfigToJson(_FlatConfig instance) => 'bottomSeparatorEnabled': instance.bottomSeparatorEnabled, 'radio': instance.radio, 'checkmark': instance.checkmark, - 'chevron': instance.chevron, + 'disclosure': instance.disclosure, }; _FloatingConfig _$FloatingConfigFromJson(Map json) => @@ -725,7 +729,7 @@ const _$RowStyleEnumMap = { RowStyle.flatWithRadio: 'flatWithRadio', RowStyle.floatingButton: 'floatingButton', RowStyle.flatWithCheckmark: 'flatWithCheckmark', - RowStyle.flatWithChevron: 'flatWithChevron', + RowStyle.flatWithDisclosure: 'flatWithDisclosure', }; _EmbeddedPaymentElementAppearance _$EmbeddedPaymentElementAppearanceFromJson( diff --git a/packages/stripe_platform_interface/lib/src/models/platform_pay.freezed.dart b/packages/stripe_platform_interface/lib/src/models/platform_pay.freezed.dart index 14f17ba99..503e7e346 100644 --- a/packages/stripe_platform_interface/lib/src/models/platform_pay.freezed.dart +++ b/packages/stripe_platform_interface/lib/src/models/platform_pay.freezed.dart @@ -1238,10 +1238,7 @@ switch (_that) { case PlatformPayPaymentMethodParamsGooglePay(): return googlePay(_that);case PlatformPayPaymentMethodParamsApplePay(): return applePay(_that);case PlatformPayPaymentMethodParamsWeb(): -return web(_that);case _: - throw StateError('Unexpected subclass'); - -} +return web(_that);} } /// A variant of `map` that fallback to returning `null`. /// @@ -1306,10 +1303,7 @@ switch (_that) { case PlatformPayPaymentMethodParamsGooglePay(): return googlePay(_that.googlePayParams,_that.googlePayPaymentMethodParams);case PlatformPayPaymentMethodParamsApplePay(): return applePay(_that.applePayParams);case PlatformPayPaymentMethodParamsWeb(): -return web(_that.options);case _: - throw StateError('Unexpected subclass'); - -} +return web(_that.options);} } /// A variant of `when` that fallback to returning `null` ///