-
-
Notifications
You must be signed in to change notification settings - Fork 618
Add EmbeddedPaymentElement support for Flutter #2239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…irm() Changes confirm() method to return payment result instead of void, allowing Flutter apps to detect payment failures without relying solely on callbacks. - Modified EmbeddedPaymentElementController.confirm() return type - Updated embedded_payment_element.dart to capture method channel result - iOS implementation complete with result dictionary - Android implementation incomplete (help wanted) Fixes detection of payment failures (insufficient funds, card declined, etc.) Follows React Native SDK pattern where confirm() returns result status.
- Added onConfirmResult callback property to EmbeddedPaymentElementView - Modified resultCallback to invoke Flutter method channel callback - Updated platform view to set callback before calling confirm() - Callback returns Map with status and optional error message - Matches iOS implementation for consistent cross-platform behavior
…errors - Removed updateConfiguration and updateIntentConfiguration from method channel handler - These methods were unused and causing Dynamic type mismatch compile errors - Configuration is set once during initialization and doesn't need updates
- Added Jetpack Compose BOM and core dependencies (ui, foundation, runtime) - Updated Kotlin from 1.8.0 to 1.9.0 for Compose compatibility - Added Compose build features and compiler extension version - Fixes 'Unresolved reference' errors for Box, requiredHeight, foundation - Required for EmbeddedPaymentElement which uses Compose UI
194f414 to
b161474
Compare
- Read kotlinVersion from rootProject.ext with fallback - Check kotlinMajor version to conditionally load compose plugin - Fixes Kotlin 2.0 compose compiler requirement
b161474 to
f9d132c
Compare
- Cast entry.value to Dynamic for ViewManager methods - Change array.size() to array.size (property not function) - Fixes Kotlin 2.0 compilation errors
Android would crash when intentConfiguration was provided. Fixed by updating how payment data is passed to native code.
Fixed compilation errors in Bundle handling and upgraded Gradle to 8.11.1 to match React Native SDK.
Bundle.getBundle() throws ClassCastException when value is a string. Wrapped in try-catch to mirror React Native's ReadableMap behavior.
Changed from try-catch to type check with Bundle.get() to avoid Android logging warnings when color values are strings.
Height changes were sent to wrong channel. Widget now receives events directly from platform view instead of global emitter. Added callbacks for all events: - onHeightChanged - onPaymentOptionChanged - onLoadingFailed - onRowSelectionImmediateAction - onFormSheetConfirmComplete Matches iOS behavior.
06e9f2f to
145e5d4
Compare
|
It looks really good upon first inspection, thanks for all the effort! I was hesitant to add it due to the Compose requirement, but I think it's a transitive dependency of stripe-android anyway. Will have a closer look soon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked it from the dart side and looks good to me only I think dart format did create a bigger change than needed
thank you for this great contribution. I will wait for @jonasbark feedback before integrating it
| black, | ||
| automatic, | ||
| } | ||
| enum ApplePayButtonStyle { white, whiteOutline, black, automatic } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What command did you run for dart format?
Looks like quite some changes were made due formatter
| @override | ||
| void setConfirmHandler(ConfirmHandler? handler) { | ||
| _confirmHandler = handler; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When opening the code locally, I get an error for WebStripe class:
"Missing concrete implementation of 'abstract class StripePlatform extends PlatformInterface. setConfirmHandler'."
I fixed it via quick fix, but should this change for web package be in the PR as well?
|
Hello @remonh87 |
|
@jonasbark can you take a look at it as well? |
What This Adds
Implements the new Embedded Payment Element from Stripe's mobile SDKs. Lets you embed the payment UI inline instead of using modal sheets.
Changes
EmbeddedPaymentElementwidget with iOS/Android platform viewsEmbeddedPaymentElementControllerto callconfirm()andclearPaymentOption()Status
iOS ✅
Works. Platform view renders properly,
confirm()returns the result, all callbacks fire. Tested with cards, Apple Pay, Link, PayPal, Revolut Pay.Android ✅
Works. Platform view renders properly,
confirm()returns the result, all callbacks fire. Tested with cards, Google Pay, Link, PayPal, Revolut Pay.Quick Example
React Native docs: https://docs.stripe.com/payments/mobile/accept-payment-embedded?platform=react-native