stripe_payment 1.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 90

pub package

stripe_payment #

Conveniently secure payments methods using Stripe. #

Quick Glance #

  • This Flutter plugin is a straight port from tipsi-stripe plugin for React Native - we tried to keep the API as close as possible so the documentation applies this this plugin as well.
  • Collect chargable tokens from users' Card Input and Apple & Google Pay
  • For SCA compliant apps, setup payment intents for later confirmation.

Supported features: #

Native Pay -  & G

  • canMakeNativePayPayments()
  • deviceSupportsNativePay()
  • potentiallyAvailableNativePayNetworks()
  • completeNativePayRequest()
  • cancelNativePayRequest()

Card Form #

  • paymentRequestWithCardForm()

Card Params Object #

  • createTokenWithCard()

Bank Account Params Object #

  • createTokenWithBankAccount()

Create Source Object With Params #

  • createSourceWithParams()

Apple Pay

Dependencies #

Android & iOS

  • Create a Stripe account and project
  • Retrieve a publishable key from the Stripe dashboard

Stripe Dashboard

Android #

  • Requires AndroidX

Include support in android/gradle.properties

android.useAndroidX=true
android.enableJetifier=true

Documentation #

As this plugin is a port from tipsi-stripe for React Native you may consult their documentation: https://github.com/tipsi/tipsi-stripe/tree/experimental-connect/website/docs-md It includes:

  • how to setup Google / Apple Pay
  • method documentations

[1.0.5]

  • fix Android kotlin compilation problems (#72)
  • fix canMakeNativePayPayments request when it includes a list of networks (thanks @alexstuckey)

[1.0.4]

  • fix Android configuration for Activities (#68)

[1.0.3]

  • fix completeNativePayRequest + cancelNativePayRequest methods (thanks @jocelyngirard)

[1.0.2]

  • cancelling paymentRequestWithCardForm will now return the Future on Android (fixes #55)
  • update minimum deployment target for iOS to 10.0

[1.0.0]

the stripe_payment plugin is now ported from tipsi-stripe React Native plugin: https://github.com/tipsi/tipsi-stripe New features include:

Native Pay -  & G

  • canMakeNativePayPayments()
  • deviceSupportsNativePay()
  • potentiallyAvailableNativePayNetworks()
  • completeNativePayRequest()
  • cancelNativePayRequest()

Card Form #

  • paymentRequestWithCardForm()

Card Params Object #

  • createTokenWithCard()

Bank Account Params Object #

  • createTokenWithBankAccount()

Create Source Object With Params #

  • createSourceWithParams()

[0.3.2]

  • Add native iOS confirmation
  • readme update

[0.3.1] - 01.10.2019

  • Lowered iOS minimum deployment target to 9.0
  • removed dependency to stripe_native
  • removed useNativeReceipt method

[0.3.0] - 29.09.2019

Breaking change: Initialize the plugin has changed: StripePayment.setSettings(StripeSettings(publishableKey: "pk_test_"));

Added support for:

[0.2.1] - 27.08.2019

  • Update Stripe dependencies

[0.2.0] - 13.08.2019

  • BREAKING: This plugin now uses the Payment Intent to create a payment method instead of creating a Source.

[0.1.1] - 07.08.2019

  • Breaking: Minimum Android target is 19 (from 18)
  • Breaking: Minimum iOS target is 9.0 (from 8.0)
  • Update Android Stripe dependency to 10.2.1
  • Update iOS Stripe dependency to 16.0.3

[0.1.0] - 22.02.2019

  • Breaking change: use AndroidX

[0.0.9] - 07.02.2019

  • Updating Android Gradle

[0.0.8] - 08.12.2018

[0.0.7] - 03.12.2018

  • Increase Kotlin and Gradle versions

[0.0.6] - 16.05.2018

  • Dart 2 fixes

[0.0.5] - 20.03.2018

  • Compatible with Flutter SDK >=0.1.4 <2.0.0"

[0.0.4] - 29.01.2018

  • Initial release.

example/README.md

stripe_payment_example #

Demonstrates how to use the stripe_payment plugin.

Getting Started #

RaisedButton(
  child: Text("Create Source"),
  onPressed: () {
    StripePayment.createSourceWithParams(SourceParams(
      type: 'ideal',
      amount: 1099,
      currency: 'eur',
      returnURL: 'example://stripe-redirect',
    )).then((source) {
      _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('Received ${source.sourceId}')));
      setState(() {
        _source = source;
      });
    }).catchError(setError);
  },
),
Divider(),
RaisedButton(
  child: Text("Create Token with Card Form"),
  onPressed: () {
    StripePayment.paymentRequestWithCardForm(CardFormPaymentRequest()).then((paymentMethod) {
      _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('Received ${paymentMethod.id}')));
      setState(() {
        _paymentMethod = paymentMethod;
      });
    }).catchError(setError);
  },
),
RaisedButton(
  child: Text("Create Token with Card"),
  onPressed: () {
    StripePayment.createTokenWithCard(
      testCard,
    ).then((token) {
      _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('Received ${token.tokenId}')));
      setState(() {
        _paymentToken = token;
      });
    }).catchError(setError);
  },
),
Divider(),
RaisedButton(
  child: Text("Create Payment Method with Card"),
  onPressed: () {
    StripePayment.createPaymentMethod(
      PaymentMethodRequest(
        card: testCard,
      ),
    ).then((paymentMethod) {
      _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('Received ${paymentMethod.id}')));
      setState(() {
        _paymentMethod = paymentMethod;
      });
    }).catchError(setError);
  },
),
RaisedButton(
  child: Text("Create Payment Method with existing token"),
  onPressed: _paymentToken == null
      ? null
      : () {
          StripePayment.createPaymentMethod(
            PaymentMethodRequest(
              card: CreditCard(
                token: _paymentToken.tokenId,
              ),
            ),
          ).then((paymentMethod) {
            _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('Received ${paymentMethod.id}')));
            setState(() {
              _paymentMethod = paymentMethod;
            });
          }).catchError(setError);
        },
),
Divider(),
RaisedButton(
  child: Text("Confirm Payment Intent"),
  onPressed: _paymentMethod == null || _currentSecret == null
      ? null
      : () {
          StripePayment.confirmPaymentIntent(
            PaymentIntent(
              clientSecret: _currentSecret,
              paymentMethodId: _paymentMethod.id,
            ),
          ).then((paymentIntent) {
            _scaffoldKey.currentState
                .showSnackBar(SnackBar(content: Text('Received ${paymentIntent.paymentIntentId}')));
            setState(() {
              _paymentIntent = paymentIntent;
            });
          }).catchError(setError);
        },
),
RaisedButton(
  child: Text("Authenticate Payment Intent"),
  onPressed: _currentSecret == null
      ? null
      : () {
          StripePayment.authenticatePaymentIntent(clientSecret: _currentSecret).then((paymentIntent) {
            _scaffoldKey.currentState
                .showSnackBar(SnackBar(content: Text('Received ${paymentIntent.paymentIntentId}')));
            setState(() {
              _paymentIntent = paymentIntent;
            });
          }).catchError(setError);
        },
),
Divider(),
RaisedButton(
  child: Text("Native payment"),
  onPressed: () {
    StripePayment.paymentRequestWithNativePay(
      androidPayOptions: AndroidPayPaymentRequest(
        total_price: "1.20",
        currency_code: "EUR",
      ),
      applePayOptions: ApplePayPaymentOptions(
        countryCode: 'DE',
        currencyCode: 'EUR',
        items: [
          ApplePayItem(
            label: 'Test',
            amount: '13',
          )
        ],
      ),
    ).then((token) {
      setState(() {
        _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('Received ${token.tokenId}')));
        _paymentToken = token;
      });
    }).catchError(setError);
  },
),
RaisedButton(
  child: Text("Complete Native Payment"),
  onPressed: () {
    StripePayment.completeNativePayRequest().then((_) {
      _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('Completed successfully')));
    }).catchError(setError);
  },
),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  stripe_payment: ^1.0.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:stripe_payment/stripe_payment.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
93
Health:
Code health derived from static analysis. [more]
77
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
90
Learn more about scoring.

