flutter_payments 0.1.5

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new74

flutter_payments

Flutter In App Purchases For Humans.

pub package

Getting Started

This plugin makes it easy to make products or subscriptions for both Apple App Store and Google Play.

Subscriptions

You can use the built-in SubscriptionManager which provides a Stream interface for purchase states and abstracts away most of the logic around subscription management. However, it does not perform extended validation of a Subscription, so it may be possible to inject an invalid Subscription depending on the platform and device security settings. It is recommended that you perform server-side validation of all purchases, if that is a concern.

SubscriptionManager Example

In App Purchases (Non-subscription Products)

You can run the included example app on an Android device to test the payment flow with test product SKUs.

Example App

FlutterPayments.billingEnabled

Determine if Billing is available on the device.

final bool billingEnabled = await FlutterPayments.billingEnabled;

FlutterPayments.getProducts

Fetch Product metadata from the store.

final List<Product> getProducts = await FlutterPayments.getProducts(
  skus: <String>[
    'android.test.purchased',
    'android.test.canceled',
  ],
  type: ProductType.InApp,
);

FlutterPayments.purchase

List<Purchase> purchase = await FlutterPayments.purchase(
  sku: 'android.test.purchased',
  type: ProductType.InApp,
);

FlutterPayments.getPurchaseHistory

Get the User's purchase history from the Store. Returns a list of Purchase instances.

final List<Purchase> purchaseHistory = await FlutterPayments.getPurchaseHistory(ProductType.InApp);
print('purchaseHistory: $purchaseHistory');

0.1.5 - Fix iOS

  • Fixed an error where channel got nuked in Swift code
  • Added purchase buttons to the SubscriptionManager example page
  • Added consumeToken for Android, still a WIP!

0.1.4 - Cleanup tasks, no library code changes.

  • Actually fix the JUnit 5 error in the build.gradle.

0.1.3 - Cleanup tasks, no library code changes.

  • Removed dead code from example app
  • Added docs to README

0.1.1 - Fixed bug SubscriptionManager

  • I made an error when copying SubscriptionManager over from my app :/

0.1.0 - Added SubscriptionManager

  • Added SubscriptionManager to make life easier for users
  • Updated example app to have buttons which trigger the Google Play sample SKUs
  • Updated Google Play error translation to use Dart exceptions :)
  • Other code cleanup tasks since apparently people found this.

0.0.2 - Bug fixes for Swift code

Fixed an error that caused the iOS plugin to forcefully eject occupants (aka an NPE).

0.0.1 - Initial release.

Releasing to make integration with my project easier, not for public consumption.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_payments/flutter_payments.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  List<String> logMessages = <String>[];

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Flutter Payments'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: new Column(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              Text('Products for Purchase'),
              buildPurchaseButton(context, 'android.test.canceled'),
              buildPurchaseButton(context, 'android.test.purchased'),
              buildPurchaseButton(context, 'android.test.item_unavailable'),
              Text('Log Messages'),
              Text(logMessages.join('\n')),
            ],
          ),
        ),
      ),
    );
  }

  Widget buildPurchaseButton(BuildContext context, String productSku) {
    return new RaisedButton(
      onPressed: () async {
        String message;
        try {
          final List<Purchase> list = await FlutterPayments.purchase(
            sku: productSku,
            type: ProductType.InApp,
          );

          message = list.toString();
        } on FlutterPaymentsException catch (error) {
          message = error.toString();
        }

        setState(() {
          logMessages.add('Purchase of "$productSku" result:\n$message');
        });
      },
      child: Text('Purchase "$productSku"'),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_payments: "^0.1.5"

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


      import 'package:flutter_payments/flutter_payments.dart';
  
Version Uploaded Documentation Archive
0.1.5 Jul 13, 2018 Go to the documentation of flutter_payments 0.1.5 Download flutter_payments 0.1.5 archive
0.1.4 Jul 12, 2018 Go to the documentation of flutter_payments 0.1.4 Download flutter_payments 0.1.4 archive
0.1.3 Jul 11, 2018 Go to the documentation of flutter_payments 0.1.3 Download flutter_payments 0.1.3 archive
0.1.2 Jul 11, 2018 Go to the documentation of flutter_payments 0.1.2 Download flutter_payments 0.1.2 archive
0.1.1 Jul 11, 2018 Go to the documentation of flutter_payments 0.1.1 Download flutter_payments 0.1.1 archive
0.1.0 Jul 11, 2018 Go to the documentation of flutter_payments 0.1.0 Download flutter_payments 0.1.0 archive
0.0.2 Jul 8, 2018 Go to the documentation of flutter_payments 0.0.2 Download flutter_payments 0.0.2 archive
0.0.1 Jul 8, 2018 Go to the documentation of flutter_payments 0.0.1 Download flutter_payments 0.0.1 archive

Analysis

We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
49 / 100
Health:
Code health derived from static analysis. [more]
98 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
74
Learn more about scoring.

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 6 hints.

    Run flutter format to format lib/src/dateutils.dart.

    Run flutter format to format lib/src/plugin.dart.

    Similar analysis of the following files failed:

    • lib/src/product.dart (hint)
    • lib/src/purchase.dart (hint)
    • lib/src/subscription_manager.dart (hint)
    • lib/src/types.dart (hint)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
url_launcher ^3.0.2 3.0.3
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7
Dev dependencies
flutter_test
mockito ^2.2.3