paynow 0.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 66

paynow #

This is an unofficial flutter package for Paynow

Getting Started #

Paynow paynow = Paynow(integrationKey: "XXXX-XXXXX-XXXXX-XXXX", integrationId: "1234", returnUrl: "", resultUrl: "");
Payment payment = paynow.createPayment(, "");

// add item to cart
payment.add("Banana", 15.9);

// error callback
paynow.onError = (data){

// set Transaction check callback
paynow.onCheck = (StatusResponse response){

// transaction callback
paynow.onDone = (response){
  print("Checking Transaction Status");

  // initiate mobile payment
  paynow._initMobile(payment, "0784442662", "ecocash");
  print("Client has insufficient funds");


It's not yet perfect but it works, try out the example.

All contributions and PRs are welcome :) AND don't be shy to open issues.

Demo Video


[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.


import 'dart:async';
import 'dart:math';

import 'package:argon_buttons_flutter/argon_buttons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_emoji/flutter_emoji.dart';
import 'package:paynow/paynow.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Paynow',
      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 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.

      home: MyHomePage(title: 'Flutter Paynow Demo'),

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

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {

  TextEditingController _phoneController = TextEditingController();
  TextEditingController _amountController = TextEditingController();
  String _status = "";
  List<GCircle> loaders = <GCircle>[];
  var parser = EmojiParser();

  void initState(){
    // Timer.periodic(Duration(seconds: 5), (t){_animateLoaders();});

  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      backgroundColor: Colors.indigoAccent,

      appBar: AppBar(
        backgroundColor: Colors.greenAccent.withOpacity(.7),
        // Here we take the value from the MyHomePage object that was created by
        // the method, and use it to set our appbar title.
        title: Text(widget.title),
        children: <Widget>[
            padding: EdgeInsets.only(right: 20, left: 20),
            child: Container(
              color: Colors.greenAccent.withOpacity(.5),
            // Center is a layout widget. It takes a single child and positions it
            // in the middle of the parent.
            child: Column(
              // Column is also a layout widget. It takes a list of children and
              // arranges them vertically. By default, it sizes itself to fit its
              // children horizontally, and tries to be as tall as its parent.
              // Invoke "debug painting" (press "p" in the console, choose the
              // "Toggle Debug Paint" action from the Flutter Inspector in Android
              // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
              // to see the wireframe for each widget.
              // Column has various properties to control how it sizes itself and
              // how it positions its children. Here we use mainAxisAlignment to
              // center the children vertically; the main axis here is the vertical
              // axis because Columns are vertical (the cross axis would be
              // horizontal).
              children: <Widget>[
                  'Ecocash Flutter Demo:',
                  style: TextStyle(
                    color: Colors.white
                  decoration: InputDecoration(
                    icon: Icon(,
                    hintText: "Phone Number",
                    hintStyle: TextStyle(
                      color: Colors.white
                  cursorColor:Colors.white ,
                  controller: _phoneController,

                  decoration: InputDecoration(
                    hintText: "5.00",
                    hintStyle: TextStyle(color:Colors.white),
                    icon: Icon(Icons.monetization_on)
                  keyboardType: TextInputType.number,
                  controller: _amountController,

                SizedBox(height: 15,),
                  height: 50,
                  width: MediaQuery.of(context).size.width * 0.45,
                  minWidth: MediaQuery.of(context).size.width * 0.30,
                  highlightColor: Colors.transparent,
                  highlightElevation: 0,
                  roundLoadingShape: false,
                  onTap: (startTimer, btnState) {
                    if (btnState == ButtonState.Idle) {

                    // this._animateLoaders();

                    Paynow paynow = Paynow(integrationKey: "ZZZZZZZZZZZZZZZZZ", integrationId: "XXXXXXXXXXXXXXXXXXXXXXXXXX", returnUrl: "", resultUrl: "");

                    Payment payment = paynow.createPayment(, "");

                    payment.add("Banana", double.parse(_amountController.text));

                    paynow.onDone = (response){
                      // Future.delayed(duration);
                      print("Checking Transaction Status");

                    paynow.onCheck = (StatusResponse response){
                      setState(() {
                          _status = response.paid;

                    paynow.sendMobile(payment, _phoneController.text, "ecocash");
                  // initialTimer: 10,
                  child: Text(
                    style: TextStyle(
                        color: Colors.white,
                        fontSize: 18,
                        fontWeight: FontWeight.w700),
                  loader: (timeLeft) {
                    return Text(
                      "Wait | $timeLeft",
                      style: TextStyle(
                          fontSize: 18,
                          fontWeight: FontWeight.w700),
                  borderRadius: 5.0,
                  color: Colors.greenAccent ,
                  elevation: 0,
                  borderSide: BorderSide(color:, width: 1.5),
                SizedBox(height: 10,),
                  children: <Widget>[
                    // Text("Transaction  Data", style: TextStyle(color:
                    Text("If you like this API, feel free to DONATE!!",

                      fontWeight: FontWeight.w500,
                      color: Colors.white
                    Text(_status, style: TextStyle(color:, fontSize: 49),)
                    ,Text("${parser.get('coffee').code} <SuperCode/>")

            alignment: Alignment.centerLeft,
            child: Column(
              children: _buildLoaders()
            alignment: Alignment.centerRight,
            child: Column(
              children: _buildLoaders()
      ) ,
       // This trailing comma makes auto-formatting nicer for build methods.

  List<GCircle>_buildLoaders() {
    for(int i=0;i<3;i++){

    return loaders;


class GCircle extends StatefulWidget{
  Color color;
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _GCircle();

  updateColor(Color color){
    this.color = color;


class _GCircle extends State<GCircle>{

Color c = Colors.black87;
  void initState(){
    List<Color> colors = [ , Colors.greenAccent, Colors.cyan];
    Random random = Random();
    Timer.periodic(Duration(seconds: 2), (t){
      setState(() {
        this.c = colors[random.nextInt(colors.length)];
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Padding(
        padding: EdgeInsets.all(5),
        child: CircleAvatar(
          backgroundColor: c,


Use this package as a library

1. Depend on it

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

  paynow: ^0.0.4

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:paynow/paynow.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
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.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [paynow] that is in a package requiring null.

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:paynow/paynow.dartpackage:dio/dio.dartpackage:dio/src/dio_http_headers.dartdart:io

Health suggestions

Fix lib/paynow.dart. (-2.48 points)

Analysis of lib/paynow.dart reported 5 hints:

line 4 col 8: Unused import: 'dart:async'.

line 6 col 8: Unused import: 'dart:io'.

line 144 col 9: The value of the local variable 'result' isn't used.

line 149 col 3: The declaration '__init' isn't referenced.

line 174 col 10: The declaration '_notQuotePlus' isn't referenced.

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (dio, steel_crypt).

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
crypto ^2.1.3 2.1.5
dio ^2.1.13 2.2.2 3.0.9
flutter 0.0.0
http ^0.12.0+2 0.12.1
steel_crypt ^1.3.1+1 1.7.1+1 2.0.3
Transitive dependencies
args 1.6.0
asn1lib 0.6.5
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
cookie_jar 1.0.1
http_parser 3.1.4
meta 1.1.8 1.2.1
path 1.7.0
pedantic 1.9.0 1.9.1
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
Dev dependencies