paynow 1.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 73

paynow #

Getting Started #

Make sure to add the paynow dependency to your pubspec.yaml file

paynow: ^latest_version

Import the paynow package #

    import 'package:paynow/paynow.dart' show Paynow;

Initialise Paynow #

    Paynow paynow = Paynow(integrationKey: "INTEGRATION_KEY", integrationId: "INTEGRATION_ID", returnUrl: "", resultUrl: "");

Create Payment Instance #

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

Add item(s) to cart #

    payment.add("Banana", 1.9);

Initiate Paynow Transaction (Web Checkout) #

    InitResponse response  = await paynow.send(payment);

Initiate Express Checkout #

    InitResponse response = await paynow.sendMobile(payment, "0784442662", "ecocash"); // defaults to ecocash if blank

Check Response results #

    // Display results

    // Print Instructions
    // For Web Checkout, you get your [redirect_url] to redirect your client to
    String redirectuUrl = response.redirectUrl

Check Transaction Status #

    StatusResponse statusResponse = await paynow.checkTransactionStatus(response.pollUrl);

    if (statusResponse.paid){
        print("Client Paid");
        print("Transaction was unsuccessful");

NB: This is an unofficial API for Paynow. The paynow community does not host a Paynow SDK for Flutter so I put up this project for those who want to implement in-app purchases in their flutter apps. All contributions and PR requests are welcome. YES even a typo fix.

Experimental.......... #

On this branch the Paynow package will automatically open a webview for you

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

Coded with love by SuperCode

[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),
      persistentFooterButtons: <Widget>[
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(40))
          child: Text("MORE"),
          onPressed: (){
            // open showcase dialog

        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) {

                    Paynow paynow = Paynow(integrationKey: "960ad10a-fc0c-403b-af14-e9520a50fbf4", integrationId: "6054", returnUrl: "", resultUrl: "");
                    Payment payment = paynow.createPayment("user", "");

                    payment.add("Banana", 1.9);

                    // Initiate Mobile Payment
                    paynow.sendMobile(payment, _phoneController.text ?? "0784442662", "ecocash")
                      ..then((InitResponse response){
                        // display results

                        // Check Transaction status from pollUrl
                          ..then((StatusResponse status){

                  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: ^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: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 5, 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.

Health suggestions

Format lib/keys.dart.

Run flutter format to format lib/keys.dart.

Format lib/paynow.dart.

Run flutter format to format lib/paynow.dart.

Maintenance suggestions

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 Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
crypto ^2.1.3 2.1.5
flutter 0.0.0
http ^0.12.0+2 0.12.1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
http_parser 3.1.4
meta 1.1.8
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