feat: add Stripe Identity Verification support#2318
Conversation
Add support for Stripe Identity Verification, allowing Flutter apps to verify
users' government-issued IDs and selfies using Stripe's native IdentityVerificationSheet.
## API Usage
```dart
final result = await Stripe.instance.presentIdentityVerificationSheet(
verificationSessionId: 'vs_xxx',
ephemeralKeySecret: 'ek_xxx',
brandLogo: 'base64EncodedImage', // Optional, iOS only
);
switch (result) {
case IdentityVerificationCompleted():
print('Verification completed');
case IdentityVerificationCanceled():
print('User canceled');
case IdentityVerificationFailed(:final error):
print('Error: ${error.message}');
}
```
## Changes
### Platform Interface
- Add `IdentityVerificationSheetParams`, `IdentityVerificationResult`, and `IdentityVerificationError` models
- Add `presentIdentityVerificationSheet` method to platform interface
### iOS
- Add `StripeIdentity` dependency to Package.swift
- Add `StripeSdkImpl+Identity.swift` extension with native implementation
### Android
- Add `com.stripe:identity` dependency to build.gradle
- Add `IdentityVerificationSheetManager` for handling the verification flow
### Web
- Add stub that throws `WebUnsupportedError` (Identity requires native SDKs)
### Example App
- Add `IdentityVerificationScreen` demo
Closes flutter-stripe#1819
|
@remonh87 - This PR implements the Stripe Identity Verification feature requested in #1819. Would you be able to review when you have a chance? Note about CI: The 16 test failures in Thanks! |
- Add .build directory to iOS gitignore - Update Package.resolved for StripeIdentity dependency - Regenerate payment_sheet.g.dart (LinkDisplay enum fix)
|
Thanks for this PR! We currently synchronize our code base with the one from Stripe React Native. Most of your Android / iOS changes would be overwritten then. There are a few possible ways to go ahead:
Since it introduces another library dependency, I would opt for variant 1) |
|
Thanks for the guidance @jonasbark! I've created a new PR #2319 with the separate package approach following the The new structure keeps Identity completely isolated from the main package:
Closing this PR in favor of #2319. |
Summary
This PR adds support for Stripe Identity Verification, allowing Flutter apps to verify users' government-issued IDs and selfies using Stripe's native
IdentityVerificationSheet.Closes #1819
API Usage
Changes
Platform Interface Layer
IdentityVerificationSheetParams,IdentityVerificationResult(sealed class), andIdentityVerificationErrormodels using FreezedpresentIdentityVerificationSheetabstract method toStripePlatformMethodChannelStripeiOS Implementation
StripeIdentitydependency toPackage.swiftStripeSdkImpl+Identity.swiftextension with native implementationAndroid Implementation
com.stripe:identitydependency tobuild.gradleIdentityVerificationSheetManagerfollowing theStripeUIManagerpatternStripeSdkModuleandStripeAndroidPluginWeb
WebUnsupportedError(Identity Verification requires native mobile SDKs)Example App
IdentityVerificationScreenwith demo implementationAPI Compatibility
IdentityVerificationSheet.present()IdentityVerificationSheet.present()presentIdentityVerificationSheet().flowCompletedCompletedIdentityVerificationCompleted.flowCanceledCanceledIdentityVerificationCanceled.flowFailed(error)Failed(throwable)IdentityVerificationFailed(error)Note on React Native
The original issue mentions "React native supports it" - however, after investigation, React Native Stripe SDK appears to have
verifyIdentityonly as part of the Onramp feature, not as a standalone Identity Verification Sheet. This implementation provides the full native Identity Verification Sheet functionality that matches the official Stripe iOS and Android SDKs directly.Test Plan
Testing Requirements
{id, ephemeral_key_secret}NSCameraUsageDescriptionon iOS)