GithubHelp home page GithubHelp logo

hochul822 / bootpay_flutter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jaceshim/bootpay_flutter

0.0 1.0 0.0 183 KB

Bootpay payment modules for Flutter

License: MIT License

Java 42.46% Ruby 7.74% Swift 16.90% Objective-C 1.02% Dart 30.59% Shell 1.30%

bootpay_flutter's Introduction

bootpay_flutter

This plugin is payment modules of Bootpay for Flutter.

Getting Started

Add the module to your project pubspec.yaml:

...
dependencies:
 ...
 bootpay_flutter: 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
            <key>CFBundleURLSchemes</key>
            <array>
                <string>bootpaySample</string> // 사용하고자 하시는 앱의 bundle url scheme
            </array>
        </dict>
    </array>

Done!

import 'dart:async';
import 'dart:io';

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _paymentResult = '';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String bootpayApplicationId;
    if (Platform.isAndroid) {
      bootpayApplicationId = "59a4d326396fa607cbe75de5"; // 안드로이드용 bootpay applicationId
    } else {
      bootpayApplicationId = "59a4d328396fa607b9e75de6"; // ios용 bootpay applicationId
    }

    String paymentResult;
    final UserInfo userInfo = UserInfo(username: "홍길동", email: "[email protected]");
    final PayParam payParam = PayParam(
        price: "1000",
        applicationId: bootpayApplicationId, // your_bootpay_id (Android or iOS)
        name: "bootpay_flutter_테스트_결제",
        userInfo: userInfo,
        orderId: "BootpayTest000001");

    try {
      final PayResult result = await BootpayFlutter.pay(payParam);
      if (result.action == "BootpayDone") {
        // 결제성공
        print("결제 성공");
      } else if (result.action == "BootpayCancel") {
        // 사용자가 결제완료전에 결제를 중지한 상태.
        print("사용자 결제 취소");
      } else if (result.action == "BootpayError") {
        // 결제에러
        print("결제 에러");
      }
      paymentResult = result.toString();
    } on Exception {
      paymentResult = 'Payment Failed.';
    }

    setState(() {
      _paymentResult = paymentResult;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Bootpay flutter example app'),
        ),
        body: Center(
          child: Text('Payment Result : $_paymentResult'),
        ),
      ),
    );
  }
}

Enjoy!

Author

Developed by Jace Shim (심천보)

Contributing

Feel free to help!

bootpay_flutter's People

Contributors

hochul822 avatar jaceshim avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.