8000 GitHub - maxakak1998/flutter_stripe: Flutter library for Stripe.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

maxakak1998/flutter_stripe

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter Stripe

pub package build

🚨 flutter_stripe is in beta - please provide feedback (and/or contribute) if you find issues 💙️

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.

payment_sheet

Features

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

Apple Pay: We provide a seamless integration with Apple Pay.

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

SCA-Ready: The SDK automatically performs native 3D Secure authentication if needed to comply with Strong 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.

Installation

dart pub add flutter_stripe

Requirements

Android

  • Android 5.0 (API level 21) and above
  • Kotlin version 1.5.0 and above: example
  • Using a descendant of Theme.AppCompact for your activity: example
  • Using FlutterFragmentActivity instead of FlutterActivity in MainActivity.kt: example

This is caused by the Stripe SDK requires the use of the AppCompact theme for their UI components and the Support Fragment Manager for the Payment Sheets

iOS

Compatible with apps targeting iOS 11 or above.

Usage example

// main.dart
import 'package:flutter_stripe/flutter_stripe.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  // set the publishable key for Stripe - this is mandatory
  Stripe.publishableKey = stripePublishableKey;
  runApp(App());
}

// payment_screen.dart
class PaymentScreen extends StatelessWidget {
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Container(
        alignment: Alignment.center,
        padding: EdgeInsets.all(16),
        child: CardField(
          onCardChanged: (card) {
            print(card);
          },
        ),
      ),
    );
  }
}

Stripe initialization

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

Stripe offers publishableKey, stripeAccountId, threeDSecureParams and merchantIdentifier. Only publishableKey is required.

Dart API

The library offers several methods to handle stripe related actions:

Future<PaymentMethod> createPaymentMethod(...);
Future<PaymentIntent> handleCardAction(...);
Future<PaymentIntent> confirmPaymentMethod(...);
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.

Run the example app

  • 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.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.
  • Start the example
    • Terminal 1: cd server && yarn example start:server
    • Terminal 2: flutter run
Additional steps for webhook forwarding

Known issues

  • The Card field on Android has focus issues - it's being tracked in #14 and related to issues in the Flutter framework. If this is a blocker for your project consider using the PaymentSheet alternative

Contributing

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

Setup

This project uses melos 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
  • Format melos run format
  • Analyze melos run analyze
  • Test melos run test
  • Pub get melos run get
Publishing
  • Use melos version and melos publish to keep all the repositories in sync

About

Flutter library for Stripe.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 35.2%
  • Swift 28.3%
  • Kotlin 26.9%
  • TypeScript 4.9%
  • Java 2.6%
  • Ruby 1.0%
  • Other 1.1%
0