cyberpaysdkflutter 1.0.0+16

  • Readme
  • Changelog
  • Installing
  • 59

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

Preview #

The example app running in Android

Installing #

  1. Add dependency to pubspec.yaml

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

dependencies:
    cyberpaysdkflutter: ^1.0.0+14
  1. Import the package
import 'package:cyberpaysdkflutter/ui/credit_card_model.dart';

import 'package:cyberpaysdkflutter/ui/flutter_credit_card.dart';
  1. Adding CreditCardWidget

With required parameters


    CreditCardWidget(
        cardNumber: cardNumber.trim(),
        expiryDate: expiryDate,
        cardHolderName: cardHolderName,
        cvvCode: cvvCode,
        showBackView: isCvvFocused, //true when you want to show cvv(back) view
        cardPin: cardPin,
    ),
    

With optional parameters

    CreditCardWidget(
        cardNumber: cardNumber,
        expiryDate: expiryDate,
        cardHolderName: cardHolderName,
        cvvCode: cvvCode,
        showBackView: isCvvFocused,
        cardbgColor: Colors.black,
        cardPin: cardPin,
        height: 175,
        textStyle: TextStyle(color: Colors.yellowAccent),
        width: MediaQuery.of(context).size.width,
        animationDuration: Duration(milliseconds: 1000),
        ),
  1. Adding CreditCardForm

  TransactionModel _transModel = TransactionModel(
      merchantRef: "merch_reference",
      amount: int.parse("amount") * 100,
      customerEmail: "email@gmail.com",
      integrationKey: "INTEGRATION KEY",
      returnUrl: "https://your return url.com/",
      customerMobile: "070949348483",
      customerName: "Surname Middlename",
      description: "Transaction from Flutter SDK",
    );

    TransactionRepository.getInstance(CyberPayApi())
        .beginTransactionApi(
            transactionModelToJson(_transModel))
        .then((result) {

      var reference = result.data.transactionReference;

      CardModel _charge = CardModel(
          name: cardHolderName,
          cardNumber: cardNumber.replaceAll(
              new RegExp(r"\s+\b|\b\s"), ""),
          expiryMonth: int.parse(splitDate[0]),
          expiryYear: int.parse(splitDate[1]),
          cvv: cvvCode,
          cardPin: cardPin,
          reference: reference);

    if (cardResult.data.status == "Failed") {
          var loadingBar = FlushbarHelper.createLoading(
              message: cardResult.data.message,
              linearProgressIndicator: null);
          loadingBar..show(context);
        }
        if (cardResult.data.status == "Otp") {
          Navigator.push(
            context,
            MaterialPageRoute(
                builder: (context) => new HomeScreen(
                    busSchedule: widget._busSchedule,
                    bookingForm: widget._bookingForm,
                    transactionModel: _charge,
                    payload: payload)),
          );
        }
    
        else if (cardResult.data.status == "Success") {
          var loadingBar = FlushbarHelper.createLoading(
              message:
              "Transaction successful: Transaction Ref: {$reference}",
              linearProgressIndicator: null);
          loadingBar..show(context);
        } else if (cardResult.data.status == "ProvidePin") {
          var loadingBar = FlushbarHelper.createLoading(
              message:
              "Transaction successful: Transaction Ref: {$reference}",
              linearProgressIndicator: null);
          loadingBar..show(context);
        } else if (cardResult.data.status == "Successful") {
          var loadingBar = FlushbarHelper.createLoading(
              message:
              "Transaction successful: with Transaction Ref: {$reference}",
              linearProgressIndicator: null);
          loadingBar..show(context);
        } else if (cardResult.data.status == "EnrollOtp") {
    
        } else if (cardResult.data.status == "Secure3D") {
          var url = cardResult.data.redirectUrl;
          if (await canLaunch(url)) {
        await launch(url);
        }
        } else if (cardResult.data.status == "Secure3DMpgs") {
        var url = cardResult.data.redirectUrl;
        if (await canLaunch(url)) {
        await launch(url);
        }
        } else if (cardResult.data.status == "Successful") {
        var loadingBar = FlushbarHelper.createLoading(
        message:
        "Transaction successful: Transaction Ref: {$reference}",
        linearProgressIndicator: null);
        loadingBar..show(context);
        }

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.

1.0.0+16 #

Bug Fixes, catch error response on Inter Switch transaction Failure

1.0.0+15 #

Bug Fixes, Surround API with try and catch

1.0.0+14 #

Bug Fixes, Revert Equatable in pubspec.yaml

1.0.0+13 #

Bug Fixes, Revert Dio in pubspec.yaml

1.0.0+12 #

Bug Fixes, updated Read ME file

1.0.0+11 #

Bug Fixes

1.0.0+10 #

Bug Fixes and implement other card payments payment - payload

1.0.0+9 #

Bug Fixes and implement other card payments

1.0.0+8 #

Bug Fixes

1.0.0+7 #

Bug Fixes

1.0.0+6 #

Exported the CardModel, TransactionModel and CyberPayAPI

1.0.0+5 #

Exported the Card and OTP model

1.0.0+4 #

  • Maintenance of the project by implementing Formatting to widgets
  • Fix additional 14 files with analysis or formatting issues.

1.0.0+3 #

  • Upgrade of packages to take custom import and export

1.0.0+2 #

  • Bug fixes
  • Upgrade of packages

1.0.0+1 #

  • Initial version, created by Shaba Okare Michael

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  cyberpaysdkflutter: ^1.0.0+16

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:cyberpaysdkflutter/generated/i18n.dart';
import 'package:cyberpaysdkflutter/main.dart';
import 'package:cyberpaysdkflutter/ui/credit_card_form.dart';
import 'package:cyberpaysdkflutter/ui/credit_card_model.dart';
import 'package:cyberpaysdkflutter/ui/credit_card_widget.dart';
import 'package:cyberpaysdkflutter/ui/flutter_credit_card.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
94
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

We analyzed this package on Oct 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/apis/CyberPayApi.dart. (-1.99 points)

Analysis of lib/src/apis/CyberPayApi.dart reported 4 hints:

line 59 col 14: The value of the local variable 'response' isn't used.

line 125 col 23: Name non-constant identifiers using lowerCamelCase.

line 162 col 31: Name non-constant identifiers using lowerCamelCase.

line 201 col 31: Name non-constant identifiers using lowerCamelCase.

Fix lib/src/repository/TransactionRepository.dart. (-1.49 points)

Analysis of lib/src/repository/TransactionRepository.dart reported 3 hints:

line 42 col 23: Name non-constant identifiers using lowerCamelCase.

line 50 col 31: Name non-constant identifiers using lowerCamelCase.

line 58 col 31: Name non-constant identifiers using lowerCamelCase.

Fix lib/src/ui/ui.dart. (-1.49 points)

Analysis of lib/src/ui/ui.dart reported 3 hints:

line 1 col 8: Unused import: 'dart:math'.

line 5 col 8: Unused import: 'package:cyberpaysdkflutter/src/models/TransactionModel.dart'.

line 13 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: HomeScreen.transactionModel

Fix additional 13 files with analysis or formatting issues. (-1.50 points)

Additional issues in the following files:

  • lib/main.dart (1 hint)
  • lib/src/apis/EndPoint.dart (1 hint)
  • lib/src/ui/otp_widget.dart (1 hint)
  • lib/generated/i18n.dart (Run flutter format to format lib/generated/i18n.dart.)
  • lib/src/exceptions/AuthenticationException.dart (Run flutter format to format lib/src/exceptions/AuthenticationException.dart.)
  • lib/src/exceptions/CleanerException.dart (Run flutter format to format lib/src/exceptions/CleanerException.dart.)
  • lib/src/exceptions/CyberPaySDKNotInitialisedException.dart (Run flutter format to format lib/src/exceptions/CyberPaySDKNotInitialisedException.dart.)
  • lib/src/interface/transactionCallBack.dart (Run flutter format to format lib/src/interface/transactionCallBack.dart.)
  • lib/src/models/OtpRequestModel.dart (Run flutter format to format lib/src/models/OtpRequestModel.dart.)
  • lib/src/network/ApiResponse.dart (Run flutter format to format lib/src/network/ApiResponse.dart.)
  • lib/src/network/ChargeResponse.dart (Run flutter format to format lib/src/network/ChargeResponse.dart.)
  • lib/ui/credit_card_form.dart (Run flutter format to format lib/ui/credit_card_form.dart.)
  • lib/ui/credit_card_widget.dart (Run flutter format to format lib/ui/credit_card_widget.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (dio, equatable).

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and cyberpaysdkflutter.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The description is too long. (-10 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
crypto ^2.0.6 2.1.3
cupertino_icons ^0.1.2 0.1.2
dio ^2.1.13 2.2.2 3.0.3
encrypt ^3.0.0 3.3.1
equatable ^0.2.0 0.2.6 0.6.1
flushbar ^1.5.0 1.9.0
flutter 0.0.0
flutter_secure_storage ^3.2.1+1 3.3.1+1
flutter_spinkit ^4.0.0 4.0.0
flutter_staggered_grid_view ^0.3.0 0.3.0
http ^0.12.0+2 0.12.0+2
image_picker ^0.6.0+3 0.6.1+7
intl ^0.16.0 0.16.0
meta ^1.1.6 1.1.7
path_provider ^1.1.0 1.3.0
rxdart ^0.22.0 0.22.3
scoped_model ^1.0.1 1.0.1
serializable ^0.12.0 0.12.0
shared_preferences ^0.5.2 0.5.3+4
sqflite ^1.1.0 1.1.7+1
url_launcher ^5.1.2 5.1.6
Transitive dependencies
analyzer 0.38.5
args 1.5.2
asn1lib 0.5.8
async 2.4.0
build 1.2.0
built_mirrors 0.11.0
charcode 1.1.2
clock 1.0.1
collection 1.14.11 1.14.12
convert 2.1.1
cookie_jar 1.0.1
csslib 0.16.1
dart_style 1.3.1
front_end 0.1.27
glob 1.1.7
html 0.14.0+3
http_parser 3.1.3
kernel 0.3.27
logging 0.11.3+2
package_config 1.1.0
path 1.6.4
pedantic 1.8.0+1
platform 2.2.1
pointycastle 1.0.1
pub_semver 1.4.2
sky_engine 0.0.99
source_gen 0.9.4+5
source_span 1.5.5
string_scanner 1.0.5
synchronized 2.1.0+1
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
watcher 0.9.7+12
yaml 2.2.0
Dev dependencies
flutter_test