Skip to content
This repository has been archived by the owner on May 16, 2020. It is now read-only.

cyberspace-ltd/cyberpay-flutter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter Cyber Pay SDK

A Flutter package allows you to easily implement the Cyber Pay Credit Card's UI easily with the Card detection.

Codacy Badge

Installing

  1. Add dependency to pubspec.yaml

    Get the latest version in the 'Installing' tab on pub.dartlang.org

dependencies:
    cyberpay_flutterplugin: ^1.0.0+22
  1. Import the package
import 'package:cyberpay_flutterplugin/model/transaction_model.dart';
import 'package:flutter/services.dart';
  1. Adding TransactionObject

With required parameters

    TransactionObject transactionObject = TransactionObject(
          integrationKey: 'YOUR INTEGRATION KEY',
          amount: (100000)AMOUNT IN KOBO,
          customerEmail: "name@mail.com",
          liveMode: false);
      
    
      static const platform = const MethodChannel('com.startCyberPay/Channel');
    
  1. Adding To your Payment Button
 FlatButton(
         onPressed: () async {
           String response = "";
           try {
             final String result = await platform.invokeMethod(
                 'chargeCard', transactionObject.toJson());
 
             response = result;
           } on PlatformException catch (e) {
             response = "Failed to Invoke: '${e.message}'.";
           }
         },
  1. Get Response Back from InitState
 @override
   void initState() {
     super.initState(); 
     
     platform.setMethodCallHandler((call) {
       final String argument = call.arguments;
       switch (call.method) {
         case "onSuccess":
           
           // Perform Action on Success
 
           break;
       }
     });
   }

How to use

Check out the example app in the example directory or the 'Example' tab on pub.dartlang.org for a more complete example.

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

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