Follow-up from #2387, which shipped the PaymentMethodMessaging widget as iOS-only.
Why Android was deferred
On Android, Stripe does not expose a PaymentMethodMessagingView. The equivalent is a Compose-based element:
- Class:
com.stripe.android.paymentmethodmessaging.element.PaymentMethodMessagingElement
- Artifact:
com.stripe:payment-method-messaging (separate from com.stripe:stripe-android)
- Visibility: marked
@OptIn(PaymentMethodMessagingElementPreview::class) — preview API
- Usage shape:
val element = PaymentMethodMessagingElement.create(application)
// suspend:
val result: ConfigureResult = element.configure(configuration)
// compose:
@Composable fun X() { element.Content(appearance) }
A correct port requires:
- Adding
implementation \"com.stripe:payment-method-messaging:\$stripe_version\" to packages/stripe_android/android/build.gradle.
- Writing a
PlatformView that embeds a ComposeView, runs element.configure(...) off a coroutine scope, reports height via onSizeChanged, and surfaces ConfigureResult.Succeeded / NoContent / Failed back to Dart.
- Probably bringing in a small
StripeAbstractComposeView-style helper, or rolling a Flutter-specific equivalent (ComposeView under an Android PlatformView). This would be the first Compose-based PlatformView in the repo.
- Possibly extending the Dart model with
locale and appearance fields to match the Android Element API surface (Appearance.theme, Appearance.Colors, Appearance.Font).
Reference
- Upstream stripe-react-native wraps this as
PaymentMethodMessagingElementView.kt + PaymentMethodMessagingElementConfig.kt. See stripe/stripe-react-native@main:android/src/main/java/com/reactnativestripesdk/.
- stripe-android API surface:
stripe/stripe-android@master:payment-method-messaging/api/payment-method-messaging.api.
Current behavior
Until this is implemented, the Dart widget throws UnsupportedError on Android with a pointer back to this issue.
Part of #2378.
Follow-up from #2387, which shipped the
PaymentMethodMessagingwidget as iOS-only.Why Android was deferred
On Android, Stripe does not expose a
PaymentMethodMessagingView. The equivalent is a Compose-based element:com.stripe.android.paymentmethodmessaging.element.PaymentMethodMessagingElementcom.stripe:payment-method-messaging(separate fromcom.stripe:stripe-android)@OptIn(PaymentMethodMessagingElementPreview::class)— preview APIA correct port requires:
implementation \"com.stripe:payment-method-messaging:\$stripe_version\"topackages/stripe_android/android/build.gradle.PlatformViewthat embeds aComposeView, runselement.configure(...)off a coroutine scope, reports height viaonSizeChanged, and surfacesConfigureResult.Succeeded / NoContent / Failedback to Dart.StripeAbstractComposeView-style helper, or rolling a Flutter-specific equivalent (ComposeViewunder an AndroidPlatformView). This would be the first Compose-based PlatformView in the repo.localeand appearance fields to match the Android Element API surface (Appearance.theme,Appearance.Colors,Appearance.Font).Reference
PaymentMethodMessagingElementView.kt+PaymentMethodMessagingElementConfig.kt. Seestripe/stripe-react-native@main:android/src/main/java/com/reactnativestripesdk/.stripe/stripe-android@master:payment-method-messaging/api/payment-method-messaging.api.Current behavior
Until this is implemented, the Dart widget throws
UnsupportedErroron Android with a pointer back to this issue.Part of #2378.