The Official Flutter Plugin Managed By Bootpay

payment window_1

bootpay_api

This is the official Flutter plugin managed by BootPay. It was created by forking the existing bootpay_flutter module. Please refer to here for the boot pay development manual .

Supporting PG company

1\. 이니시스
2\. 나이스페이
3\. 다날
4\. KCP
5\. EasyPay (KICC)
6\. TPay (JTNet)
7\. LG U+
8\. 페이레터
9\. 네이버페이
10\. 카카오페이
11\. 페이코

Getting Started

Add the module to your project pubspec.yaml:

...
dependencies:
 ...
 bootpay_api: last_version
...

And install it using flutter packages get on your project folder. After that, just import the module and use it:

Settings

Android

No configuration required.

iOS

** {your project root}/ios/Runner/Info.plist **

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            < string >kr.co.bootpaySample</ string > // bundle url name of the app you want to use
            <key>CFBundleURLSchemes</key>
            <array>
                < string >bootpaySample</ string > // bundle url scheme of the app you want to use
            </array>
        </dict>
    </array>

Done!

Getting Started

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

import 'package:flutter/services.dart';
import 'package:bootpay_api/bootpay_api.dart';
import 'package:bootpay_api/model/payload.dart';
import 'package:bootpay_api/model/extra.dart';
import 'package:bootpay_api/model/user.dart';
import 'package:bootpay_api/model/item.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Test",
      home: TestPage(),
    );
  }
}

class TestPage extends StatefulWidget {
  @override
  TestPageState createState() => TestPageState();
}

class TestPageState extends State<TestPage> {
//  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
//    initPlatformState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar :  AppBar (
          title: const Text('Plugin example app'),
        ),
        body: Container(
          child:  RaisedButton(
            onPressed: () {
              goBootpayRequest(context);
            },
            child :  Text ( "BootPay Payment Request" ),
          ),
        )
    );
  }

  static Future<void> request(BuildContext context, Payload payload,
      {User user,
      List<Item> items,
      Extra extra,
      StringCallback onDone,
      StringCallback onReady,
      StringCallback onCancel,
      StringCallback onError}) async {

    payload.applicationId = Platform.isIOS
        ? payload.iosApplicationId
        : payload.androidApplicationId;

    if (user == null) user = User();
    if (items == null) items = [];
    if (extra == null) extra = Extra();

    Map<String, dynamic> params = {
      "payload": payload.toJson(),
      "user": user.toJson(),
      "items": items.map((v) => v.toJson()).toList(),
      "extra": extra.toJson()
    };

    Map<dynamic, dynamic> result = await _channel.invokeMethod(
      "bootpayRequest",
      params,
    );

    String method = result["method"];
    if (method == null) method = result["action"];

    String message = result["message"];
    if (message == null) message = result["msg"];

    //confirm 생략
    if (method == 'onDone' || method == 'BootpayDone') {
      if (onDone != null) onDone(message);
    } else if (method == 'onReady' || method == 'BootpayReady') {
      if (onReady != null) onReady(message);
    } else  if (method ==  'onCancel'  || method ==  'BootpayCancel' ) {
       if (onCancel ! =  null ) onCancel (message);
    } else if (method == 'onError' || method == 'BootpayError') {
      if (onError != null) onError(message);
    } else if (result['receipt_id'] != null && result['receipt_id'].isNotEmpty) {
      if (onDone != null) onDone(jsonEncode(result));
    }
  }
}

Download Details:

Author: bootpay

Source Code: https://github.com/bootpay/flutter

#flutter #dart #mobile-apps

The Official Flutter Plugin Managed By Bootpay
4.30 GEEK