Skip to content

boussarilatif/kkiapay-flutter-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 successCallback: Function(Map<String, dynamic> response, BuildContext context),
    @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';

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

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

final kkiapay = KKiaPay(
    successCallback: successCallback,
    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
themeStringNo the hexadecimal code of the color you want to give to your widget
apikeyStringYespublic api key
sandboxBooleanNoThe true value of this attribute allows you to switch to test mode
successCallbackFunctionNoThis 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!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 81.7%
  • Objective-C 8.2%
  • Shell 6.1%
  • Java 4.0%