foloosi_payment 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 58

foloosi_payment #

pub package Say Thanks!

A Flutter plugin for making payments via Foloosi Payment Gateway. Fully supports Android and iOS.

💻 Installation #

In the dependencies: section of your pubspec.yaml, add the following line:

foloosi_payment: ^0.1.2

Import in your project:

import 'package:foloosi_payment/foloosi_payment.dart';

❔Basic Usage #

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

bool proceedToPayment = false;

  void _proceeedToPayment() {
    setState(() {
      proceedToPayment = true;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldKey,
      appBar: proceedToPayment
          ? null
          : AppBar(
              title: Text('Foloosi Payment Flutter'),
            ),
      body: proceedToPayment
          ? FoloosiPayment(
              headerText: 'Foloosi Payment',
              successRoute: '/OrderSuccess',
              successRouteParam: 'Foloosi',
              loaderText: "Processing Request",
              merchantKey: 'YOUR_FOLOOSI_MERCHANT_KEY',
              secretKey: 'YOUR_FOLOOSI_SECRET_KEY',
              transactionAmount: 2000,
              currency: 'AED',
              customerName: 'Joshua Chinemezu',
              customerEmail: 'joshuachinemezu@gmail.com',
              customerMobile: '+971500000000',
              onError: (value) {
                print("Payment Error : $value");
                setState(() {
                  proceedToPayment = false;
                });
                _scaffoldKey.currentState.showSnackBar(SnackBar(
                  content: Text(value.toString()),
                  duration: Duration(seconds: 3),
                ));
              },
              onSuccess: (value) {
                print("Payment Success : $value");
                setState(() {
                  proceedToPayment = false;
                });
                _scaffoldKey.currentState.showSnackBar(SnackBar(
                  content: Text(value.toString()),
                  duration: Duration(seconds: 3),
                ));
              },
            )
          : Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  RaisedButton(
                    onPressed: _proceeedToPayment,
                    child: new Text(
                      "Proceed to Payment",
                    ),
                  )
                ],
              ),
            ),
    );
  }
}

Note: If you're using the foloosi secret and merchant keys as a string in flutter, remember to escape the $ dollar signs although it is recommended to load these from your backend

merchantKey: 'test_\$2y\$10\$PQ8r...',
secretKey: 'test_\$2y\$10\$psrewC...',

Properties #

Here is a list of properties available:

| Name | Type | Required | Description | |:------------------: |:---------------:| :---------------: |:---------------------------------------------------------:| | headerText | String | false | the title of the widget's appbar | | onError | Function | true | function to run on payment error | | onSuccess | Function | true | function to run on payment success | | loaderText | String | false | text to display under the loader | | merchantKey | String | true | your foloosi merchant key | | secretKey | String | true | your foloosi secret key | | referenceToken | String | false | the reference token - generates automatically if null | | redirectUrl | String | false | the redirect url | | transactionAmount | String | - | transaction amount - required if referenceToken is null | | currency | String | - | transaction currency - required if referenceToken is null | | customerName | String | false | customer name - auto render in payment popup if passed | | customerEmail | String | false | customer email - auto render in payment popup if passed | | customerMobile | String | false | customer mobile - auto render in payment popup if passed | | customerAddress | String | false | customer address - auto render in payment popup if passed | | customerCity | String | false | customer city - auto render in payment popup if passed | | paymentCancellationMsg | String | false | message returned when user cancels the payment | | debugMode | bool | false | to enable or disable package logs |

TODO #

  • Add QR code Payment.

Show some ❤️ and star the repo to support the project #

GitHub followers Twitter Follow

Open Source Love

👨 Developed with ❤️ by #

Joshua Chinemezu

👍 How to Contribute #

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

📃 License #

Copyright (c) 2020 Joshua Chinemezu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

[0.0.1] - Initial Release. #

[0.0.1+1] - Format code #

[0.0.2] - Format code #

[0.1.0] - Main release #

[0.1.1] - Remove unused parameters #

[0.1.2] - Refactor, Remove unused files and export utils #

example/lib/main.dart

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Foloosi Payment Flutter',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool proceedToPayment = false;
  final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

  void _proceeedToPayment() {
    setState(() {
      proceedToPayment = true;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldKey,
      appBar: proceedToPayment
          ? null
          : AppBar(
              title: Text('Foloosi Payment Flutter'),
            ),
      body: proceedToPayment
          ? FoloosiPayment(
              headerText: "Foloosi Payment",
              loaderText: "Processing Request",
              merchantKey: 'YOUR_MERCHANT_KEY',
              secretKey: 'YOUR_SECRET_KEY',
              transactionAmount: 2000,
              currency: 'AED',
              customerName: 'Joshua Chinemezu',
              customerEmail: 'joshuachinemezu@gmail.com',
              customerMobile: '+971500000000',
              onError: (value) {
                print("Payment Error : $value");
                setState(() {
                  proceedToPayment = false;
                });
                _scaffoldKey.currentState.showSnackBar(SnackBar(
                  content: Text(value.toString()),
                  duration: Duration(seconds: 3),
                ));
              },
              onSuccess: (value) {
                print("Payment Success : $value");
                setState(() {
                  proceedToPayment = false;
                });
                _scaffoldKey.currentState.showSnackBar(SnackBar(
                  content: Text(value.toString()),
                  duration: Duration(seconds: 3),
                ));
              },
            )
          : Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  RaisedButton(
                    onPressed: _proceeedToPayment,
                    child: new Text(
                      "Proceed to Payment",
                    ),
                  )
                ],
              ),
            ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  foloosi_payment: ^0.1.2

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:foloosi_payment/foloosi_payment.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
15
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
58
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Linux

Because:

  • package:foloosi_payment/foloosi_payment.dart that imports:
  • package:foloosi_payment/src/foloosi_payment.dart that imports:
  • package:flutter_webview_plugin/flutter_webview_plugin.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:foloosi_payment/foloosi_payment.dart that imports:
  • package:foloosi_payment/src/foloosi_payment.dart that imports:
  • package:flutter_webview_plugin/flutter_webview_plugin.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:foloosi_payment/foloosi_payment.dart that imports:
  • package:foloosi_payment/src/foloosi_payment.dart that imports:
  • package:flutter_webview_plugin/flutter_webview_plugin.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform macOS

Because:

  • package:foloosi_payment/foloosi_payment.dart that imports:
  • package:foloosi_payment/src/foloosi_payment.dart that imports:
  • package:flutter_webview_plugin/flutter_webview_plugin.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • foloosi_payment that is a package requiring null.

Health issues and suggestions

Document public APIs. (-0.08 points)

61 out of 63 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/foloosi_payment.dart.

Run flutter format to format lib/foloosi_payment.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
flutter_webview_plugin ^0.3.11 0.3.11
http ^0.12.0+2 0.12.1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
http_parser 3.1.4
meta 1.1.8 1.2.2
path 1.7.0
pedantic 1.9.0 1.9.2
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test