my_fatoorah 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 63

my_fatoorah #

My Fatoorah Payment SDK Integration

Getting Started #

Installation #

add this to your pubspec.yaml
my_fatoorah: any

Usage #

import 'package:my_fatoorah/my_fatoorah.dart';
There are 3 methods that you can use
1- MyFatoorah.config
   This can be called once in your app the example uses test values
2- MyFatoorah.initiatePayment
   This method is for intializing payment and get availble payment methods
3- MyFatoorah.executePayment
   This will fire the payment screen and get a call back when finish

See the example for more details

1.0.1 #

  • TODO: Add internet permission for android

1.0.0 #

  • TODO: Formatting code

0.0.1 #

  • TODO: initial release.For the api

example/README.md

my_fatoorah_example #

import 'package:my_fatoorah/my_fatoorah.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:my_fatoorah/my_fatoorah.dart';
import 'package:my_fatoorah/requests/configRequest.dart';
import 'package:my_fatoorah/requests/initiatePaymentRequest.dart';
import 'package:my_fatoorah/requests/excutePaymentRequest.dart';
import 'package:my_fatoorah/responses/paymentMethod.dart';

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

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

class _MyAppState extends State<MyApp> {
  bool loading = true;
  List<PaymentMethod> paymentMethods = [];
  @override
  void initState() {
    super.initState();
    MyFatoorah.config(ConfigRequest(
      baseUrl: "https://apitest.myfatoorah.com",
      title: "الدفع الإلكترونى",
      iosCancelButton: "إلغاء",
      token:
          "7Fs7eBv21F5xAocdPvvJ-sCqEyNHq4cygJrQUFvFiWEexBUPs4AkeLQxH4pzsUrY3Rays7GVA6SojFCz2DMLXSJVqk8NG-plK-cZJetwWjgwLPub_9tQQohWLgJ0q2invJ5C5Imt2ket_-JAlBYLLcnqp_WmOfZkBEWuURsBVirpNQecvpedgeCx4VaFae4qWDI_uKRV1829KCBEH84u6LYUxh8W_BYqkzXJYt99OlHTXHegd91PLT-tawBwuIly46nwbAs5Nt7HFOozxkyPp8BW9URlQW1fE4R_40BXzEuVkzK3WAOdpR92IkV94K_rDZCPltGSvWXtqJbnCpUB6iUIn1V-Ki15FAwh_nsfSmt_NQZ3rQuvyQ9B3yLCQ1ZO_MGSYDYVO26dyXbElspKxQwuNRot9hi3FIbXylV3iN40-nCPH4YQzKjo5p_fuaKhvRh7H8oFjRXtPtLQQUIDxk-jMbOp7gXIsdz02DrCfQIihT4evZuWA6YShl6g8fnAqCy8qRBf_eLDnA9w-nBh4Bq53b1kdhnExz0CMyUjQ43UO3uhMkBomJTXbmfAAHP8dZZao6W8a34OktNQmPTbOHXrtxf6DS-oKOu3l79uX_ihbL8ELT40VjIW3MJeZ_-auCPOjpE3Ax4dzUkSDLCljitmzMagH2X8jN8-AYLl46KcfkBV",
    )).then((d) {
      intaitePayment();
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      locale: Locale("ar"),
      supportedLocales: [
        const Locale('ar'),
      ],
      home: Scaffold(
        appBar: AppBar(
          title: Text(loading ? "دفع ماى فاتورة" : "إختر طريقة الدفع"),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: intaitePayment,
          child: Icon(Icons.sync),
        ),
        body: Column(
          children: <Widget>[
            if (loading == true) LinearProgressIndicator(),
            Expanded(
              child: ListView.builder(
                itemBuilder: (BuildContext context, int index) {
                  PaymentMethod method = paymentMethods[index];
                  return ListTile(
                    onTap: () {
                      excutePayment(method.paymentMethodId);
                    },
                    leading: Image.network(method.imageUrl),
                    title: Text(method.paymentMethodAr),
                    trailing: Text(method.currencyIso),
                    subtitle: Text(
                        "العمولة : ${method.serviceCharge.toStringAsFixed(2)}"),
                  );
                },
                itemCount: paymentMethods.length,
              ),
            ),
          ],
        ),
      ),
    );
  }

  void intaitePayment() {
    setState(() {
      loading = true;
    });
    MyFatoorah.initiatePayment(InitiatePaymentRequest(invoiceAmount: 100))
        .then((data) {
      setState(() {
        paymentMethods.clear();
        paymentMethods.addAll(data);
        loading = false;
      });
    }).catchError((e) {
      setState(() {
        loading = false;
      });
    });
  }

  void excutePayment(int id) {
    MyFatoorah.executePayment(ExcutePaymentRequest(
      callBackUrl: "http://google.com",
      errorUrl: "http://google.com",
      invoiceAmount: 100,
      paymentMethod: id,
    ));
  }
}


Use this package as a library

1. Depend on it

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


dependencies:
  my_fatoorah: ^1.0.1

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

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

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-1 points)

261 out of 261 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test