paystack_manager 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new66

Paystack Manager #

A Flutter plugin for making payments via Paystack Payment Gateway. Fully supports Android and iOS.

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Usage #

To use this package :

dependencies:
    flutter:
      sdk: flutter
    paystack_manager:

Then initialize the package whenever you need it:


    PaystackPayManager(context: context)
        ..setSecretKey("sk_test_7e3a3dbff5d7b8b2ee7e61125b503ecbba8c850f")
        //accepts widget
        ..setCompanyAssetImage(
          Image(
            image: AssetImage("assets/images/logo.png"),
          )
        )
        ..setAmount(152)
        ..setCurrency("GHS")
        ..setEmail("bakoambrose@gmail.com")
        ..setFirstName("Ambrose")
        ..setLastName("Bako")
        ..setMetadata(
          {
            "custom_fields": [
              {
                "value": "snapTask",
                "display_name": "Payment to",
                "variable_name": "payment_to"
              }
            ]
          },
        )
        ..onSuccesful(_onPaymentSuccessful)
        ..onFailed(_onPaymentFailed)
        ..onCancel(_onPaymentCancelled)
        ..initialize();

No other configuration required—the plugin works out of the box.

🚁 Testing your implementation #

Paystack provides tons of payment cards for testing.

▶️ Running Example project #

For help getting started with Flutter, view the online documentation.

An example project has been provided in this plugin. Clone this repo and navigate to the example folder. Open it with a supported IDE or execute flutter run from that folder in terminal.

:pencil: Contributing, 😞 Issues and 🐛 Bug Reports #

The project is open to public contribution. Please feel very free to contribute. Experienced an issue or want to report a bug? Please, report it here. Remember to be as descriptive as possible.

🏆 Credits #

Thanks to the authors of Paystack Flutter. I leveraged on their work to bring this plugin to fruition.

[0.0.1] - 2020-06-21 #

  • A Flutter plugin for making payments via Paystack Payment Gateway. Fully supports Android and iOS.

[1.0.1] - 2020-06-21 #

  • Re-formatted code.

[1.0.2] - 2020-06-22 #

  • Added transaction reference

