Skip to content

Add Android implementation for PaymentMethodMessaging widget #2402

@realmeylisdev

Description

@realmeylisdev

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:

  1. Adding implementation \"com.stripe:payment-method-messaging:\$stripe_version\" to packages/stripe_android/android/build.gradle.
  2. 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.
  3. 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.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions