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 :sunglasses:.

Installation

To use this package :

dependencies:
  flutter:
    sdk: flutter
  kkiapay_flutter_sdk:

Add this line in index.html in Web folder :

<head>
    ...
    <script src="https://cdn.kkiapay.me/k.js"></script>
</head>

Usage

    import 'package:kkiapay_flutter_sdk/kkiapay/view/widget_builder_view.dart';
Initialise the Kkiapay Instance
final kkiapay = KKiaPay(
    @required callback: Function(Map<String, dynamic> response, BuildContext context),
    @required amount: String,
    @required apikey: String,
    sandbox: bool,
    data: String,
    phone: String,
    name: String,
    reason: String,
    email: String,
    theme: dynamic,
    countries: List<String>,
    partnerId: String,
    paymentMethods: List<String>
);

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

Example

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:kkiapay_flutter_sdk/kkiapay/view/widget_builder_view.dart';
import 'package:kkiapay_flutter_sdk/kkiapayWeb/web_widget_builder.dart';
import 'package:kkiapay_flutter_sdk/utils/kkiapayConf.sample.dart';


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

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

final kkiapay = KKiaPay(
    amount: 100,
    countries: ["BJ"],
    phone: "22961000000",
    name: "John Doe",
    email: "email@mail.com",
    reason: 'transaction reason',
    data: 'Fake data',
    sandbox: true,
    apikey: 'XXXXXXXXXXXXXXXXXXXXXX',
    callback: successCallback,
    theme: defaultTheme, // Ex : "#222F5A",
    partnerId: 'AxXxXXxId',
    paymentMethods: ["momo","card"]
);

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: () {
            if (kIsWeb) {
              KKiaPayWeb.pay(kkiapay, (response){
                successCallback(response, context);
              });
            }else{
              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
partnerIdStringNoYour id to find transaction
countriesList of StringNoSet widget countries ex: ["CI"]
paymentMethodsList of StringNoSet widget payment methods ex: ["momo","card"]
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
successCallbackFunctionYesThis 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
  { 
    'requestData': {
      'amount': int,
      'phone': String,
      'reason': String,
      'data': String,
      'paymentMethods': List<String>,
      'partnerId': String,
      'countries': List<String>,
      'sandbox': bool,
      'name': String,
      'email': String
    },
    'transactionId': String, 
    'status': String 
  }
  
- the context of type BuildContext


Issues and feedback

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