[1.0.3] - 2020-06-30 #

  • Now using status message directly from paystack api response

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:paystack_manager/models/transaction.dart';
import 'package:paystack_manager/paystack_pay_manager.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Paystack Payment"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            //initiate payment button
            RaisedButton(
              onPressed: _processPayment,
              child: Text(
                "Pay",
              ),
            ),
          ],
        ),
      ),
    );
  }

  void _processPayment() {
    try {
      PaystackPayManager(context: context)
        ..setSecretKey("sk_test_7e3a3dbff5d7b8b2ee7e61125b503ecbba8c850f")
        //accepts widget
        ..setCompanyAssetImage(Image(
          image: AssetImage("assets/images/logo.png"),
        ))
        ..setAmount(152)
        // ..setReference("your-unique-transaction-reference")
        ..setReference(DateTime.now().millisecondsSinceEpoch.toString())
        ..setCurrency("GHS")
        ..setEmail("bakoambrose@gmail.com")
        ..setFirstName("Ambrose")
        ..setLastName("Bako")
        ..setMetadata(
          {
            "custom_fields": [
              {
                "value": "snapTask",
                "display_name": "Payment to",
                "variable_name": "payment_to"
              }
            ]
          },
        )
        ..onSuccesful(_onPaymentSuccessful)
        ..onFailed(_onPaymentFailed)
        ..onCancel(_onPaymentCancelled)
        ..initialize();
    } catch (error) {
      print("Payment Error ==> $error");
    }
  }

  void _onPaymentSuccessful(Transaction transaction) {
    print("Transaction was successful");
    print("Transaction Message ===> ${transaction.message}");
    print("Transaction Refrence ===> ${transaction.refrenceNumber}");
  }

  void _onPaymentFailed(Transaction transaction) {
    print("Transaction failed");
  }

  void _onPaymentCancelled(Transaction transaction) {
    print("Transaction was cancelled");
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  paystack_manager: ^1.0.3

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:paystack_manager/paystack_manager.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
36
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:paystack_manager/paystack_manager.dart that imports:
  • package:paystack_manager/paystack_pay_manager.dart that imports:
  • package:paystack_manager/views/paystack_payment_checkout_page.dart that imports:
  • package:paystack_manager/widgets/payment_bank_auth_view.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:paystack_manager/paystack_manager.dart that imports:
  • package:paystack_manager/paystack_pay_manager.dart that imports:
  • package:paystack_manager/views/paystack_payment_checkout_page.dart that imports:
  • package:paystack_manager/widgets/payment_bank_auth_view.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:paystack_manager/paystack_manager.dart that imports:
  • package:paystack_manager/paystack_pay_manager.dart that imports:
  • package:paystack_manager/views/paystack_payment_checkout_page.dart that imports:
  • package:paystack_manager/widgets/payment_bank_auth_view.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:paystack_manager/paystack_manager.dart that imports:
  • package:paystack_manager/paystack_pay_manager.dart that imports:
  • package:paystack_manager/views/paystack_payment_checkout_page.dart that imports:
  • package:paystack_manager/widgets/payment_bank_auth_view.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • paystack_manager that is a package requiring null.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

exitCode: 255 stdout: Documenting paystack_manager... Initialized dartdoc with 666 libraries in 205.1 seconds Generating docs for library accent_button from package:paystack_manager/widgets/accent_button.dart... Generating docs for library api_response from package:paystack_manager/models/api_response.dart... Generating docs for library apis from package:paystack_manager/api/apis.dart... Generating docs for library bank_payment_view from package:paystack_manager/widgets/bank_payment_view.dart... Generating docs for library card_cvv_text_field from package:paystack_manager/widgets/card_cvv_text_field.dart... Generating docs for library card_expiry_text_field from package:paystack_manager/widgets/card_expiry_text_field.dart... Generating docs for library card_number_text_field from package:paystack_manager/widgets/card_number_text_field.dart... Generating docs for library card_payment_view from package:paystack_manager/widgets/card_payment_view.dart... Generating docs for library card_type from package:paystack_manager/models/card_type.dart... Generating docs for library card_utils from package:paystack_manager/utils/card_utils.dart... Generating docs for library custom_dialog from package:paystack_manager/utils/custom_dialog.dart... Generating docs for library input_formatters from package:paystack_manager/utils/input_formatters.dart... Generating docs for library loading_Transaction_view from package:paystack_manager/widgets/loading_Transaction_view.dart... Generating docs for library mobile_money_payment_view from package:paystack_manager/widgets/mobile_money_payment_view.dart... Generating docs for library payment_address_entry_view from package:paystack_manager/widgets/payment_address_entry_view.dart... Generating docs for library payment_bank_auth_view from package:paystack_manager/widgets/payment_bank_auth_view.dart... Generating docs for library payment_birthday_entry_view from package:paystack_manager/widgets/payment_birthday_entry_view.dart... Generating docs for library payment_card from package:paystack_manager/models/payment_card.dart... Generating docs for library payment_failed_view from package:paystack_manager/widgets/payment_failed_view.dart... Generating docs for library payment_info from package:paystack_manager/models/payment_info.dart... Generating docs for library payment_option from package:paystack_manager/models/payment_option.dart... Generating docs for library payment_option_header from package:paystack_manager/widgets/payment_option_header.dart... Generating docs for library payment_option_list_view_item from package:paystack_manager/widgets/payment_option_list_view_item.dart... Generating docs for library payment_options from package:paystack_manager/data/payment_options.dart... Generating docs for library payment_options_list_view from package:paystack_manager/widgets/payment_options_list_view.dart... Generating docs for library payment_options_selector_view from package:paystack_manager/widgets/payment_options_selector_view.dart... Generating docs for library payment_otp_entry_view from package:paystack_manager/widgets/payment_otp_entry_view.dart... Generating docs for library payment_phone_entry from package:paystack_manager/widgets/payment_phone_entry.dart... Generating docs for library payment_pin_entry_view from package:paystack_manager/widgets/payment_pin_entry_view.dart... Generating docs for library paystack_manager from package:paystack_manager/paystack_manager.dart... Generating docs for library paystack_manager from package:paystack_manager/paystack_pay_manager.dart... Generating docs for library paystack_payment_api from package:paystack_manager/api/paystack_payment_api.dart... Generating docs for library paystack_payment_checkout_page from package:paystack_manager/views/paystack_payment_checkout_page.dart... Generating docs for library secured_by from package:paystack_manager/widgets/secured_by.dart... Generating docs for library text_input_field from package:paystack_manager/widgets/text_input_field.dart... Generating docs for library transaction from package:paystack_manager/models/transaction.dart... Generating docs for library transaction_status from package:paystack_manager/models/transaction_status.dart... Generating docs for library ui_color from package:paystack_manager/utils/ui_color.dart... Generating docs for library ui_strings from package:paystack_manager/utils/ui_strings.dart... Validating docs... Documented 39 public libraries in 25.7 seconds stderr: warning: unresolved doc reference [EditableText] from input_formatters.CardMonthInputFormatter.formatEditUpdate: (file:///tmp/pub-dartlang-dartdocPSOGNF/pkg/lib/utils/input_formatters.dart:6:20) in documentation inherited from text_formatter.TextInputFormatter.formatEditUpdate: (file:///flutter/packages/flutter/lib/src/services/text_formatter.dart:41:20) warning: unresolved doc reference [EditableText] from input_formatters.CardNumberInputFormatter.formatEditUpdate: (file:///tmp/pub-dartlang-dartdocPSOGNF/pkg/lib/utils/input_formatters.dart:32:20) in documentation inherited from text_formatter.TextInputFormatter.formatEditUpdate: (file:///flutter/packages/flutter/lib/src/services/text_formatter.dart:41:20) warning: paystack_manager has no library level documentation comments, from paystack_manager: (file:///tmp/pub-dartlang-dartdocPSOGNF/pkg/lib/paystack_manager.dart:1:9) warning: paystack_manager has no library level documentation comments, from paystack_manager: (file:///tmp/pub-dartlang-dartdocPSOGNF/pkg/lib/paystack_pay_manager.dart:1:9) error: failed to write file at: paystack_manager/paystack_manager-library.html for symbol paystack_manager: (file:///tmp/pub-dartlang-dartdocPSOGNF/pkg/lib/paystack_pay_manager.dart:1:9) conflicting with file already generated by paystack_manager: (file:///tmp/pub-dartlang-dartdocPSOGNF/pkg/lib/paystack_manager.dart:1:9) Dartdoc generates a path and filename to write to for each symbol. paystack_manager conflicts with another symbol in the generated path, and therefore can not be written out. Changing the name, library name, or class name (if appropriate) of one of the conflicting items can resolve the conflict. Alternatively, use the @nodoc tag in one symbol's documentation comments to hide it. found 4 warnings and 1 error Unhandled exception: dartdoc encountered 1 errors while processing. #0 Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:225:9)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
dio ^3.0.9 3.0.9
flutter 0.0.0
flutter_icons ^1.0.0+1 1.1.0
intl ^0.16.1 0.16.1
pin_code_fields ^3.1.2 3.1.2
pinput ^0.2.0 0.2.4
webview_flutter ^0.3.22+1 0.3.22+1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
http_parser 3.1.4
meta 1.1.8 1.2.1
path 1.7.0
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test