KKIAPAY
DashboardSupport
EN 1.0.0
EN 1.0.0
  • Introduction
  • Home
    • KKiaPay
  • Account
    • Create an account
    • Account activation
    • KKiaPay Sandbox : Test Guide
    • Using KKiaPay
  • Payements
    • Supported Currencies
    • Payment Methods
    • Fees
    • Payouts
    • Transactions
  • Plugin and SDK
    • Prestashop
    • WooCommerce
    • Wordpress Give
    • Wordpress Jobster
    • Javascript SDK
      • Using KKiaPay with Vue.js
      • Using KKiaPay with React.js
      • Using KKiaPay with Angular
      • Using KKiaPay with Svelte
    • Android SDK
    • SDK Flutter
    • SDK React-Native
    • SDK Swift for iOS
    • Admin SDKs (Server-side)
      • PHP Admin SDK
      • Python Admin SDK
      • Node.js Admin SDK
  • KKIAPAY SERVICES
    • KKiaPay Direct
    • KKiaPay POS
  • Dashboard
    • General Presentation
    • Menu
      • Transactions
      • Customers
      • Payouts
      • Developers
      • Settings
    • Webhook
  • Security
    • Security provisions
    • Suspicious email and website
    • Untitled
Powered by GitBook
On this page
  • Installation
  • Usage
  • Example
  • Reference

Was this helpful?

  1. Plugin and SDK

SDK Flutter

PreviousAndroid SDKNextSDK React-Native

Last updated 7 months ago

Was this helpful?

This SDK is designed to allow the integration of KKiaPay into your Flutter mobile application. To set it up you will need to on platform and follow the process here describes :

Installation

To use this package :

dependencies:
  flutter:
    sdk: flutter
  kkiapay_flutter_sdk:

For web

add to your index.html
<script src="https://cdn.kkiapay.me/k.js"></script>

Usage

import 'package:kkiapay_flutter_sdk/kkiapay_flutter_sdk.dart';

Initialise the Kkiapay Instance

final kkiapay = KKiaPay(
    @required callback: Function(Map<String, dynamic> response, BuildContext context),
    @required amount: int, // Ex : 1000
    @required apikey: String, // Ex : XXXX_public_api_key_XXX
    @required sandbox: bool, // Ex : true
    data: String, // Ex : 'Big data'
    phone: String, // Ex : "22961000000"
    name: String, // Ex : "John Doe"
    reason: String, // Ex : "transaction reason"
    email: String, // Ex : "email@mail.com"
    callbackUrl: String, // Ex : "http://kkiapay.me"
    theme: String, // Ex : "#222F5A"
    countries: List<String>, // Ex :  ["CI","BJ"]
    partnerId: String, // Ex : 'AxXxXXxId'
    paymentMethods: List<String> // Ex : ["momo","card"]
);

Create payment webview instance

Mobile:

Navigator.push( context, MaterialPageRoute(builder: (context) => kkiapay), );

Web:

KkiapayFlutterSdkPlatform.instance.pay( kkiapay, context, callback );

Example

import 'package:flutter/material.dart';
import 'package:kkiapay_flutter_sdk/kkiapay_flutter_sdk.dart';


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

void callback(response, context) {
  switch ( response['status'] ) {

    case PAYMENT_CANCELLED:
      Navigator.pop(context);
      debugPrint(PAYMENT_CANCELLED);
    break;

    case PAYMENT_INIT:
      debugPrint(PAYMENT_INIT);
      break;

    case PENDING_PAYMENT:
      debugPrint(PENDING_PAYMENT);
      break;
      
    case PAYMENT_SUCCESS:
      Navigator.pop(context);
      Navigator.push(
        context,
        MaterialPageRoute(
          builder: (context) => SuccessScreen(
            amount: response['requestData']['amount'],
            transactionId: response['transactionId'],
          ),
        ),
      );
      break;

    default:
      debugPrint(UNKNOWN_EVENT);
      break;
  }
}

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

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: nColorPrimary,
          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: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ButtonTheme(
              minWidth: 500.0,
              height: 100.0,
              child: TextButton(
                style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all(Color(0xff222F5A)),
                  foregroundColor: MaterialStateProperty.all(Colors.white),
                ),
                child: const Text(
                  'Pay Now',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) => kkiapay),
                  );
                },
              ),
            ),
            const SizedBox(height: 50,),
            ButtonTheme(
              minWidth: 500.0,
              height: 100.0,
              child: TextButton(
                style: ButtonStyle(
                  backgroundColor:
                  MaterialStateProperty.all(const Color(0xff222F5A)),
                  foregroundColor: MaterialStateProperty.all(Colors.white),
                ),
                child: const Text(
                  'Pay Now ( WEB )',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () {
                  KkiapayFlutterSdkPlatform.instance.pay(kkiapay, context, callback);
                },
              ),
            )
          ],
        )
    );
  }
}

Reference

Argument
Type
Required
Details

phone

String

Yes

Valid mobile money number to debit. ex : 22967434270

amount

Numeric

Yes

Amount to debit from user account (XOF)

name

String

No

Client firstname and lastname

partnerId

String

No

Your id to find transaction

countries

List of String

No

Set widget countries ex: ["CI"]

paymentMethods

List of String

No

Set widget payment methods ex: ["momo","card"]

theme

String

No

the hexadecimal code of the color you want to give to your widget

apikey

String

Yes

public api key

sandbox

Boolean

No

The true value of this attribute allows you to switch to test mode

successCallback

Function

Yes

This 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,
      'partnerId': String,
      'sandbox': bool,
      'name': String,
      'email': String
    },
    'transactionId': String, 
    'status': String 
  }
  
- the context of type BuildContext

For more informations on the SDK please follow the link below : .

create an account
kkiapay.me
KKiaPay Flutter SDK