kkiapay_flutter_sdk 0.4.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

kkiapay_flutter_sdk #

Kkiapay is developer friendly solution that allows you to accept mobile money and credit card payments in your application or website.

Before using this SDK, make sure you have a right Merchant Account on Kkiapay, otherwise go and create your account is free and without pain 😎.

Installation #

To use this package :

dependencies:
  flutter:
    sdk: flutter
  kkiapay_flutter_sdk:

Usage #

    import 'package:kkiapay_flutter_sdk/kkiapayWebview.dart';
Initialise the Kkiapay Instance
final kkiapay = Kkiapay(
    @required sucessCallback: Function,
    @required amount: String,
    @required apikey: String,
    sandbox: bool,
    data: String,
    phone: String,
    name: String,
    theme: dynamic
);

Create payment webview instance
final Widget kkiapayWebview = KkiapayWebview(kkiapay)

Example #

import 'package:example/screens/successScreen.dart';
import 'package:flutter/material.dart';
import 'package:kkiapay_flutter_sdk/kkiapayWebview.dart';
import 'package:kkiapay_flutter_sdk/utils/Kkiapay.dart';

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

void sucessCallback(response, context) {
  Navigator.pop(context);
  Navigator.push(
    context,
    MaterialPageRoute(
        builder: (context) => SuccessScreen( 
              amount: response['amount'],
              transactionId: response['transactionId']
            )),
  );
}

final kkiapay = Kkiapay(
    sucessCallback: sucessCallback,
    amount: '2000',
    sandbox: true,
    data: 'fakedata',
    apikey: 'xxxxxxxxxxxxxxxxxxxxxxx',
    phone: '97000000',
    name: 'JOHN DOE',
    theme: '#2ba359');

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      appBar: AppBar(
        title: Text('Kkiapay Sample'),
        centerTitle: true,
      ),
      body: KkiapaySample(),
    ));
  }
}

class KkiapaySample extends StatelessWidget {
  const KkiapaySample({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: ButtonTheme(
        minWidth: 250.0,
        height: 60.0,
        child: FlatButton(
          color: Color(0xFFE30E25),
          child: Text(
            'Pay Now',
            style: TextStyle(color: Colors.white),
          ),
          onPressed: () {
            Navigator.push(
              context,
              MaterialPageRoute(builder: (context) => kkiapay),
            );
          },
        ),
      ),
    );
  }
}

Reference #

ArgumentTypeRequiredDetails
phoneStringYesValid mobile money number to debit. ex : 22967434270
amountNumericYesAmount to debit from user account (XOF)
nameStringNoClient firstname and lastname
apikeyStringYespublic api key
sandboxBooleanNoThe true value of this attribute allows you to switch to test mode
sucessCallbackFunctionNoThis function is called once the payment has been successfully made


the successCallback function takes two parameters in the following order
- Map<String,dynamic> containing the transaction information

- the context of type BuildContext


Issues and feedback #

Please file issues to send feedback or report a bug. Thank you!

0.2.0 #

  • refactor

0.0.2 #

  • Initial version, created by kkiapay

0.1.0 #

  • add description and fix version issue

example/lib/main.dart

// import 'successScreen.dart';
// import 'package:example/screens/main.dart' ;
import 'package:flutter/material.dart';
import 'package:kkiapay_flutter_sdk/kkiapayWebview.dart';
import './successScreen.dart';


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

void sucessCallback(response, context) {
  print(response);
  print('-============>');
  Navigator.pop(context);
  print('function appelé avec succès');
  Navigator.push(
    context,
    MaterialPageRoute(
        builder: (context) => SuccessScreen(
              
              amount: response['amount'],
              transactionId: response['transactionId']
            )),
  );
}
// KkiapayWebview()
// _SdkData()

final kkiapay = KKiaPay(amount: 1,phone: '97000000',data: 'hello world',sandbox: true,apikey: 'xxxxxxxxxxxxxxx',callback: sucessCallback,);

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      appBar: AppBar(
        title: Text('Kkiapay Sample'),
        centerTitle: true,
      ),
      body: KkiapaySample(),
    ));
  }
}

class KkiapaySample extends StatelessWidget {
  const KkiapaySample({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: ButtonTheme(
        minWidth: 250.0,
        height: 60.0,
        child: FlatButton(
          color: Color(0xFFE30E25),
          child: Text(
            'Pay Now',
            style: TextStyle(color: Colors.white),
          ),
          onPressed: () {
            Navigator.push(
              context,
              MaterialPageRoute(builder: (context) => kkiapay),
            );
          },
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  kkiapay_flutter_sdk: ^0.4.0

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:kkiapay_flutter_sdk/kkiapayConf.sample.dart';
import 'package:kkiapay_flutter_sdk/kkiapayWebview.dart';
import 'package:kkiapay_flutter_sdk/utils/Kkiapay.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
32
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Jul 7, 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 does not support Flutter platform linux

Because of import path [package:kkiapay_flutter_sdk/kkiapayWebview.dart, package:flutter_webview_plugin/flutter_webview_plugin.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:kkiapay_flutter_sdk/kkiapayWebview.dart, package:flutter_webview_plugin/flutter_webview_plugin.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:kkiapay_flutter_sdk/kkiapayWebview.dart, package:flutter_webview_plugin/flutter_webview_plugin.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:kkiapay_flutter_sdk/kkiapayWebview.dart, package:flutter_webview_plugin/flutter_webview_plugin.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

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

Health suggestions

Fix lib/kkiapayConf.sample.dart. (-1.99 points)

Analysis of lib/kkiapayConf.sample.dart reported 4 hints:

line 2 col 38: Prefer using /// for doc comments.

line 3 col 47: Prefer using /// for doc comments.

line 5 col 25: Prefer using /// for doc comments.

line 6 col 16: Prefer using /// for doc comments.

Fix lib/kkiapayWebview.dart. (-1 points)

Analysis of lib/kkiapayWebview.dart reported 2 hints:

line 7 col 7: This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: KKiaPay.amount, KKiaPay.phone, KKiaPay.data, KKiaPay.apikey, KKiaPay.sandbox, KKiaPay.callback

line 103 col 3: Prefer using /// for doc comments.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
cupertino_icons ^0.1.2 0.1.3
flutter 0.0.0
flutter_webview_plugin ^0.3.10 0.3.11
http ^0.12.0+2 0.12.1
webview_flutter ^0.3.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
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
flutter_test