kkiapay_flutter_sdk 1.2.8-dev.1 copy "kkiapay_flutter_sdk: ^1.2.8-dev.1" to clipboard
kkiapay_flutter_sdk: ^1.2.8-dev.1 copied to clipboard

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

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:kkiapay_flutter_sdk/src/widget_builder_view.dart';
import 'package:kkiapay_flutter_sdk/utils/config.dart';
import './successScreen.dart';

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

void successCallback(response, context) {
  Navigator.pop(context);

  switch ( response['status'] ) {

    case PAYMENT_CANCELLED: print(PAYMENT_CANCELLED);
    break;

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

    case PAYMENT_FAILED: print(PAYMENT_FAILED);
    break;

    default:
      break;
  }
}

const 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,
    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: const Text('Kkiapay Sample'),
          centerTitle: true,
        ),
        body: const 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),
                  );
                },
              ),
            )
          ],
        )
    );
  }
}
25
likes
0
pub points
86%
popularity

Publisher

unverified uploader

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

Homepage

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