We analyzed this package on Nov 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/source.dart. (-14.82 points)

Analysis of lib/src/source.dart reported 32 hints, including:

line 6 col 21: Name non-constant identifiers using lowerCamelCase.

line 8 col 10: Name non-constant identifiers using lowerCamelCase.

line 16 col 10: Name non-constant identifiers using lowerCamelCase.

line 24 col 12: Name non-constant identifiers using lowerCamelCase.

line 26 col 12: Name non-constant identifiers using lowerCamelCase.

Fix lib/src/android_pay_payment_request.dart. (-8.63 points)

Analysis of lib/src/android_pay_payment_request.dart reported 18 hints, including:

line 4 col 8: Name non-constant identifiers using lowerCamelCase.

line 5 col 10: Name non-constant identifiers using lowerCamelCase.

line 6 col 18: Name non-constant identifiers using lowerCamelCase.

line 7 col 8: Name non-constant identifiers using lowerCamelCase.

line 8 col 16: Name non-constant identifiers using lowerCamelCase.

Fix lib/src/source_params.dart. (-1 points)

Analysis of lib/src/source_params.dart reported 2 hints:

line 10 col 10: Name non-constant identifiers using lowerCamelCase.

line 21 col 12: Name non-constant identifiers using lowerCamelCase.

Fix additional 7 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/apple_pay_payment_request.dart (Run flutter format to format lib/src/apple_pay_payment_request.dart.)
  • lib/src/card_form_payment_request.dart (Run flutter format to format lib/src/card_form_payment_request.dart.)
  • lib/src/error_codes.dart (Run flutter format to format lib/src/error_codes.dart.)
  • lib/src/payment_intent.dart (Run flutter format to format lib/src/payment_intent.dart.)
  • lib/src/payment_method.dart (Run flutter format to format lib/src/payment_method.dart.)
  • lib/src/stripe_payment.dart (Run flutter format to format lib/src/stripe_payment.dart.)
  • lib/src/token.dart (Run flutter format to format lib/src/token.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8