stripe_dart_flutter 0.1.0

  • Readme
  • Changelog
  • Installing
  • 59

Stripe Dart/Flutter #

Stripe API implemented in Dart, for use in Flutter and Web applications

Most of the model class documentation have been taken from the Stripe API Docs. And each model should have the URL to that specific object as well as almost the exact wording that the Stripe docs have

Getting Started #

To use this package you will need: #

  1. A Stripe account that uses at least API version 2019-03-14 and access to the public/secret API keys for that account
  2. An app (Flutter) or server that is running Dart code or makes use of a pubspec.yaml file

Config #

Aftering importing the You can set your API key via the top-level function, setApiKey(). Like so:

setApiKey('sk_test_YOUR_API_KEY')

For your account security, we recommend that you put your API keys in separate file that is not committed to your code repo, such as a JSON file.

Remember: When in production use the sk_live key, when testing use the sk_test key

Usage #

This example will change in the future once Tokens are fully supported and tested

import "package:stripe_dart_flutter/stripe.dart";

main() async {

    setApiKey('YOUR_API_KEY_READ_FROM_A_FILE');

    // Make an AccountCreation object. Only certain models will have a Creation or Update counterpart. The others should use the fromMap constructor
  var accountCreate = AccountCreation()
    ..type = 'custom'
    ..businessType = 'company'
    ..defaultCurrency = 'usd'
    ..email = 'demo@test.net'
    ..metadata = {'user_type': 'advertiser'}
    ..requestedCapabilities = ['card_payments', 'platform_payments']
    ..tosAcceptance = TosAcceptance.fromMap(
            // Make a map that contains the TosAcceptance attributes
    ); 
    ... // Add all the fields available while still following the Stripe API guidelines

    // Send to the Stripe API via the create method
    Account createdAccount = await accountCreate.create();

    // Make an AccountUpdate object
    var accountUpdate = AccountUpdate()
        ..individual = Individual.fromMap(jsonDecode(updateIndividualExample))
        ..email = 'updatedemail@test.net';

    // Send to the Stripe API via the update method
    Account updatedAccount = await accountUpdate.update(createdAccountId);

}

Testing your app #

To learn more about testing your mobile or web app check out Stripe's docs for test card numbers or tokens.

Unit Tests #

The majority of the unit tests rely on connecting to a real Stripe Account in testmode. Therefore all tests expect your API Test Secret Key as the first script argument and your account must be set to US. Test coverage is limited for now (some tests would require livemode and or OAuth).

Authors #

Current Authors #

  • Tanner Davis (Cholojuanito) - Repo owner and repo update author
  • Brandon Derbidge (bderbidge) - Repo update author

Previous Authors #

This repo is a fork from the original Stirpe Dart API repo which was originally created by:

  • Matias Meno
  • Matrin Flucka

A big shoutout to them for the great work and time they put into their repo. We are sad they were not able to continue maintaining their repo.

Versioning #

  • Github: We will name each new release the same way that Stripe versions their API. Stripe versions their API by using the date that version become available. i.e. We first built this repo based on the 2019-03-14 (March 14, 2019) API version, thus the first stable release will be named 2019-03-24

  • Dart pub package: We will follow the Dart pubspec versioning standards for the packages that are published to pub.dev. But we will make notes in the CHANGELOG indicating which Stripe API version a particular package version corresponds to (see above about Github).

License #

See the License file for more info

0.1.0 (2019-05-20) #

  • Stripe API Version: 2019-03-14, unless otherwise stated any versions greater than 0.1.0 correspond to the 2019-03-14 Stripe API version.
  • Creating/updating/deleting a Stripe account is supported

Use this package as a library

1. Depend on it

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


dependencies:
  stripe_dart_flutter: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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_dart_flutter/stripe_dart_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
46
Health:
Code health derived from static analysis. [more]
59
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:stripe_dart_flutter/stripe_dart_flutter.dart with components: io.

Health suggestions

Fix lib/src/api_resources/customer.dart. (-7.71 points)

Analysis of lib/src/api_resources/customer.dart reported 16 hints, including:

line 2 col 8: Unused import: '../exceptions.dart'.

line 40 col 7: DO use curly braces for all flow control structures.

line 42 col 7: DO use curly braces for all flow control structures.

line 59 col 7: DO use curly braces for all flow control structures.

line 61 col 7: DO use curly braces for all flow control structures.

Fix lib/src/api_resources/charge.dart. (-7.24 points)

Analysis of lib/src/api_resources/charge.dart reported 15 hints, including:

line 80 col 7: DO use curly braces for all flow control structures.

line 82 col 7: DO use curly braces for all flow control structures.

line 107 col 7: DO use curly braces for all flow control structures.

line 109 col 7: DO use curly braces for all flow control structures.

line 122 col 7: DO use curly braces for all flow control structures.

Fix lib/src/api_resources/invoice.dart. (-5.84 points)

Analysis of lib/src/api_resources/invoice.dart reported 12 hints, including:

line 38 col 7: DO use curly braces for all flow control structures.

line 40 col 7: DO use curly braces for all flow control structures.

line 48 col 7: DO use curly braces for all flow control structures.

line 50 col 7: DO use curly braces for all flow control structures.

line 74 col 7: DO use curly braces for all flow control structures.

Fix additional 18 files with analysis or formatting issues. (-31.27 points)

Additional issues in the following files:

  • lib/src/api_resources/application_fee.dart (6 hints)
  • lib/src/api_resources/subscription.dart (6 hints)
  • lib/src/api_resources/transfer.dart (6 hints)
  • lib/src/resources/additional_owner.dart (6 hints)
  • lib/src/api_resources/dispute.dart (5 hints)
  • lib/src/resource.dart (5 hints)
  • lib/src/api_resources/invoice_item.dart (4 hints)
  • lib/src/api_resources/token.dart (4 hints)
  • lib/src/api_resources/transfer_reversal.dart (4 hints)
  • lib/src/api_resource.dart (2 hints)
  • lib/src/api_resources/balance.dart (2 hints)
  • lib/src/api_resources/card.dart (2 hints)
  • lib/src/api_resources/discount.dart (2 hints)
  • lib/src/api_resources/event.dart (2 hints)
  • lib/src/api_resources/refund.dart (2 hints)
  • lib/src/resources/shipping.dart (2 hints)
  • lib/src/resources/verification.dart (2 hints)
  • lib/src/resource_collection.dart (1 hint)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and stripe_dart_flutter.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
http >=0.11.2 <0.13.0 0.12.0+2
logging ^0.11.0 0.11.3+2
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.7
path 1.6.4
pedantic 1.8.0+1
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test ^1.0.0