Skip to content

WinKoKo91/flutter_kpay_kit

Repository files navigation

Flutter Kpay Kit

KBZ Mobile Payment package for Flutter

Getting Started

Installation

dependencies:
  flutter_kpay_kit:latest version

Usage

Android

UAT version

  • add or overwirte uat kbzsdk.arr under yourproject/android/app/lib

Product version

  • add or overwirte prod kbzsdk.arr under yourproject/android/app/lib

CallBack Function

  • add following code in android/app/src/main/manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
....
	<activity android:name="com.kbzbank.payment.sdk.callback.CallbackResultActivity" android:theme="@android:style/Theme.NoDisplay" android:exported="true"
....

IOS

App project configuration in the Info. Add kbzpay pist white list ios/Runner/Info.plist

<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>kbzpay</string>
	</array>

Payment callback

Payment callback, payment completion or payment cancellation, currently there are only two states. The callback parameter is returned as an OpenUrl, as shown below

1:Pay for success, 2:Payment failed, 3: Payment cancel

the remaining fields are reserved for later addition。

Example

import 'package:flutter_kpay_kit/flutter_kpay_kit.dart';

  void startPay() {
    FlutterKpayKit.startPay(
            merchCode: this.merchCode,
            // "10000",
            appId: this.appId,
            //"kp4c1706c8675a45fghjklrskyf",
            signKey: this.signKey,
            //"123",
            orderId: this.orderId,
            //"294",
            amount: this.amount,
            title: "title",
            urlScheme: "",
            //Only Ios
            isProduction: false,
            notifyURL: 'http://test.payment.com/notify')
        .then((res) {
      print('startPay' + res.toString());
    });
  }

void openKpay() {
  FlutterKpayKit.connectKBZPay(
      prepayID: '123',
      merchCode: '123',
      appId: '123',
      //Only Ios
      urlScheme: 'https',
      signKey: 'signKey')
      .then((res) {
    Map response = json.decode(res);
    String result = response["Response"]["result"];
    if (result == "FAIL") {
      _messangerKey.currentState!.showSnackBar(
        SnackBar(content: Text(response["Response"]["msg"])),
      );
    }
  });
}

    
  @override
  void initState() {
    super.initState();
    FlutterKpayKit.onPayStatus().listen((data) {
      print('onPayStatus $data');
    });
  }

Getting Started

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.