kkiapay_flutter_sdk 1.2.12 copy "kkiapay_flutter_sdk: ^1.2.12" to clipboard
kkiapay_flutter_sdk: ^1.2.12 copied to clipboard

KKiaPay allows businesses to safely receive payments by mobile money, credit card and bank account.

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 😎.

version License: MIT popularity all contributors

Installation #

To use this package :

dependencies:
  flutter:
    sdk: flutter
  kkiapay_flutter_sdk:

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"
    theme: String, // Ex : "#222F5A"
    countries: List<String>, // Ex :  ["CI","BJ"]
    partnerId: String, // Ex : 'AxXxXXxId'
    paymentMethods: List<String> // Ex : ["momo","card"]
);

Create payment webview instance
Navigator.push(context, MaterialPageRoute(builder: (context) => kkiapay),

Example #

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

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

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

    case PAYMENT_CANCELLED:
      debugPrint(PAYMENT_CANCELLED);
      Navigator.pop(context);
      ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
        content: Text(PAYMENT_CANCELLED),
      ));
    break;

    case PENDING_PAYMENT:
      debugPrint(PENDING_PAYMENT);
      ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
        content: Text(PENDING_PAYMENT),
      ));
      break;

    case PAYMENT_INIT:
      debugPrint(PAYMENT_INIT);
      ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
        content: Text(PAYMENT_INIT),
      ));
      break;  

    case PAYMENT_SUCCESS:
      Navigator.push(
        context,
        MaterialPageRoute(
          builder: (context) => SuccessScreen(
            amount: response['requestData']['amount'],
            transactionId: response['transactionId'],
          ),
        ),
      );
      ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
        content: Text(PAYMENT_SUCCESS),
      ));
      break;

    case PAYMENT_FAILED: print(PAYMENT_FAILED);
    break;

    default:
      break;
  }
}

final kkiapay = KKiaPay(
    amount: 1000,//
    countries: ["BJ"],//
    phone: "22961000000",//
    name: "John Doe",//
    email: "email@mail.com",//
    reason: 'transaction reason',//
    data: 'Fake data',//
    sandbox: true,//
    apikey: public_api_key,//
    callback: successCallback,//
    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),
                  );
                },
              ),
            )
          ],
        )
    );
  }
}

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,
      'partnerId': 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!

25
likes
100
pub points
86%
popularity

Publisher

unverified uploader

KKiaPay allows businesses to safely receive payments by mobile money, credit card and bank account.

Homepage

Documentation

API reference

License

unknown (LICENSE)

Dependencies

cupertino_icons, flutter, http, stacked, stacked_services, url_launcher, webview_flutter, webview_flutter_android, webview_flutter_wkwebview

More

Packages that depend on kkiapay_flutter_sdk