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
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,
'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!
Libraries
- Kkiapay/app/app
- Kkiapay/app/appBloger
- Maybe this should be generated for the user as well?
- Kkiapay/app/appLocator
- Kkiapay/view/viewp
- Kkiapay/view/widgetBView
- Kkiapay/view/WidgetBviewModel
- kkiapay_WEb/WebWidgetB
- utils/KaiPayConSample
- utils/utils