Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Flutter SDK for Stripe.

NotificationsYou must be signed in to change notification settings

flutter-stripe/flutter_stripe

Repository files navigation

Flutter Stripe

pub packagebuild

The Stripe Flutter SDK allows you to build delightful payment experiences in your native Android and iOS apps using Flutter. We provide powerful and customizable UI screens and elements that can be used out-of-the-box to collect your users' payment details.

stripe-flutter_cover

Features

Simplified Security: We make it simple for you to collect sensitive data such as credit card numbers and remainPCI compliant. This means the sensitive data is sent directly to Stripe instead of passing through your server. For more information, see ourIntegration Security Guide.

Apple Pay: We provide aseamless integration with Apple Pay.

Google Pay: The plugin can easily act as payment provider for thePay plugin that enables you to seamlessly integrate Google Pay or Apple Pay. All you need to do is add your stripe publishable key to the payment profile.

Payment methods: Accepting morepayment methods helps your business expand its global reach and improve checkout conversion.

SCA-Ready: The SDK automatically performs native3D Secure authentication if needed to comply withStrong Customer Authentication regulation in Europe.

Native UI: We provide native screens and elements to securely collect payment details on Android and iOS.

Pre-built payments UI: Learn how to integrate Payment Sheet, the new pre-built payments UI for mobile apps. This pre-built UI lets you accept cards, Apple Pay, and Google Pay out of the box, and includes support for saving & reusing cards.

Recommended usage

If you're selling digital products or services within your app, (e.g. subscriptions, in-game currencies, game levels, access to premium content, or unlocking a full version), you must use the app store's in-app purchase APIs. This does not apply to app developers in the USA as they are excluded by new court ruling in 2025. SeeApple's andGoogle's guidelines for more information. For all other scenarios you can use this SDK to process payments via Stripe.

Installation

dart pub add flutter_stripe

Requirements

Android

This plugin requires several changes to be able to work on Android devices. Please make sure you follow all these steps:

  1. Use Android 5.0 (API level 21) and above.
  2. Use Kotlin version 1.8.0 and above:example
  3. Requires Android Gradle plugin 8 and higher
  4. Using a descendant ofTheme.AppCompat for your activity:example,example night theme
  5. Using an up-to-date Android gradle build tools version:example and an up-to-date gradle version accordingly:example
  6. UsingFlutterFragmentActivity instead ofFlutterActivity inMainActivity.kt:example
  7. Add the following rules to yourproguard-rules.pro file:example
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivity$g-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter-dontwarn com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider-dontwarn kotlinx.parcelize.Parceler$DefaultImpls-dontwarn kotlinx.parcelize.Parceler-dontwarn kotlinx.parcelize.Parcelize# Keep Stripe classes-keep class com.stripe.** { *; }
  1. Rebuild the app, as the above changes don't update with hot reload

These changes are needed because the Android Stripe SDK requires the use of the AppCompat theme for their UI components and the Support Fragment Manager for the Payment Sheets

If you are having troubles to make this package to work on Android, jointhis discussion to get some support.

iOS

Compatible with apps targeting iOS 13 or above.

To upgrade your iOS deployment target to 13.0, you can either do so in Xcode under your Build Settings, or by modifying IPHONEOS_DEPLOYMENT_TARGET in your project.pbxproj directly.

You will also need to update in your Podfile:

platform :ios, '13.0'

For card scanning add the following to your Info.plist:

<key>NSCameraUsageDescription</key><string>Scan your card to add it automatically</string><key>NSCameraUsageDescription</key><string>To scan cards</string>

Web

Now you can use Stripe with Flutter web! Notice right now it is highly experimental and only a subset of features is implemented. Namely:

  • Create paymentmethod
  • Confirm payment intent
  • Confirm setup intent
  • Create token

Supported widgets

To use Stripe on web, it is required to addflutter_stripe_web in your pubspec file

Usage

Card payments

There are 3 ways of handling card payments

MethodEase of usedescriptionImplementation docs
Payment sheetEasyOur recommended way of handling payments. It offers localization, animations and error handling out of the box.docs
CardfieldMediumSingle line cardfield. Offers more flexibility but has less built-in functionality.docs
Card formMediumSimilar as the cardfield but the entry fields are spread across multi linesdocs

Wallets

This library fully supports native Apple Pay andGoogle pay integration.

Mobile elements [BETA]

We also support the customer sheet mobile element. Check out thedocs to learn more on how to set it up.

Financial connections

We also support Financial connections in our latest sdk. Check out thedocs to learn more on how to set it up.

Stripe initialization

To initialize Stripe in your Flutter app, use theStripe base class.

Stripe offerspublishableKey,stripeAccountId,threeDSecureParams andmerchantIdentifier. OnlypublishableKey is required.

Dart API

The library offers several methods to handle stripe related actions:

Future<PaymentMethod>createPaymentMethod(...);Future<PaymentIntent>handleNextAction(...);Future<PaymentIntent>confirmPayment(...);Future<void>configure3dSecure(...);Future<bool>isApplePaySupported();Future<void>presentApplePay(...);Future<void>confirmApplePayPayment(...);Future<SetupIntent>confirmSetupIntent(...);Future<PaymentIntent>retrievePaymentIntent(...);Future<String>createTokenForCVCUpdate(...);Future<void>initPaymentSheet(...);Future<void>presentPaymentSheet(...);Future<void>confirmPaymentSheetPayment()

The example app offers examples on how to use these methods.

Pay Plugin support

flutter_stripe fully supports thePay plugin from the Google Pay team. By including a few lines you can integrate Stripe as a payment processor for Google / Apple Pay:

Future<void>onGooglePayResult(paymentResult)async {final response=awaitfetchPaymentIntentClientSecret();final clientSecret= response['clientSecret'];final token= paymentResult['paymentMethodData']['tokenizationData']['token'];final tokenJson=Map.castFrom(json.decode(token));final params=PaymentMethodParams.cardFromToken(      token: tokenJson['id'],    );// Confirm Google pay payment methodawaitStripe.instance.confirmPayment(      clientSecret,      params,    );}

Run the example app

  • Navigate to the example foldercd example
  • Install the dependencies
    • flutter pub get
  • Set up env vars for the flutter app and a local backend.
    • Get your test Stripe API keys
    • cp lib/.env.example.dart lib/.env.dart and set your Stripe publishable key.
    • cp server/.env.example server/.env and set the variable values in your newly created.env file.
  • Install the server dependencies in theserver directory:
    • cd server
    • npm install oryarn --cwd "server"
  • Start the example
    • Terminal 1:
      • Move to theserver directory:cd server
      • Run npm or yarn:npm start oryarn --cwd "server" start
    • Terminal 2:
      • Move to thelib directory:cd lib
      • Run flutter:flutter run
Additional steps for webhook forwarding

Contributing

You can help us make this project better, feel free to open an new issue or a pull request.

Setup

This project usesmelos to manage all the packages inside this repo.

  • Install melos:dart pub global activate melos
  • Setup melos in your local folder:melos bootstrap
Useful commands
  • Formatmelos run format
  • Analyzemelos run analyze
  • Testmelos run unittest
  • Pub getmelos run get
Publishing
  • Usemelos version andmelos publish to keep all the repositories in sync

[8]ページ先頭

©2009-2025 Movatter.jp